001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.deployment.plugin;
017:
018: import java.io.File;
019: import java.io.InputStream;
020: import java.util.Collection;
021: import java.util.Locale;
022:
023: import javax.enterprise.deploy.model.DeployableObject;
024: import javax.enterprise.deploy.shared.DConfigBeanVersionType;
025: import javax.enterprise.deploy.shared.ModuleType;
026: import javax.enterprise.deploy.spi.DeploymentConfiguration;
027: import javax.enterprise.deploy.spi.DeploymentManager;
028: import javax.enterprise.deploy.spi.Target;
029: import javax.enterprise.deploy.spi.TargetModuleID;
030: import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
031: import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
032: import javax.enterprise.deploy.spi.exceptions.TargetException;
033: import javax.enterprise.deploy.spi.status.ProgressObject;
034:
035: import org.apache.geronimo.deployment.ModuleConfigurer;
036:
037: /**
038: * Implementation of a disconnected JSR88 DeploymentManager.
039: *
040: *
041: * @version $Rev: 512979 $ $Date: 2007-02-28 13:28:28 -0800 (Wed, 28 Feb 2007) $
042: */
043: public class DisconnectedDeploymentManager implements DeploymentManager {
044:
045: private final Collection<ModuleConfigurer> moduleConfigurers;
046:
047: public DisconnectedDeploymentManager(
048: Collection<ModuleConfigurer> moduleConfigurers) {
049: if (null == moduleConfigurers) {
050: throw new IllegalArgumentException(
051: "moduleConfigurers is required");
052: }
053: this .moduleConfigurers = moduleConfigurers;
054: }
055:
056: public DeploymentConfiguration createConfiguration(
057: DeployableObject dObj) throws InvalidModuleException {
058: if (dObj == null) {
059: throw new NullPointerException(
060: "No deployable object supplied to configure");
061: }
062: ModuleConfigurer configurer = null;
063: for (ModuleConfigurer moduleConfigurer : moduleConfigurers) {
064: if (moduleConfigurer.getModuleType() == dObj.getType()) {
065: configurer = moduleConfigurer;
066: break;
067: }
068: }
069: if (configurer == null) {
070: throw new InvalidModuleException(
071: "No configurer for module type: " + dObj.getType()
072: + " registered");
073: }
074: return configurer.createConfiguration(dObj);
075: }
076:
077: public Locale[] getSupportedLocales() {
078: return new Locale[] { getDefaultLocale() };
079: }
080:
081: public Locale getCurrentLocale() {
082: return getDefaultLocale();
083: }
084:
085: public Locale getDefaultLocale() {
086: return Locale.getDefault();
087: }
088:
089: public boolean isLocaleSupported(Locale locale) {
090: return getDefaultLocale().equals(locale);
091: }
092:
093: public void setLocale(Locale locale) {
094: if (isLocaleSupported(locale)) {
095: throw new UnsupportedOperationException(
096: "Unsupported Locale");
097: }
098: }
099:
100: public DConfigBeanVersionType getDConfigBeanVersion() {
101: return DConfigBeanVersionType.V1_4;
102: }
103:
104: public boolean isDConfigBeanVersionSupported(
105: DConfigBeanVersionType version) {
106: return DConfigBeanVersionType.V1_4.equals(version);
107: }
108:
109: public void setDConfigBeanVersion(DConfigBeanVersionType version)
110: throws DConfigBeanVersionUnsupportedException {
111: if (!isDConfigBeanVersionSupported(version)) {
112: throw new DConfigBeanVersionUnsupportedException(
113: "Version not supported " + version);
114: }
115: }
116:
117: public Target[] getTargets() throws IllegalStateException {
118: throw new IllegalStateException("Disconnected");
119: }
120:
121: public TargetModuleID[] getRunningModules(ModuleType moduleType,
122: Target[] targets) throws TargetException,
123: IllegalStateException {
124: throw new IllegalStateException("Disconnected");
125: }
126:
127: public TargetModuleID[] getNonRunningModules(ModuleType moduleType,
128: Target[] targets) throws TargetException,
129: IllegalStateException {
130: throw new IllegalStateException("Disconnected");
131: }
132:
133: public TargetModuleID[] getAvailableModules(ModuleType moduleType,
134: Target[] targets) throws TargetException,
135: IllegalStateException {
136: throw new IllegalStateException("Disconnected");
137: }
138:
139: public ProgressObject distribute(Target[] targets, File file,
140: File file1) throws IllegalStateException {
141: throw new IllegalStateException("Disconnected");
142: }
143:
144: /**
145: * @deprecated
146: */
147: public ProgressObject distribute(Target[] targets,
148: InputStream inputStream, InputStream inputStream1)
149: throws IllegalStateException {
150: throw new IllegalStateException("Disconnected");
151: }
152:
153: public ProgressObject distribute(Target[] targets,
154: ModuleType moduleType, InputStream inputStream,
155: InputStream inputStream1) throws IllegalStateException {
156: throw new IllegalStateException("Disconnected");
157: }
158:
159: public ProgressObject start(TargetModuleID[] targetModuleIDs)
160: throws IllegalStateException {
161: throw new IllegalStateException("Disconnected");
162: }
163:
164: public ProgressObject stop(TargetModuleID[] targetModuleIDs)
165: throws IllegalStateException {
166: throw new IllegalStateException("Disconnected");
167: }
168:
169: public ProgressObject undeploy(TargetModuleID[] targetModuleIDs)
170: throws IllegalStateException {
171: throw new IllegalStateException("Disconnected");
172: }
173:
174: public boolean isRedeploySupported() {
175: return false;
176: }
177:
178: public ProgressObject redeploy(TargetModuleID[] targetModuleIDs,
179: File file, File file1)
180: throws UnsupportedOperationException, IllegalStateException {
181: throw new IllegalStateException("Disconnected");
182: }
183:
184: public ProgressObject redeploy(TargetModuleID[] targetModuleIDs,
185: InputStream inputStream, InputStream inputStream1)
186: throws UnsupportedOperationException, IllegalStateException {
187: throw new IllegalStateException("Disconnected");
188: }
189:
190: public void release() {
191: throw new IllegalStateException("Disconnected");
192: }
193: }
|