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 2009/07/01 21:22:07 UTC
svn commit: r790327 - in /geronimo/server/trunk/framework:
buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/
modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/
Author: djencks
Date: Wed Jul 1 19:22:07 2009
New Revision: 790327
URL: http://svn.apache.org/viewvc?rev=790327&view=rev
Log:
GERONIMO-4628 Have deployer save plan in META-INF/plan.xml if its not already there. Don't have the car-maven-plugin install the plan. Also cleanup the add class methods of DeploymentContext. Original patch from Rex Wang, thanks
Modified:
geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PlanProcessorMojo.java
geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java
geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java
Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java (original)
+++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java Wed Jul 1 19:22:07 2009
@@ -116,7 +116,7 @@
/**
* The plan file for the CAR.
*
- * @parameter expression="${project.build.directory}/resources/META-INF/plan.xml"
+ * @parameter expression="${project.build.directory}/work/plan.xml"
* @required
*/
private File planFile = null;
Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PlanProcessorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PlanProcessorMojo.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PlanProcessorMojo.java (original)
+++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PlanProcessorMojo.java Wed Jul 1 19:22:07 2009
@@ -67,7 +67,7 @@
/**
* Directory to put the processed plan in.
*
- * @parameter expression="${project.build.directory}/resources/META-INF"
+ * @parameter expression="${project.build.directory}/work"
* @required
*/
protected File targetDir = null;
@@ -75,7 +75,7 @@
/**
* XXX
*
- * @parameter expression="${project.build.directory}/resources/META-INF/plan.xml"
+ * @parameter expression="${project.build.directory}/work/plan.xml"
* @required
*/
protected File targetFile = null;
@@ -99,7 +99,7 @@
/**
* we copy the plan here for filtering, then add env stuff.
*
- * @parameter expression="${project.build.directory}/fliteredplan/plan.xml"
+ * @parameter expression="${project.build.directory}/work/filteredplan.xml"
* @required
*/
protected File filteredPlanFile;
Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java Wed Jul 1 19:22:07 2009
@@ -144,6 +144,19 @@
addFile(getTargetFile(targetPath), new ByteArrayInputStream(source.getBytes()));
}
+ public void addFile(URI targetPath, byte[] contents) throws IOException {
+ File file = getTargetFile(targetPath);
+ if (!file.getParentFile().mkdirs()) {
+ throw new IOException("Could not create parent directory for entry: " + targetPath + " at " + file.getParentFile());
+ }
+ FileOutputStream out = new FileOutputStream(file);
+ try {
+ out.write(contents);
+ } finally {
+ DeploymentUtil.close(out);
+ }
+ }
+
public File getTargetFile(URI targetPath) {
if (targetPath == null) throw new NullPointerException("targetPath is null");
if (targetPath.isAbsolute()) throw new IllegalArgumentException("targetPath is absolute");
Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java Wed Jul 1 19:22:07 2009
@@ -77,6 +77,7 @@
private final Collection watchers;
private final ArtifactResolver artifactResolver;
private final Kernel kernel;
+ private static final URI PLAN_LOCATION = URI.create("META-INF/plan.xml");
public Deployer(String remoteDeployAddress, Collection builders, Collection stores, Collection watchers, Kernel kernel) {
this(remoteDeployAddress, builders, stores, watchers, getArtifactResolver(kernel), kernel);
@@ -254,7 +255,11 @@
// It's our responsibility to close this context, once we're done with it...
DeploymentContext context = builder.buildConfiguration(inPlace, configID, plan, module, stores, artifactResolver, store);
-
+ // Copy the external plan to the META-INF folder with the uniform name plan.xml if there is nothing there already
+ if (planFile != null && !context.getTargetFile(PLAN_LOCATION).exists()) {
+ context.addFile(PLAN_LOCATION, planFile);
+ }
+ // install the configuration
return install(targetFile, install, manifest, store, context);
} catch (Throwable e) {
//TODO not clear all errors will result in total cleanup
Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java Wed Jul 1 19:22:07 2009
@@ -594,9 +594,7 @@
throw new IllegalStateException("target path must end with a '/' character: " + targetPath);
String classFileName = fqcn.replace('.', '/') + ".class";
-
- File targetFile = getTargetFile(new URI(targetPath.toString() + classFileName));
- addFile(targetFile, new ByteArrayInputStream(bytes));
+ resourceContext.addFile(new URI(targetPath.toString() + classFileName), bytes);
configuration.addToClassPath(targetPath.toString());
}
@@ -617,21 +615,6 @@
resourceContext.addFile(targetPath, source);
}
- private void addFile(File targetFile, InputStream source) throws IOException {
- targetFile.getParentFile().mkdirs();
- OutputStream out = null;
- try {
- out = new FileOutputStream(targetFile);
- byte[] buffer = new byte[4096];
- int count;
- while ((count = source.read(buffer)) > 0) {
- out.write(buffer, 0, count);
- }
- } finally {
- DeploymentUtil.close(out);
- }
- }
-
public File getTargetFile(URI targetPath) {
return resourceContext.getTargetFile(targetPath);
}
Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java Wed Jul 1 19:22:07 2009
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.FileOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -93,7 +94,21 @@
public void addFile(URI targetPath, String source) throws IOException {
}
-
+
+ //completely untested
+ public void addFile(URI targetPath, byte[] contents) throws IOException {
+ File file = getTargetFile(targetPath);
+ if (!file.getParentFile().mkdirs()) {
+ throw new IOException("Could not create parent directory for entry: " + targetPath + " at " + file.getParentFile());
+ }
+ FileOutputStream out = new FileOutputStream(file);
+ try {
+ out.write(contents);
+ } finally {
+ DeploymentUtil.close(out);
+ }
+ }
+
public File getTargetFile(URI targetPath) {
if (targetPath == null) throw new NullPointerException("targetPath is null");
if (targetPath.isAbsolute()) throw new IllegalArgumentException("targetPath is absolute");
Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java?rev=790327&r1=790326&r2=790327&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java Wed Jul 1 19:22:07 2009
@@ -40,6 +40,8 @@
void addFile(URI targetPath, File source) throws IOException;
void addFile(URI targetPath, String source) throws IOException;
+
+ void addFile(URI targetPath, byte[] contents) throws IOException;
File getTargetFile(URI targetPath);