geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r933374 - in /geronimo/server/trunk: framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ plugins/j2ee/geronim...
Date Mon, 12 Apr 2010 19:24:40 GMT
Author: gawor
Date: Mon Apr 12 19:24:39 2010
New Revision: 933374

URL: http://svn.apache.org/viewvc?rev=933374&view=rev
Log:
GERONIMO-5251: Support environment entires of type Class or Enum

Added:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ClassReference.java
  (with props)
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/JndiReference.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/pom.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ClassReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ClassReference.java?rev=933374&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ClassReference.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ClassReference.java
Mon Apr 12 19:24:39 2010
@@ -0,0 +1,44 @@
+/**
+ *  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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ClassReference extends SimpleAwareReference {
+
+    private String className;
+    
+    public ClassReference(String className) {
+        this.className = className;
+    }
+
+    @Override
+    public Object getContent() throws NamingException {
+        ClassLoader loader = getClassLoader();
+        try {
+            return loader.loadClass(className);
+        } catch (ClassNotFoundException e) {
+            NamingException ex = new NamingException("Unable to load class " + className);
+            ex.initCause(e);
+            throw ex;
+        }
+    }    
+        
+}

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

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

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

Added: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/JndiReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/JndiReference.java?rev=933374&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/JndiReference.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/JndiReference.java
Mon Apr 12 19:24:39 2010
@@ -0,0 +1,39 @@
+/**
+ *  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.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JndiReference extends SimpleAwareReference {
+
+    private String jndiName;
+    
+    public JndiReference(String jndiName) {
+        this.jndiName = jndiName;
+    }
+
+    @Override
+    public Object getContent() throws NamingException {
+        InitialContext ctx = new InitialContext();
+        return ctx.lookup(jndiName);
+    }    
+        
+}

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

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

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

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java?rev=933374&r1=933373&r2=933374&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
Mon Apr 12 19:24:39 2010
@@ -179,7 +179,7 @@ public final class ResourceAnnotationHel
             return getName(annotation.name(), method, field);
         }
 
-        protected static String getResourceType(Resource annotation, Method method, Field
field) {
+        protected static Class getResourceTypeClass(Resource annotation, Method method, Field
field) {
             //------------------------------------------------------------------------------------------
             // Resource type:
             // -- When annotation is applied on a class:    Type must be provided (cannot
be inferred)
@@ -188,16 +188,20 @@ public final class ResourceAnnotationHel
             // -- When annotation is applied on a field:    Type is the field type (or as
provided on
             //                                              the annotation)
             //------------------------------------------------------------------------------------------
-            String resourceType = annotation.type().getCanonicalName();
-            if (resourceType.equals("") || resourceType.equals(Object.class.getName())) {
+            Class resourceType = annotation.type();
+            if (resourceType.equals(Object.class)) {
                 if (method != null) {
-                    resourceType = method.getParameterTypes()[0].getCanonicalName();
+                    resourceType = method.getParameterTypes()[0];
                 } else if (field != null) {
-                    resourceType = field.getType().getName();
+                    resourceType = field.getType();
                 }
             }
             return resourceType;
         }
+        
+        protected static String getResourceType(Resource annotation, Method method, Field
field) {
+            return getResourceTypeClass(annotation, method, field).getCanonicalName();
+        }
     }
 
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/pom.xml?rev=933374&r1=933373&r2=933374&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/pom.xml Mon Apr 12 19:24:39
2010
@@ -58,6 +58,14 @@
             <artifactId>geronimo-jta_1.1_spec</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?rev=933374&r1=933373&r2=933374&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
Mon Apr 12 19:24:39 2010
@@ -35,6 +35,8 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.naming.reference.ClassReference;
+import org.apache.geronimo.naming.reference.JndiReference;
 import org.apache.geronimo.naming.reference.KernelReference;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEnvEntryDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEnvEntryType;
@@ -46,6 +48,7 @@ import org.apache.geronimo.xbeans.javaee
 import org.apache.geronimo.xbeans.javaee6.XsdStringType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
+import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -95,55 +98,80 @@ public class EnvironmentEntryBuilder ext
             }
         }
 
+        Bundle bundle = module.getEarContext().getDeploymentBundle();
         List<EnvEntryType> envEntriesUntyped = convert(specDD.selectChildren(envEntryQNameSet),
JEE_CONVERTER, EnvEntryType.class, EnvEntryType.type);
         XmlObject[] gerEnvEntryUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_ENV_ENTRY_QNAME_SET);
         Map<String, String> envEntryMap = mapEnvEntries(gerEnvEntryUntyped);
         for (EnvEntryType envEntry: envEntriesUntyped) {
             String name = getStringValue(envEntry.getEnvEntryName());
             String type = getStringValue(envEntry.getEnvEntryType());
-            String text = envEntryMap.remove(name);
-            if (text == null) {
-                text = getStringValue(envEntry.getEnvEntryValue());
-            }
+            
+            Class typeClass;
             try {
-                Object value;
-                if (text == null) {
+                typeClass = bundle.loadClass(type);
+            } catch (ClassNotFoundException e) {
+                throw new DeploymentException("Could not env-entry type class " + type, e);
+            }
+            
+            Object value = null;
+            
+            String strValue = envEntryMap.remove(name);
+            if (strValue == null) {
+                strValue = getStringValue(envEntry.getEnvEntryValue());
+                if (strValue == null) {
+                    String lookupName = getStringValue(envEntry.getLookupName());
+                    if (lookupName != null) {
+                        value = new JndiReference(lookupName);
+                    }
+                }
+            }
+            
+            if (value == null) {
+                if (strValue == null) {
                     if ("org.apache.geronimo.kernel.Kernel".equals(type)) {
                         value = new KernelReference();
-                    } else {
-                        value = null;
                     }
-                } else if ("java.lang.String".equals(type)) {
-                    value = text;
-                } else if ("java.lang.Character".equals(type)) {
-                    value = text.charAt(0);
-                } else if ("java.lang.Boolean".equals(type)) {
-                    value = Boolean.valueOf(text);
-                } else if ("java.lang.Byte".equals(type)) {
-                    value = Byte.valueOf(text);
-                } else if ("java.lang.Short".equals(type)) {
-                    value = Short.valueOf(text);
-                } else if ("java.lang.Integer".equals(type)) {
-                    value = Integer.valueOf(text);
-                } else if ("java.lang.Long".equals(type)) {
-                    value = Long.valueOf(text);
-                } else if ("java.lang.Float".equals(type)) {
-                    value = Float.valueOf(text);
-                } else if ("java.lang.Double".equals(type)) {
-                    value = Double.valueOf(text);
                 } else {
-                    throw new DeploymentException("unrecognized type: " + type);
-                }
-                // perform resource injection only if there is a value specified
-                // see Java EE 5 spec, section EE.5.4.1.3
-                if (value != null) {
-                    addInjections(name, envEntry.getInjectionTargetArray(), sharedContext);
-                    put(name, value, getJndiContextMap(sharedContext));
+                    try {
+                        if (String.class.equals(typeClass)) {
+                            value = strValue;
+                        } else if (Character.class.equals(typeClass)) {
+                            value = strValue.charAt(0);
+                        } else if (Boolean.class.equals(typeClass)) {
+                            value = Boolean.valueOf(strValue);
+                        } else if (Byte.class.equals(typeClass)) {
+                            value = Byte.valueOf(strValue);
+                        } else if (Short.class.equals(typeClass)) {
+                            value = Short.valueOf(strValue);
+                        } else if (Integer.class.equals(typeClass)) {
+                            value = Integer.valueOf(strValue);
+                        } else if (Long.class.equals(typeClass)) {
+                            value = Long.valueOf(strValue);
+                        } else if (Float.class.equals(typeClass)) {
+                            value = Float.valueOf(strValue);
+                        } else if (Double.class.equals(typeClass)) {
+                            value = Double.valueOf(strValue);
+                        } else if (Class.class.equals(typeClass)) {
+                            value = new ClassReference(strValue);
+                        } else if (typeClass.isEnum()) {
+                            value = Enum.valueOf(typeClass, strValue);
+                        } else {
+                            throw new DeploymentException("Unrecognized env-entry type: "
+ type);
+                        }
+                    } catch (NumberFormatException e) {
+                        throw new DeploymentException("Invalid env-entry value for name:
" + name, e);
+                    }
                 }
-            } catch (NumberFormatException e) {
-                throw new DeploymentException("Invalid env-entry value for name: " + name,
e);
+            }
+            
+            // perform resource injection only if there is a value specified
+            // see Java EE 5 spec, section EE.5.4.1.3
+            if (value != null) {
+                addInjections(name, envEntry.getInjectionTargetArray(), sharedContext);
+                put(name, value, getJndiContextMap(sharedContext));
             }
         }
+        
         if (!envEntryMap.isEmpty()) {
             throw new DeploymentException("Unknown env-entry elements in geronimo plan: "
+ envEntryMap);
         }
@@ -177,16 +205,18 @@ public class EnvironmentEntryBuilder ext
 
         public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class
cls, Method method, Field field) {
             String resourceName = getResourceName(annotation, method, field);
-            String resourceType = getResourceType(annotation, method, field);
-            if (resourceType.equals("java.lang.String") ||
-                    resourceType.equals("java.lang.Character") ||
-                    resourceType.equals("java.lang.Integer") ||
-                    resourceType.equals("java.lang.Boolean") ||
-                    resourceType.equals("java.lang.Double") ||
-                    resourceType.equals("java.lang.Byte") ||
-                    resourceType.equals("java.lang.Short") ||
-                    resourceType.equals("java.lang.Long") ||
-                    resourceType.equals("java.lang.Float")) {
+            Class resourceType = getResourceTypeClass(annotation, method, field);
+            if (resourceType.equals(String.class) ||
+                    resourceType.equals(Character.class) ||
+                    resourceType.equals(Integer.class) ||
+                    resourceType.equals(Boolean.class) ||
+                    resourceType.equals(Double.class) ||
+                    resourceType.equals(Byte.class) ||
+                    resourceType.equals(Short.class) ||
+                    resourceType.equals(Long.class) ||
+                    resourceType.equals(Float.class) ||
+                    resourceType.equals(Class.class) ||
+                    resourceType.isEnum()) {
 
                 log.debug("addResource(): <env-entry> found");
 
@@ -220,10 +250,10 @@ public class EnvironmentEntryBuilder ext
                         JndiNameType envEntryName = envEntry.addNewEnvEntryName();
                         envEntryName.setStringValue(resourceName);
 
-                        if (!resourceType.equals("")) {
+                        if (!resourceType.equals(Object.class)) {
                             // env-entry-type
                             EnvEntryTypeValuesType envEntryType = envEntry.addNewEnvEntryType();
-                            envEntryType.setStringValue(resourceType);
+                            envEntryType.setStringValue(resourceType.getCanonicalName());
                         }                         
                         if (method != null || field != null) {
                             // injectionTarget

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java?rev=933374&r1=933373&r2=933374&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
Mon Apr 12 19:24:39 2010
@@ -17,11 +17,16 @@
 
 package org.apache.geronimo.naming.deployment;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import javax.naming.Context;
 import javax.naming.NameClassPair;
@@ -29,11 +34,24 @@ import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
 import junit.framework.TestCase;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.j2ee.deployment.ConnectorModule;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.jndi.JndiScope;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.mock.MockConfigurationManager;
+import org.apache.geronimo.kernel.osgi.MockBundleContext;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.osgi.framework.BundleContext;
 
 /**
  * @version $Rev$ $Date$
@@ -96,7 +114,20 @@ public class EnvironmentEntryBuilderTest
             "<env-entry-type>java.lang.Boolean</env-entry-type>" +
             "<env-entry-value>TRUE</env-entry-value>" +
             "</env-entry>" +
+            
+            "<env-entry>" +
+            "<env-entry-name>class</env-entry-name>" +
+            "<env-entry-type>java.lang.Class</env-entry-type>" +
+            "<env-entry-value>java.net.URI</env-entry-value>" +
+            "</env-entry>" +
+            
+            "<env-entry>" +
+            "<env-entry-name>enum</env-entry-name>" +
+            "<env-entry-type>java.util.concurrent.TimeUnit</env-entry-type>"
+
+            "<env-entry-value>NANOSECONDS</env-entry-value>" +
+            "</env-entry>" +
             "</tmp>";
+    
     private static final String TEST_PLAN = "<tmp xmlns=\"http://geronimo.apache.org/xml/ns/naming-1.2\">"
+
             "<env-entry>" +
             "<env-entry-name>string</env-entry-name>" +
@@ -142,8 +173,47 @@ public class EnvironmentEntryBuilderTest
             "<env-entry-name>boolean</env-entry-name>" +
             "<env-entry-value>FALSE</env-entry-value>" +
             "</env-entry>" +
+            
+            "<env-entry>" +
+            "<env-entry-name>class</env-entry-name>" +
+            "<env-entry-type>java.lang.Class</env-entry-type>" +
+            "<env-entry-value>java.net.URL</env-entry-value>" +
+            "</env-entry>" +
+            
+            "<env-entry>" +
+            "<env-entry-name>enum</env-entry-name>" +
+            "<env-entry-type>java.util.concurrent.TimeUnit</env-entry-type>"
+
+            "<env-entry-value>SECONDS</env-entry-value>" +
+            "</env-entry>" +
             "</tmp>";
 
+    private Module module;
+    
+    protected void setUp() throws Exception {
+        Artifact artifact = new Artifact("foo", "bar", "1.0", "car");
+        Map<String, Artifact> locations = new HashMap<String, Artifact>();
+        locations.put(null, artifact);
+        BundleContext bundleContext = new MockBundleContext(getClass().getClassLoader(),
"", null, locations);
+        Artifact id = new Artifact("test", "test", "", "car");
+        module  = new ConnectorModule(false, new AbstractName(id, Collections.singletonMap("name",
"test")), null, null, "foo", null, null, null, null);
+        ConfigurationManager configurationManager = new MockConfigurationManager();
+        EARContext earContext = new EARContext(new File("foo"),
+            null,
+            new Environment(artifact),
+            ConfigurationModuleType.EAR,
+            new Jsr77Naming(),
+            configurationManager,
+            bundleContext,
+            null,
+            null,
+            null,
+            null,
+            null);
+        earContext.initializeConfiguration();
+        module.setEarContext(earContext);
+        module.setRootEarContext(earContext);
+    }
+            
     public void testEnvEntries() throws Exception {
 
         String stringVal = "Hello World";
@@ -164,14 +234,14 @@ public class EnvironmentEntryBuilderTest
         } finally {
             cursor.dispose();
         }
-        environmentEntryBuilder.buildNaming(doc, null, null, componentContext);
-        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp),
null, null, null, "comp/");
+        environmentEntryBuilder.buildNaming(doc, null, module, componentContext);
+        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp),
null, null, getClass().getClassLoader(), "comp/");
         Set actual = new HashSet();
         for (NamingEnumeration e = context.listBindings("comp/env"); e.hasMore();) {
             NameClassPair pair = (NameClassPair) e.next();
             actual.add(pair.getName());
         }
-        Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short",
"int", "long", "float", "double", "boolean"}));
+        Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short",
"int", "long", "float", "double", "boolean", "class", "enum"}));
         assertEquals(expected, actual);
         assertEquals(stringVal, context.lookup("comp/env/string"));
         assertEquals(charVal, context.lookup("comp/env/char"));
@@ -182,6 +252,8 @@ public class EnvironmentEntryBuilderTest
         assertEquals(floatVal, context.lookup("comp/env/float"));
         assertEquals(doubleVal, context.lookup("comp/env/double"));
         assertEquals(booleanVal, context.lookup("comp/env/boolean"));
+        assertEquals(URI.class, context.lookup("comp/env/class"));
+        assertEquals(TimeUnit.NANOSECONDS, context.lookup("comp/env/enum"));
     }
 
     public void testEnvEntriesOverride() throws Exception {
@@ -212,14 +284,14 @@ public class EnvironmentEntryBuilderTest
         } finally {
             cursor.dispose();
         }
-        environmentEntryBuilder.buildNaming(doc, plan, null, componentContext);
-        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp),
null, null, null, "comp/");
+        environmentEntryBuilder.buildNaming(doc, plan, module, componentContext);
+        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp),
null, null, getClass().getClassLoader(), "comp/");
         Set actual = new HashSet();
         for (NamingEnumeration e = context.listBindings("comp/env"); e.hasMore();) {
             NameClassPair pair = (NameClassPair) e.next();
             actual.add(pair.getName());
         }
-        Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short",
"int", "long", "float", "double", "boolean"}));
+        Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short",
"int", "long", "float", "double", "boolean", "class", "enum"}));
         assertEquals(expected, actual);
         assertEquals(stringVal, context.lookup("comp/env/string"));
         assertEquals(charVal, context.lookup("comp/env/char"));
@@ -230,6 +302,8 @@ public class EnvironmentEntryBuilderTest
         assertEquals(floatVal, context.lookup("comp/env/float"));
         assertEquals(doubleVal, context.lookup("comp/env/double"));
         assertEquals(booleanVal, context.lookup("comp/env/boolean"));
+        assertEquals(URL.class, context.lookup("comp/env/class"));
+        assertEquals(TimeUnit.SECONDS, context.lookup("comp/env/enum"));
     }
 
     public void testEmptyEnvironment() throws NamingException {
@@ -237,5 +311,4 @@ public class EnvironmentEntryBuilderTest
         Context env = (Context) context.lookup("comp/env");
         assertNotNull(env);
     }
-
 }



Mime
View raw message