You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/11/13 09:03:02 UTC
svn commit: r332943 - in /geronimo/trunk/plugins/geronimo-packaging-plugin:
plugin.jelly project.xml
src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
Author: djencks
Date: Sun Nov 13 00:02:58 2005
New Revision: 332943
URL: http://svn.apache.org/viewcvs?rev=332943&view=rev
Log:
run the package builder in an isolated classloader
Added:
geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
Modified:
geronimo/trunk/plugins/geronimo-packaging-plugin/plugin.jelly
geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml
geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/plugin.jelly?rev=332943&r1=332942&r2=332943&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/plugin.jelly (original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/plugin.jelly Sun Nov 13 00:02:58 2005
@@ -26,7 +26,7 @@
xmlns:car="geronimo:packaging"
>
<define:taglib uri="geronimo:packaging">
- <define:jellybean name="package" className="org.apache.geronimo.plugin.packaging.PackageBuilder" method="execute"/>
+ <define:jellybean name="package" className="org.apache.geronimo.plugin.packaging.PackageBuilderShell" method="execute"/>
<define:jellybean name="jmxDistribute" className="org.apache.geronimo.plugin.packaging.JMXDistributor" method="execute"/>
<define:jellybean name="dependencies" className="org.apache.geronimo.plugin.packaging.PlanProcessor" method="execute"/>
</define:taglib>
@@ -52,6 +52,8 @@
<goal name="car:package" prereqs="car:prepare-plan" description="Package a Geronimo Configuration">
<car:package
+ context="${context}"
+ artifacts="${pom.artifacts}"
repository="${geronimo.packaging.repository}"
deploymentConfig="${geronimo.packaging.deploymentConfig}"
deployerName="${geronimo.packaging.deployerName}"
Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml?rev=332943&r1=332942&r2=332943&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml (original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/project.xml Sun Nov 13 00:02:58 2005
@@ -29,23 +29,51 @@
<groupId>geronimo</groupId>
<artifactId>geronimo-kernel</artifactId>
<version>1.0-SNAPSHOT</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_2</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
</dependency>
<dependency>
<groupId>mx4j</groupId>
<artifactId>mx4j</artifactId>
<version>3.0.1</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
</dependency>
<dependency>
<groupId>mx4j</groupId>
<artifactId>mx4j-remote</artifactId>
<version>3.0.1</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.8</version>
+ <properties>
+ <packaging.classpath>true</packaging.classpath>
+ </properties>
+ </dependency>
<!-- dependency addition -->
<dependency>
Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=332943&r1=332942&r2=332943&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java (original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java Sun Nov 13 00:02:58 2005
@@ -31,6 +31,7 @@
import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.log4j.BasicConfigurator;
/**
* JellyBean that builds a Geronimo Configuration using the local Mavem
@@ -89,7 +90,8 @@
}
private File repository;
- private URI deploymentConfig;
+ private String deploymentConfigString;
+ private URI[] deploymentConfig;
private ObjectName deployerName;
private File planFile;
@@ -114,16 +116,22 @@
}
public String getDeploymentConfig() {
- return deploymentConfig.toString();
+ return deploymentConfigString;
}
/**
* Set the id of the Configuration to use to perform the packaging.
*
- * @param deploymentConfig the id of the Configuration performing the deployment
+ * @param deploymentConfigString comma-separated list of the ids of the Configurations performing the deployment
*/
- public void setDeploymentConfig(String deploymentConfig) {
- this.deploymentConfig = URI.create(deploymentConfig);
+ public void setDeploymentConfig(String deploymentConfigString) {
+ this.deploymentConfigString = deploymentConfigString;
+ String[] configNames = deploymentConfigString.split(",");
+ deploymentConfig = new URI[configNames.length];
+ for (int i = 0; i < configNames.length; i++) {
+ String configName = configNames[i];
+ deploymentConfig[i] = URI.create(configName);
+ }
}
public String getDeployerName() {
@@ -225,15 +233,19 @@
// start the Configuration we're going to use for this deployment
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
try {
- if (!configurationManager.isLoaded(deploymentConfig)) {
- List configs = configurationManager.loadRecursive(deploymentConfig);
- for (int i = 0; i < configs.size(); i++) {
- URI configName = (URI) configs.get(i);
- try {
- configurationManager.start(configName);
- } catch (Throwable e) {
- throw new RuntimeException("Could not start configuration: " + configName, e);
+ for (int i = 0; i < deploymentConfig.length; i++) {
+ URI configName = deploymentConfig[i];
+ if (!configurationManager.isLoaded(configName)) {
+ List configs = configurationManager.loadRecursive(configName);
+ for (Iterator iterator = configs.iterator(); iterator.hasNext(); ) {
+ URI ancestorConfigName = (URI) iterator.next();
+ try {
+ configurationManager.loadGBeans(ancestorConfigName);
+ } catch (Throwable e) {
+ throw new RuntimeException("Could not start configuration: " + configName, e);
+ }
}
+ configurationManager.start(configName);
}
}
} finally {
@@ -259,7 +271,8 @@
if (kernel != null) {
return kernel;
}
-
+
+ BasicConfigurator.configure();
// boot one ourselves
kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
kernel.boot();
Added: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java?rev=332943&view=auto
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java (added)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilderShell.java Sun Nov 13 00:02:58 2005
@@ -0,0 +1,246 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.geronimo.plugin.packaging;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.commons.jelly.JellyContext;
+import org.apache.maven.jelly.MavenJellyContext;
+import org.apache.maven.project.Dependency;
+import org.apache.maven.repository.Artifact;
+
+/**
+ * JellyBean that builds a Geronimo Configuration using the local Mavem
+ * infrastructure.
+ *
+ * @version $Rev: 330620 $ $Date: 2005-11-03 12:07:18 -0800 (Thu, 03 Nov 2005) $
+ */
+public class PackageBuilderShell {
+
+// private URL[] builderClassPath;
+ private List artifacts;
+ private MavenJellyContext context;
+
+ private static ClassLoader classLoader;
+
+ private File repository;
+ private String deploymentConfigString;
+ private String deployerName;
+
+ private File planFile;
+ private File moduleFile;
+ private File packageFile;
+ private String mainClass;
+ private String classPath;
+ private String endorsedDirs;
+ private String extensionDirs;
+ private static final String PACKAGING_CLASSPATH_PROPERTY = "packaging.classpath";
+
+ public File getRepository() {
+ return repository;
+ }
+
+ /**
+ * Set the location of the Maven repository; typically ${maven.repo.local}
+ *
+ * @param repository the location of the Maven repository
+ */
+ public void setRepository(File repository) {
+ this.repository = repository;
+ }
+
+ public String getDeploymentConfig() {
+ return deploymentConfigString;
+ }
+
+ /**
+ * Set the id of the Configuration to use to perform the packaging.
+ *
+ * @param deploymentConfigString comma-separated list of the ids of the Configurations performing the deployment
+ */
+ public void setDeploymentConfig(String deploymentConfigString) {
+ this.deploymentConfigString = deploymentConfigString;
+ }
+
+ public String getDeployerName() {
+ return deployerName;
+ }
+
+ /**
+ * Set the name of the GBean that is the Deployer.
+ *
+ * @param deployerName the name of the Deployer GBean
+ */
+ public void setDeployerName(String deployerName) {
+ this.deployerName = deployerName;
+ }
+
+ public File getPlanFile() {
+ return planFile;
+ }
+
+ /**
+ * Set the File that is the deployment plan.
+ *
+ * @param planFile the deployment plan
+ */
+ public void setPlanFile(File planFile) {
+ this.planFile = planFile;
+ }
+
+ public File getModuleFile() {
+ return moduleFile;
+ }
+
+ /**
+ * Set the File that is the module being deployed.
+ *
+ * @param moduleFile the module to deploy
+ */
+ public void setModuleFile(File moduleFile) {
+ this.moduleFile = moduleFile;
+ }
+
+ public File getPackageFile() {
+ return packageFile;
+ }
+
+ /**
+ * Set the File where the Configuration will be stored; normally the artifact being produced.
+ *
+ * @param packageFile the package file to produce
+ */
+ public void setPackageFile(File packageFile) {
+ this.packageFile = packageFile;
+ }
+
+ public String getMainClass() {
+ return mainClass;
+ }
+
+ /**
+ * Set the name of the class containing the main method for a executable configuration.
+ *
+ * @param mainClass
+ */
+ public void setMainClass(String mainClass) {
+ this.mainClass = mainClass;
+ }
+
+ public String getClassPath() {
+ return classPath;
+ }
+
+ public void setClassPath(String classPath) {
+ this.classPath = classPath;
+ }
+
+ public String getEndorsedDirs() {
+ return endorsedDirs;
+ }
+
+ public void setEndorsedDirs(String endorsedDirs) {
+ this.endorsedDirs = endorsedDirs;
+ }
+
+ public String getExtensionDirs() {
+ return extensionDirs;
+ }
+
+ public void setExtensionDirs(String extensionDirs) {
+ this.extensionDirs = extensionDirs;
+ }
+
+ public List getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public MavenJellyContext getContext() {
+ return context;
+ }
+
+ public void setContext(MavenJellyContext context) {
+ this.context = context;
+ }
+
+ public void execute() throws Exception {
+ Object packageBuilder = getPackageBuilder();
+ set("setClassPath", classPath, String.class, packageBuilder);
+ set("setDeployerName", deployerName, String.class, packageBuilder);
+ set("setDeploymentConfig", deploymentConfigString, String.class, packageBuilder);
+ set("setEndorsedDirs", endorsedDirs, String.class, packageBuilder);
+ set("setExtensionDirs", extensionDirs, String.class, packageBuilder);
+ set("setMainClass", mainClass, String.class, packageBuilder);
+ set("setModuleFile", moduleFile, File.class, packageBuilder);
+ set("setPackageFile", packageFile, File.class, packageBuilder);
+ set("setPlanFile", planFile, File.class, packageBuilder);
+ set("setRepository", repository, File.class, packageBuilder);
+
+ Method m = packageBuilder.getClass().getMethod("execute", new Class[]{});
+ m.invoke(packageBuilder, new Object[]{});
+ }
+
+ private void set(String methodName, Object value, Class type, Object packageBuilder) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ Method m = packageBuilder.getClass().getMethod(methodName, new Class[]{type});
+ m.invoke(packageBuilder, new Object[]{value});
+ }
+
+
+ private Object getPackageBuilder() throws ClassNotFoundException, IllegalAccessException, InstantiationException, MalformedURLException {
+ if (classLoader == null) {
+ String repo = context.getMavenRepoLocal();
+ String pluginDir = context.getPluginsDir();
+ List urls = new ArrayList();
+// for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
+// Artifact artifact = (Artifact) iterator.next();
+// Dependency dependency = (Dependency) artifact.getDependency();
+// if ("true".equals(dependency.getProperty(PACKAGING_CLASSPATH_PROPERTY))) {
+// String urlString = artifact.getUrlPath();
+// URL url = new File(repo + urlString).toURL();
+// urls.add(url);
+// }
+// }
+ urls.add(new File(repo + "/geronimo/jars/geronimo-kernel-1.0-SNAPSHOT.jar").toURL());
+ urls.add(new File(repo + "/geronimo/jars/geronimo-system-1.0-SNAPSHOT.jar").toURL());
+ urls.add(new File(repo + "/mx4j/jars/mx4j-3.0.1.jar").toURL());
+ urls.add(new File(repo + "/mx4j/jars/mx4j-remote-3.0.1.jar").toURL());
+ urls.add(new File(repo + "/cglib/jars/cglib-nodep-2.1_2.jar").toURL());
+ urls.add(new File(repo + "/commons-logging/jars/commons-logging-1.0.4.jar").toURL());
+ urls.add(new File(repo + "/log4j/jars/log4j-1.2.8.jar").toURL());
+ urls.add(new File(pluginDir + "/geronimo-packaging-plugin-1.0-SNAPSHOT.jar").toURL());
+ URL[] builderClassPath = (URL[]) urls.toArray(new URL[urls.size()]);
+ classLoader = new URLClassLoader(builderClassPath, ClassLoader.getSystemClassLoader());
+ }
+ return classLoader.loadClass(PackageBuilder.class.getName()).newInstance();
+ }
+
+
+}