tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r675379 - in /tuscany/java/sca: itest/validation/src/test/java/binding/ejb/ modules/core/src/main/java/org/apache/tuscany/sca/core/work/
Date Wed, 09 Jul 2008 23:15:03 GMT
Author: rfeng
Date: Wed Jul  9 16:15:02 2008
New Revision: 675379

URL: http://svn.apache.org/viewvc?rev=675379&view=rev
Log:
Defer the creation of WorkManager to avoid the JNDI lookup
Also clear the openejb related system properties to avoid warnings in JNDI lookup

Modified:
    tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBSessionTypeTestCase.java
    tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBVersionTestCase.java
    tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java

Modified: tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBSessionTypeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBSessionTypeTestCase.java?rev=675379&r1=675378&r2=675379&view=diff
==============================================================================
--- tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBSessionTypeTestCase.java
(original)
+++ tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBSessionTypeTestCase.java
Wed Jul  9 16:15:02 2008
@@ -31,33 +31,37 @@
  */
 public class UnknownEJBSessionTypeTestCase extends TestCase {
 
-	private CustomCompositeBuilder customDomain;
+    private CustomCompositeBuilder customDomain;
 
     @Override
     protected void setUp() throws Exception {
-    	System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
+        System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
         System.setProperty("java.naming.provider.url", "ejbd://localhost:8085");
-        System.setProperty("managed", "false");  
-        
+        System.setProperty("managed", "false");
+
         customDomain = CustomCompositeBuilder.getInstance();
         try {
-        	customDomain.loadContribution("src/main/resources/bindingejb/UnknownEJBSessionType/account.composite",

-        			"TestContribution", "src/main/resources/bindingejb/UnknownEJBSessionType/");
-        } catch (Exception ex){
+            customDomain.loadContribution("src/main/resources/bindingejb/UnknownEJBSessionType/account.composite",
+                                          "TestContribution",
+                                          "src/main/resources/bindingejb/UnknownEJBSessionType/");
+        } catch (Exception ex) {
             //throw ex;
         }
     }
 
     @Override
     protected void tearDown() throws Exception {
+        System.clearProperty("java.naming.factory.initial");
+        System.clearProperty("java.naming.provider.url");
+        System.clearProperty("managed");
         //node.stop();
     }
 
     public void testCalculator() {
-    	Monitor monitor = customDomain.getMonitorInstance();
-    	Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
-        
-    	assertNotNull(problem);
-        assertEquals("UnknownEJBSessionType", problem.getMessageId()); 
+        Monitor monitor = customDomain.getMonitorInstance();
+        Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+
+        assertNotNull(problem);
+        assertEquals("UnknownEJBSessionType", problem.getMessageId());
     }
 }

Modified: tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBVersionTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBVersionTestCase.java?rev=675379&r1=675378&r2=675379&view=diff
==============================================================================
--- tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBVersionTestCase.java
(original)
+++ tuscany/java/sca/itest/validation/src/test/java/binding/ejb/UnknownEJBVersionTestCase.java
Wed Jul  9 16:15:02 2008
@@ -50,6 +50,9 @@
 
     @Override
     protected void tearDown() throws Exception {
+        System.clearProperty("java.naming.factory.initial");
+        System.clearProperty("java.naming.provider.url");
+        System.clearProperty("managed");
         //node.stop();
     }
 

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java?rev=675379&r1=675378&r2=675379&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
(original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
Wed Jul  9 16:15:02 2008
@@ -56,16 +56,22 @@
      * @param jsr237WorkManager JSR 237 work manager.
      */
     public Jsr237WorkScheduler() {
-        
+    }
+
+    private synchronized WorkManager getWorkManager() {
+        if (jsr237WorkManager != null) {
+            return jsr237WorkManager;
+        }
         try {
-            InitialContext ctx  = new InitialContext();
-            jsr237WorkManager = (WorkManager) ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
+            InitialContext ctx = new InitialContext();
+            jsr237WorkManager = (WorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
         } catch (NamingException e) {
             // ignore
         }
         if (jsr237WorkManager == null) {
             jsr237WorkManager = new ThreadPoolWorkManager(10);
         }
+        return jsr237WorkManager;
     }
 
     /**
@@ -94,10 +100,10 @@
         Jsr237Work<T> jsr237Work = new Jsr237Work<T>(work);
         try {
             if (listener == null) {
-                jsr237WorkManager.schedule(jsr237Work);
+                getWorkManager().schedule(jsr237Work);
             } else {
                 Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener,
work);
-                jsr237WorkManager.schedule(jsr237Work, jsr237WorkListener);
+                getWorkManager().schedule(jsr237Work, jsr237WorkListener);
             }
         } catch (IllegalArgumentException ex) {
             if (listener != null) {



Mime
View raw message