geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1026390 - in /geronimo/server/trunk: framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ plugins...
Date Fri, 22 Oct 2010 16:05:56 GMT
Author: gawor
Date: Fri Oct 22 16:05:55 2010
New Revision: 1026390

URL: http://svn.apache.org/viewvc?rev=1026390&view=rev
Log:
GERONIMO-5659: Inject Bundle or BundleContext using @Resource annotation

Added:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
  (with props)
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml   (with
props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/
    geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/pom.xml

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.geronimo.naming.reference;
+
+import javax.naming.NamingException;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BundleContextReference extends BundleReference {
+
+    public Object getContent() throws NamingException {
+        return bundle.getBundleContext();
+    }
+    
+    @Override
+    public String getClassName() {
+        return BundleContext.class.getName();
+    }
+        
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleContextReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
Fri Oct 22 16:05:55 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.geronimo.naming.reference;
+
+import javax.naming.NamingException;
+
+import org.apache.xbean.naming.reference.SimpleReference;
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BundleReference extends SimpleReference implements BundleAwareReference {
+
+    protected transient Bundle bundle;
+
+    public Object getContent() throws NamingException {
+        return bundle;
+    }
+    
+    @Override
+    public String getClassName() {
+        return Bundle.class.getName();
+    }
+    
+    public void setBundle(Bundle bundle) {
+        this.bundle = bundle;
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/BundleReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java?rev=1026390&r1=1026389&r2=1026390&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
Fri Oct 22 16:05:55 2010
@@ -20,7 +20,9 @@ package org.apache.geronimo.connector.de
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -48,6 +50,8 @@ import org.apache.geronimo.kernel.GBeanN
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
+import org.apache.geronimo.naming.reference.BundleContextReference;
+import org.apache.geronimo.naming.reference.BundleReference;
 import org.apache.geronimo.naming.reference.GBeanReference;
 import org.apache.geronimo.naming.reference.JndiReference;
 import org.apache.geronimo.naming.reference.UserTransactionReference;
@@ -132,11 +136,14 @@ public class AdminObjectRefBuilder exten
             Set<AbstractNameQuery> query = new HashSet<AbstractNameQuery>();
             query.add(transactionManager);
             GBeanReference transactionManagerRef = new GBeanReference(module.getConfigId(),
query, TransactionManager.class);
-            put("java:comp/TransactionManager", transactionManagerRef, module.getJndiContext(),
new ArrayList<InjectionTarget>(), sharedContext);
+            put("java:comp/TransactionManager", transactionManagerRef, module.getJndiContext(),
Collections.<InjectionTarget>emptyList(), sharedContext);
             GBeanReference transactionSynchronizationRef = new GBeanReference(module.getConfigId(),
query, TransactionSynchronizationRegistry.class);
-            put("java:comp/TransactionSynchronizationRegistry", transactionSynchronizationRef,
module.getJndiContext(), new ArrayList<InjectionTarget>(), sharedContext);
+            put("java:comp/TransactionSynchronizationRegistry", transactionSynchronizationRef,
module.getJndiContext(), Collections.<InjectionTarget>emptyList(), sharedContext);
         }
         
+        put("java:comp/Bundle", new BundleReference(), module.getJndiContext(), Collections.<InjectionTarget>emptyList(),
sharedContext);
+        put("java:comp/BundleContext", new BundleContextReference(), module.getJndiContext(),
Collections.<InjectionTarget>emptyList(), sharedContext);
+        
         XmlObject[] gerResourceEnvRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
         Map<String, GerResourceEnvRefType> refMap = mapResourceEnvRefs(gerResourceEnvRefsUntyped);
         Map<String, Map<String, GerMessageDestinationType>> messageDestinations
= module.getRootEarContext().getMessageDestinations();
@@ -283,6 +290,12 @@ public class AdminObjectRefBuilder exten
         if ("javax.transaction.TransactionManager".equals(type)) {
             return new JndiReference("java:comp/TransactionManager");
         }
+        if ("org.osgi.framework.Bundle".equals(type)) {
+            return new JndiReference("java:comp/Bundle");
+        }
+        if ("org.osgi.framework.BundleContext".equals(type)) {
+            return new JndiReference("java:comp/BundleContext");
+        }
         try {
             AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
             Reference ref = buildAdminObjectReference(module, containerId);
@@ -414,6 +427,20 @@ public class AdminObjectRefBuilder exten
     public static class AdminObjectRefProcessor extends ResourceAnnotationHelper.ResourceProcessor
{
         public static final AdminObjectRefProcessor INSTANCE = new AdminObjectRefProcessor(null,
null, null);
 
+        private static final Set<String> knownResourceEnvEntries = new HashSet<String>(Arrays.asList(
+                "javax.ejb.SessionContext", 
+                "javax.ejb.MessageDrivenContext", 
+                "javax.ejb.EntityContext", 
+                "javax.ejb.TimerService", 
+                "javax.validation.Validator", 
+                "javax.validation.ValidatorFactory", 
+                "javax.transaction.UserTransaction", 
+                "javax.transaction.TransactionManager", 
+                "javax.transaction.TransactionSynchronizationRegistry",
+                "org.osgi.framework.Bundle",
+                "org.osgi.framework.BundleContext"
+        ));
+        
         private final EARContext earContext;
         private final Map<String, GerResourceEnvRefType> refMap;
         private final Map<String, Map<String, GerMessageDestinationType>> messageDestinations;
@@ -467,17 +494,7 @@ public class AdminObjectRefBuilder exten
                 if (refMap != null) {
                     resourceEnvRefType = refMap.get(jndiName);
                 }
-                if (resourceEnvRefType != null ||
-                        resourceType.equals("javax.ejb.EJBContext") ||
-                        resourceType.equals("javax.ejb.SessionContext") ||
-                        resourceType.equals("javax.ejb.MessageDrivenContext") ||
-                        resourceType.equals("javax.ejb.EntityContext") ||
-                        resourceType.equals("javax.ejb.TimerService") ||
-                        resourceType.equals("javax.validation.Validator") ||
-                        resourceType.equals("javax.validation.ValidatorFactory") ||
-                        resourceType.equals("javax.transaction.UserTransaction") ||
-                        resourceType.equals("javax.transaction.TransactionManager") ||
-                        resourceType.equals("javax.transaction.TransactionSynchronizationRegistry"))
{
+                if (resourceEnvRefType != null || knownResourceEnvEntries.contains(resourceType))
{
                     //mapped resource-env-ref
                     addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field,
annotation);
                     return true;

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java?rev=1026390&r1=1026389&r2=1026390&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/MessageDestinationTest.java
Fri Oct 22 16:05:55 2010
@@ -142,7 +142,8 @@ public class MessageDestinationTest exte
         configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.class));
         configuration.addGBean(new GBeanData(n2, AdminObjectWrapperGBean.class));
         adminObjectRefBuilder.buildNaming(specDD, plan, module, componentContext);
-        assertEquals(2, module.getJndiScope(JndiScope.comp).size());
+        assertTrue(module.getJndiScope(JndiScope.comp).containsKey("comp/env/n1"));
+        assertTrue(module.getJndiScope(JndiScope.comp).containsKey("comp/env/n2"));
     }
 
     private static final String PLAN2 = "<tmp xmlns=\"http://geronimo.apache.org/xml/ns/naming-1.2\">"
+
@@ -166,7 +167,8 @@ public class MessageDestinationTest exte
         configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.class));
         configuration.addGBean(new GBeanData(n2, AdminObjectWrapperGBean.class));
         adminObjectRefBuilder.buildNaming(specDD, plan, module, componentContext);
-        assertEquals(2, module.getJndiScope(JndiScope.comp).size());
+        assertTrue(module.getJndiScope(JndiScope.comp).containsKey("comp/env/n1"));
+        assertTrue(module.getJndiScope(JndiScope.comp).containsKey("comp/env/n2"));
     }
 
     private static final String SPECDD2 = "<web-app xmlns=\"http://java.sun.com/xml/ns/j2ee\">"
+

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml (added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml Fri Oct
22 16:05:55 2010
@@ -0,0 +1,108 @@
+<?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.
+-->
+<!-- $Rev$ $Date$ -->
+<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.geronimo.testsuite</groupId>
+        <artifactId>enterprise-testsuite</artifactId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>bundle-inject-test</artifactId>
+    <name>Geronimo TestSuite :: Enterprise Testsuite :: Bundle Inject Test</name>
+    <packaging>war</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-ejb_3.1_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>it</id>
+            <activation>
+                <property>
+                    <name>it</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <systemProperties>
+                                <property>
+                                    <name>webAppName</name>
+                                    <value>bundle-inject</value>
+                                </property>
+                                <property>
+                                    <name>symbolicName</name>
+                                    <value>${project.groupId}.${project.artifactId}</value>
+                                </property>
+                            </systemProperties>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.geronimo.buildsupport</groupId>
+                        <artifactId>geronimo-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>deploy-wars</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>deploy-module</goal>
+                                </goals>
+                                <configuration>
+                                    <moduleArchive>${project.build.directory}/${project.artifactId}-${project.version}.war</moduleArchive>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>undeploy-war-as-moduleId</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>undeploy-module</goal>
+                                </goals>
+                                <configuration>
+                                    <moduleId>${project.groupId}/${project.artifactId}/${project.version}/war</moduleId>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,47 @@
+/*
+    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.geronimo.test.bundleinject;
+
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+@Singleton
+public class TestBean {
+
+    @Resource
+    private Bundle bundle;
+
+    @Resource
+    private BundleContext bundleContext;
+
+    public String getOutput() {
+        StringBuffer buf = new StringBuffer();
+        
+        buf.append("Bundle: " + bundle.getSymbolicName());
+        buf.append(" ");
+        buf.append("BundleContext: ").append((bundleContext != null) ? "ok" : "failed");
+        
+        return buf.toString();
+    }
+ 
+}

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,91 @@
+/*
+    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.geronimo.test.bundleinject;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+public class TestServlet extends HttpServlet {
+
+    @Resource
+    private Bundle bundle;
+
+    @Resource
+    private BundleContext bundleContext;
+
+    @EJB
+    private TestBean testBean;
+
+    protected void processRequest(HttpServletRequest req, HttpServletResponse response) throws
ServletException, IOException {
+        PrintWriter out = response.getWriter();
+        try {
+            String testName = req.getParameter("testName");
+            
+            out.println("Test name:" + testName);
+            if ("servlet".equals(testName)) {
+                out.println(getOutput());
+            } else if ("ejb".equals(testName)) {
+                out.println(testBean.getOutput());      
+            } else if ("jsp".equals(testName)) {
+                getServletContext().getRequestDispatcher("/test.jsp").forward(req, response);
+            } else {
+                throw new Exception("Invalid test name: " + testName);
+            }            
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new ServletException(e);
+        }
+    } 
+
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        processRequest(request, response);
+    } 
+
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        processRequest(request, response);
+    }
+
+    @Override
+    public String getServletInfo() {
+        return "Short description";
+    }
+    
+    public String getOutput() {
+        StringBuffer buf = new StringBuffer();
+        
+        buf.append("Bundle: " + bundle.getSymbolicName());
+        buf.append(" ");
+        buf.append("BundleContext: ").append((bundleContext != null) ? "ok" : "failed");
+        
+        return buf.toString();
+    }
+
+}

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/java/org/apache/geronimo/test/bundleinject/TestServlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,28 @@
+<?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.
+-->
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
+    <dep:environment>
+        <dep:moduleId>
+            <dep:groupId>${project.groupId}</dep:groupId>
+            <dep:artifactId>${project.artifactId}</dep:artifactId>
+            <dep:version>${project.version}</dep:version>
+            <dep:type>war</dep:type>
+        </dep:moduleId>
+    </dep:environment>
+    <context-root>/bundle-inject</context-root>
+</web-app>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,37 @@
+<?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.
+-->
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+    <welcome-file-list>
+        <welcome-file>
+            index.jsp
+        </welcome-file>
+    </welcome-file-list>
+   <servlet>
+        <servlet-name>TestServlet</servlet-name>
+        <servlet-class>org.apache.geronimo.test.bundleinject.TestServlet</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>TestServlet</servlet-name>
+        <url-pattern>/TestServlet</url-pattern>
+    </servlet-mapping>
+    <session-config>
+        <session-timeout>
+            30
+        </session-timeout>
+    </session-config>
+</web-app>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,32 @@
+<%-- 
+    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.
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>OSGi Integration Tests</title>
+    </head>
+    <body>
+        <a href="TestServlet?testName=servlet">Test Servlet</a> <br/>
+        <a href="TestServlet?testName=ejb">Test EJB</a> <br/>
+        <a href="TestServlet?testName=jsp">Test JSP</a> <br/>
+    </body>
+</html>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,36 @@
+<%-- 
+    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.
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8" import="org.osgi.framework.*" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>OSGi Integration Tests</title>
+    </head>
+    <body>
+      <h2>OSGi Integration Test - JSP</h2>
+      <p>
+      <%
+          BundleContext bundleContext = (BundleContext) getServletContext().getAttribute("osgi-bundlecontext");
+          out.println("Bundle: " + bundleContext.getBundle().getSymbolicName() + " BundleContext:
ok");
+      %>
+      </p>
+    </body>
+</html>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/main/webapp/test.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java?rev=1026390&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
Fri Oct 22 16:05:55 2010
@@ -0,0 +1,55 @@
+/**
+ *  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.geronimo.test.bundleinject;
+
+import java.net.URL;
+
+import org.apache.geronimo.testsupport.HttpUtils;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.testng.annotations.Test;
+
+public class TestBundleInjection extends TestSupport {
+    
+    private String baseURL = "http://localhost:8080/";
+
+    @Test
+    public void testServletInjection() throws Exception {
+        checkReply("servlet");
+    }
+    
+    @Test
+    public void testEJBInjection() throws Exception {
+        checkReply("ejb");
+    }
+    
+    @Test
+    public void testJSPInjection() throws Exception {
+        checkReply("jsp");
+    }
+
+    private void checkReply(String testName) throws Exception {
+        String warName = System.getProperty("webAppName");
+        assertNotNull(warName);
+        URL url = new URL(baseURL + warName + "/TestServlet?testName=" + testName);
+        String reply = HttpUtils.doGET(url);
+        assertTrue("Bundle Lookup", reply.contains("Bundle: " + System.getProperty("symbolicName")
+ " BundleContext: ok"));
+    }
+
+}

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/bundle-inject-test/src/test/java/org/apache/geronimo/test/bundleinject/TestBundleInjection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/pom.xml?rev=1026390&r1=1026389&r2=1026390&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/pom.xml Fri Oct 22 16:05:55 2010
@@ -55,6 +55,7 @@
         <module>jpa-tests</module>
         <module>sec-client-tests</module>
         <module>appname-tests</module>
+        <module>bundle-inject-test</module>
     </modules>
 
 </project>



Mime
View raw message