You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jo...@apache.org on 2012/02/27 09:28:52 UTC
svn commit: r1294060 -
/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
Author: johnxiao
Date: Mon Feb 27 08:28:52 2012
New Revision: 1294060
URL: http://svn.apache.org/viewvc?rev=1294060&view=rev
Log:
GERONIMO-6288 When deploy a EBA with long symbolicname, showing an error Msg "xxxx already existes in the server"
Modified:
geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java?rev=1294060&r1=1294059&r2=1294060&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java Mon Feb 27 08:28:52 2012
@@ -18,8 +18,10 @@ package org.apache.geronimo.deployment.p
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Collection;
@@ -28,6 +30,7 @@ import java.util.List;
import java.util.Stack;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import java.util.jar.Manifest;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.xml.parsers.ParserConfigurationException;
@@ -56,9 +59,9 @@ public class ConfigIDExtractor {
private static final Logger log = LoggerFactory.getLogger(ConfigIDExtractor.class);
- private static final String APPLICATION_SYMBOLICNAME="Application-SymbolicName:";
+ private static final String APPLICATION_SYMBOLICNAME="Application-SymbolicName";
- private static final String APPLICATION_VERION="Application-Version:";
+ private static final String APPLICATION_VERION="Application-Version";
/**
* Attempt to calculate the Geronimo ModuleID for a J2EE application
@@ -104,7 +107,7 @@ public class ConfigIDExtractor {
if (target.getName().endsWith("xml")) {
name = extractModuleIdFromPlan(in);
} else if (target.getName().endsWith("MF")) {
- name = extractModuleIdFromAPPLICATION_MF(in);
+ name = extractModuleIdFromAPPLICATION_MF(new FileInputStream(target));
}
if(name != null) {
@@ -149,7 +152,7 @@ public class ConfigIDExtractor {
if (entry.getName().endsWith("xml")) {
name = extractModuleIdFromPlan(in);
} else if (entry.getName().endsWith("MF")) {
- name = extractModuleIdFromAPPLICATION_MF(in);
+ name = extractModuleIdFromAPPLICATION_MF(input.getInputStream(entry));
}
if(name != null) {
@@ -239,30 +242,14 @@ public class ConfigIDExtractor {
}
- private static String extractModuleIdFromAPPLICATION_MF(Reader APPLICATION_MF) throws IOException,DeploymentException {
+ private static String extractModuleIdFromAPPLICATION_MF(InputStream in) throws IOException,DeploymentException {
- BufferedReader br = new BufferedReader(APPLICATION_MF);
-
- String artifactID = null;
- String artifactVersion = null;
-
+ Manifest appMf = new Manifest(in);
- String line = br.readLine();
-
- while (line != null) {
-
- if (line.startsWith(APPLICATION_SYMBOLICNAME)) {
- artifactID = line.substring(APPLICATION_SYMBOLICNAME.length(), line.length());
- }
-
- if (line.startsWith(APPLICATION_VERION)) {
- artifactVersion = line.substring(APPLICATION_VERION.length(), line.length());
- }
-
- line = br.readLine();
-
- }
+ String artifactID = appMf.getMainAttributes().getValue(APPLICATION_SYMBOLICNAME);
+ String artifactVersion = appMf.getMainAttributes().getValue(APPLICATION_VERION);;
+
if (artifactID == null || artifactVersion == null) {
throw new DeploymentException("Could not determine artifact or version with APPLICATION.MF of your EBA application");
}