Modified: geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/jsr88/ClientConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/jsr88/ClientConfigurer.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/jsr88/ClientConfigurer.java (original)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/jsr88/ClientConfigurer.java Sat Feb 17 00:01:26 2007
@@ -20,16 +20,15 @@
package org.apache.geronimo.client.builder.jsr88;
-import javax.enterprise.deploy.spi.DeploymentConfiguration;
import javax.enterprise.deploy.model.DeployableObject;
import javax.enterprise.deploy.shared.ModuleType;
+import javax.enterprise.deploy.spi.DeploymentConfiguration;
import org.apache.geronimo.deployment.ModuleConfigurer;
-import org.apache.geronimo.j2ee.jsr88.EARConfiguration;
-import org.apache.geronimo.j2ee.jsr88.EARConfigurer;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jsr88.EARConfiguration;
/**
*
Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/LICENSE.txt?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/LICENSE.txt (added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/LICENSE.txt Sat Feb 17 00:01:26 2007
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/NOTICE.txt?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/NOTICE.txt (added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/NOTICE.txt Sat Feb 17 00:01:26 2007
@@ -0,0 +1,6 @@
+Apache Geronimo
+Copyright 2003-2006 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/pom.xml?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/pom.xml (added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/pom.xml Sat Feb 17 00:01:26 2007
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 493181 $ $Date: 2007-01-06 07:32:03 +1100 (Sat, 06 Jan 2007) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>geronimo-deploy-jsr88-bootstrapper</artifactId>
+ <name>Geronimo :: Deploy :: JSR-88 Bootstrapper</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-kernel</artifactId>
+ <version>${version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-deployment_1.1_spec</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
+
Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryBootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryBootstrapper.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryBootstrapper.java (added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88-bootstrapper/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryBootstrapper.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.deployment.plugin.factories;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.util.MainBootstrapper;
+
+/**
+ *
+ * @version $Rev: 503905 $ $Date: 2007-02-06 09:20:49 +1100 (Tue, 06 Feb 2007) $
+ */
+public class DeploymentFactoryBootstrapper implements DeploymentFactory {
+ private final Kernel kernel;
+ private final DeploymentFactory delegate;
+
+ public DeploymentFactoryBootstrapper() throws DeploymentManagerCreationException {
+ kernel = newKernel();
+
+ try {
+ delegate = (DeploymentFactory) kernel.getGBean(DeploymentFactory.class);
+ } catch (Exception e) {
+ throw (DeploymentManagerCreationException) new DeploymentManagerCreationException("See nested").initCause(e);
+ }
+ }
+
+
+ public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException {
+ return delegate.getDeploymentManager(uri, username, password);
+ }
+
+ public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException {
+ return delegate.getDisconnectedDeploymentManager(uri);
+ }
+
+ public String getDisplayName() {
+ return delegate.getDisplayName();
+ }
+
+ public String getProductVersion() {
+ return delegate.getProductVersion();
+ }
+
+ public boolean handlesURI(String uri) {
+ return delegate.handlesURI(uri);
+ }
+
+ protected Kernel newKernel() throws DeploymentManagerCreationException {
+ ClassLoader classLoader = DeploymentFactoryBootstrapper.class.getClassLoader();
+
+ MainBootstrapper bootstrapper = new MainBootstrapper();
+ try {
+ bootstrapper.bootKernel();
+ bootstrapper.loadBootConfiguration(classLoader);
+ bootstrapper.loadPersistentConfigurations();
+ } catch (Exception e) {
+ throw (DeploymentManagerCreationException) new DeploymentManagerCreationException("See nested").initCause(e);
+ }
+ return bootstrapper.getKernel();
+ }
+
+}
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/pom.xml?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/pom.xml Sat Feb 17 00:01:26 2007
@@ -53,24 +53,5 @@
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- </manifest>
- <manifestEntries>
- <J2EE-DeploymentFactory-Implementation-Class>org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl</J2EE-DeploymentFactory-Implementation-Class>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/DisconnectedDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/DisconnectedDeploymentManager.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/DisconnectedDeploymentManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/DisconnectedDeploymentManager.java Sat Feb 17 00:01:26 2007
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.InputStream;
+import java.util.Collection;
import java.util.Locale;
import javax.enterprise.deploy.model.DeployableObject;
@@ -35,6 +36,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.ModuleConfigurer;
/**
* Implementation of a disconnected JSR88 DeploymentManager.
@@ -45,25 +47,30 @@
public class DisconnectedDeploymentManager implements DeploymentManager {
private static final Log log = LogFactory.getLog(DisconnectedDeploymentManager.class);
+ private final Collection<ModuleConfigurer> moduleConfigurers;
+
+ public DisconnectedDeploymentManager(Collection<ModuleConfigurer> moduleConfigurers) {
+ if (null == moduleConfigurers) {
+ throw new IllegalArgumentException("moduleConfigurers is required");
+ }
+ this.moduleConfigurers = moduleConfigurers;
+ }
+
public DeploymentConfiguration createConfiguration(DeployableObject dObj) throws InvalidModuleException {
- if(dObj.getType().equals(ModuleType.CAR)) {
- //todo: need a client configurer
- } else if(dObj.getType().equals(ModuleType.EAR)) {
- //todo: need an EAR configurer
- } else if(dObj.getType().equals(ModuleType.EJB)) {
- try {
- Class cls = Class.forName("org.apache.openejb.deployment.EJBConfigurer");
- return (DeploymentConfiguration)cls.getMethod("createConfiguration", new Class[]{DeployableObject.class}).invoke(cls.newInstance(), new Object[]{dObj});
- } catch (Exception e) {
- log.error("Unable to invoke EJB deployer", e);
+ if (dObj == null) {
+ throw new NullPointerException("No deployable object supplied to configure");
+ }
+ ModuleConfigurer configurer = null;
+ for (ModuleConfigurer moduleConfigurer : moduleConfigurers) {
+ if (moduleConfigurer.getModuleType() == dObj.getType()) {
+ configurer = moduleConfigurer;
+ break;
}
- } else if(dObj.getType().equals(ModuleType.RAR)) {
-// return new RARConfigurer().createConfiguration(dObj);
- } else if(dObj.getType().equals(ModuleType.WAR)) {
-// return new WARConfigurer().createConfiguration(dObj); // this is jetty
- // todo: Tomcat WARConfigurer
}
- throw new InvalidModuleException("Not supported");
+ if (configurer == null) {
+ throw new InvalidModuleException("No configurer for module type: " + dObj.getType() + " registered");
+ }
+ return configurer.createConfiguration(dObj);
}
public Locale[] getSupportedLocales() {
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java Sat Feb 17 00:01:26 2007
@@ -17,12 +17,11 @@
package org.apache.geronimo.deployment.plugin.factories;
-import org.apache.geronimo.deployment.plugin.DisconnectedDeploymentManager;
-import org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager;
-import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
-import org.apache.geronimo.kernel.KernelRegistry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
import javax.enterprise.deploy.spi.DeploymentManager;
@@ -31,9 +30,14 @@
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.ModuleConfigurer;
+import org.apache.geronimo.deployment.plugin.DisconnectedDeploymentManager;
+import org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager;
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.kernel.KernelRegistry;
/**
* Implementation of JSR88 DeploymentFactory.
@@ -50,6 +54,9 @@
public static final String URI_PREFIX = "deployer:geronimo:";
private static final int DEFAULT_PORT = 1099;
+ public DeploymentFactoryImpl() {
+ }
+
public String getDisplayName() {
return "Apache Geronimo";
}
@@ -109,8 +116,9 @@
if (!handlesURI(uri)) {
return null;
}
-
- return new DisconnectedDeploymentManager();
+
+ Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
+ return new DisconnectedDeploymentManager(moduleConfigurers);
}
public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException {
@@ -121,22 +129,7 @@
try {
if (params.getProtocol().equals("jmx")) {
- Map environment = new HashMap();
- String[] credentials = new String[]{username, password};
- environment.put(JMXConnector.CREDENTIALS, credentials);
- try {
- JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+params.getHost()+":"+params.getPort()+"/JMXConnector");
- JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
- RemoteDeploymentManager manager = new RemoteDeploymentManager(jmxConnector, params.getHost());
- if(!manager.isSameMachine()) {
- manager.setAuthentication(username, password);
- }
- return manager;
- } catch (IOException e) {
- throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);
- } catch (SecurityException e) {
- throw (AuthenticationFailedException) new AuthenticationFailedException("Invalid login.").initCause(e);
- }
+ return newRemoteDeploymentManager(username, password, params);
} else if(params.getProtocol().equals("inVM")) {
return new LocalDeploymentManager(KernelRegistry.getKernel(params.getHost()));
} else {
@@ -153,6 +146,35 @@
}
}
+ protected Collection<ModuleConfigurer> getModuleConfigurers() throws DeploymentManagerCreationException {
+ return Collections.EMPTY_LIST;
+ }
+
+ protected DeploymentManager newRemoteDeploymentManager(String username, String password, ConnectParams params) throws DeploymentManagerCreationException, AuthenticationFailedException {
+ Map environment = new HashMap();
+ String[] credentials = new String[]{username, password};
+ environment.put(JMXConnector.CREDENTIALS, credentials);
+ try {
+ JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+params.getHost()+":"+params.getPort()+"/JMXConnector");
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
+ RemoteDeploymentManager manager = getRemoteDeploymentManager();
+ manager.init(jmxConnector, params.getHost());
+ if(!manager.isSameMachine()) {
+ manager.setAuthentication(username, password);
+ }
+ return manager;
+ } catch (IOException e) {
+ throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);
+ } catch (SecurityException e) {
+ throw (AuthenticationFailedException) new AuthenticationFailedException("Invalid login.").initCause(e);
+ }
+ }
+
+ protected RemoteDeploymentManager getRemoteDeploymentManager() throws DeploymentManagerCreationException {
+ Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
+ return new RemoteDeploymentManager(moduleConfigurers);
+ }
+
static {
DeploymentFactoryManager manager = DeploymentFactoryManager.getInstance();
manager.registerDeploymentFactory(new DeploymentFactoryImpl());
@@ -186,7 +208,4 @@
}
}
- public static void main(String[] args) {
- System.out.println("Parsed: "+new DeploymentFactoryImpl().parseURI("deployer:geronimo:inVM"));
- }
}
Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java (added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.deployment.plugin.factories;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+
+import org.apache.geronimo.deployment.ModuleConfigurer;
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ *
+ * @version $Rev: 503905 $ $Date: 2007-02-06 09:20:49 +1100 (Tue, 06 Feb 2007) $
+ */
+public class DeploymentFactoryWithKernel extends DeploymentFactoryImpl {
+ private final Kernel kernel;
+
+ public DeploymentFactoryWithKernel(Kernel kernel) {
+ if (null == kernel) {
+ throw new IllegalArgumentException("kernel is required");
+ }
+ this.kernel = kernel;
+ }
+
+ protected Collection<ModuleConfigurer> getModuleConfigurers() throws DeploymentManagerCreationException {
+ Collection<ModuleConfigurer> moduleConfigurers = new ArrayList<ModuleConfigurer>();
+ Set<AbstractName> configurerNames = kernel.listGBeans(new AbstractNameQuery(ModuleConfigurer.class.getName()));
+ for (AbstractName configurerName : configurerNames) {
+ try {
+ ModuleConfigurer configurer = (ModuleConfigurer) kernel.getGBean(configurerName);
+ moduleConfigurers.add(configurer);
+ } catch (GBeanNotFoundException e) {
+ throw new AssertionError("No gbean found for name returned in query : " + configurerName);
+ }
+ }
+ return moduleConfigurers;
+ }
+
+ protected RemoteDeploymentManager getRemoteDeploymentManager() throws DeploymentManagerCreationException {
+ try {
+ return (RemoteDeploymentManager) kernel.getGBean(RemoteDeploymentManager.class);
+ } catch (Exception e) {
+ throw (DeploymentManagerCreationException) new DeploymentManagerCreationException("See nested").initCause(e);
+ }
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ static {
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(DeploymentFactoryWithKernel.class, "DeploymentFactory");
+
+ infoBuilder.addInterface(DeploymentFactory.class);
+
+ infoBuilder.setConstructor(new String[] {"kernel"});
+
+ GBEAN_INFO = infoBuilder.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
+}
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java Sat Feb 17 00:01:26 2007
@@ -19,11 +19,9 @@
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
import javax.enterprise.deploy.model.DeployableObject;
import javax.enterprise.deploy.shared.DConfigBeanVersionType;
@@ -49,8 +47,6 @@
import org.apache.geronimo.deployment.plugin.local.StopCommand;
import org.apache.geronimo.deployment.plugin.local.UndeployCommand;
import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationInfo;
import org.apache.geronimo.kernel.config.ConfigurationManager;
@@ -68,8 +64,15 @@
protected Kernel kernel;
private ConfigurationManager configurationManager;
private CommandContext commandContext;
- protected final Map<ModuleType, ModuleConfigurer> moduleConfigurers = new HashMap<ModuleType, ModuleConfigurer>();
+ private final Collection<ModuleConfigurer> moduleConfigurers;
+ public JMXDeploymentManager(Collection<ModuleConfigurer> moduleConfigurers) {
+ if (null == moduleConfigurers) {
+ throw new IllegalArgumentException("moduleConfigurers is required");
+ }
+ this.moduleConfigurers = moduleConfigurers;
+ }
+
protected void initialize(Kernel kernel) {
this.kernel = kernel;
configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -288,7 +291,13 @@
if (dObj == null) {
throw new NullPointerException("No deployable object supplied to configure");
}
- ModuleConfigurer configurer = moduleConfigurers.get(dObj.getType());
+ ModuleConfigurer configurer = null;
+ for (ModuleConfigurer moduleConfigurer : moduleConfigurers) {
+ if (moduleConfigurer.getModuleType() == dObj.getType()) {
+ configurer = moduleConfigurer;
+ break;
+ }
+ }
if (configurer == null) {
throw new InvalidModuleException("No configurer for module type: " + dObj.getType() + " registered");
}
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/LocalDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/LocalDeploymentManager.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/LocalDeploymentManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/LocalDeploymentManager.java Sat Feb 17 00:01:26 2007
@@ -16,15 +16,17 @@
*/
package org.apache.geronimo.deployment.plugin.jmx;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Set;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.deployment.ModuleConfigurer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.ModuleConfigurer;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
/**
* Connects to a kernel in the same VM.
@@ -36,16 +38,23 @@
private static final AbstractNameQuery CONFIGURER_QUERY = new AbstractNameQuery(ModuleConfigurer.class.getName());
public LocalDeploymentManager(Kernel kernel) {
+ super(loadModuleConfigurers(kernel));
initialize(kernel);
+ }
+
+ private static Collection<ModuleConfigurer> loadModuleConfigurers(Kernel kernel) {
+ Collection<ModuleConfigurer> moduleConfigurers = new ArrayList<ModuleConfigurer>();
Set configurerNames = kernel.listGBeans(CONFIGURER_QUERY);
for (Object configurerName : configurerNames) {
AbstractName name = (AbstractName) configurerName;
try {
ModuleConfigurer configurer = (ModuleConfigurer) kernel.getGBean(name);
- moduleConfigurers.put(configurer.getModuleType(), configurer);
+ moduleConfigurers.add(configurer);
} catch (GBeanNotFoundException e) {
log.warn("No gbean found for name returned in query : " + name);
}
}
+ return moduleConfigurers;
}
+
}
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java Sat Feb 17 00:01:26 2007
@@ -22,13 +22,15 @@
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.Set;
-import java.util.Map;
import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
import javax.enterprise.deploy.shared.CommandType;
import javax.enterprise.deploy.spi.Target;
import javax.enterprise.deploy.spi.TargetModuleID;
@@ -38,6 +40,9 @@
import javax.management.remote.JMXConnector;
import javax.security.auth.login.FailedLoginException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.ModuleConfigurer;
import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
import org.apache.geronimo.deployment.plugin.local.AbstractDeployCommand;
import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
@@ -45,16 +50,16 @@
import org.apache.geronimo.deployment.plugin.remote.RemoteDeployUtil;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.apache.geronimo.system.plugin.DownloadPoller;
import org.apache.geronimo.system.plugin.DownloadResults;
+import org.apache.geronimo.system.plugin.PluginInstaller;
import org.apache.geronimo.system.plugin.PluginList;
-import org.apache.geronimo.system.plugin.DownloadPoller;
import org.apache.geronimo.system.plugin.PluginMetadata;
-import org.apache.geronimo.system.plugin.PluginInstaller;
import org.apache.geronimo.system.plugin.PluginRepositoryList;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Connects to a Kernel in a remote VM (may or many not be on the same machine).
@@ -67,13 +72,17 @@
private JMXConnector jmxConnector;
private boolean isSameMachine;
- public RemoteDeploymentManager(JMXConnector jmxConnector, String hostname) throws IOException {
+ public RemoteDeploymentManager(Collection<ModuleConfigurer> moduleConfigurers) {
+ super(moduleConfigurers);
+ }
+
+ public void init(JMXConnector jmxConnector, String hostname) throws IOException {
this.jmxConnector = jmxConnector;
MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
initialize(new KernelDelegate(mbServerConnection));
checkSameMachine(hostname);
}
-
+
public boolean isSameMachine() {
return isSameMachine;
}
@@ -274,4 +283,22 @@
}
return (URL[]) list.toArray(new URL[list.size()]);
}
+
+ public static final GBeanInfo GBEAN_INFO;
+ public static final String GBEAN_REF_MODULE_CONFIGURERS = "ModuleConfigurers";
+
+ static {
+ GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(RemoteDeploymentManager.class, "RemoteDeploymentManager");
+ infoFactory.addInterface(GeronimoDeploymentManager.class);
+ infoFactory.addReference(GBEAN_REF_MODULE_CONFIGURERS, ModuleConfigurer.class);
+
+ infoFactory.setConstructor(new String[] {GBEAN_REF_MODULE_CONFIGURERS});
+
+ GBEAN_INFO = infoFactory.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
}
Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/test/java/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/test/java/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/test/java/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/test/java/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java Sat Feb 17 00:01:26 2007
@@ -17,13 +17,12 @@
package org.apache.geronimo.deployment.plugin;
-import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.DeploymentConfiguration;
import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
import junit.framework.TestCase;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
/**
*
Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java Sat Feb 17 00:01:26 2007
@@ -17,21 +17,20 @@
package org.apache.geronimo.deployment.cli;
-import org.apache.geronimo.common.DeploymentException;
-
-import javax.enterprise.deploy.spi.status.ProgressObject;
-import javax.enterprise.deploy.spi.status.ProgressListener;
-import javax.enterprise.deploy.spi.status.ProgressEvent;
-import javax.enterprise.deploy.spi.TargetModuleID;
-import javax.enterprise.deploy.spi.Target;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import java.io.PrintWriter;
import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.LinkedList;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.common.DeploymentException;
/**
* Base class for CLI deployer commands. Tracks some simple properties and
Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java Sat Feb 17 00:01:26 2007
@@ -17,11 +17,32 @@
package org.apache.geronimo.deployment.cli;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+
import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.common.GeronimoEnvironment;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.util.Main;
-import java.util.*;
-import java.io.*;
/**
* The main class for the CLI deployer. Handles chunking the input arguments
@@ -35,56 +56,43 @@
*
* @version $Rev$ $Date$
*/
-public class DeployTool {
- private final static Map commands = new HashMap();
+public class DeployTool implements Main {
- public static void registerCommand(DeployCommand command) {
- String key = command.getCommandName();
- if(commands.containsKey(key)) {
- throw new IllegalArgumentException("Command "+key+" is already registered!");
- } else {
- commands.put(key, command);
- }
- }
-
- private static DeployCommand getCommand(String name) {
- return (DeployCommand) commands.get(name);
- }
-
- private static DeployCommand[] getAllCommands() {
- DeployCommand[] list = (DeployCommand[]) commands.values().toArray(new DeployCommand[0]);
- Arrays.sort(list, new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((DeployCommand)o1).getCommandName().compareTo(((DeployCommand)o2).getCommandName());
- }
- });
- return list;
- }
+ private static final Collection<DeployCommand> commands = new ArrayList<DeployCommand>();
static {
- // Perform initialization tasks common with the various Geronimo process environments.
- GeronimoEnvironment.init();
-
- registerCommand(new CommandLogin());
- registerCommand(new CommandDeploy());
- registerCommand(new CommandDistribute());
- registerCommand(new CommandListModules());
- registerCommand(new CommandListTargets());
- registerCommand(new CommandRedeploy());
- registerCommand(new CommandStart());
- registerCommand(new CommandStop());
- registerCommand(new CommandRestart());
- registerCommand(new CommandUndeploy());
- registerCommand(new CommandListConfigurations());
- registerCommand(new CommandInstallCAR());
+ commands.add(new CommandLogin());
+ commands.add(new CommandDeploy());
+ commands.add(new CommandDistribute());
+ commands.add(new CommandListModules());
+ commands.add(new CommandListTargets());
+ commands.add(new CommandRedeploy());
+ commands.add(new CommandStart());
+ commands.add(new CommandStop());
+ commands.add(new CommandRestart());
+ commands.add(new CommandUndeploy());
+ commands.add(new CommandListConfigurations());
+ commands.add(new CommandInstallCAR());
}
private boolean failed = false;
String[] generalArgs = new String[0];
ServerConnection con = null;
private boolean multipleCommands = false;
+ private final Kernel kernel;
+ private final DeploymentFactory deploymentFactory;
- public boolean execute(String args[]) {
+ public DeployTool(Kernel kernel, DeploymentFactory deploymentFactory) {
+ if (null == kernel) {
+ throw new IllegalArgumentException("kernel is required");
+ } else if (null == deploymentFactory) {
+ throw new IllegalArgumentException("deploymentFactory is required");
+ }
+ this.kernel = kernel;
+ this.deploymentFactory = deploymentFactory;
+ }
+
+ public int execute(String args[]) {
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);
InputStream in = System.in;
@@ -154,7 +162,7 @@
} else {
try {
if(con == null) {
- con = new ServerConnection(generalArgs, out, in);
+ con = new ServerConnection(generalArgs, out, in, kernel, deploymentFactory);
}
try {
dc.execute(out, con, commandArgs);
@@ -178,7 +186,7 @@
}
out.flush();
System.out.flush();
- return !failed;
+ return failed ? 1 : 0;
}
public static String[] splitCommand(String line) {
@@ -310,11 +318,42 @@
return (String[]) list.toArray(new String[list.size()]);
}
- public static void main(String[] args) {
- if(!new DeployTool().execute(args)) {
- System.exit(1);
- } else {
- System.exit(0);
+ private DeployCommand getCommand(String commandName) {
+ for (DeployCommand command : commands) {
+ if (command.getCommandName().equals(commandName)) {
+ return command;
+ }
}
+ return null;
}
+
+ private DeployCommand[] getAllCommands() {
+ DeployCommand[] list = (DeployCommand[]) commands.toArray(new DeployCommand[0]);
+ Arrays.sort(list, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((DeployCommand)o1).getCommandName().compareTo(((DeployCommand)o2).getCommandName());
+ }
+ });
+ return list;
+ }
+
+
+ public static final GBeanInfo GBEAN_INFO;
+ public static final String GBEAN_REF_DEPLOYMENT_FACTORY = "DeploymentFactory";
+
+ static {
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("DeployTool", DeployTool.class, "DeployTool");
+
+ infoBuilder.addReference(GBEAN_REF_DEPLOYMENT_FACTORY, DeploymentFactory.class);
+ infoBuilder.addInterface(Main.class);
+
+ infoBuilder.setConstructor(new String[] {"kernel", GBEAN_REF_DEPLOYMENT_FACTORY});
+
+ GBEAN_INFO = infoBuilder.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
}
Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java (original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java Sat Feb 17 00:01:26 2007
@@ -20,11 +20,11 @@
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Serializable;
-import java.io.FileNotFoundException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -38,14 +38,10 @@
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
import org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager;
-import org.apache.geronimo.util.SimpleEncryption;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.system.main.LocalServer;
+import org.apache.geronimo.util.SimpleEncryption;
/**
* Supports online connections to the server, via JSR-88, valid only
@@ -106,6 +102,8 @@
private final static String DEFAULT_URI = "deployer:geronimo:jmx";
+ private final DeploymentFactory geronimoDeploymentFactory;
+
private DeploymentManager manager;
private PrintWriter out;
private InputStream in;
@@ -113,7 +111,12 @@
private boolean logToSysErr;
private boolean verboseMessages;
- public ServerConnection(String[] args, PrintWriter out, InputStream in) throws DeploymentException {
+ public ServerConnection(String[] args, PrintWriter out, InputStream in, Kernel kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
+ if (null == kernel) {
+ throw new IllegalArgumentException("kernel is required");
+ }
+ this.geronimoDeploymentFactory = geronimoDeploymentFactory;
+
String uri = null, driver = null, user = null, password = null, host = null;
Integer port = null;
this.out = out;
@@ -194,17 +197,8 @@
uri = DEFAULT_URI + "://" + (host == null ? "" : host) + (port == null ? "" : ":" + port);
}
if (offline) {
- LocalServer localServer;
- try {
- localServer = new LocalServer("org.apache.geronimo.configs/j2ee-system//car", "var/config/offline-deployer-list");
- } catch (Exception e) {
- throw new DeploymentException("Could not start local server", e);
- }
- Kernel kernel = localServer.getKernel();
- ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
- configurationManager.setOnline(false);
-
- manager = new LocalDeploymentManager(localServer.getKernel());
+ startOfflineDeployer(kernel);
+ manager = new LocalDeploymentManager(kernel);
} else {
tryToConnect(uri, driver, user, password, true);
}
@@ -213,6 +207,11 @@
}
}
+ protected void startOfflineDeployer(Kernel kernel) throws DeploymentException {
+ OfflineDeployerStarter offlineDeployerStarter = new OfflineDeployerStarter(kernel);
+ offlineDeployerStarter.start();
+ }
+
public void close() throws DeploymentException {
if (manager != null) {
manager.release();
@@ -232,7 +231,7 @@
if (driver != null) {
loadDriver(driver, mgr);
} else {
- mgr.registerDeploymentFactory(new DeploymentFactoryImpl());
+ mgr.registerDeploymentFactory(geronimoDeploymentFactory);
}
String useURI = argURI == null ? DEFAULT_URI : argURI;
Modified: geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java (original)
+++ geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java Sat Feb 17 00:01:26 2007
@@ -16,36 +16,37 @@
*/
package org.apache.geronimo.deployment.hot;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.cli.DeployUtils;
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryWithKernel;
+import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
-import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
-import org.apache.geronimo.deployment.cli.DeployUtils;
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.kernel.config.PersistentConfigurationList;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.DeploymentWatcher;
-import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.MissingDependencyException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.TargetModuleID;
-import javax.enterprise.deploy.spi.Target;
-import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
-import javax.enterprise.deploy.spi.status.ProgressObject;
-import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-
-import java.io.File;
-import java.util.Set;
-import java.util.Iterator;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
* A directory-scanning hot deployer
@@ -142,7 +143,7 @@
public void doStart() throws Exception {
if (factory == null) {
- factory = new DeploymentFactoryImpl();
+ factory = new DeploymentFactoryWithKernel(kernel);
}
File dir = serverInfo.resolve(path);
if (!dir.exists()) {
Modified: geronimo/server/trunk/modules/geronimo-kernel/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/pom.xml?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/pom.xml Sat Feb 17 00:01:26 2007
@@ -65,6 +65,47 @@
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>test-resources</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <delete dir="${project.build.directory}/tmp"/>
+ <mkdir dir="${project.build.directory}/tmp"/>
+
+ <mkdir dir="${project.build.directory}/m1"/>
+ <copy todir="${project.build.directory}/m1">
+ <fileset dir="${basedir}/src/test/repo/m1"/>
+ </copy>
+
+ <mkdir dir="${project.build.directory}/m2"/>
+ <copy todir="${project.build.directory}/m2">
+ <fileset dir="${basedir}/src/test/repo/m2"/>
+ </copy>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Sat Feb 17 00:01:26 2007
@@ -16,23 +16,27 @@
*/
package org.apache.geronimo.kernel.config;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
-import java.io.File;
+import java.net.JarURLConnection;
+import java.net.URI;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Set;
+import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Collections;
-import java.util.ArrayList;
-import java.util.Properties;
import java.util.Map;
-import java.util.LinkedHashSet;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GAttributeInfo;
@@ -40,16 +44,18 @@
import org.apache.geronimo.gbean.GReferenceInfo;
import org.apache.geronimo.gbean.InvalidConfigurationException;
import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.ClassLoading;
import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.basic.BasicKernel;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.Maven2Repository;
/**
* @version $Rev:386276 $ $Date$
@@ -83,6 +89,29 @@
configurationMarshaler = marshaler;
}
+
+ private static final File bootDirectory;
+
+ static {
+ // guess from the location of the jar
+ URL url = ConfigurationUtil.class.getClassLoader().getResource("META-INF/startup-jar");
+
+ File directory = null;
+ if (url != null) {
+ try {
+ JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+ url = jarConnection.getJarFileURL();
+
+ URI baseURI = new URI(url.toString()).resolve("..");
+ directory = new File(baseURI);
+ } catch (Exception ignored) {
+ log.error("Error while determining the installation directory of Apache Geronimo", ignored);
+ }
+ } else {
+ log.error("Cound not determine the installation directory of Apache Geronimo, because the startup jar could not be found in the current class loader.");
+ }
+ bootDirectory = directory;
+ }
public static ConfigurationMarshaler createConfigurationMarshaler(String marshalerClass) throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@@ -122,28 +151,44 @@
}
public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader) throws Exception {
+ return loadBootstrapConfiguration(kernel, in, classLoader, false);
+ }
+
+ public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader, boolean enableBootRepo) throws Exception {
ConfigurationData configurationData = readConfigurationData(in);
- return loadBootstrapConfiguration(kernel, configurationData, classLoader);
+ return loadBootstrapConfiguration(kernel, configurationData, classLoader, enableBootRepo);
}
public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, ClassLoader classLoader) throws Exception {
+ return loadBootstrapConfiguration(kernel, configurationData, classLoader, false);
+ }
+
+ public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, ClassLoader classLoader, boolean enableBootRepo) throws Exception {
if (kernel == null) throw new NullPointerException("kernel is null");
if (configurationData == null) throw new NullPointerException("configurationData is null");
if (classLoader == null) throw new NullPointerException("classLoader is null");
- // a bootstrap configuration can not have any dependencies
- List dependencies = configurationData.getEnvironment().getDependencies();
- if (!dependencies.isEmpty()) {
- configurationData.getEnvironment().setDependencies(Collections.EMPTY_SET);
-// throw new InvalidConfigurationException("Booststrap configuration can not have dependendencies: " + dependencies);
- }
-
// build the gbean data
Artifact configId = configurationData.getId();
AbstractName abstractName = Configuration.getConfigurationAbstractName(configId);
GBeanData gbeanData = new GBeanData(abstractName, Configuration.GBEAN_INFO);
gbeanData.setAttribute("configurationData", configurationData);
- gbeanData.setAttribute("configurationResolver", new ConfigurationResolver(configurationData, null, null));
+
+ Collection repositories = null;
+ ArtifactResolver artifactResolver = null;
+ if (enableBootRepo) {
+ String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path", "repository");
+ Maven2Repository bootRepository = new Maven2Repository(new File(bootDirectory, repository));
+ repositories = Collections.singleton(bootRepository);
+ artifactResolver = new DefaultArtifactResolver(new DefaultArtifactManager(), bootRepository);
+ } else {
+ // a bootstrap configuration can not have any dependencies
+ List dependencies = configurationData.getEnvironment().getDependencies();
+ if (!dependencies.isEmpty()) {
+ configurationData.getEnvironment().setDependencies(Collections.EMPTY_SET);
+ }
+ }
+ gbeanData.setAttribute("configurationResolver", new ConfigurationResolver(configurationData, repositories, artifactResolver));
// load and start the gbean
kernel.loadGBean(gbeanData, classLoader);
@@ -237,12 +282,12 @@
}
/**
- * Gets a reference or proxy to the ConfigurationManager running in the specified kernel.
+ * Gets the name of the ConfigurationManager running in the specified kernel.
*
- * @return The ConfigurationManager
+ * @return Its AbstractName
* @throws IllegalStateException Occurs if a ConfigurationManager cannot be identified
*/
- public static ConfigurationManager getConfigurationManager(Kernel kernel) {
+ public static AbstractName getConfigurationManagerName(Kernel kernel) {
Set names = kernel.listGBeans(new AbstractNameQuery(ConfigurationManager.class.getName()));
for (Iterator iterator = names.iterator(); iterator.hasNext();) {
AbstractName abstractName = (AbstractName) iterator.next();
@@ -256,7 +301,18 @@
if (names.size() > 1) {
throw new IllegalStateException("More than one Configuration Manager was found in the kernel");
}
- AbstractName configurationManagerName = (AbstractName) names.iterator().next();
+ return (AbstractName) names.iterator().next();
+ }
+
+
+ /**
+ * Gets a reference or proxy to the ConfigurationManager running in the specified kernel.
+ *
+ * @return The ConfigurationManager
+ * @throws IllegalStateException Occurs if a ConfigurationManager cannot be identified
+ */
+ public static ConfigurationManager getConfigurationManager(Kernel kernel) {
+ AbstractName configurationManagerName = getConfigurationManagerName(kernel);
return (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,209 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.util.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @version $Rev: 506425 $ $Date: 2007-02-12 22:49:46 +1100 (Mon, 12 Feb 2007) $
+ */
+public abstract class AbstractRepository implements WriteableRepository {
+ protected static final Log log = LogFactory.getLog(AbstractRepository.class);
+ private final static ArtifactTypeHandler DEFAULT_TYPE_HANDLER = new CopyArtifactTypeHandler();
+ protected final File rootFile;
+ private final Map typeHandlers = new HashMap();
+
+ public AbstractRepository(File rootFile) {
+ if (rootFile == null) throw new NullPointerException("root is null");
+
+ if (!rootFile.exists() || !rootFile.isDirectory() || !rootFile.canRead()) {
+ throw new IllegalStateException("Maven2Repository must have a root that's a valid readable directory (not " + rootFile.getAbsolutePath() + ")");
+ }
+
+ this.rootFile = rootFile;
+ log.debug("Repository root is " + rootFile.getAbsolutePath());
+
+ typeHandlers.put("car", new UnpackArtifactTypeHandler());
+ }
+
+ public boolean contains(Artifact artifact) {
+ // Note: getLocation(artifact) does an artifact.isResolved() check - no need to do it here.
+ File location = getLocation(artifact);
+ return location.canRead() && (location.isFile() || new File(location, "META-INF").isDirectory());
+ }
+
+ private static final String NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
+ public LinkedHashSet getDependencies(Artifact artifact) {
+ if(!artifact.isResolved()) {
+ throw new IllegalArgumentException("Artifact "+artifact+" is not fully resolved");
+ }
+ LinkedHashSet dependencies = new LinkedHashSet();
+ URL url;
+ try {
+ File location = getLocation(artifact);
+ url = location.toURL();
+ } catch (MalformedURLException e) {
+ throw (IllegalStateException)new IllegalStateException("Unable to get URL for dependency " + artifact).initCause(e);
+ }
+ ClassLoader depCL = new URLClassLoader(new URL[]{url}, new ClassLoader() {
+ @Override
+ public URL getResource(String name) {
+ return null;
+ }
+ });
+ InputStream is = depCL.getResourceAsStream("META-INF/geronimo-dependency.xml");
+ try {
+ if (is != null) {
+ InputSource in = new InputSource(is);
+ DocumentBuilderFactory dfactory = XmlUtil.newDocumentBuilderFactory();
+ dfactory.setNamespaceAware(true);
+ try {
+ Document doc = dfactory.newDocumentBuilder().parse(in);
+ Element root = doc.getDocumentElement();
+ NodeList configs = root.getElementsByTagNameNS(NAMESPACE, "dependency");
+ for (int i = 0; i < configs.getLength(); i++) {
+ Element dependencyElement = (Element) configs.item(i);
+ String groupId = getString(dependencyElement, "groupId");
+ String artifactId = getString(dependencyElement, "artifactId");
+ String version = getString(dependencyElement, "version");
+ String type = getString(dependencyElement, "type");
+ if (type == null) {
+ type = "jar";
+ }
+ dependencies.add(new Artifact(groupId, artifactId, version, type));
+ }
+ } catch (IOException e) {
+ throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
+ } catch (ParserConfigurationException e) {
+ throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
+ } catch (SAXException e) {
+ throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
+ }
+ }
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ignore) {
+ // ignore
+ }
+ }
+ }
+ return dependencies;
+ }
+
+ private String getString(Element dependencyElement, String childName) {
+ NodeList children = dependencyElement.getElementsByTagNameNS(NAMESPACE, childName);
+ if (children == null || children.getLength() == 0) {
+ return null;
+ }
+ String value = "";
+ NodeList text = children.item(0).getChildNodes();
+ for (int t = 0; t < text.getLength(); t++) {
+ Node n = text.item(t);
+ if (n.getNodeType() == Node.TEXT_NODE) {
+ value += n.getNodeValue();
+ }
+ }
+ return value.trim();
+ }
+
+ public void setTypeHandler(String type, ArtifactTypeHandler handler) {
+ typeHandlers.put(type, handler);
+ }
+
+ public void copyToRepository(File source, Artifact destination, FileWriteMonitor monitor) throws IOException {
+ if(!destination.isResolved()) {
+ throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
+ }
+ if (!source.exists() || !source.canRead() || source.isDirectory()) {
+ throw new IllegalArgumentException("Cannot read source file at " + source.getAbsolutePath());
+ }
+ int size = 0;
+ try {
+ ZipFile zip = new ZipFile(source);
+ for (Enumeration entries=zip.entries(); entries.hasMoreElements();) {
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ size += entry.getSize();
+ }
+ } catch (ZipException ze) {
+ size = (int)source.length();
+ }
+ FileInputStream is = new FileInputStream(source);
+ try {
+ copyToRepository(is, size, destination, monitor);
+ } finally {
+ try {
+ is.close();
+ } catch (IOException ignored) {
+ // ignored
+ }
+ }
+ }
+
+ public void copyToRepository(InputStream source, int size, Artifact destination, FileWriteMonitor monitor) throws IOException {
+ if(!destination.isResolved()) {
+ throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
+ }
+ // is this a writable repository
+ if (!rootFile.canWrite()) {
+ throw new IllegalStateException("This repository is not writable: " + rootFile.getAbsolutePath() + ")");
+ }
+
+ // where are we going to install the file
+ File location = getLocation(destination);
+
+ // assure that there isn't already a file installed at the specified location
+ if (location.exists()) {
+ throw new IllegalArgumentException("Destination " + location.getAbsolutePath() + " already exists!");
+ }
+
+ ArtifactTypeHandler typeHandler = (ArtifactTypeHandler) typeHandlers.get(destination.getType());
+ if (typeHandler == null) typeHandler = DEFAULT_TYPE_HANDLER;
+ typeHandler.install(source, size, destination, monitor, location);
+
+ if (destination.getType().equalsIgnoreCase("car")) {
+ log.debug("Installed module configuration; id=" + destination + "; location=" + location);
+ }
+ }
+}
|