You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/08/04 21:44:34 UTC
svn commit: r428856 [8/12] - in /geronimo/sandbox/svkmerge/trunk: ./
applications/ applications/console/ applications/console/console-core/
applications/console/console-ear/ applications/console/console-framework/
applications/console/console-framework...
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * 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.car;
+
+import org.apache.geronimo.plugin.car.PackageBuilder;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+import java.util.Arrays;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PackagingCommandLine {
+
+ public static void Main(String[] args) throws Exception {
+ File configFile = new File("packaging.properties");
+ Properties config = new Properties();
+ InputStream in = new FileInputStream(configFile);
+ try {
+ config.load(in);
+ } finally {
+ in.close();
+ }
+ mergeArgs(config, args);
+
+ new PackagingCommandLine(config).execute();
+ }
+
+ private static void mergeArgs(Properties config, String[] args) throws Exception {
+ if (args.length % 2 != 0) {
+ throw new Exception("There must be an even number of args, --<name> followed by value");
+ }
+
+ for (int i = 0; i < args.length; i++) {
+ String key = args[i++];
+ String value = args[i];
+
+ if (!key.startsWith("--")) {
+ throw new Exception("Keys must be preceded by '--'");
+ }
+
+ key = key.substring(2);
+ config.put(key, value);
+ }
+ }
+
+ private final Properties config;
+
+ public PackagingCommandLine(Properties config) {
+ this.config = config;
+ }
+
+ public void execute() throws Exception {
+ PackageBuilder builder = new PackageBuilder();
+
+ builder.setClassPath(config.getProperty("classPath"));
+ builder.setConfigurationStoreClass(config.getProperty("configurationStoreClass"));
+ builder.setDeployerName(config.getProperty("deployerName"));
+ String[] artifactNames = config.getProperty("deploymentConfig").split("/");
+ builder.setDeploymentConfig(Arrays.asList(artifactNames));
+ builder.setEndorsedDirs(config.getProperty("endorsedDirs"));
+ builder.setExtensionDirs(config.getProperty("extensionDirs"));
+ builder.setMainClass(config.getProperty("mainClass"));
+ builder.setModuleFile(getFile(config.getProperty("moduleFile")));
+ builder.setPackageFile(getFile(config.getProperty("packageFile")));
+ builder.setPlanFile(getFile(config.getProperty("planFile")));
+ builder.setRepository(getFile(config.getProperty("repository")));
+ builder.setRepositoryClass(config.getProperty("repositoryClass"));
+
+ builder.execute();
+ }
+
+ private File getFile(String fileName) {
+ if (fileName == null) {
+ return null;
+ }
+ return new File(fileName);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PackagingCommandLine.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,288 @@
+/**
+ *
+ * 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.car;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ImportType;
+
+import org.apache.maven.model.Dependency;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+
+//
+// TODO: Rename to PreparePlanMojo
+//
+
+/**
+ * Add dependencies to a plan and process with velocity
+ *
+ * @goal prepare-plan
+ *
+ * @version $Rev$ $Date$
+ */
+public class PlanProcessorMojo
+ extends AbstractCarMojo
+{
+ private static final String ENVIRONMENT_LOCAL_NAME = "environment";
+
+ private static final QName ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1", "environment");
+
+ /**
+ * @parameter expression="${basedir}/src/plan"
+ * @required
+ */
+ private File sourceDir;
+
+ /**
+ * @parameter expression="${project.build.directory}/plan"
+ * @required
+ */
+ private File targetDir;
+
+ /**
+ * @parameter default-value="plan.xml"
+ * @required
+ */
+ private String planFileName;
+
+ /**
+ * @parameter expression="${project.build.directory}/plan/plan.xml"
+ * @required
+ */
+ private File targetFile;
+
+ //
+ // FIXME: Resolve what to do about this comment...
+ //
+ // This is needed for ${pom.currentVersion} and will be removed when
+ // we move to a full m2 build
+ //
+
+ private VelocityContext createContext() {
+ VelocityContext context = new VelocityContext();
+ Map pom = new HashMap();
+ pom.put("groupId", project.getGroupId());
+ pom.put("artifactId", project.getArtifactId());
+ pom.put("currentVersion", project.getVersion());
+ context.put("pom", pom);
+
+ // Load properties, It inherits them all!
+ Properties props = project.getProperties();
+ for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ String value = props.getProperty(key);
+
+ log.debug("Setting " + key + "=" + value);
+ context.put(key, value);
+ }
+
+ return context;
+ }
+
+ protected void doExecute() throws Exception {
+ //
+ // FIXME: Do not need velocity here, we only need to filter,
+ // could use resources plugin to do this for us, or
+ // implement what resources plugin does here
+ //
+
+ VelocityContext context = createContext();
+
+ VelocityEngine velocity = new VelocityEngine();
+ velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());
+ velocity.init();
+
+ Template template = velocity.getTemplate(planFileName);
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+
+ String plan = writer.toString();
+
+ XmlObject doc = XmlObject.Factory.parse(plan);
+ XmlCursor xmlCursor = doc.newCursor();
+ LinkedHashSet dependencies = toDependencies();
+ Artifact configId = new Artifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "car");
+
+ try {
+ mergeEnvironment(xmlCursor, configId, dependencies);
+
+ if (targetDir.exists()) {
+ if (!targetDir.isDirectory()) {
+ throw new RuntimeException("TargetDir: " + this.targetDir + " exists and is not a directory");
+ }
+ }
+ else {
+ targetDir.mkdirs();
+ }
+
+ XmlOptions xmlOptions = new XmlOptions();
+ xmlOptions.setSavePrettyPrint();
+ doc.save(targetFile, xmlOptions);
+
+ log.info("Generated: " + targetFile);
+ }
+ finally {
+ xmlCursor.dispose();
+ }
+ }
+
+ void mergeEnvironment(final XmlCursor xmlCursor, final Artifact configId, final LinkedHashSet dependencies) {
+ xmlCursor.toFirstContentToken();
+ xmlCursor.toFirstChild();
+ QName childName = xmlCursor.getName();
+ Environment oldEnvironment;
+
+ if (childName != null && childName.getLocalPart().equals(ENVIRONMENT_LOCAL_NAME)) {
+ convertElement(xmlCursor, ENVIRONMENT_QNAME.getNamespaceURI());
+ XmlObject xmlObject = xmlCursor.getObject();
+ EnvironmentType environmentType = (EnvironmentType) xmlObject.copy().changeType(EnvironmentType.type);
+ oldEnvironment = EnvironmentBuilder.buildEnvironment(environmentType);
+ xmlCursor.removeXml();
+ }
+ else {
+ oldEnvironment = new Environment();
+ }
+
+ Environment newEnvironment = new Environment();
+ newEnvironment.setConfigId(configId);
+ newEnvironment.setDependencies(dependencies);
+
+ EnvironmentBuilder.mergeEnvironments(oldEnvironment, newEnvironment);
+ EnvironmentType environmentType = EnvironmentBuilder.buildEnvironmentType(oldEnvironment);
+
+ xmlCursor.beginElement(ENVIRONMENT_QNAME);
+ XmlCursor element = environmentType.newCursor();
+
+ try {
+ element.copyXmlContents(xmlCursor);
+ }
+ finally {
+ element.dispose();
+ }
+ }
+
+ private void convertElement(final XmlCursor cursor, final String namespace) {
+ cursor.push();
+ XmlCursor end = cursor.newCursor();
+
+ try {
+ end.toCursor(cursor);
+ end.toEndToken();
+
+ while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+ if (cursor.isStart()) {
+ if (!namespace.equals(cursor.getName().getNamespaceURI())) {
+ cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+ }
+ }
+
+ cursor.toNextToken();
+ }
+
+ cursor.pop();
+ }
+ finally {
+ end.dispose();
+ }
+ }
+
+ private LinkedHashSet toDependencies() {
+ List artifacts = project.getDependencies();
+ LinkedHashSet dependencies = new LinkedHashSet();
+
+ Iterator iterator = artifacts.iterator();
+ while (iterator.hasNext()) {
+ //Artifact artifact = (Artifact) iterator.next();
+ Dependency dependency = (Dependency) iterator.next();
+ //Dependency dependency = artifact.getDependency();
+ org.apache.geronimo.kernel.repository.Dependency geronimoDependency = toGeronimoDependency(dependency);
+
+ if (geronimoDependency != null) {
+ dependencies.add(geronimoDependency);
+ }
+ }
+
+ return dependencies;
+ }
+
+ private static org.apache.geronimo.kernel.repository.Dependency toGeronimoDependency(final Dependency dependency) {
+ Artifact artifact = toGeronimoArtifact(dependency);
+ String type = dependency.getType();
+ String scope = dependency.getScope();
+ String groupId = dependency.getGroupId();
+
+ //!"org.apache.geronimo.specs".equals(groupId) jacc spec needed in plan.xml
+ if ("jar".equalsIgnoreCase(type) && !"junit".equals(groupId)) {
+ if (dependency.getVersion() != null) {
+ artifact = new Artifact(
+ artifact.getGroupId(),
+ artifact.getArtifactId(),
+ dependency.getVersion(),
+ artifact.getType());
+ }
+ return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.CLASSES);
+ }
+ else if ("car".equalsIgnoreCase(type) && ("runtime").equalsIgnoreCase(type)) {
+ return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.SERVICES);
+ }
+ else if ("car".equalsIgnoreCase(type) && ("compile".equalsIgnoreCase(scope))) {
+ return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.CLASSES);
+ }
+ else if ("car".equalsIgnoreCase(type) && (scope == null)) { //parent
+ return new org.apache.geronimo.kernel.repository.Dependency(artifact, ImportType.ALL);
+ }
+ else {
+ // not one of ours
+ return null;
+ }
+ }
+
+ private static Artifact toGeronimoArtifact(final Dependency dependency) {
+ String groupId = dependency.getGroupId();
+ String artifactId = dependency.getArtifactId();
+ String version = null;
+ String type = dependency.getType();
+
+ return new Artifact(groupId, artifactId, version, type);
+ }
+
+ interface Inserter {
+ ArtifactType insert(EnvironmentType environmentType);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/PlanProcessorMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml Fri Aug 4 12:44:18 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Rev$ $Date$ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>car</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+ <compile>org.apache.geronimo.plugins:car-maven-plugin:prepare-plan</compile>
+ <package>org.apache.geronimo.plugins:car-maven-plugin:package</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ </phases>
+ </configuration>
+ </component>
+ </components>
+</component-set>
+
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/apt/usage.apt Fri Aug 4 12:44:18 2006
@@ -0,0 +1,118 @@
+ ------
+ Geronimo CAR Plugin for Maven 2
+ ------
+ ???
+ ------
+ ???
+
+Basic Usage
+
+* Setup Plugin Repository
+
++----------+
+<project>
+ ...
+ <pluginRepositories>
+ ...
+ <pluginRepository>
+ <id>apache</id>
+ <name>Apache Repository</name>
+ <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+
+ <pluginRepository>
+ <id>apache-snapshots</id>
+ <name>Apache Snapshots Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ <checksumPolicy>ignore</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ ...
+ </pluginRepositories>
+ ...
+</project>
++----------+
+
+* Define Dependency as Extention
+
++----------+
+<project>
+ ...
+ <packaging>car</packaging>
+ ...
+ <build>
+ ...
+ <plugins>
+ ...
+ <plugin>
+ <groupId>org.apache.geronimo.plugins</groupId>
+ <artifactId>car-maven-plugin</artifactId>
+ <!-- Install as extention to allow 'car' packaging to be used. -->
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ ...
+ </build>
+ ...
+</project>
++----------+
+
+* CAR with ClassPath and MainClass
+
++----------+
+<project>
+ ...
+ <packaging>car</packaging>
+ ...
+ <build>
+ ...
+ <plugins>
+ ...
+ <plugin>
+ <groupId>org.apache.geronimo.plugins</groupId>
+ <artifactId>car-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <classPath>
+ <element>../lib/geronimo-qname_1.1_spec-${geronimoSpecQnameVersion}.jar</element>
+ <element>../lib/geronimo-common-${pom.version}.jar</element>
+ <element>../lib/geronimo-kernel-${pom.version}.jar</element>
+ <element>../lib/geronimo-system-${pom.version}.jar</element>
+ <element>../lib/geronimo-util-${pom.version}.jar</element>
+ <element>../lib/cglib-nodep-${cglibVersion}.jar</element>
+ <element>../lib/concurrent-${concurrentVersion}.jar</element>
+ <element>../lib/commons-cli-${commonsCliVersion}.jar</element>
+ <element>../lib/commons-logging-${commonsLoggingVersion}.jar</element>
+ <element>../lib/log4j-${log4jVersion}.jar</element>
+ <element>../lib/mx4j-${mx4jVersion}.jar</element>
+ <element>../lib/mx4j-remote-${mx4jVersion}.jar</element>
+ <element>../lib/endorsed/xercesImpl-${xercesVersion}.jar</element>
+ <element>../lib/endorsed/xmlParserAPIs-${xmlParserApisVersion}.jar</element>
+ <element>../lib/xpp3-${xpp3Version}.jar</element>
+ <element>../lib/xstream-${xstreamVersion}.jar</element>
+ </classPath>
+ <mainClass>org.apache.geronimo.system.main.Daemon</mainClass>
+ <logLevel>DEBUG</logLevel>
+ </configuration>
+ </plugin>
+ ...
+ </plugins>
+ ...
+ </build>
+ ...
+<project>
++----------+
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml Fri Aug 4 12:44:18 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+
+<!-- $Id$ -->
+
+<project name="CAR Plugin">
+ <bannerLeft>
+ <name>Geronimo</name>
+ <src>http://geronimo.apache.org/images/topleft_logo_437x64.gif</src>
+ <href>http://geronimo.apache.org/</href>
+ </bannerLeft>
+
+ <!--
+ <bannerRight>
+ <name>Codehaus</name>
+ <src>http://mojo.codehaus.org/images/codehaus-small.png</src>
+ <href>http://www.codehaus.org</href>
+ </bannerRight>
+ -->
+
+ <body>
+ <links>
+ <item name="Geronimo" href="http://geronimo.apache.org/"/>
+ <item name="Apache" href="http://apache.org/"/>
+ </links>
+
+ <menu name="Geronimo">
+ <item name="Maven2 Plugins" href="../index.html"/>
+ </menu>
+
+ <menu name="CAR Plugin">
+ <item name="Overview" href="index.html"/>
+ <item name="Usage" href="usage.html"/>
+ <item name="Configuration" href="plugin-info.html"/>
+ </menu>
+
+ ${reports}
+ </body>
+</project>
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/car-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml Fri Aug 4 12:44:18 2006
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<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.plugins</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>geronimo-deployment-plugin</artifactId>
+ <name>Geronimo Maven2 Plugins :: Deployment</name>
+ <packaging>maven-plugin</packaging>
+
+ <dependencies>
+
+ <!-- Module Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-deploy-jsr88</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- Thirdparty Dependencies -->
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <goalPrefix>deploy</goalPrefix>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,172 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.plugin.MojoSupport;
+
+//
+// TODO: Rename to AbstractDeploymentMojo
+//
+
+/**
+ * Support for deployment Mojos.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractModuleMojo extends MojoSupport {
+
+ /**
+ * The uri to look up the JMXConnector.
+ *
+ * @parameter default-value="jmx:rmi://localhost/jndi/rmi:/JMXConnector"
+ */
+ private String uri;
+
+ /**
+ * @parameter
+ */
+ protected String id;
+
+ /**
+ * The uri to connect to the jmx connector with.
+ *
+ * @parameter default-value="deployer:geronimo:jmx"
+ */
+ private String distributeURI;
+
+ /**
+ * The authentication user name.
+ *
+ * @parameter default-value="system"
+ */
+ private String username;
+
+ /**
+ * The authentication password.
+ *
+ * @parameter default-value="manager"
+ */
+ private String password;
+
+ /**
+ * The time between connect attempts.
+ *
+ * @parameter default-value=0
+ */
+ private long sleepTimer;
+
+ /**
+ * @parameter default-value=100
+ */
+ private int maxTries;
+
+ /**
+ * @parameter default-value=2000
+ */
+ private int retryIntervalMilliseconds;
+
+ /**
+ * @parameter default-value=true
+ */
+ private boolean failOnError;
+
+ /**
+ * @parameter
+ */
+ private File outputDirectory;
+
+ /**
+ * @parameter default-value=null
+ */
+ private File resultsLog;
+
+ /**
+ * @return Returns the maxTries.
+ */
+ public int getMaxTries() {
+ return maxTries;
+ }
+
+ /**
+ * @return Returns the retryIntervalMilliseconds.
+ */
+ public int getRetryIntervalMilliseconds() {
+ return retryIntervalMilliseconds;
+ }
+
+ /**
+ * @return Returns the sleepTimer.
+ */
+ public long getSleepTimer() {
+ return sleepTimer;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getDistributeURI() {
+ return distributeURI;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public boolean isFailOnError() {
+ return failOnError;
+ }
+
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException {
+ //
+ // NOTE: username, password, and distributeURI will never be null
+ //
+
+ //
+ // TODO: Document why this is here... seems very odd
+ //
+ new DeploymentFactoryImpl();
+
+ ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
+ return factoryManager.getDeploymentManager(getDistributeURI(), getUsername(), getPassword());
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(oldcl);
+ }
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/AbstractModuleMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.io.File;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.plugins.util.DeploymentClient;
+
+//
+// TODO: Rename to DistributeMojo
+//
+
+/**
+ * ???
+ *
+ * @goal distribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class DistributeModuleMojo extends AbstractModuleMojo {
+
+ /**
+ * @parameter
+ */
+ private File module;
+
+ /**
+ * @parameter
+ */
+ private File plan;
+
+ protected void doExecute() throws Exception {
+ DeploymentManager manager = getDeploymentManager();
+ Target[] targets = manager.getTargets();
+
+ ProgressObject progress = manager.distribute(targets, module, plan);
+ DeploymentClient.waitFor(progress);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/DistributeModuleMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.plugins.util.DeploymentClient;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * ???
+ *
+ * @goal start
+ *
+ * @version $Rev$ $Date$
+ */
+public class StartModuleMojo extends AbstractModuleMojo {
+
+ protected void doExecute() throws Exception {
+ RemoteDeploymentManager manager;
+
+ manager = (RemoteDeploymentManager) getDeploymentManager();
+ manager.setLogConfiguration(true, true);
+
+ Target[] targets = manager.getTargets();
+ TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
+ List toStart = new ArrayList(moduleIds.length);
+
+ for (int i = 0; i < moduleIds.length; i++) {
+ TargetModuleID moduleId = moduleIds[i];
+
+ if (this.id.equals(moduleId.getModuleID())) {
+ toStart.add(moduleId);
+ }
+ }
+
+ if (toStart.size() == 0) {
+ throw new MojoExecutionException("Module is already running or may not be deployed: " + this.id);
+ }
+
+ moduleIds = (TargetModuleID[]) toStart.toArray(new TargetModuleID[toStart.size()]);
+ ProgressObject progress = manager.start(moduleIds);
+ DeploymentClient.waitFor(progress);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartModuleMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,163 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.StringTokenizer;
+
+import org.apache.geronimo.plugins.util.ServerBehavior;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.DefaultConsumer;
+import org.codehaus.plexus.util.cli.CommandLineException;
+
+//
+// TODO: Rename to StartRemoteServerMojo
+//
+
+/**
+ * ???
+ *
+ * @goal startRemoteServer
+ *
+ * @version $Rev$ $Date$
+ */
+public class StartRemoteServerMojo extends AbstractModuleMojo {
+
+ /**
+ * @parameter
+ */
+ private File geronimoTarget;
+
+ /**
+ * @parameter expression="${basedir}/target"
+ */
+ private File workingDirectory;
+
+ //
+ // FIXME: Use <args><args>...</args></args> and let M2 handle parsing
+ //
+
+ /**
+ * @parameter default-value=""
+ */
+ private String vmArgs;
+
+ /**
+ * @parameter
+ */
+ private String[] configs;
+
+ /**
+ * @parameter
+ */
+ private String debugPort;
+
+ /**
+ * Get the path of Java depending the OS.
+ *
+ * @return the path of the Java
+ */
+ private String getJavaPath() {
+ String javaCommand = "java" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");
+
+ File javaExe;
+
+ // For IBM's JDK 1.2
+ if (SystemUtils.IS_OS_AIX) {
+ javaExe = new File(SystemUtils.JAVA_HOME + "/../sh", javaCommand);
+ }
+ else if (SystemUtils.IS_OS_MAC_OSX ) {
+ javaExe = new File(SystemUtils.JAVA_HOME + "/bin", javaCommand);
+ }
+ else {
+ javaExe = new File(SystemUtils.JAVA_HOME + "/../bin", javaCommand);
+ }
+
+ log.debug("Java executable=[" + javaExe.getAbsolutePath() + "]");
+
+ return javaExe.getAbsolutePath();
+ }
+
+ protected void doExecute() throws Exception {
+ Commandline cmd = new Commandline();
+
+ cmd.setWorkingDirectory(workingDirectory.getAbsolutePath());
+ cmd.setExecutable(getJavaPath());
+
+ if (debugPort != null) {
+ cmd.createArgument().setValue("-Xdebug");
+ cmd.createArgument().setValue("-Xnoagent");
+ cmd.createArgument().setValue("-Djava.compiler=NONE");
+ cmd.createArgument().setValue("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort);
+ }
+
+ for (StringTokenizer st = new StringTokenizer(this.vmArgs); st.hasMoreTokens();) {
+ cmd.createArgument().setValue(st.nextToken());
+ }
+
+ cmd.createArgument().setValue("-ea");
+ cmd.createArgument().setValue("-jar");
+
+ File serverJar = new File(new File(geronimoTarget, "bin"), "server.jar");
+ if (serverJar.exists()) {
+ cmd.createArgument().setFile(serverJar);
+ }
+ else {
+ throw new FileNotFoundException(serverJar.getAbsolutePath());
+ }
+
+ cmd.createArgument().setValue("--quiet");
+
+ if (this.configs != null && this.configs.length > 0) {
+ cmd.createArgument().setValue("--override");
+
+ for (int i=0; i < this.configs.length; i++) {
+ cmd.createArgument().setValue(this.configs[i]);
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(Commandline.toString(cmd.getCommandline()));
+ }
+
+ CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+ try {
+ int exitCode = CommandLineUtils.executeCommandLine(cmd, new DefaultConsumer(), err);
+
+ if (exitCode != 0) {
+ throw new MojoExecutionException("Exit code: " + exitCode + " - " + err.getOutput());
+ }
+ }
+ catch (CommandLineException e) {
+ throw new MojoExecutionException("Unable to execute java command", e);
+ }
+
+ ServerBehavior sb = new ServerBehavior(getUri(), getMaxTries(), getRetryIntervalMilliseconds());
+ if (!sb.isFullyStarted()) {
+ CommandLineUtils.killProcess(cmd.getPid());
+
+ throw new MojoExecutionException("Server did not start");
+ }
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartRemoteServerMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,125 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.io.File;
+import java.io.ObjectInputStream;
+import java.io.PrintStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.ManageableAttributeStore;
+import org.apache.geronimo.kernel.log.GeronimoLogging;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * This starts a geronimo server in vm. It might not have ever been used.
+ *
+ * @goal startServer
+ *
+ * @version $Rev$ $Date$
+ */
+public class StartServerMojo extends AbstractModuleMojo {
+
+ static {
+ // This MUST be done before the first log is acquired
+ GeronimoLogging.initialize(GeronimoLogging.INFO);
+ }
+
+ /**
+ * @parameter expression="${basedir}/target"
+ */
+ private File geronimoHome;
+
+ /**
+ * @parameter
+ */
+ private String domainName;
+
+ /**
+ * @parameter
+ */
+ private String[] configs;
+
+ private String kernelName;
+
+ protected void doExecute() throws Exception {
+ if (!geronimoHome.exists()) {
+ throw new RuntimeException("No such directory: " + geronimoHome);
+ }
+ System.setProperty("org.apache.geronimo.base.dir", this.geronimoHome.getAbsolutePath());
+
+ List configList = new ArrayList();
+ if (this.configs != null && this.configs.length > 0) {
+ for (int i=0; i < this.configs.length; i++) {
+ configList.add(Artifact.create(this.configs[i]));
+ }
+ }
+
+ URL systemURL = new File(geronimoHome, "bin/server.jar").toURL();
+ URL configURL = new URL("jar:" + systemURL.toString() + "!/META-INF/config.ser");
+
+ GBeanData configuration = new GBeanData();
+ ObjectInputStream ois = new ObjectInputStream(configURL.openStream());
+ configuration.readExternal(ois);
+
+ URI configurationId = (URI) configuration.getAttribute("id");
+ AbstractName abstractName = new AbstractName(configurationId);
+
+ configuration.setAbstractName(abstractName);
+ configuration.setAttribute("baseURL", systemURL);
+
+ // build a basic kernel without a configuration-store, our configuration store is
+ Kernel kernel = KernelFactory.newInstance().createKernel(this.kernelName);
+ kernel.boot();
+
+ kernel.loadGBean(configuration, this.getClass().getClassLoader());
+ kernel.startGBean(abstractName);
+ kernel.invoke(abstractName, "loadGBeans", new Object[] { null }, new String[] { ManageableAttributeStore.class.getName() });
+ kernel.invoke(abstractName, "startRecursiveGBeans");
+
+ // load the rest of the configuration listed on the command line
+ ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+ try {
+ for (Iterator i = configList.iterator(); i.hasNext();) {
+ Artifact configID = (Artifact) i.next();
+ configurationManager.loadConfiguration(configID);
+ configurationManager.startConfiguration(configID);
+
+ log.info("Started GBean: " + configID);
+ }
+ }
+ finally {
+ ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
+ }
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StartServerMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.plugins.util.DeploymentClient;
+import org.apache.maven.plugin.MojoExecutionException;
+
+//
+// TODO: Rename to StopMojo
+//
+
+/**
+ * ???
+ *
+ * @goal stop
+ *
+ * @version $Rev$ $Date$
+ */
+public class StopModuleMojo extends AbstractModuleMojo {
+
+ protected void doExecute() throws Exception {
+ RemoteDeploymentManager manager = (RemoteDeploymentManager) getDeploymentManager();
+ manager.setLogConfiguration(true, true);
+
+ Target[] targets = manager.getTargets();
+ TargetModuleID moduleIds[] = manager.getRunningModules(null, targets);
+ List toStop = new ArrayList(moduleIds.length);
+
+ for (int i = 0; i < moduleIds.length; i++) {
+ TargetModuleID moduleId = moduleIds[i];
+
+ if (this.id.equals(moduleId.getModuleID())) {
+ toStop.add(moduleId);
+ }
+ }
+
+ if (toStop.size() == 0) {
+ throw new MojoExecutionException("Module is not deployed: " + this.id);
+ }
+
+ moduleIds = (TargetModuleID[]) toStop.toArray(new TargetModuleID[toStop.size()]);
+ ProgressObject progress = manager.stop(moduleIds);
+ DeploymentClient.waitFor(progress);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopModuleMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * ???
+ *
+ * @goal stopRemoteServer
+ *
+ * @version $Rev$ $Date$
+ */
+public class StopRemoteServerMojo extends AbstractModuleMojo {
+
+ protected void doExecute() throws Exception {
+ stopRemoteServer();
+ }
+
+ private void stopRemoteServer() throws Exception {
+ String uri = getUri();
+ if (!uri.startsWith("jmx")) {
+ throw new MojoExecutionException("Bad JMX URI: " + uri);
+ }
+
+ Map environment = new HashMap();
+ String[] credentials = new String[]{getUsername(), getPassword()};
+ environment.put(JMXConnector.CREDENTIALS, credentials);
+
+ JMXServiceURL address = new JMXServiceURL("service:" + uri);
+
+ ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
+ MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
+ Kernel kernel = new KernelDelegate(mbServerConnection);
+
+ kernel.shutdown();
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(oldcl);
+ }
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopRemoteServerMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * In vm server stop. May not have been tested.
+
+ * @goal stopServer
+ *
+ * @version $Rev$ $Date$
+ */
+public class StopServerMojo extends AbstractModuleMojo {
+
+ private String kernelName;
+
+ protected void doExecute() throws Exception {
+ Kernel kernel = KernelRegistry.getKernel(this.kernelName);
+ kernel.shutdown();
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/StopServerMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.deployment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.plugins.util.DeploymentClient;
+import org.apache.maven.plugin.MojoExecutionException;
+
+//
+// TODO: Rename to UndeployMojo
+//
+
+/**
+ * ???
+ *
+ * @goal undeploy
+ *
+ * @version $Rev$ $Date$
+ */
+public class UndeployModuleMojo extends AbstractModuleMojo {
+
+ protected void doExecute() throws Exception {
+ DeploymentManager manager = getDeploymentManager();
+
+ Target[] targets = manager.getTargets();
+ TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
+ List toUndeploy = new ArrayList(moduleIds.length);
+
+ for (int i = 0; i < moduleIds.length; i++) {
+ TargetModuleID moduleId = moduleIds[i];
+ if (this.id.equals(moduleId.getModuleID())) {
+ toUndeploy.add(moduleId);
+ }
+ }
+
+ if (toUndeploy.size() == 0) {
+ throw new MojoExecutionException("Module is running or not deployed: " + this.id);
+ }
+
+ moduleIds = (TargetModuleID[]) toUndeploy.toArray(new TargetModuleID[toUndeploy.size()]);
+ ProgressObject progress = manager.undeploy(moduleIds);
+ DeploymentClient.waitFor(progress);
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/deployment/UndeployModuleMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,111 @@
+/**
+ *
+ * Copyright 2004-2006 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.plugins.util;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+
+import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+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.status.DeploymentStatus;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class DeploymentClient {
+ private static final DeploymentFactoryManager FACTORY_MANAGER = DeploymentFactoryManager.getInstance();
+
+ private URL provider;
+
+ public URL getProvider() {
+ return provider;
+ }
+
+ public void setProvider(URL provider) {
+ this.provider = provider;
+ }
+
+ public void doIt() throws IOException {
+ registerProvider(provider, null);
+ }
+
+ public static void registerProvider(URL provider, ClassLoader parent) throws IOException {
+ if (parent == null) {
+ parent = Thread.currentThread().getContextClassLoader();
+ }
+
+ //
+ // FIXME: parent will never be null at this point...
+ //
+ if (parent == null) {
+ parent = DeploymentClient.class.getClassLoader();
+ }
+
+ // read manifest entry from provider
+ URL url = new URL("jar:" + provider.toString() + "!/");
+ JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+ Attributes attrs = jarConnection.getMainAttributes();
+ String factoryNames = attrs.getValue("J2EE-DeploymentFactory-Implementation-Class");
+ if (factoryNames == null) {
+ throw new IOException("No DeploymentFactory found in jar");
+ }
+
+ // register listed DeploymentFactories
+ ClassLoader cl = new URLClassLoader(new URL[]{provider}, parent);
+ for (StringTokenizer tokenizer = new StringTokenizer(factoryNames); tokenizer.hasMoreTokens();) {
+ String className = tokenizer.nextToken();
+ try {
+ DeploymentFactory factory = (DeploymentFactory) cl.loadClass(className).newInstance();
+ FACTORY_MANAGER.registerDeploymentFactory(factory);
+ } catch (Exception e) {
+ throw (IOException) new IOException("Unable to instantiate DeploymentFactory: " + className).initCause(e);
+ }
+ }
+ }
+
+ public static void waitFor(final ProgressObject progress) throws InterruptedException {
+ ProgressListener listener = new ProgressListener() {
+ public void handleProgressEvent(ProgressEvent event) {
+ DeploymentStatus status = event.getDeploymentStatus();
+ if (status.getMessage() != null) {
+ System.out.println(status.getMessage());
+ }
+ if (!status.isRunning()) {
+ synchronized (progress) {
+ progress.notify();
+ }
+ }
+ }
+ };
+ progress.addProgressListener(listener);
+ synchronized (progress) {
+ while (progress.getDeploymentStatus().isRunning()) {
+ progress.wait();
+ }
+ }
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/DeploymentClient.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java?rev=428856&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java (added)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java Fri Aug 4 12:44:18 2006
@@ -0,0 +1,176 @@
+/**
+ *
+ * Copyright 2006 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.plugins.util;
+
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerBehavior {
+
+ private int maxTries = 100;
+
+ private int retryIntervalMilliseconds = 1000;
+
+ private String uri = "jmx:rmi://localhost/jndi/rmi:/JMXConnector";
+
+ private String username = "system";
+
+ private String password = "manager";
+
+ private PrintStream logStream = System.out;
+
+ protected final String lineSep = "===========================================";
+
+ /**
+ * @param uri
+ * specify null for default
+ * @param maxTries
+ * specify -1 for default. default-value=40
+ * @param retryIntervalMilliseconds
+ * specify -1 for default. default-value=1000
+ */
+ public ServerBehavior(String uri, int maxTries, int retryIntervalMilliseconds) {
+ if (uri != null)
+ this.uri = uri;
+ if (maxTries > -1)
+ this.maxTries = maxTries;
+ if (retryIntervalMilliseconds > -1)
+ this.retryIntervalMilliseconds = retryIntervalMilliseconds;
+ }
+
+ public ServerBehavior(String uri) {
+ this(uri, -1, -1);
+ }
+
+ public ServerBehavior() {
+ this(null, -1, -1);
+ }
+
+ public boolean isFullyStarted() {
+ Kernel kernel = null;
+
+ if (!uri.startsWith("jmx")) {
+ logStream.println("Bad JMX URI (" + uri + ")");
+ logStream.println(lineSep);
+ return false;
+ }
+
+ // Get the kernel first
+ Map environment = new HashMap();
+ String[] credentials = new String[] { username, password };
+ environment.put(JMXConnector.CREDENTIALS, credentials);
+ ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
+ try {
+ JMXServiceURL address = new JMXServiceURL("service:" + uri);
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ for (int tries = maxTries; true; tries--) {
+ try {
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
+ MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
+ kernel = new KernelDelegate(mbServerConnection);
+ break;
+ }
+ catch (Exception e) {
+ if (tries == 0) {
+ e.printStackTrace(logStream);
+ logStream.println("Could not connect");
+ logStream.println(lineSep);
+ return false;
+ }
+ Thread.sleep(retryIntervalMilliseconds);
+ }
+ }
+ }
+ catch (Exception e1) {
+ e1.printStackTrace(logStream);
+ logStream.println(lineSep);
+ return false;
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(oldcl);
+ }
+
+ // Now check to see if all configurations have started
+ ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(kernel);
+ List configLists = mgr.listConfigurations();
+ ObjectName on = null;
+ if (!configLists.isEmpty())
+ on = (ObjectName) configLists.toArray()[0];
+
+ for (int tries = maxTries; tries > 0; tries--) {
+ try {
+ Thread.sleep(retryIntervalMilliseconds);
+ Boolean b = (Boolean) kernel.getAttribute(on, "kernelFullyStarted");
+ //System.out.println("attempt.. " + (maxTries - tries));
+ if (b.booleanValue())
+ return true;
+ }
+ catch (InternalKernelException e) {
+ //hasn't been loaded yet, keep trying
+ }
+ catch (GBeanNotFoundException e) {
+ //hasn't been loaded yet, keep trying
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace(logStream);
+ logStream.println(lineSep);
+ return false;
+ }
+ catch (NoSuchAttributeException e) {
+ e.printStackTrace(logStream);
+ logStream.println(lineSep);
+ return false;
+ }
+ catch (Exception e) {
+ e.printStackTrace(logStream);
+ logStream.println(lineSep);
+ return false;
+ }
+ }
+ return false;
+ }
+
+ public void setLogStream(PrintStream logStream) {
+ if (logStream != null)
+ this.logStream = logStream;
+ }
+
+ public void destroy() {
+ logStream.close();
+ }
+}
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/plugins/util/ServerBehavior.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/svkmerge/trunk/m2-plugins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/trunk/m2-plugins/pom.xml?rev=428856&r1=428855&r2=428856&view=diff
==============================================================================
--- geronimo/sandbox/svkmerge/trunk/m2-plugins/pom.xml (original)
+++ geronimo/sandbox/svkmerge/trunk/m2-plugins/pom.xml Fri Aug 4 12:44:18 2006
@@ -17,53 +17,147 @@
<!-- $Rev$ $Date$ -->
-<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">
+<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</groupId>
- <artifactId>geronimo-parent</artifactId>
+ <artifactId>geronimo</artifactId>
<version>1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.apache.geronimo.plugins</groupId>
- <artifactId>plugins-parent</artifactId>
- <name>Geronimo Plugins</name>
- <description>Geronimo :: Plugins</description>
+ <artifactId>plugins</artifactId>
+ <name>Geronimo :: Maven2 Plugins</name>
<packaging>pom</packaging>
- <properties>
- <maven.version>2.0</maven.version>
- </properties>
+ <!--
+
+ HACK: Need to explicitly configure SCM for this module since its artifactId
+ does not match the directory it lives in.
+
+ FIXME: Rename module directory.
+
+ -->
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/geronimo/sandbox/svkmerge/m2migration/m2-plugins</connection>
+ <developerConnection>scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/sandbox/svkmerge/m2migration/m2-plugins</developerConnection>
+ <url>http://svn.apache.org/repos/asf/geronimo/sandbox/svkmerge/m2migration/m2-plugins</url>
+ </scm>
<dependencies>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
+ <groupId>org.apache.geronimo.genesis.plugins</groupId>
+ <artifactId>plugin-support</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
<modules>
- <module>geronimo-packaging-plugin</module>
+ <module>car-maven-plugin</module>
+ <module>geronimo-deployment-plugin</module>
</modules>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <minmemory>128m</minmemory>
+ <maxmemory>512</maxmemory>
+ <breakiterator>true</breakiterator>
+ <quiet>true</quiet>
+ <verbose>false</verbose>
+ <source>1.4</source>
+ <!--
+ FIXME: This worked in m1, but m2 complains about it being an invalid flag
+
+ <additionalparam>-J-Djava.awt.headless=true</additionalparam>
+ -->
+ <linksource>true</linksource>
+ <links>
+ <!-- JSE -->
+ <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
+ <link>http://java.sun.com/j2se/1.4.2/docs/api/</link>
+ <link>http://java.sun.com/j2se/1.3/docs/api/</link>
+
+ <!-- JEE -->
+ <link>http://java.sun.com/j2ee/1.4/docs/api/</link>
+ <link>http://java.sun.com/j2ee/sdk_1.3/techdocs/api/</link>
+
+ <!-- Libraries -->
+ <link>http://jakarta.apache.org/commons/collections/apidocs</link>
+ <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
+ <link>http://www.junit.org/junit/javadoc/</link>
+ <link>http://logging.apache.org/log4j/docs/api/</link>
+ <link>http://jakarta.apache.org/regexp/apidocs/</link>
+ <link>http://jakarta.apache.org/velocity/api/</link>
+ </links>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.0.1</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clover-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <!-- Pulled as resource from checkstyle-config plugin -->
+ <configLocation>org/apache/geronimo/checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Propchange: geronimo/sandbox/svkmerge/trunk/m2-plugins/pom.xml
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Fri Aug 4 12:44:18 2006
@@ -1 +1 @@
-Date Revision
+Date Author Id Revision HeadURL