geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r945817 - in /geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment: AdminObjectRefBuilder.java ResourceRefBuilder.java
Date Tue, 18 May 2010 18:49:58 GMT
Author: djencks
Date: Tue May 18 18:49:57 2010
New Revision: 945817

URL: http://svn.apache.org/viewvc?rev=945817&view=rev
Log:
GERONIMO-5221 Link up jndi entries for Validator and ValidatorFactory to the ones at java:comp/Validator(Factory)

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/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java

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=945817&r1=945816&r2=945817&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
Tue May 18 18:49:57 2010
@@ -28,6 +28,8 @@ import javax.annotation.Resource;
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
 
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.DeploymentException;
@@ -68,6 +70,7 @@ import org.osgi.framework.Bundle;
 /**
  * @version $Rev$ $Date$
  */
+@GBean(j2eeType = NameFactory.MODULE_BUILDER)
 public class AdminObjectRefBuilder extends AbstractNamingBuilder {
     private static final Logger log = LoggerFactory.getLogger(AdminObjectRefBuilder.class);
     private final QNameSet adminOjbectRefQNameSet;
@@ -79,7 +82,9 @@ public class AdminObjectRefBuilder exten
     private static final QName GER_MESSAGE_DESTINATION_QNAME = GerMessageDestinationDocument.type.getDocumentElementName();
     private static final QNameSet GER_MESSAGE_DESTINATION_QNAME_SET = QNameSet.singleton(GER_MESSAGE_DESTINATION_QNAME);
 
-    public AdminObjectRefBuilder(Environment defaultEnvironment, String[] eeNamespaces) {
+    public AdminObjectRefBuilder(
+            @ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
+            @ParamAttribute(name = "eeNamespaces") String[] eeNamespaces) {
         super(defaultEnvironment);
         adminOjbectRefQNameSet = buildQNameSet(eeNamespaces, "resource-env-ref");
         messageDestinationQNameSet = buildQNameSet(eeNamespaces, "message-destination");
@@ -117,7 +122,7 @@ public class AdminObjectRefBuilder exten
         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();
-        
+
         // Discover and process any @Resource annotations (if !metadata-complete)
         if (module.getClassFinder() != null) {
 
@@ -130,8 +135,8 @@ public class AdminObjectRefBuilder exten
             }
         }
 
-        List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet),
JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);        
-        List<String> unresolvedRefs = new ArrayList<String>();  
+        List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet),
JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
+        List<String> unresolvedRefs = new ArrayList<String>();
         for (ResourceEnvRefType resourceEnvRef : resourceEnvRefsUntyped) {
             String name = getStringValue(resourceEnvRef.getResourceEnvRefName());
             if (lookupJndiContextMap(componentContext, name) != null) {
@@ -140,16 +145,16 @@ public class AdminObjectRefBuilder exten
             }
             String refType = getStringValue(resourceEnvRef.getResourceEnvRefType());
             if (refType.equals("javax.ejb.TimerService") ||
-                refType.equals("javax.ejb.EntityContext") ||
-                refType.equals("javax.ejb.MessageDrivenContext") ||
-                refType.equals("javax.ejb.SessionContext") ||
-                refType.equals("javax.xml.ws.WebServiceContext")) {
+                    refType.equals("javax.ejb.EntityContext") ||
+                    refType.equals("javax.ejb.MessageDrivenContext") ||
+                    refType.equals("javax.ejb.SessionContext") ||
+                    refType.equals("javax.xml.ws.WebServiceContext")) {
                 continue;
             }
             addInjections(name, resourceEnvRef.getInjectionTargetArray(), componentContext);
             String type = getStringValue(resourceEnvRef.getResourceEnvRefType());
             GerResourceEnvRefType gerResourceEnvRef = refMap.remove(name);
-            
+
             Object value = null;
             if (gerResourceEnvRef == null) {
                 String lookupName = getStringValue(resourceEnvRef.getLookupName());
@@ -160,22 +165,22 @@ public class AdminObjectRefBuilder exten
                     value = new JndiReference(lookupName);
                 }
             }
-            
+
             if (value == null) {
                 value = buildResourceReference(module, name, type, gerResourceEnvRef);
             }
-            
+
             if (value == null) {
                 unresolvedRefs.add(name);
             } else {
                 put(name, value, getJndiContextMap(componentContext));
-            }            
+            }
         }
-        
+
         if (unresolvedRefs.size() > 0) {
             log.warn("Failed to build reference to resource env reference " + unresolvedRefs
+ " defined in plan file. The corresponding entry in Geronimo deployment descriptor is missing.");
         }
-        
+
         //message-destination-refs
         List<MessageDestinationRefType> messageDestinationRefsUntyped = convert(specDD.selectChildren(messageDestinationRefQNameSet),
JEE_CONVERTER, MessageDestinationRefType.class, MessageDestinationRefType.type);
 
@@ -205,7 +210,7 @@ public class AdminObjectRefBuilder exten
             }
 
             GerMessageDestinationType destination = getMessageDestination(linkName, messageDestinations);
-            
+
             Object value = null;
             if (destination == null) {
                 String lookupName = getStringValue(messageDestinationRef.getLookupName());
@@ -216,11 +221,11 @@ public class AdminObjectRefBuilder exten
                     value = new JndiReference(lookupName);
                 }
             }
-            
+
             if (value == null) {
                 value = buildMessageReference(module, linkName, type, destination);
             }
-            
+
             if (value != null) {
                 put(name, value, getJndiContextMap(componentContext));
             }
@@ -228,43 +233,48 @@ public class AdminObjectRefBuilder exten
 
     }
 
-    private Object buildResourceReference(Module module, String name, String type, GerResourceEnvRefType
gerResourceEnvRef) 
-        throws DeploymentException {
+    private Object buildResourceReference(Module module, String name, String type, GerResourceEnvRefType
gerResourceEnvRef)
+            throws DeploymentException {
         Bundle bundle = module.getEarContext().getDeploymentBundle();
-    
+
         Class iface;
         try {
             iface = bundle.loadClass(type);
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Could not load resource-env-ref entry class "
+ type, e);
         }
-    
+
         if (type.equals("javax.transaction.UserTransaction")) {
             return new UserTransactionReference();
-        } else {
-            try {
-                AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
-                ResourceReferenceFactory<RuntimeException> ref = buildAdminObjectReference(module,
containerId, iface);
-                return ref;
-            } catch (UnresolvedReferenceException e) {
-                throw new DeploymentException("Unable to resolve resource env reference '"
+ name + "' (" + (e.isMultiple() ? "found multiple matching resources" : "no matching resources
found") + ")", e);
-            }
-        } 
-    }
-    
-    private Object buildMessageReference(Module module, String linkName, String type, GerMessageDestinationType
destination) 
-        throws DeploymentException {
+        }
+        if ("javax.validation.Validator".equals(type)) {
+            return new JndiReference("java:comp/Validator");
+        }
+        if ("javax.validation.ValidatorFactory".equals(type)) {
+            return new JndiReference("java:comp/ValidatorFactory");
+        }
+        try {
+            AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
+            ResourceReferenceFactory<RuntimeException> ref = buildAdminObjectReference(module,
containerId, iface);
+            return ref;
+        } catch (UnresolvedReferenceException e) {
+            throw new DeploymentException("Unable to resolve resource env reference '" +
name + "' (" + (e.isMultiple() ? "found multiple matching resources" : "no matching resources
found") + ")", e);
+        }
+    }
+
+    private Object buildMessageReference(Module module, String linkName, String type, GerMessageDestinationType
destination)
+            throws DeploymentException {
         Bundle bundle = module.getEarContext().getDeploymentBundle();
-        
+
         Class iface;
         try {
             iface = bundle.loadClass(type);
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Could not load message-destination-ref entry type
class " + type, e);
         }
-        
+
         String moduleURI = null;
-        
+
         if (destination != null) {
             if (destination.isSetAdminObjectLink()) {
                 if (destination.isSetAdminObjectModule()) {
@@ -288,7 +298,7 @@ public class AdminObjectRefBuilder exten
         ResourceReferenceFactory<RuntimeException> ref = buildAdminObjectReference(module,
containerId, iface);
         return ref;
     }
-    
+
     public static GerMessageDestinationType getMessageDestination(String messageDestinationLink,
Map<String, Map<String, GerMessageDestinationType>> messageDestinations) throws
DeploymentException {
         GerMessageDestinationType destination = null;
         int pos = messageDestinationLink.indexOf('#');
@@ -393,10 +403,6 @@ public class AdminObjectRefBuilder exten
             if (resourceType.equals("javax.ejb.EntityContext")) return true;
             if (resourceType.equals("javax.ejb.TimerService")) return true;
 
-            //validator special cases
-            if (resourceType.equals("javax.validation.Validator")) return true;
-            if (resourceType.equals("javax.validation.ValidatorFactory")) return true;
-
             //If it already exists in xml as a message-destination-ref or resource-env-ref,
we are done.
             MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
             for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs)
{
@@ -437,7 +443,10 @@ public class AdminObjectRefBuilder exten
                 if (refMap != null) {
                     resourceEnvRefType = refMap.get(resourceName);
                 }
-                if (resourceEnvRefType != null || resourceType.equals("javax.transaction.UserTransaction"))
{
+                if (resourceEnvRefType != null ||
+                        resourceType.equals("javax.validation.Validator") ||
+                        resourceType.equals("javax.validation.ValidatorFactory") ||
+                        resourceType.equals("javax.transaction.UserTransaction")) {
                     //mapped resource-env-ref
                     addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field,
annotation);
                     return true;
@@ -453,7 +462,7 @@ public class AdminObjectRefBuilder exten
                             return false;
                         }
                     } else {
-                        if (!("javax.jms.Queue".equals(resourceType) || "javax.jms.Topic".equals(resourceType)

+                        if (!("javax.jms.Queue".equals(resourceType) || "javax.jms.Topic".equals(resourceType)
                                 || "javax.jms.Destination".equals(resourceType))) {
                             // not identifiable as an admin object ref
                             return false;
@@ -506,7 +515,7 @@ public class AdminObjectRefBuilder exten
                 XsdStringType mappedName = resourceEnvRef.addNewMappedName();
                 mappedName.setStringValue(mappdedNameAnnotation);
             }
-            
+
             // lookup
             String lookup = annotation.lookup();
             if (!lookup.equals("")) {
@@ -555,7 +564,7 @@ public class AdminObjectRefBuilder exten
                 XsdStringType mappedName = messageDestinationRef.addNewMappedName();
                 mappedName.setStringValue(mappdedNameAnnotation);
             }
-            
+
             // lookup
             String lookup = annotation.lookup();
             if (!lookup.equals("")) {
@@ -565,21 +574,4 @@ public class AdminObjectRefBuilder exten
         }
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AdminObjectRefBuilder.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
-        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
-
-        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces"});
-
-        GBEAN_INFO = infoBuilder.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo
-            () {
-        return GBEAN_INFO;
-    }
-
 }

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.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/ResourceRefBuilder.java?rev=945817&r1=945816&r2=945817&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
Tue May 18 18:49:57 2010
@@ -34,6 +34,10 @@ import javax.annotation.Resource;
 import javax.resource.ResourceException;
 import javax.xml.namespace.QName;
 
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.DeploymentException;
@@ -78,6 +82,7 @@ import org.osgi.framework.Bundle;
 /**
  * @version $Rev$ $Date$
  */
+@GBean(j2eeType = NameFactory.MODULE_BUILDER)
 public class ResourceRefBuilder extends AbstractNamingBuilder implements ResourceEnvironmentSetter
{
 
     private static final Logger log = LoggerFactory.getLogger(ResourceRefBuilder.class);
@@ -89,21 +94,25 @@ public class ResourceRefBuilder extends 
 
     private final QNameSet resourceRefQNameSet;
     private final Environment corbaEnvironment;
-    private final SingleElementCollection corbaGBeanNameSourceCollection;
+    private final SingleElementCollection<CorbaGBeanNameSource> corbaGBeanNameSourceCollection;
 
-    public ResourceRefBuilder(Environment defaultEnvironment, Environment corbaEnvironment,
String[] eeNamespaces, Collection corbaGBeanNameSourceCollection) {
+    public ResourceRefBuilder(
+            @ParamAttribute(name = "defaultEnvironment")Environment defaultEnvironment,
+            @ParamAttribute(name = "corbaEnvironment")Environment corbaEnvironment,
+            @ParamAttribute(name = "eeNamespaces")String[] eeNamespaces,
+            @ParamReference(name = "CorbaGBeanNameSource")Collection<CorbaGBeanNameSource>
corbaGBeanNameSourceCollection) {
         super(defaultEnvironment);
 
         resourceRefQNameSet = buildQNameSet(eeNamespaces, "resource-ref");
         this.corbaEnvironment = corbaEnvironment;
-        this.corbaGBeanNameSourceCollection = new SingleElementCollection(corbaGBeanNameSourceCollection);
+        this.corbaGBeanNameSourceCollection = new SingleElementCollection<CorbaGBeanNameSource>(corbaGBeanNameSourceCollection);
     }
 
     protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) {
         return specDD.selectChildren(resourceRefQNameSet).length > 0;
     }
 
-    public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext)
throws DeploymentException {
+    public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map<EARContext.Key,
Object> componentContext) throws DeploymentException {
 
         // Discover and process any @Resource annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
@@ -120,18 +129,18 @@ public class ResourceRefBuilder extends 
         List<ResourceRefType> resourceRefsUntyped = convert(specDD.selectChildren(resourceRefQNameSet),
J2EE_CONVERTER, ResourceRefType.class, ResourceRefType.type);
         XmlObject[] gerResourceRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_RESOURCE_REF_QNAME_SET);
         Map<String, GerResourceRefType> refMap = mapResourceRefs(gerResourceRefsUntyped);
-        List<String> unresolvedRefs = new ArrayList<String>();        
+        List<String> unresolvedRefs = new ArrayList<String>();
         for (ResourceRefType resourceRef : resourceRefsUntyped) {
-            String name = getStringValue(resourceRef.getResRefName());            
+            String name = getStringValue(resourceRef.getResRefName());
             if (lookupJndiContextMap(componentContext, name) != null) {
                 // some other builder handled this entry already
                 continue;
-            }            
+            }
             addInjections(name, resourceRef.getInjectionTargetArray(), componentContext);
             String type = getStringValue(resourceRef.getResType());
             GerResourceRefType gerResourceRef = refMap.get(name);
             log.debug("trying to resolve " + name + ", type " + type + ", resourceRef " +
gerResourceRef);
-            
+
             Object value = null;
             if (gerResourceRef == null) {
                 String lookupName = getStringValue(resourceRef.getLookupName());
@@ -142,17 +151,17 @@ public class ResourceRefBuilder extends 
                     value = new JndiReference(lookupName);
                 }
             }
-            
+
             if (value == null) {
                 value = buildReference(module, name, type, gerResourceRef);
             }
-            
+
             if (value == null) {
                 unresolvedRefs.add(name);
             } else {
                 put(name, value, getJndiContextMap(componentContext));
             }
-            
+
         }
 
         if (unresolvedRefs.size() > 0) {
@@ -160,17 +169,16 @@ public class ResourceRefBuilder extends 
         }
     }
 
-    private Object buildReference(Module module, String name, String type, GerResourceRefType
gerResourceRef) 
-        throws DeploymentException {
+    private Object buildReference(Module module, String name, String type, GerResourceRefType
gerResourceRef) throws DeploymentException {
         Bundle bundle = module.getEarContext().getDeploymentBundle();
-        
+
         Class iface;
         try {
             iface = bundle.loadClass(type);
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Could not resource-ref entry class " + type, e);
         }
-        
+
         if (iface == URL.class) {
             if (gerResourceRef == null || !gerResourceRef.isSetUrl()) {
                 throw new DeploymentException("No url supplied to resolve: " + name);
@@ -185,7 +193,7 @@ public class ResourceRefBuilder extends 
             }
             return new URLReference(url);
         } else if (ORB.class.isAssignableFrom(iface)) {
-            CorbaGBeanNameSource corbaGBeanNameSource = (CorbaGBeanNameSource) corbaGBeanNameSourceCollection.getElement();
+            CorbaGBeanNameSource corbaGBeanNameSource = corbaGBeanNameSourceCollection.getElement();
             if (corbaGBeanNameSource == null) {
                 throw new DeploymentException("No orb setup but there is a orb reference");
             }
@@ -240,15 +248,15 @@ public class ResourceRefBuilder extends 
                 throw new DeploymentException(errorMessage.toString());
             }
         }
-        
+
         return null;
     }
-    
+
     public void setResourceEnvironment(ResourceEnvironmentBuilder builder, XmlObject[] resourceRefs,
GerResourceRefType[] gerResourceRefs) throws DeploymentException {
         List<ResourceRefType> resourceRefList = convert(resourceRefs, J2EE_CONVERTER,
ResourceRefType.class, ResourceRefType.type);
         Map refMap = mapResourceRefs(gerResourceRefs);
-        Set unshareableResources = new HashSet();
-        Set applicationManagedSecurityResources = new HashSet();
+        Set<AbstractNameQuery> unshareableResources = new HashSet<AbstractNameQuery>();
+        Set<AbstractNameQuery> applicationManagedSecurityResources = new HashSet<AbstractNameQuery>();
         for (ResourceRefType resourceRefType : resourceRefList) {
 
             String type = resourceRefType.getResType().getStringValue().trim();
@@ -284,6 +292,9 @@ public class ResourceRefBuilder extends 
     }
 
     private AbstractNameQuery getResourceContainerId(String name, String type, URI moduleURI,
GerResourceRefType gerResourceRef) {
+        if (name.startsWith("java:")) {
+            name = name.substring(name.indexOf("/env/") + 5);
+        }
         AbstractNameQuery containerId;
         String module = moduleURI == null ? null : moduleURI.toString();
         if (gerResourceRef == null) {
@@ -423,22 +434,4 @@ public class ResourceRefBuilder extends 
         }
     }
 
-
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ResourceRefBuilder.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
-        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
-        infoBuilder.addAttribute("corbaEnvironment", Environment.class, true, true);
-        infoBuilder.addReference("CorbaGBeanNameSource", CorbaGBeanNameSource.class);
-
-        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "corbaEnvironment",
"eeNamespaces", "CorbaGBeanNameSource"});
-
-        GBEAN_INFO = infoBuilder.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }



Mime
View raw message