[seam-commits] Seam SVN: r10989 - in modules/trunk: bridge-api/src/main/java/org/jboss/seam/bridge and 19 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue May 26 11:31:37 EDT 2009


Author: dan.j.allen
Date: 2009-05-26 11:31:37 -0400 (Tue, 26 May 2009)
New Revision: 10989

Added:
   modules/trunk/jndi-bridge/
   modules/trunk/jndi-bridge/pom.xml
   modules/trunk/jndi-bridge/src/
   modules/trunk/jndi-bridge/src/main/
   modules/trunk/jndi-bridge/src/main/java/
   modules/trunk/jndi-bridge/src/main/java/org/
   modules/trunk/jndi-bridge/src/main/java/org/jboss/
   modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/
   modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/
   modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/
   modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
   modules/trunk/jndi-bridge/src/main/resources/
   modules/trunk/jndi-bridge/src/main/resources/META-INF/
   modules/trunk/jndi-bridge/src/main/resources/META-INF/services/
   modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider
Modified:
   modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
   modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
   modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
   modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
   modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
   modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
   modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
   modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
   modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java
   modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
   modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
Log:
upgrade bridge so that the provider only has one method, getCurrentManager()
introduce JNDI bridge impl


Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -114,7 +114,7 @@
       managerImplClass = manager.getClass();
       for (ManagerProvider candidate : resolver.getManagerProviders())
       {
-         if (manager.equals(candidate.getRootManager()))
+         if (manager.equals(candidate.getCurrentManager()))
          {
             provider = candidate;
             if (log.isDebugEnabled())

Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,19 +1,14 @@
 package org.jboss.seam.bridge.spi;
 
-import javax.el.ELResolver;
 import javax.inject.manager.Manager;
 
 /**
- * A contract between the provider engine and the JCDI bootstrap
- * mechanism to return the current (root) Manager instance.
+ * A contract between the provider engine and the JCDI bootstrap mechanism to
+ * return the current Manager instance.
  * 
  * @author Dan Allen
  */
 public interface ManagerProvider
 {
-   Manager getRootManager();
-   
    Manager getCurrentManager();
-   
-   ELResolver getELResolver();
 }

Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -2,7 +2,6 @@
 
 import static org.testng.Assert.assertSame;
 
-import javax.el.ELResolver;
 import javax.inject.manager.Manager;
 
 import org.jboss.seam.bridge.spi.ManagerProvider;
@@ -16,7 +15,7 @@
  * @author Dan Allen
  */
 public class ManagerBridgeOverrideTest
-{ 
+{
    @Test
    public void testProviderOverride()
    {
@@ -34,20 +33,9 @@
    
    class MockManagerProvider implements ManagerProvider
    {
-      public Manager getRootManager()
-      {
-         return null;
-      }
-
       public Manager getCurrentManager()
       {
          return null;
       }
-
-      public ELResolver getELResolver()
-      {
-         return null;
-      }
-      
    }
 }

Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -44,7 +44,6 @@
    {
       ManagerProvider provider = ManagerBridge.getProvider();
       assertTrue(provider instanceof ManagerProviderStub);
-      assertSame(provider.getRootManager(), getCurrentManager());
       assertSame(provider.getCurrentManager(), getCurrentManager());
       Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
       assertSame(provider.getCurrentManager(), currentManager);

Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -48,7 +48,6 @@
       bridge.onManagerDeployed(getCurrentManager());
       ManagerProvider provider = ManagerBridge.getProvider();
       assertTrue(provider instanceof ManagerProviderStub);
-      assertSame(provider.getRootManager(), getCurrentManager());
       assertSame(provider.getCurrentManager(), getCurrentManager());
       Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
       assertSame(provider.getCurrentManager(), currentManager);

Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,20 +1,16 @@
-/**
- * 
- */
 package org.jboss.seam.bridge.stubs;
 
 import javax.inject.manager.Manager;
 
+import org.jboss.seam.bridge.spi.ManagerProvider;
 import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.ManagerImpl;
 
-public class IncorrectManagerProviderStub extends ManagerProviderStub
+public class IncorrectManagerProviderStub implements ManagerProvider
 {
-   public Manager getRootManager()
-   {
-      return ManagerImpl.newChildManager(CurrentManager.rootManager());
-   }
-   
+   /**
+    * Just return something bogus.
+    */
    public Manager getCurrentManager()
    {
       return ManagerImpl.newChildManager(CurrentManager.rootManager());

Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,29 +1,14 @@
-/**
- * 
- */
 package org.jboss.seam.bridge.stubs;
 
-import javax.el.ELResolver;
 import javax.inject.manager.Manager;
 
 import org.jboss.seam.bridge.spi.ManagerProvider;
 import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.el.WebBeansELResolver;
 
 public class ManagerProviderStub implements ManagerProvider
 {
-   public Manager getRootManager()
-   {
-      return CurrentManager.rootManager();
-   }
-   
    public Manager getCurrentManager()
    {
       return CurrentManager.rootManager().getCurrent();
    }
-   
-   public ELResolver getELResolver()
-   {
-      return new WebBeansELResolver();
-   }
 }
\ No newline at end of file


Property changes on: modules/trunk/jndi-bridge
___________________________________________________________________
Name: svn:ignore
   + .classpath
.project
.settings
target


Added: modules/trunk/jndi-bridge/pom.xml
===================================================================
--- modules/trunk/jndi-bridge/pom.xml	                        (rev 0)
+++ modules/trunk/jndi-bridge/pom.xml	2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1,51 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <artifactId>seam-parent</artifactId>
+      <groupId>org.jboss.seam</groupId>
+      <version>3.0.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>seam-jndi-bridge</artifactId>
+   <packaging>jar</packaging>
+   <version>3.0.0-SNAPSHOT</version>
+   <name>Seam Web Beans Bridge</name>
+   <description>An implementation of the Seam Bridge SPI to obtain a Manager generically via JNDI.</description>
+
+   <build>
+      <plugins>
+
+         <!--
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <suiteXmlFiles>
+                  <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+               </suiteXmlFiles>
+            </configuration>
+         </plugin>
+         -->
+
+      </plugins>
+   </build>
+
+   <dependencies>
+
+      <dependency>
+         <groupId>${seam.groupId}</groupId>
+         <artifactId>seam-bridge-api</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>jsr299-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+
+   </dependencies>
+
+</project>

Added: modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
===================================================================
--- modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java	                        (rev 0)
+++ modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1,59 @@
+package org.jboss.seam.bridge.jndi;
+
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.seam.bridge.spi.ManagerProvider;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * An implementation of Seam's Manager SPI interface for integrating Seam with
+ * a JCDI Manager that is register in JNDI. This implementation has a limitation
+ * that it cannot distinguish between the root manager and the current manager.
+ * 
+ * @author Dan Allen
+ */
+public class JndiManagerProvider implements ManagerProvider
+{
+   private static final String JCDI_MANAGER_JNDI_NAME = "java:app/Manager";
+
+   private static final String JCDI_MANAGER_ALT_JNDI_NAME = "java:comp/env/app/Manager";
+
+   private LogProvider log = Logging.getLogProvider(JndiManagerProvider.class);
+   
+   private Manager manager;
+
+   public JndiManagerProvider()
+   {
+      lookupManager();
+   }
+
+   public Manager getCurrentManager()
+   {
+      return manager;
+   }
+
+   private void lookupManager()
+   {
+      try
+      {
+         InitialContext initialContext = new InitialContext();
+         try
+         {
+            manager = (Manager) initialContext.lookup(JCDI_MANAGER_JNDI_NAME);
+         }
+         catch (NamingException e)
+         {
+            manager = (Manager) initialContext.lookup(JCDI_MANAGER_ALT_JNDI_NAME);
+         }
+      }
+      catch (NamingException e)
+      {
+         log.debug("Could not locate a Manager in JNDI");
+      }
+      
+   }
+
+}

Added: modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider
===================================================================
--- modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider	                        (rev 0)
+++ modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider	2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1 @@
+org.jboss.seam.bridge.jndi.JndiManagerProvider

Modified: modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
===================================================================
--- modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -19,15 +19,4 @@
    {
       return ActivityManager.getInstance().getCurrentActivity();
    }
-
-   public Manager getRootManager()
-   {
-      return ActivityManager.getInstance().getRootActivity();
-   }
-
-   public ELResolver getELResolver()
-   {
-      return new WebBeansELResolver();
-   }
-
 }

Modified: modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java
===================================================================
--- modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -60,7 +60,7 @@
             
             private void registerSession(HttpSession session)
             {
-               ManagerBridge.getProvider().getRootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
+               ManagerBridge.getProvider().getCurrentManager().getInstanceByType(HttpSessionManager.class).setSession(session);
                registeredSession = session;
             }
             

Modified: modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
===================================================================
--- modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,11 +1,9 @@
 package org.jboss.seam.bridge.webbeans;
 
-import javax.el.ELResolver;
 import javax.inject.manager.Manager;
 
 import org.jboss.seam.bridge.spi.ManagerProvider;
 import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.el.WebBeansELResolver;
 
 /**
  * An implementation of Seam's Manager SPI interface for integrating Seam with
@@ -19,15 +17,4 @@
    {
       return CurrentManager.rootManager().getCurrent();
    }
-
-   public Manager getRootManager()
-   {
-      return CurrentManager.rootManager();
-   }
-
-   public ELResolver getELResolver()
-   {
-      return new WebBeansELResolver();
-   }
-
 }

Modified: modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
===================================================================
--- modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java	2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java	2009-05-26 15:31:37 UTC (rev 10989)
@@ -10,7 +10,6 @@
 import org.jboss.seam.bridge.spi.ManagerProvider;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.webbeans.el.WebBeansELResolver;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
@@ -37,11 +36,9 @@
    {
       ManagerProvider provider = ManagerBridge.getProvider();
       assertTrue(provider instanceof WebBeansManagerProvider);
-      assertSame(provider.getRootManager(), getCurrentManager());
       assertSame(provider.getCurrentManager(), getCurrentManager());
       Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
       assertSame(provider.getCurrentManager(), currentManager);
-      assertTrue(provider.getELResolver() instanceof WebBeansELResolver);
    }
    
 }




More information about the seam-commits mailing list