Author: gpetracek
Date: Fri Dec 3 23:27:21 2010
New Revision: 1042050
URL: http://svn.apache.org/viewvc?rev=1042050&view=rev
Log:
OWB-501
Added:
openwebbeans/trunk/webbeans-jee5-ejb-resource/
openwebbeans/trunk/webbeans-jee5-ejb-resource/pom.xml
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/site.xml
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/java/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/java/org/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/java/org/apache/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/java/org/apache/webbeans/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/java/org/apache/webbeans/resource/
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/test/resources/
Modified:
openwebbeans/trunk/pom.xml
Modified: openwebbeans/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/pom.xml?rev=1042050&r1=1042049&r2=1042050&view=diff
==============================================================================
--- openwebbeans/trunk/pom.xml (original)
+++ openwebbeans/trunk/pom.xml Fri Dec 3 23:27:21 2010
@@ -437,6 +437,7 @@
<module>webbeans-jsf12</module>
<module>webbeans-el10</module>
<module>webbeans-resource</module>
+ <module>webbeans-jee5-ejb-resource</module>
<module>webbeans-osgi</module>
<module>webbeans-porting</module>
<module>webbeans-test</module>
Added: openwebbeans/trunk/webbeans-jee5-ejb-resource/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/pom.xml?rev=1042050&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-jee5-ejb-resource/pom.xml (added)
+++ openwebbeans/trunk/webbeans-jee5-ejb-resource/pom.xml Fri Dec 3 23:27:21
2010
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<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>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openwebbeans-jee5-ejb-resource</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+ <name>EE Resource plugin</name>
+ <description>Apache OpenWebBeans EE 5 Resource Integration</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-resource</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.0_spec</artifactId>
+ <version>${geronimo_ejb.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-spi</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Added:
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java?rev=1042050&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
(added)
+++
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
Fri Dec 3 23:27:21 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.resource.spi.ee;
+
+import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.resource.spi.se.StandaloneResourceInjectionService;
+import org.apache.webbeans.spi.api.ResourceReference;
+
+import javax.ejb.EJB;
+import javax.enterprise.inject.spi.Bean;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+
+/**
+ * Allows to use @EJB in JEE 5 app servers
+ */
+public class ExtendedStandaloneResourceInjectionService extends
StandaloneResourceInjectionService
+{
+ @Override
+ public <X, T extends Annotation> X
getResourceReference(ResourceReference<X, T> resourceReference)
+ {
+ if (resourceReference.supports(EJB.class))
+ {
+ String jndiName =
convertToJndiName(resourceReference.getResourceType());
+ X result = lookupRemoteEjb(jndiName,
resourceReference.getResourceType());
+
+ return result;
+ }
+
+ return super.getResourceReference(resourceReference);
+ }
+
+ private String convertToJndiName(Class resourceType)
+ {
+ return resourceType.getSimpleName() + "#" + resourceType.getName();
+ }
+
+ private <X> X lookupRemoteEjb(String jndiName, Class<X> resourceType)
+ {
+ try
+ {
+ Context context = new InitialContext();
+ X result = (X) context.lookup(jndiName);
+ return result;
+ }
+ catch (NamingException e)
+ {
+ //fallback for a servlet container
+ BeanManagerImpl beanManager = BeanManagerImpl.getManager();
+
+ Iterator<Bean<?>> beansIterator =
beanManager.getBeans(resourceType, new DefaultLiteral()).iterator();
+
+ if (!beansIterator.hasNext())
+ {
+ e.printStackTrace();
+ throw new RuntimeException("can't find ejb (via jndi) or cdi
bean for type "
+ + resourceType.getName(), e);
+ }
+ Bean<?> simulatedStatelessEjbBean = beansIterator.next();
+
+ return (X)beanManager.getReference(simulatedStatelessEjbBean,
+ resourceType,
+
beanManager.createCreationalContext(simulatedStatelessEjbBean));
+ }
+ }
+}
Added:
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1042050&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(added)
+++
openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Fri Dec 3 23:27:21 2010
@@ -0,0 +1,20 @@
+#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.
+
+configuration.ordinal=12
+
+org.apache.webbeans.spi.ResourceInjectionService=org.apache.webbeans.resource.spi.ee.ExtendedStandaloneResourceInjectionService
\ No newline at end of file
Added: openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/site.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/site.xml?rev=1042050&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/site.xml (added)
+++ openwebbeans/trunk/webbeans-jee5-ejb-resource/src/site/site.xml Fri Dec 3
23:27:21 2010
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<project name="OpenWebBeans">
+ <bannerLeft>
+ <name>Apache OpenWebBeans</name>
+
<src>http://openwebbeans.apache.org/1.0.0-SNAPSHOT/images/openwebbeans.png</src>
+ <href>http://openwebbeans.apache.org</href>
+ </bannerLeft>
+
+ <bannerRight>
+ <name>Apache Banner</name>
+ <src>http://www.apache.org/images/asf-logo.gif</src>
+ <href>http://www.apache.org</href>
+ </bannerRight>
+
+ <publishDate format="dd MMM yyyy" />
+ <version position="left"/>
+
+ <body>
+ <breadcrumbs>
+ <item name="Apache" href="http://www.apache.org"/>
+ <item name="OpenWebBeans" href="http://openwebbeans.apache.org"/>
+ <item name="OWB-Resource"
href="http://openwebbeans.apache.org/${project.version}/webbeans-jee5-ejb-resource"/>
+ </breadcrumbs>
+
+ <menu ref="reports"/>
+ </body>
+</project>
+