openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r934402 - in /openwebbeans/trunk/webbeans-openejb: ./ src/main/java/org/apache/webbeans/ejb/ src/main/java/org/apache/webbeans/ejb/service/
Date Thu, 15 Apr 2010 13:48:26 GMT
Author: gerdogdu
Date: Thu Apr 15 13:48:25 2010
New Revision: 934402

URL: http://svn.apache.org/viewvc?rev=934402&view=rev
Log:
ejb integration update

Added:
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java
  (with props)
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-openejb/pom.xml
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java

Modified: openwebbeans/trunk/webbeans-openejb/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/pom.xml?rev=934402&r1=934401&r2=934402&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/pom.xml (original)
+++ openwebbeans/trunk/webbeans-openejb/pom.xml Thu Apr 15 13:48:25 2010
@@ -80,6 +80,11 @@
 			<artifactId>openwebbeans-ejb-common</artifactId>
 			<version>${project.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-ee</artifactId>
+			<version>${project.version}</version>
+		</dependency>
 		
 	</dependencies>
 </project>

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java?rev=934402&r1=934401&r2=934402&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
(original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
Thu Apr 15 13:48:25 2010
@@ -30,9 +30,13 @@ import org.apache.openejb.spi.ContainerS
 import org.apache.webbeans.ejb.common.util.EjbDefinitionUtility;
 import org.apache.webbeans.ejb.common.util.EjbUtility;
 import org.apache.webbeans.ejb.component.OpenEjbBean;
+import org.apache.webbeans.ejb.service.OpenEJBSecurityService;
+import org.apache.webbeans.ejb.service.OpenEJBTransactionService;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.plugins.OpenWebBeansEjbPlugin;
+import org.apache.webbeans.spi.SecurityService;
+import org.apache.webbeans.spi.TransactionService;
 
 /**
  * EJB related stuff.
@@ -51,6 +55,10 @@ public class EjbPlugin extends AbstractO
     private Map<Class<?>,DeploymentInfo> statefullBeans = new ConcurrentHashMap<Class<?>,
DeploymentInfo>();
     
     private Map<Class<?>,DeploymentInfo> singletonBeans = new ConcurrentHashMap<Class<?>,
DeploymentInfo>();
+    
+    private static final TransactionService TRANSACTION_SERVICE = new OpenEJBTransactionService();
+    
+    private static final SecurityService SECURITY_SERVICE = new OpenEJBSecurityService();
 
     public EjbPlugin()
     {
@@ -175,5 +183,33 @@ public class EjbPlugin extends AbstractO
     {
         return EjbDefinitionUtility.defineEjbBeanProxy((OpenEjbBean<?>)bean,iface,
creationalContext);
     }
+    
+    
+    @Override    
+    public <T> T getSupportedService(Class<T> serviceClass)
+    {
+        if(serviceClass == TransactionService.class)
+        {
+            return serviceClass.cast(TRANSACTION_SERVICE);    
+        }
+        else if(serviceClass == SecurityService.class)
+        {
+            return serviceClass.cast(SECURITY_SERVICE);
+        }
+        
+        return null;
+    }
+
+    @Override
+    public boolean supportService(Class<?> serviceClass)
+    {
+        if((serviceClass == TransactionService.class) ||
+                serviceClass == SecurityService.class)
+        {
+            return true;
+        }
+        
+        return false;
+    }
        
 }

Added: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java?rev=934402&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java
(added)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java
Thu Apr 15 13:48:25 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.ejb.service;
+
+import java.security.Principal;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.webbeans.spi.SecurityService;
+
+public class OpenEJBSecurityService implements SecurityService
+{
+    public OpenEJBSecurityService()
+    {
+                
+    }
+
+    @Override
+    public Principal getCurrentPrincipal()
+    {
+        org.apache.openejb.spi.SecurityService<?> service = SystemInstance.get().getComponent(org.apache.openejb.spi.SecurityService.class);
+        if(service != null)
+        {
+            return service.getCallerPrincipal();
+        }
+        
+        return null; 
+    }
+    
+    
+}

Propchange: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBSecurityService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java?rev=934402&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java
(added)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java
Thu Apr 15 13:48:25 2010
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.ejb.service;
+
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.webbeans.ee.event.TransactionalEventNotifier;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.TransactionService;
+
+public class OpenEJBTransactionService implements TransactionService
+{
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(OpenEJBTransactionService.class);
+    
+    public OpenEJBTransactionService()
+    {
+        
+    }
+
+    @Override
+    public Transaction getTransaction()
+    {
+        TransactionManager manager = getTransactionManager();
+        if(manager != null)
+        {
+            try
+            {
+                return manager.getTransaction();
+            }
+            catch (SystemException e)
+            {
+                logger.error(e);
+            }
+        }        
+        
+        return null; 
+    }
+
+    @Override
+    public TransactionManager getTransactionManager()
+    {
+        return SystemInstance.get().getComponent(TransactionManager.class);
+    }
+
+    @Override
+    public UserTransaction getUserTransaction()
+    {
+        return SystemInstance.get().getComponent(UserTransaction.class);
+    }
+
+    @Override
+    public void registerTransactionSynchronization(TransactionPhase phase, ObserverMethod<?
super Object> observer, Object event) throws Exception
+    {
+        TransactionalEventNotifier.registerTransactionSynchronization(phase, observer, event);
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/service/OpenEJBTransactionService.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message