From daac67ff4255bd4c65892eb42c76ac74807c0bdf Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 21 Oct 2009 10:34:41 +0000 Subject: [PATCH] TUSCANY-3347 make the name of the implementation.jee composite unique git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@827953 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/resources/helloworld.composite | 2 +- .../jee/TestExternalEarModelResolver.java | 2 +- .../jee/xml/JEEImplementationProcessor.java | 21 +++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/branches/sca-java-1.5.2/itest/contribution-jee-samples/scajar-ear-appcomp/src/main/resources/helloworld.composite b/branches/sca-java-1.5.2/itest/contribution-jee-samples/scajar-ear-appcomp/src/main/resources/helloworld.composite index ebd8377725..8f8d46ccd7 100644 --- a/branches/sca-java-1.5.2/itest/contribution-jee-samples/scajar-ear-appcomp/src/main/resources/helloworld.composite +++ b/branches/sca-java-1.5.2/itest/contribution-jee-samples/scajar-ear-appcomp/src/main/resources/helloworld.composite @@ -29,7 +29,7 @@ - + diff --git a/branches/sca-java-1.5.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java b/branches/sca-java-1.5.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java index 34bf3702d3..1c4bd34352 100644 --- a/branches/sca-java-1.5.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java +++ b/branches/sca-java-1.5.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java @@ -91,7 +91,7 @@ public class TestExternalEarModelResolver implements ModelResolver { URL earLocation = null; if ( uri.toString().equals("itest-contribution-jee-samples-13-ear-nonenhanced.ear")){ earLocation = new File("../contribution-jee-samples/ear-nonenhanced/target/itest-contribution-jee-samples-13-ear-nonenhanced.ear").toURL(); - } else if ( uri.toString().equals("itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear")){ + } else if ( uri.toString().equals("./itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear")){ earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit/target/itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear").toURL(); } else if ( uri.toString().equals("itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear")){ earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit-war-appcomp/target/itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear").toURL(); diff --git a/branches/sca-java-1.5.2/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java b/branches/sca-java-1.5.2/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java index 9059d2da26..83b56cf990 100644 --- a/branches/sca-java-1.5.2/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java +++ b/branches/sca-java-1.5.2/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java @@ -106,8 +106,6 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem JEEImplementation implementation = implementationFactory.createJEEImplementation(); implementation.setUnresolved(true); - implementation.setName(IMPLEMENTATION_JEE); - // Read the archive attribute String archive = getString(reader, "archive"); if (archive != null) { @@ -116,6 +114,25 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem // Set the URI of the component type implementation.setURI(archive); } + + // the resulting implementation (composite) will be cached by the CompositeModelResolver + // based on it's name so we need to derive a unique name for this implementation based + // on the name of the archive that it represents + String path = URI.create(archive).getPath(); + String localName = "impl-jee-current-dir-archive"; + if (path != null){ + int s = path.lastIndexOf('/'); + if (s > -1){ + localName = path.substring(s + 1); + } else { + if (path.length() > 0 && !path.equals(".")){ + localName = path; + } + } + } + + QName name = new QName(Constants.SCA10_TUSCANY_NS, localName); + implementation.setName(name); // Read policies policyProcessor.readPolicies(implementation, reader);