tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject svn commit: r1415216 - in /openejb/trunk/openejb: arquillian/ arquillian/arquillian-openejb-embedded-4/ arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/ arquillian/arquillian-tomee-embedded/src/main/java/org...
Date Thu, 29 Nov 2012 15:40:36 GMT
Author: andygumbrecht
Date: Thu Nov 29 15:40:34 2012
New Revision: 1415216

URL: http://svn.apache.org/viewvc?rev=1415216&view=rev
Log:
Fix bad windows URI/path in TomcatWebAppBuilder.java
Fix TomEEWebappExtension.java and RemoteTomEEExtension.java multiple registration exceptions.
Update to Maven.resolver() syntax and libs.
Finals.

Modified:
    openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/pom.xml
    openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
    openejb/trunk/openejb/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
    openejb/trunk/openejb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEExtension.java
    openejb/trunk/openejb/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/hibernate/HibernateTest.java
    openejb/trunk/openejb/arquillian/arquillian-tomee-tests/pom.xml
    openejb/trunk/openejb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappExtension.java
    openejb/trunk/openejb/arquillian/pom.xml
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java

Modified: openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/pom.xml?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/pom.xml (original)
+++ openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/pom.xml Thu Nov 29 15:40:34
2012
@@ -84,7 +84,7 @@
     <dependency>
       <groupId>org.jboss.shrinkwrap.resolver</groupId>
       <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
-      <version>2.0.0-alpha-1</version>
+      <version>2.0.0-alpha-5</version>
       <scope>test</scope>
     </dependency>
 

Modified: openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
(original)
+++ openejb/trunk/openejb/arquillian/arquillian-openejb-embedded-4/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
Thu Nov 29 15:40:34 2012
@@ -94,7 +94,7 @@ public class OpenEJBArchiveProcessor {
             prefix = WEB_INF;
 
             final Map<ArchivePath, Node> content = archive.getContent(new IncludeRegExpPaths("/WEB-INF/lib/.*"));
-            for (Map.Entry<ArchivePath, Node> node : content.entrySet()) {
+            for (final Map.Entry<ArchivePath, Node> node : content.entrySet()) {
                 final Asset asset = node.getValue().getAsset();
                 if (UrlAsset.class.isInstance(asset)) {
                     additionalPaths.add(get(URL.class, "url", asset));
@@ -241,7 +241,7 @@ public class OpenEJBArchiveProcessor {
         return appModule;
     }
 
-    private static <T> T get(Class<T> fileClass, String attr, Asset asset) {
+    private static <T> T get(final Class<T> fileClass, final String attr, final
Asset asset) {
         try {
             final Field field = asset.getClass().getDeclaredField(attr);
             field.setAccessible(true);
@@ -254,7 +254,7 @@ public class OpenEJBArchiveProcessor {
     private static org.apache.xbean.finder.archive.Archive finderArchive(final Node beansXml,
final Archive<?> archive, final ClassLoader cl, final Collection<URL> additionalPaths)
{
         final List<Class<?>> classes = new ArrayList<Class<?>>();
         final Map<ArchivePath, Node> content = archive.getContent(new IncludeRegExpPaths(".*.class"));
-        for (Map.Entry<ArchivePath, Node> node : content.entrySet()) {
+        for (final Map.Entry<ArchivePath, Node> node : content.entrySet()) {
             final String classname = name(node.getKey().get());
             try {
                 classes.add(cl.loadClass(classname));
@@ -266,7 +266,7 @@ public class OpenEJBArchiveProcessor {
         final Map<URL, List<String>> classesByUrl = new HashMap<URL, List<String>>();
 
         final List<org.apache.xbean.finder.archive.Archive> archives = new ArrayList<org.apache.xbean.finder.archive.Archive>();
-        for (URL url : DeploymentLoader.filterWebappUrls(additionalPaths.toArray(new URL[additionalPaths.size()]),
null)) {
+        for (final URL url : DeploymentLoader.filterWebappUrls(additionalPaths.toArray(new
URL[additionalPaths.size()]), null)) {
             final List<String> currentClasses = new ArrayList<String>();
             final org.apache.xbean.finder.archive.Archive newArchive = new FilteredArchive(new
JarArchive(cl, url), new WebappAggregatedArchive.ScanXmlSaverFilter(false, null, currentClasses));
             classesByUrl.put(url, currentClasses);
@@ -276,7 +276,7 @@ public class OpenEJBArchiveProcessor {
         archives.add(new ClassesArchive(classes));
         if (beansXml != null) {
             final List<String> mainClasses = new ArrayList<String>();
-            for (Class<?> clazz : classes) {
+            for (final Class<?> clazz : classes) {
                 mainClasses.add(clazz.getName());
             }
             // look org.apache.openejb.config.AnnotationDeployer.DiscoverAnnotatedBeans.hasBeansXml()
@@ -303,7 +303,7 @@ public class OpenEJBArchiveProcessor {
     private static class AssetSource implements ReadDescriptors.Source {
         private Asset asset;
 
-        private AssetSource(Asset asset) {
+        private AssetSource(final Asset asset) {
             this.asset = asset;
         }
 

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
(original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
Thu Nov 29 15:40:34 2012
@@ -43,23 +43,24 @@ public class EmbeddedTomEEContainer exte
 
     private Container container;
 
+    @Override
     public Class<EmbeddedTomEEConfiguration> getConfigurationClass() {
         return EmbeddedTomEEConfiguration.class;
     }
 
     @Override
-    public void setup(EmbeddedTomEEConfiguration configuration) {
+    public void setup(final EmbeddedTomEEConfiguration configuration) {
         super.setup(configuration);
-        container = new Container();
-        container.setup(convertConfiguration(configuration));
+        this.container = new Container();
+        this.container.setup(this.convertConfiguration(configuration));
     }
 
     /*
      * Not exactly as elegant as I'd like. Maybe we could have the EmbeddedServer configuration
in openejb-core so all the adapters can use it.
      * Depending on tomee-embedded is fine in this adapter, but less desirable in the others,
as we'd get loads of stuff in the classpath we don't need.
      */
-    private Configuration convertConfiguration(EmbeddedTomEEConfiguration tomeeConfiguration)
{
-    	Configuration configuration = new Configuration();
+    private Configuration convertConfiguration(final EmbeddedTomEEConfiguration tomeeConfiguration)
{
+    	final Configuration configuration = new Configuration();
     	configuration.setDir(tomeeConfiguration.getDir());
     	configuration.setHttpPort(tomeeConfiguration.getHttpPort());
     	configuration.setStopPort(tomeeConfiguration.getStopPort());
@@ -73,7 +74,7 @@ public class EmbeddedTomEEContainer exte
     @Override
     public void start() throws LifecycleException {
         try {
-            container.start();
+            this.container.start();
             SystemInstance.get().setComponent(AdditionalBeanDiscoverer.class, new TestClassDiscoverer());
         } catch (Exception e) {
             e.printStackTrace();
@@ -84,7 +85,7 @@ public class EmbeddedTomEEContainer exte
     @Override
     public void stop() throws LifecycleException {
         try {
-            container.stop();
+            this.container.stop();
         } catch (Exception e) {
             throw new LifecycleException("Unable to stop server", e);
         }
@@ -103,17 +104,17 @@ public class EmbeddedTomEEContainer exte
             final File file = new File(tempDir, name);
             */
             final String name = archive.getName();
-            final File file = dumpFile(archive);
+            final File file = this.dumpFile(archive);
             ARCHIVES.put(archive, file);
-            archiveWithTestInfo(archive).as(ZipExporter.class).exportTo(file, true);
+            this.archiveWithTestInfo(archive).as(ZipExporter.class).exportTo(file, true);
 
-            container.deploy(name, file);
-            final AppInfo info = container.getInfo(name);
-            final String context = getArchiveNameWithoutExtension(archive);
+            this.container.deploy(name, file);
+            final AppInfo info = this.container.getInfo(name);
+            final String context = this.getArchiveNameWithoutExtension(archive);
 
-            final HTTPContext httpContext = new HTTPContext(configuration.getHost(), configuration.getHttpPort());
+            final HTTPContext httpContext = new HTTPContext(this.configuration.getHost(),
this.configuration.getHttpPort());
             httpContext.add(new Servlet("ArquillianServletRunner", "/" + context));
-            addServlets(httpContext, info);
+            this.addServlets(httpContext, info);
 
             return new ProtocolMetaData().addContext(httpContext);
         } catch (Exception e) {
@@ -123,16 +124,16 @@ public class EmbeddedTomEEContainer exte
     }
 
     @Override
-    public void undeploy(Archive<?> archive) throws DeploymentException {
+    public void undeploy(final Archive<?> archive) throws DeploymentException {
     	try {
             final String name = archive.getName();
-            container.undeploy(name);
+            this.container.undeploy(name);
         } catch (Exception e) {
             e.printStackTrace();
             throw new DeploymentException("Unable to undeploy", e);
         }
-        File file = ARCHIVES.remove(archive);
-        File folder = new File(file.getParentFile(), file.getName().substring(0, file.getName().length()
- 5));
+        final File file = ARCHIVES.remove(archive);
+        final File folder = new File(file.getParentFile(), file.getName().substring(0, file.getName().length()
- 5));
         if (folder.exists()) {
             Files.delete(folder);
         }

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEExtension.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEExtension.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEExtension.java
(original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEExtension.java
Thu Nov 29 15:40:34 2012
@@ -26,16 +26,41 @@ import org.jboss.arquillian.container.te
 import org.jboss.arquillian.core.spi.LoadableExtension;
 import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 public class RemoteTomEEExtension implements LoadableExtension {
+
     private static final String ADAPTER = "tomee-remote";
+    private static final AtomicBoolean registered = new AtomicBoolean(false);
+    private static final ReentrantLock lock = new ReentrantLock();
 
-    @Override public void register(ExtensionBuilder builder) {
+    @Override
+    public void register(final ExtensionBuilder builder) {
         if (ArquillianUtil.isCurrentAdapter(ADAPTER)) {
-            builder.service(DeployableContainer.class, RemoteTomEEContainer.class)
-                .service(AuxiliaryArchiveAppender.class, RemoteTomEEEJBEnricherArchiveAppender.class)
-                .observer(DeploymentExceptionObserver.class)
-                .observer(RemoteInitialContextObserver.class)
-                .service(ResourceProvider.class, DeploymentExceptionProvider.class);
+
+            final ReentrantLock l = lock;
+            l.lock();
+
+            try {
+
+                if (!registered.getAndSet(true)) {
+
+                    try {
+                        builder.observer(RemoteInitialContextObserver.class);
+                        builder.observer(DeploymentExceptionObserver.class);
+                        builder.service(DeployableContainer.class, RemoteTomEEContainer.class)
+                                                    .service(AuxiliaryArchiveAppender.class,
RemoteTomEEEJBEnricherArchiveAppender.class)
+                                                    .service(ResourceProvider.class, DeploymentExceptionProvider.class);
+                    } catch (IllegalArgumentException e) {
+                        Logger.getLogger(RemoteTomEEExtension.class.getName()).log(Level.WARNING,
"RemoteTomEEExtension: " + e.getMessage());
+                    }
+                }
+            } finally {
+                l.unlock();
+            }
         }
     }
 }

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/hibernate/HibernateTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/hibernate/HibernateTest.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/hibernate/HibernateTest.java
(original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/hibernate/HibernateTest.java
Thu Nov 29 15:40:34 2012
@@ -28,17 +28,17 @@ import org.jboss.shrinkwrap.api.ArchiveP
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
 import org.jboss.shrinkwrap.resolver.api.ResolutionException;
-import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
-import org.jboss.shrinkwrap.resolver.api.maven.MavenResolutionFilter;
-import org.jboss.shrinkwrap.resolver.api.maven.filter.ScopeFilter;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
+import org.jboss.shrinkwrap.resolver.api.maven.strategy.AcceptScopesStrategy;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import javax.persistence.EntityManagerFactory;
 import java.io.File;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 @RunWith(Arquillian.class)
@@ -47,50 +47,51 @@ public class HibernateTest {
     public static WebArchive war() {
         File[] hibernate;
         try { // try offline first since it is generally faster
-            hibernate = DependencyResolvers.use(MavenDependencyResolver.class)
-                .goOffline()
-                .loadEffectivePom("src/test/resources/hibernate-pom.xml")
-                .importAnyDependencies(new ScopeFilter("compile"))
-                .resolveAsFiles();
+            hibernate = Maven.resolver()
+                    .offline(true)
+                    .loadPomFromFile("src/test/resources/hibernate-pom.xml")
+                    .importRuntimeAndTestDependencies(new AcceptScopesStrategy(ScopeType.COMPILE))
+                    .asFile();
         } catch (ResolutionException re) { // try on central
-            hibernate = DependencyResolvers.use(MavenDependencyResolver.class)
-                    .loadEffectivePom("src/test/resources/hibernate-pom.xml")
-                    .importAnyDependencies(new ScopeFilter("compile"))
-                    .resolveAsFiles();
+            hibernate = Maven.resolver()
+                    .loadPomFromFile("src/test/resources/hibernate-pom.xml")
+                    .importRuntimeAndTestDependencies(new AcceptScopesStrategy(ScopeType.COMPILE))
+                    .asFile();
         }
 
         return ShrinkWrap.create(WebArchive.class, "hibernate-app.war")
-                    .addAsWebInfResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+
-                            "<persistence version=\"2.0\"\n" +
-                            "    xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+
-                            "    xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence"
+
-                            "                         http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n"
+
-                            "  <persistence-unit name=\"hibernate\">\n" +
-                            "    <provider>org.hibernate.ejb.HibernatePersistence</provider>\n"
+
-                            "    <exclude-unlisted-classes>true</exclude-unlisted-classes>\n"
+
-                            "    <properties>\n" +
-                            "      <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"
/>\n" +
-                            "    </properties>\n" +
-                            "  </persistence-unit>\n" +
-                            "</persistence>"), ArchivePaths.create("persistence.xml"))
-                    .addAsLibraries(hibernate)
-                    .addAsLibraries(JarLocation.jarLocation(ResolutionException.class))
-                    .addAsLibraries(JarLocation.jarLocation(MavenResolutionFilter.class));
+                .addAsWebInfResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+
+                        "<persistence version=\"2.0\"\n" +
+                        "    xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+
+                        "    xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence"
+
+                        "                         http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n"
+
+                        "  <persistence-unit name=\"hibernate\">\n" +
+                        "    <provider>org.hibernate.ejb.HibernatePersistence</provider>\n"
+
+                        "    <exclude-unlisted-classes>true</exclude-unlisted-classes>\n"
+
+                        "    <properties>\n" +
+                        "      <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"
/>\n" +
+                        "    </properties>\n" +
+                        "  </persistence-unit>\n" +
+                        "</persistence>"), ArchivePaths.create("persistence.xml"))
+                .addAsLibraries(hibernate)
+                .addAsLibraries(JarLocation.jarLocation(ResolutionException.class))
+                .addAsLibraries(JarLocation.jarLocation(org.jboss.shrinkwrap.resolver.api.maven.filter.MavenResolutionFilter.class));
     }
 
     @Test // using an internal lookup because in tomee embedded new InitialContext() is not
guaranteed
     public void checkEmIsHibernateOne() throws Exception {
         AppInfo info = null;
-        for (AppInfo app : SystemInstance.get().getComponent(Assembler.class).getDeployedApplications())
{
+        for (final AppInfo app : SystemInstance.get().getComponent(Assembler.class).getDeployedApplications())
{
             if (app.appId.endsWith("hibernate-app")) {
                 info = app;
                 break;
             }
         }
 
+        assertNotNull(info);
         final EntityManagerFactory emf = (EntityManagerFactory)
-            SystemInstance.get().getComponent(ContainerSystem.class)
-                .getJNDIContext().lookup(Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT + info.persistenceUnits.iterator().next().id);
+                SystemInstance.get().getComponent(ContainerSystem.class)
+                        .getJNDIContext().lookup(Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT
+ info.persistenceUnits.iterator().next().id);
         assertTrue(((ReloadableEntityManagerFactory) emf).getDelegate().getClass().getName().startsWith("org.hibernate."));
     }
 }

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-tests/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-tests/pom.xml?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-tests/pom.xml (original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-tests/pom.xml Thu Nov 29 15:40:34 2012
@@ -41,7 +41,7 @@
     <dependency>
       <groupId>org.jboss.shrinkwrap.resolver</groupId>
       <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
-      <version>2.0.0-alpha-1</version>
+      <version>2.0.0-alpha-5</version>
       <scope>test</scope>
     </dependency>
 

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappExtension.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappExtension.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappExtension.java
(original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappExtension.java
Thu Nov 29 15:40:34 2012
@@ -26,17 +26,42 @@ import org.jboss.arquillian.container.te
 import org.jboss.arquillian.core.spi.LoadableExtension;
 import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 public class TomEEWebappExtension implements LoadableExtension {
+
     private static final String ADAPTER = "tomee-webapp";
+    private static final AtomicBoolean registered = new AtomicBoolean(false);
+    private static final ReentrantLock lock = new ReentrantLock();
 
     @Override
-    public void register(ExtensionBuilder builder) {
+    public void register(final ExtensionBuilder builder) {
         if (ArquillianUtil.isCurrentAdapter(ADAPTER)) {
-            builder.service(DeployableContainer.class, TomEEWebappContainer.class)
-                .service(AuxiliaryArchiveAppender.class, TomEEWebappEJBEnricherArchiveAppender.class)
-                .observer(DeploymentExceptionObserver.class)
-                .observer(RemoteInitialContextObserver.class)
-                .service(ResourceProvider.class, DeploymentExceptionProvider.class);
+
+            final ReentrantLock l = lock;
+            l.lock();
+
+            try {
+
+                if (!registered.getAndSet(true)) {
+
+                    try {
+                        builder.observer(DeploymentExceptionObserver.class);
+                        builder.observer(RemoteInitialContextObserver.class);
+
+                        builder.service(DeployableContainer.class, TomEEWebappContainer.class)
+                                .service(AuxiliaryArchiveAppender.class, TomEEWebappEJBEnricherArchiveAppender.class)
+                                .service(ResourceProvider.class, DeploymentExceptionProvider.class);
+                    } catch (IllegalArgumentException e) {
+                        Logger.getLogger(TomEEWebappExtension.class.getName()).log(Level.WARNING,
"TomEEWebappExtension: " + e.getMessage());
+                    }
+                }
+            } finally {
+                l.unlock();
+            }
         }
     }
 }

Modified: openejb/trunk/openejb/arquillian/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/pom.xml?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/pom.xml (original)
+++ openejb/trunk/openejb/arquillian/pom.xml Thu Nov 29 15:40:34 2012
@@ -34,7 +34,7 @@
   <properties>
     <version.arquillian>1.0.3.Final</version.arquillian>
     <version.shrinkwrap.descriptor>2.0.0-alpha-4</version.shrinkwrap.descriptor>
-    <version.shrinkwrap.shrinkwrap>1.1.1-alpha-1</version.shrinkwrap.shrinkwrap>
+    <version.shrinkwrap.shrinkwrap>1.1.1-alpha-2</version.shrinkwrap.shrinkwrap>
   </properties>
 
   <modules>

Modified: openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java?rev=1415216&r1=1415215&r2=1415216&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
Thu Nov 29 15:40:34 2012
@@ -383,7 +383,7 @@ public class TomcatWebAppBuilder impleme
             InputStream contextXml = null;
             URL contextXmlUrl = null;
             if (war.isDirectory()) {
-                final File cXml = new File(war, Constants.ApplicationContextXml);
+                final File cXml = new File(war, Constants.ApplicationContextXml).getAbsoluteFile();
                 if (cXml.exists()) {
                     contextXml = IO.read(cXml);
                     contextXmlUrl = cXml.toURI().toURL();
@@ -393,7 +393,7 @@ public class TomcatWebAppBuilder impleme
                 final JarFile warAsJar = new JarFile(war);
                 final JarEntry entry = warAsJar.getJarEntry(Constants.ApplicationContextXml);
                 if (entry != null) {
-                    contextXmlUrl = new URL("jar:file://" + war.getAbsolutePath() + "!/"
+ Constants.ApplicationContextXml);
+                    contextXmlUrl = new URL("jar:" + war.getAbsoluteFile().toURI().toURL().toExternalForm()
+ "!/" + Constants.ApplicationContextXml);
                     contextXml = warAsJar.getInputStream(entry);
                 }
             }



Mime
View raw message