Author: pdodds
Date: Mon Oct 2 11:01:32 2006
New Revision: 452148
URL: http://svn.apache.org/viewvc?view=rev&rev=452148
Log:
Refactored getClasspath up to AbstractJbiMojo and also made bootstrap an
optional parameter and allowed for the injection of DefaultBootstrap from
servicemix-common into a component that doesn't specify a bootstrap
Modified:
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentDescriptorMojo.java
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
incubator/servicemix/trunk/tooling/pom.xml
Modified:
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java?view=diff&rev=452148&r1=452147&r2=452148
==============================================================================
---
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
(original)
+++
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
Mon Oct 2 11:01:32 2006
@@ -17,6 +17,9 @@
package org.apache.servicemix.maven.plugin.jbi;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -37,6 +40,7 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.MavenProjectHelper;
@@ -250,4 +254,42 @@
return map;
}
+ /**
+ * Set up a classloader for the execution of the main class.
+ *
+ * @return
+ * @throws MojoExecutionException
+ */
+ protected URLClassLoader getClassLoader() throws MojoExecutionException
{
+ try {
+ Set urls = new HashSet();
+
+ URL mainClasses = new
File(project.getBuild().getOutputDirectory())
+ .toURL();
+ getLog().debug("Adding to classpath : " + mainClasses);
+ urls.add(mainClasses);
+
+ URL testClasses = new File(project.getBuild()
+ .getTestOutputDirectory()).toURL();
+ getLog().debug("Adding to classpath : " + testClasses);
+ urls.add(testClasses);
+
+ Set dependencies = project.getArtifacts();
+ Iterator iter = dependencies.iterator();
+ while (iter.hasNext()) {
+ Artifact classPathElement = (Artifact)
iter.next();
+ getLog().debug(
+ "Adding artifact: " +
classPathElement.getFile()
+ + " to
classpath");
+ urls.add(classPathElement.getFile().toURL());
+ }
+ URLClassLoader appClassloader = new
URLClassLoader((URL[]) urls
+ .toArray(new URL[urls.size()]),
this.getClass()
+ .getClassLoader());
+ return appClassloader;
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException(
+ "Error during setting up classpath", e);
+ }
+ }
}
Modified:
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentDescriptorMojo.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentDescriptorMojo.java?view=diff&rev=452148&r1=452147&r2=452148
==============================================================================
---
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentDescriptorMojo.java
(original)
+++
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentDescriptorMojo.java
Mon Oct 2 11:01:32 2006
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -66,7 +67,6 @@
* The bootstrap class name.
*
* @parameter
- * @required
*/
private String bootstrap;
@@ -86,6 +86,13 @@
private String name;
/**
+ * The destination of the default bootstrap.
+ *
+ * @parameter
expression="${project.build.directory}/classes/org/apache/servicemix/common/DefaultBootstrap.class"
+ */
+ private File defaultBootstrapFile;
+
+ /**
* The component description.
*
* @parameter expression="${project.name}"
@@ -106,19 +113,19 @@
*/
private String generatedDescriptorLocation;
- /**
- * The component class loader delegation
- *
- * @parameter expression="parent-first"
- */
- private String componentClassLoaderDelegation;
-
- /**
- * The bootstrap class loader delegation
- *
- * @parameter expression="parent-first"
- */
- private String bootstrapClassLoaderDelegation;
+ /**
+ * The component class loader delegation
+ *
+ * @parameter expression="parent-first"
+ */
+ private String componentClassLoaderDelegation;
+
+ /**
+ * The bootstrap class loader delegation
+ *
+ * @parameter expression="parent-first"
+ */
+ private String bootstrapClassLoaderDelegation;
public void execute() throws MojoExecutionException,
MojoFailureException {
@@ -141,6 +148,9 @@
return;
}
+ if (bootstrap == null)
+ injectBootStrap();
+
// Generate jbi descriptor and copy it to the build directory
getLog().info("Generating jbi.xml");
try {
@@ -159,6 +169,28 @@
}
/**
+ * Helper method used to inject the BaseBootstrap from
servicemix-commons
+ * into the component this allows to you bypass actually having to
create a
+ * bootstrap
+ *
+ * @throws MojoExecutionException
+ *
+ */
+ private void injectBootStrap() throws MojoExecutionException {
+
+ try {
+ URL defaultBootStrap = getClassLoader().getResource(
+
"org/apache/servicemix/common/DefaultBootstrap.class");
+ FileUtils.copyURLToFile(defaultBootStrap,
defaultBootstrapFile);
+ bootstrap =
"org.apache.servicemix.common.DefaultBootstrap";
+ } catch (IOException e) {
+ throw new MojoExecutionException(
+ "Unable to copy DefaultBootstrap.class
to "
+ +
defaultBootstrapFile.getAbsolutePath(), e);
+ }
+ }
+
+ /**
* Generates the deployment descriptor if necessary.
*/
protected void generateJbiDescriptor() throws JbiPluginException {
@@ -237,7 +269,7 @@
JbiComponentDescriptorWriter writer = new
JbiComponentDescriptorWriter(
encoding);
writer.write(descriptor, component, bootstrap, type, name,
description,
- componentClassLoaderDelegation, bootstrapClassLoaderDelegation,
+ componentClassLoaderDelegation,
bootstrapClassLoaderDelegation,
uris);
}
}
Modified:
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java?view=diff&rev=452148&r1=452147&r2=452148
==============================================================================
---
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
(original)
+++
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
Mon Oct 2 11:01:32 2006
@@ -139,45 +139,6 @@
}
/**
- * Set up a classloader for the execution of the main class.
- *
- * @return
- * @throws MojoExecutionException
- */
- private URLClassLoader getClassLoader() throws MojoExecutionException {
- try {
- Set urls = new HashSet();
-
- URL mainClasses = new
File(project.getBuild().getOutputDirectory())
- .toURL();
- getLog().debug("Adding to classpath : " + mainClasses);
- urls.add(mainClasses);
-
- URL testClasses = new File(project.getBuild()
- .getTestOutputDirectory()).toURL();
- getLog().debug("Adding to classpath : " + testClasses);
- urls.add(testClasses);
-
- Set dependencies = project.getArtifacts();
- Iterator iter = dependencies.iterator();
- while (iter.hasNext()) {
- Artifact classPathElement = (Artifact)
iter.next();
- getLog().debug(
- "Adding artifact: " +
classPathElement.getFile()
- + " to
classpath");
- urls.add(classPathElement.getFile().toURL());
- }
- URLClassLoader appClassloader = new
URLClassLoader((URL[]) urls
- .toArray(new URL[urls.size()]),
this.getClass()
- .getClassLoader());
- return appClassloader;
- } catch (MalformedURLException e) {
- throw new MojoExecutionException(
- "Error during setting up classpath", e);
- }
- }
-
- /**
* Generates the deployment descriptor if necessary.
*/
protected void generateJbiDescriptor() throws JbiPluginException {
Modified:
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java?view=diff&rev=452148&r1=452147&r2=452148
==============================================================================
---
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
(original)
+++
incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
Mon Oct 2 11:01:32 2006
@@ -96,39 +96,4 @@
}
}
- /**
- * Set up a classloader for the execution of the
- * main class.
- *
- * @return
- * @throws MojoExecutionException
- */
- private URLClassLoader getClassLoader() throws MojoExecutionException {
- try {
- Set urls = new HashSet();
-
- URL mainClasses = new
File(project.getBuild().getOutputDirectory()).toURL();
- getLog().debug("Adding to classpath : " + mainClasses);
- urls.add(mainClasses);
-
- URL testClasses = new
File(project.getBuild().getTestOutputDirectory()).toURL();
- getLog().debug("Adding to classpath : " + testClasses);
- urls.add(testClasses);
-
- Set dependencies = project.getArtifacts();
- Iterator iter = dependencies.iterator();
- while (iter.hasNext()) {
- Artifact classPathElement = (Artifact) iter.next();
- getLog().debug("Adding artifact: " +
classPathElement.getArtifactId() + " to classpath");
- urls.add(classPathElement.getFile().toURL());
- }
- URLClassLoader appClassloader = new URLClassLoader(
- (URL[]) urls.toArray(new URL[urls.size()]),
- this.getClass().getClassLoader());
- return appClassloader;
- } catch (MalformedURLException e) {
- throw new MojoExecutionException("Error during setting up
classpath", e);
- }
- }
-
}
Modified: incubator/servicemix/trunk/tooling/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/pom.xml?view=diff&rev=452148&r1=452147&r2=452148
==============================================================================
--- incubator/servicemix/trunk/tooling/pom.xml (original)
+++ incubator/servicemix/trunk/tooling/pom.xml Mon Oct 2 11:01:32 2006
@@ -52,6 +52,8 @@
<module>servicemix-embedded-simple</module>
<module>servicemix-ode-service-unit</module>
<module>servicemix-jsr181-annotated-service-unit</module>
+ <module>servicemix-saxon-xquery-service-unit</module>
+ <module>servicemix-saxon-xslt-service-unit</module>
<module>jbi-maven-plugin</module>
<module>servicemix-archetypes-itests</module>
</modules>