tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1614714 - in /tomee/tomee/trunk: arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java
Date Wed, 30 Jul 2014 16:55:26 GMT
Author: rmannibucau
Date: Wed Jul 30 16:55:25 2014
New Revision: 1614714

URL: http://svn.apache.org/r1614714
Log:
style + compilation

Modified:
    tomee/tomee/trunk/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java
    tomee/tomee/trunk/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java

Modified: tomee/tomee/trunk/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java?rev=1614714&r1=1614713&r2=1614714&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/TestObserver.java
Wed Jul 30 16:55:25 2014
@@ -30,7 +30,6 @@ import org.jboss.arquillian.core.api.ann
 import org.jboss.arquillian.core.api.annotation.Observes;
 import org.jboss.arquillian.core.spi.EventContext;
 import org.jboss.arquillian.test.spi.TestClass;
-import org.jboss.arquillian.test.spi.event.suite.ClassLifecycleEvent;
 import org.jboss.arquillian.test.spi.event.suite.TestEvent;
 
 import javax.enterprise.context.spi.CreationalContext;

Modified: tomee/tomee/trunk/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java?rev=1614714&r1=1614713&r2=1614714&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java
(original)
+++ tomee/tomee/trunk/server/openejb-hessian/src/main/java/org/apache/openejb/cdi/internal/HessianExtension.java
Wed Jul 30 16:55:25 2014
@@ -27,6 +27,7 @@ import org.apache.openejb.server.hessian
 import org.apache.openejb.server.hessian.HessianServer;
 import org.apache.openejb.server.hessian.HessianService;
 import org.apache.openejb.spi.ContainerSystem;
+import org.apache.openejb.util.AppFinder;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectableBeanManager;
@@ -49,8 +50,8 @@ import java.util.logging.Logger;
 public class HessianExtension implements Extension {
     private static final Logger LOGGER = Logger.getLogger(HessianExtension.class.getName());
 
-    private final Collection<Deployment> toDeploy = new ArrayList<Deployment>();
-    private final Collection<DeployedEndpoint> deployed = new ArrayList<DeployedEndpoint>();
+    private final Collection<Deployment> toDeploy = new ArrayList<>();
+    private final Collection<DeployedEndpoint> deployed = new ArrayList<>();
 
     private AppInfo appInfo;
 
@@ -87,6 +88,7 @@ public class HessianExtension implements
 
         final HessianRegistry registry = service.getRegistry();
 
+        final String appName = findAppName();
         for (final Deployment deployment : toDeploy) {
             final Hessian hessian = deployment.itf.getAnnotation(Hessian.class);
             final HessianServer server;
@@ -113,7 +115,6 @@ public class HessianExtension implements
             server.createSkeleton(bm.getReference(deployment.bean, deployment.itf, null),
deployment.itf);
 
             final String name = getName(deployment.path, deployment.itf);
-            final String appName = findAppName(bm);
             try {
                 LOGGER.info("Hessian(url=" + registry.deploy(deployment.itf.getClassLoader(),
server,
                     service.getVirtualHost(), appName,
@@ -127,14 +128,14 @@ public class HessianExtension implements
         toDeploy.clear();
     }
 
-    private String findAppName(final BeanManager bm) {
+    private String findAppName() {
         if (appInfo.webAppAlone) {
             return appInfo.webApps.iterator().next().contextRoot;
         }
 
         for (final AppContext app : SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts())
{
             for (final WebContext webContext : app.getWebContexts()) {
-                if (isSameContext(bm, webContext.getWebBeansContext())) {
+                if (isSameContext(webContext.getWebBeansContext())) {
                     String contextRoot = webContext.getContextRoot();
                     if (contextRoot != null) {
                         if (contextRoot.startsWith("/")) {
@@ -145,16 +146,20 @@ public class HessianExtension implements
                     return webContext.getId();
                 }
             }
-            if (isSameContext(bm, app.getWebBeansContext())) {
+            if (isSameContext(app.getWebBeansContext())) {
                 return app.getId();
             }
         }
-        throw new IllegalArgumentException("Can't find application matching bean manager
" + bm);
+        throw new IllegalArgumentException("Can't find application matching bean manager");
     }
 
-    private static boolean isSameContext(final BeanManager bm, WebBeansContext app) {
-        return InjectableBeanManager.class.isInstance(bm) && app == InjectableBeanManager.class.cast(bm).getWebBeansContext()
-            || BeanManagerImpl.class.isInstance(bm) && app == BeanManagerImpl.class.cast(bm).getWebBeansContext();
+    private boolean isSameContext(final WebBeansContext app) {
+        final BeanManagerImpl bm = app.getBeanManagerImpl();
+        try {
+            return bm.isInUse() && equals(bm.getExtension(HessianExtension.class));
+        } catch (final Exception e) {
+            return false;
+        }
     }
 
     protected void shutdown(final @Observes BeforeShutdown unused) {



Mime
View raw message