geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r442387 [4/5] - in /geronimo/server/trunk: configs/axis-deployer/src/plan/ configs/client-deployer/src/plan/ configs/j2ee-deployer/src/plan/ configs/jetty-deployer/src/plan/ configs/openejb-deployer/src/plan/ configs/tomcat-deployer/src/pla...
Date Mon, 11 Sep 2006 23:51:36 GMT
Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?view=diff&rev=442387&r1=442386&r2=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java Mon Sep 11 16:51:32 2006
@@ -17,60 +17,22 @@
 
 package org.apache.geronimo.naming.deployment;
 
-import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.transaction.UserTransaction;
-import javax.xml.namespace.QName;
+
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.j2ee.deployment.EARContext;
-import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.RefContext;
-import org.apache.geronimo.j2ee.deployment.ServiceReferenceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.ClassLoading;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.naming.java.ComponentContextBuilder;
-import org.apache.geronimo.naming.reference.GBeanReference;
-import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanLocatorType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
-import org.apache.geronimo.xbeans.j2ee.EjbLocalRefType;
-import org.apache.geronimo.xbeans.j2ee.EjbRefType;
-import org.apache.geronimo.xbeans.j2ee.EnvEntryType;
-import org.apache.geronimo.xbeans.j2ee.MessageDestinationRefType;
-import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
-import org.apache.geronimo.xbeans.j2ee.ParamValueType;
-import org.apache.geronimo.xbeans.j2ee.PortComponentRefType;
-import org.apache.geronimo.xbeans.j2ee.ResourceEnvRefType;
 import org.apache.geronimo.xbeans.j2ee.ResourceRefType;
-import org.apache.geronimo.xbeans.j2ee.ServiceRefHandlerType;
-import org.apache.geronimo.xbeans.j2ee.ServiceRefType;
-import org.apache.geronimo.xbeans.j2ee.XsdQNameType;
-import org.apache.geronimo.xbeans.j2ee.XsdStringType;
 
 /**
  * @version $Rev:385232 $ $Date$
@@ -79,27 +41,6 @@
 
     private static final String JAXR_CONNECTION_FACTORY_CLASS = "javax.xml.registry.ConnectionFactory";
 
-    public static void registerMessageDestinations(RefContext refContext, String moduleName, MessageDestinationType[] specDestinations, GerMessageDestinationType[] destinations) throws DeploymentException {
-        Map nameMap = new HashMap();
-        for (int i = 0; i < destinations.length; i++) {
-            GerMessageDestinationType destination = destinations[i];
-            String name = destination.getMessageDestinationName().trim();
-            nameMap.put(name, destination);
-            boolean found = false;
-            for (int j = 0; j < specDestinations.length; j++) {
-                MessageDestinationType specDestination = specDestinations[j];
-                if (specDestination.getMessageDestinationName().getStringValue().trim().equals(name)) {
-                    found = true;
-                    break;
-                }
-            }
-            if (!found) {
-                throw new DeploymentException("No spec DD message-destination for " + name);
-            }
-        }
-        refContext.registerMessageDestionations(moduleName, nameMap);
-    }
-
 
     public static AbstractNameQuery getGBeanQuery(String j2eeType, GerGbeanLocatorType gerGbeanLocator) {
         AbstractNameQuery abstractNameQuery;
@@ -117,100 +58,6 @@
         return abstractNameQuery;
     }
 
-
-    static void addEnvEntries(EnvEntryType[] envEntries, ComponentContextBuilder builder, ClassLoader classLoader) throws DeploymentException {
-        for (int i = 0; i < envEntries.length; i++) {
-            EnvEntryType envEntry = envEntries[i];
-            String name = getStringValue(envEntry.getEnvEntryName());
-            String type = getStringValue(envEntry.getEnvEntryType());
-            String text = getStringValue(envEntry.getEnvEntryValue());
-            try {
-                builder.addEnvEntry(name, type, text, classLoader);
-            } catch (NumberFormatException e) {
-                throw new DeploymentException("Invalid env-entry value for name: " + name, e);
-            } catch (NamingException e) {
-                throw new DeploymentException("Invalid env-entry definition for name: " + name, e);
-            }
-        }
-
-    }
-
-    static void addResourceRefs(Configuration earContext, RefContext refContext, ResourceRefType[] resourceRefs, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        if (refMap == null) {
-            refMap = Collections.EMPTY_MAP;
-        }
-        Map newMap = new HashMap();
-        for (Iterator it = refMap.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            newMap.put(name.trim(), refMap.get(name));
-        }
-        refMap = newMap;
-
-        for (int i = 0; i < resourceRefs.length; i++) {
-            ResourceRefType resourceRef = resourceRefs[i];
-            String name = getStringValue(resourceRef.getResRefName());
-            String type = getStringValue(resourceRef.getResType());
-            GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(name);
-            Class iface;
-            try {
-                iface = cl.loadClass(type);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("could not load class " + type, e);
-            }
-            Reference ref;
-            if (iface == URL.class) {
-                if (gerResourceRef == null || !gerResourceRef.isSetUrl()) {
-                    throw new DeploymentException("No url supplied to resolve: " + name);
-                }
-                try {
-                    //TODO expose jsr-77 objects for these guys
-                    builder.bind(name, new URL(gerResourceRef.getUrl()));
-                } catch (MalformedURLException e) {
-                    throw new DeploymentException("Could not convert " + gerResourceRef.getUrl() + " to URL", e);
-                }
-            } else {
-                //determine jsr-77 type from interface
-                String j2eeType;
-
-
-                if ("javax.mail.Session".equals(type)) {
-                    j2eeType = NameFactory.JAVA_MAIL_RESOURCE;
-                } else if (JAXR_CONNECTION_FACTORY_CLASS.equals(type)) {
-                    j2eeType = NameFactory.JAXR_CONNECTION_FACTORY;
-                } else {
-                    j2eeType = NameFactory.JCA_MANAGED_CONNECTION_FACTORY;
-                }
-                try {
-                    AbstractNameQuery containerId = getResourceContainerId(name, j2eeType, null, gerResourceRef);
-
-                    ref = refContext.getConnectionFactoryRef(containerId, iface, earContext);
-                    builder.bind(name, ref);
-                } catch (UnresolvedReferenceException e) {
-
-                    StringBuffer errorMessage = new StringBuffer("Unable to resolve resource reference '");
-                    errorMessage.append(name);
-                    errorMessage.append("' (");
-                    if (e.isMultiple()) {
-                        errorMessage.append("Found multiple matching resources.  Try being more specific in a resource-ref mapping in your Geronimo deployment plan.");
-                    } else if (gerResourceRef == null){
-                        errorMessage.append("Could not auto-map to resource.  Try adding a resource-ref mapping to your Geronimo deployment plan.");
-                    } else if (gerResourceRef.isSetResourceLink()){
-                        errorMessage.append("Could not find resource '");
-                        errorMessage.append(gerResourceRef.getResourceLink());
-                        errorMessage.append("'.  Perhaps it has not yet been configured, or your application does not have a dependency declared for that resource module?");
-                    } else {
-                        errorMessage.append("Could not find the resource specified in your Geronimo deployment plan:");
-                        errorMessage.append(gerResourceRef.getPattern());
-                    }
-                    errorMessage.append(")");
-
-                    throw new DeploymentException(errorMessage.toString());
-                }
-            }
-        }
-
-    }
-
     private static AbstractNameQuery getResourceContainerId(String name, String type, URI moduleURI, GerResourceRefType gerResourceRef) {
         AbstractNameQuery containerId;
         String module = moduleURI == null ? null : moduleURI.toString();
@@ -226,415 +73,6 @@
         return containerId;
     }
 
-    static void addResourceEnvRefs(Configuration earContext, RefContext refContext, ResourceEnvRefType[] resourceEnvRefArray, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        if (refMap == null) {
-            refMap = Collections.EMPTY_MAP;
-        }
-        Map newMap = new HashMap();
-        for (Iterator it = refMap.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            newMap.put(name.trim(), refMap.get(name));
-        }
-        refMap = newMap;
-
-        for (int i = 0; i < resourceEnvRefArray.length; i++) {
-            ResourceEnvRefType resourceEnvRef = resourceEnvRefArray[i];
-            String name = getStringValue(resourceEnvRef.getResourceEnvRefName());
-            String type = getStringValue(resourceEnvRef.getResourceEnvRefType());
-            Class iface;
-            try {
-                iface = cl.loadClass(type);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("could not load class " + type, e);
-            }
-            GerResourceEnvRefType gerResourceEnvRef = (GerResourceEnvRefType) refMap.get(name);
-            try {
-                AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
-                Reference ref = refContext.getAdminObjectRef(containerId, iface, earContext);
-
-                builder.bind(name, ref);
-            } catch (UnresolvedReferenceException e) {
-                throw new DeploymentException("Unable to resolve resource env reference '" + name + "' (" + (e.isMultiple() ? "found multiple matching resources" : "no matching resources found") + ")");
-            }
-        }
-    }
-
-    private static AbstractNameQuery getAdminObjectContainerId(String name, GerResourceEnvRefType gerResourceEnvRef) {
-        AbstractNameQuery containerId;
-        if (gerResourceEnvRef == null) {
-            containerId = buildAbstractNameQuery(null, null, name, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
-        } else if (gerResourceEnvRef.isSetMessageDestinationLink()) {
-            containerId = buildAbstractNameQuery(null, null, gerResourceEnvRef.getMessageDestinationLink().trim(), NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
-        } else if (gerResourceEnvRef.isSetAdminObjectLink()) {
-            String moduleURI = null;
-            if (gerResourceEnvRef.isSetAdminObjectModule()) {
-                moduleURI = gerResourceEnvRef.getAdminObjectModule().trim();
-            }
-            containerId = buildAbstractNameQuery(null, moduleURI, gerResourceEnvRef.getAdminObjectLink().trim(), NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
-        } else {
-            //construct name from components
-            GerPatternType patternType = gerResourceEnvRef.getPattern();
-            containerId = buildAbstractNameQuery(patternType, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE, null);
-        }
-        return containerId;
-    }
-
-    static void addMessageDestinationRefs(Configuration earContext, RefContext refContext, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        for (int i = 0; i < messageDestinationRefs.length; i++) {
-            MessageDestinationRefType messageDestinationRef = messageDestinationRefs[i];
-            String name = getStringValue(messageDestinationRef.getMessageDestinationRefName());
-            String linkName = getStringValue(messageDestinationRef.getMessageDestinationLink());
-            String type = getStringValue(messageDestinationRef.getMessageDestinationType());
-            Class iface;
-            try {
-                iface = cl.loadClass(type);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("could not load class " + type, e);
-            }
-            String moduleURI = null;
-            GerMessageDestinationType destination = (GerMessageDestinationType) refContext.getMessageDestination(linkName);
-            if (destination != null) {
-                if (destination.isSetAdminObjectLink()) {
-                    if (destination.isSetAdminObjectModule()) {
-                        moduleURI = destination.getAdminObjectModule().trim();
-                    }
-                    linkName = destination.getAdminObjectLink().trim();
-                }
-            } else {
-                //well, we know for sure an admin object is not going to be defined in a modules that can have a message-destination
-                int pos = linkName.indexOf('#');
-                if (pos > -1) {
-                    //AMM -- the following line causes blowups; e.g. to look in DayTrader EJB module for a RA -- why is that?!?
-                    //moduleURI = linkName.substring(0, pos);
-                    linkName = linkName.substring(pos + 1);
-                }
-            }
-
-            //try to resolve ref based only matching resource-ref-name
-            //throws exception if it can't locate ref.
-            AbstractNameQuery containerId = buildAbstractNameQuery(null, moduleURI, linkName, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
-            Reference ref = refContext.getAdminObjectRef(containerId, iface, earContext);
-            builder.bind(name, ref);
-
-        }
-
-    }
-
-    static void addEJBRefs(Configuration earContext, Configuration ejbContext, RefContext refContext, URI moduleURI, EjbRefType[] ejbRefs, Map ejbRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        Map newMap = new HashMap();
-        for (Iterator it = ejbRefMap.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            newMap.put(name.trim(), ejbRefMap.get(name));
-        }
-        ejbRefMap = newMap;
-        for (int i = 0; i < ejbRefs.length; i++) {
-            EjbRefType ejbRef = ejbRefs[i];
-
-            String ejbRefName = getStringValue(ejbRef.getEjbRefName());
-            GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
-
-            Reference ejbReference = addEJBRef(earContext, ejbContext, refContext, moduleURI, ejbRef, remoteRef, cl);
-            builder.bind(ejbRefName, ejbReference);
-        }
-    }
-
-    static Reference addEJBRef(Configuration earContext, Configuration ejbContext, RefContext refContext, URI moduleURI, EjbRefType ejbRef, GerEjbRefType remoteRef, ClassLoader cl) throws DeploymentException {
-        String remote = getStringValue(ejbRef.getRemote());
-        String refName = getStringValue(ejbRef.getEjbRefName());
-        try {
-            assureEJBObjectInterface(remote, cl);
-        } catch (DeploymentException e) {
-            throw new DeploymentException("Error processing 'remote' element for EJB Reference '" + refName + "' for module '" + moduleURI + "': " + e.getMessage());
-        }
-
-        String home = getStringValue(ejbRef.getHome());
-        try {
-            assureEJBHomeInterface(home, cl);
-        } catch (DeploymentException e) {
-            throw new DeploymentException("Error processing 'home' element for EJB Reference '" + refName + "' for module '" + moduleURI + "': " + e.getMessage());
-        }
-
-        Reference ejbReference;
-        boolean isSession = "Session".equals(getStringValue(ejbRef.getEjbRefType()));
-
-        if (isSession && remote.equals("javax.management.j2ee.Management") && home.equals("javax.management.j2ee.ManagementHome")) {
-            AbstractNameQuery query = new AbstractNameQuery(null, Collections.singletonMap("name", "ejb/mgmt/MEJB"));
-            ejbReference = refContext.getEJBRemoteRef(null, ejbContext, null, null, null, null, query, isSession, home, remote);
-        } else {
-
-            String ejbLink = null;
-            if (remoteRef != null && remoteRef.isSetNsCorbaloc()) {
-                try {
-                    AbstractNameQuery cssBean;
-                    if (remoteRef.isSetCssLink()) {
-                        String cssLink = remoteRef.getCssLink().trim();
-                        cssBean = buildAbstractNameQuery(null, null, cssLink, NameFactory.CORBA_CSS, NameFactory.EJB_MODULE);
-                    } else {
-                        GerPatternType css = remoteRef.getCss();
-                        cssBean = buildAbstractNameQuery(css, NameFactory.CORBA_CSS, NameFactory.EJB_MODULE, null);
-                    }
-                    ejbReference = refContext.getCORBARemoteRef(earContext,
-                            cssBean,
-                            new URI(getStringValue(remoteRef.getNsCorbaloc())),
-                            getStringValue(remoteRef.getName()),
-                            home);
-                } catch (URISyntaxException e) {
-                    throw new DeploymentException("Could not construct CORBA NameServer URI: " + remoteRef.getNsCorbaloc(), e);
-                }
-            } else {
-                Artifact targetConfigId = null;
-                String optionalModule = moduleURI == null ? null : moduleURI.toString();
-                String requiredModule = null;
-                AbstractNameQuery containerQuery = null;
-                if (remoteRef != null && remoteRef.isSetEjbLink()) {
-                    ejbLink = remoteRef.getEjbLink();
-                } else if (ejbRef.isSetEjbLink()) {
-                    ejbLink = getStringValue(ejbRef.getEjbLink());
-                    targetConfigId = ejbContext.getId();
-                }
-                if (ejbLink != null) {
-                    String[] bits = ejbLink.split("#");
-                    if (bits.length == 2) {
-                        //look only in specified module.
-                        requiredModule = bits[0];
-                        if (moduleURI != null) {
-                            requiredModule = moduleURI.resolve(requiredModule).getPath();
-                        }
-                        ejbLink = bits[1];
-                    }
-                } else if (remoteRef != null) {
-                    GerPatternType patternType = remoteRef.getPattern();
-                    containerQuery = buildAbstractNameQuery(patternType, null, NameFactory.EJB_MODULE, null);
-                }
-                ejbReference = refContext.getEJBRemoteRef(refName, ejbContext, ejbLink, requiredModule, optionalModule, targetConfigId, containerQuery, isSession, home, remote);
-            }
-        }
-        return ejbReference;
-    }
-
-    static void addEJBLocalRefs(Configuration ejbContext, RefContext refContext, URI moduleURI, EjbLocalRefType[] ejbLocalRefs, Map ejbLocalRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        Map newMap = new HashMap();
-        for (Iterator it = ejbLocalRefMap.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            newMap.put(name.trim(), ejbLocalRefMap.get(name));
-        }
-        ejbLocalRefMap = newMap;
-        for (int i = 0; i < ejbLocalRefs.length; i++) {
-            EjbLocalRefType ejbLocalRef = ejbLocalRefs[i];
-
-            String ejbRefName = getStringValue(ejbLocalRef.getEjbRefName());
-            GerEjbLocalRefType localRef = (GerEjbLocalRefType) ejbLocalRefMap.get(ejbRefName);
-
-            Reference ejbReference = addEJBLocalRef(ejbContext, refContext, moduleURI, ejbLocalRef, localRef, cl);
-            builder.bind(ejbRefName, ejbReference);
-        }
-    }
-
-    static Reference addEJBLocalRef(Configuration ejbContext, RefContext refContext, URI moduleURI, EjbLocalRefType ejbLocalRef, GerEjbLocalRefType localRef, ClassLoader cl) throws DeploymentException {
-        String local = getStringValue(ejbLocalRef.getLocal());
-        String refName = getStringValue(ejbLocalRef.getEjbRefName());
-        try {
-            assureEJBLocalObjectInterface(local, cl);
-        } catch (DeploymentException e) {
-            throw new DeploymentException("Error processing 'local' element for EJB Local Reference '" + refName + "' for module '" + moduleURI + "': " + e.getMessage());
-        }
-
-        String localHome = getStringValue(ejbLocalRef.getLocalHome());
-        try {
-            assureEJBLocalHomeInterface(localHome, cl);
-        } catch (DeploymentException e) {
-            throw new DeploymentException("Error processing 'local-home' element for EJB Local Reference '" + refName + "' for module '" + moduleURI + "': " + e.getMessage());
-        }
-
-        boolean isSession = "Session".equals(getStringValue(ejbLocalRef.getEjbRefType()));
-
-        String ejbLink = null;
-        if (localRef != null && localRef.isSetEjbLink()) {
-            ejbLink = localRef.getEjbLink();
-        } else if (ejbLocalRef.isSetEjbLink()) {
-            ejbLink = getStringValue(ejbLocalRef.getEjbLink());
-        }
-
-        Artifact targetConfigId = null;
-        String optionalModule = moduleURI == null ? null : moduleURI.toString();
-        String requiredModule = null;
-        AbstractNameQuery containerQuery = null;
-        if (localRef != null && localRef.isSetEjbLink()) {
-            ejbLink = localRef.getEjbLink();
-        } else if (ejbLocalRef.isSetEjbLink()) {
-            ejbLink = getStringValue(ejbLocalRef.getEjbLink());
-            targetConfigId = ejbContext.getId();
-        }
-        if (ejbLink != null) {
-            String[] bits = ejbLink.split("#");
-            if (bits.length == 2) {
-                //look only in specified module.
-                requiredModule = bits[0];
-                ejbLink = bits[1];
-            }
-        } else if (localRef != null) {
-            GerPatternType patternType = localRef.getPattern();
-            containerQuery = buildAbstractNameQuery(patternType, null, NameFactory.EJB_MODULE, null);
-        }
-        return refContext.getEJBLocalRef(refName, ejbContext, ejbLink, requiredModule, optionalModule, targetConfigId, containerQuery, isSession, localHome, local);
-    }
-
-//TODO current implementation does not deal with portComponentRef links.
-
-    static void addServiceRefs(EARContext earContext, Module module, ServiceRefType[] serviceRefs, Map serviceRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        Map newMap = new HashMap();
-        for (Iterator it = serviceRefMap.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            newMap.put(name.trim(), serviceRefMap.get(name));
-        }
-        serviceRefMap = newMap;
-
-        RefContext refContext = earContext.getRefContext();
-
-        for (int i = 0; i < serviceRefs.length; i++) {
-            ServiceRefType serviceRef = serviceRefs[i];
-            String name = getStringValue(serviceRef.getServiceRefName());
-            GerServiceRefType serviceRefType = (GerServiceRefType) serviceRefMap.get(name);
-//            Map credentialsNameMap = (Map) serviceRefCredentialsNameMap.get(name);
-            String serviceInterfaceName = getStringValue(serviceRef.getServiceInterface());
-            assureInterface(serviceInterfaceName, "javax.xml.rpc.Service", "[Web]Service", cl);
-            Class serviceInterface;
-            try {
-                serviceInterface = cl.loadClass(serviceInterfaceName);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("Could not load service interface class: " + serviceInterfaceName, e);
-            }
-            URI wsdlURI = null;
-            if (serviceRef.isSetWsdlFile()) {
-                try {
-                    wsdlURI = new URI(getStringValue(serviceRef.getWsdlFile().getStringValue()));
-                } catch (URISyntaxException e) {
-                    throw new DeploymentException("could not construct wsdl uri from " + serviceRef.getWsdlFile().getStringValue(), e);
-                }
-            }
-            URI jaxrpcMappingURI = null;
-            if (serviceRef.isSetJaxrpcMappingFile()) {
-                try {
-                    jaxrpcMappingURI = new URI(getStringValue(serviceRef.getJaxrpcMappingFile()));
-                } catch (URISyntaxException e) {
-                    throw new DeploymentException("Could not construct jaxrpc mapping uri from " + serviceRef.getJaxrpcMappingFile(), e);
-                }
-            }
-            QName serviceQName = null;
-            if (serviceRef.isSetServiceQname()) {
-                serviceQName = serviceRef.getServiceQname().getQNameValue();
-            }
-            Map portComponentRefMap = new HashMap();
-            PortComponentRefType[] portComponentRefs = serviceRef.getPortComponentRefArray();
-            if (portComponentRefs != null) {
-                for (int j = 0; j < portComponentRefs.length; j++) {
-                    PortComponentRefType portComponentRef = portComponentRefs[j];
-                    String portComponentLink = getStringValue(portComponentRef.getPortComponentLink());
-                    String serviceEndpointInterfaceType = getStringValue(portComponentRef.getServiceEndpointInterface());
-                    assureInterface(serviceEndpointInterfaceType, "java.rmi.Remote", "ServiceEndpoint", cl);
-                    Class serviceEndpointClass;
-                    try {
-                        serviceEndpointClass = cl.loadClass(serviceEndpointInterfaceType);
-                    } catch (ClassNotFoundException e) {
-                        throw new DeploymentException("could not load service endpoint class " + serviceEndpointInterfaceType, e);
-                    }
-                    portComponentRefMap.put(serviceEndpointClass, portComponentLink);
-                }
-            }
-            ServiceRefHandlerType[] handlers = serviceRef.getHandlerArray();
-            List handlerInfos = buildHandlerInfoList(handlers, cl);
-
-//we could get a Reference or the actual serializable Service back.
-            Object ref = refContext.getServiceReference(serviceInterface, wsdlURI, jaxrpcMappingURI, serviceQName, portComponentRefMap, handlerInfos, serviceRefType, earContext, module, cl);
-            builder.bind(name, ref);
-        }
-
-    }
-
-    private static List buildHandlerInfoList(ServiceRefHandlerType[] handlers, ClassLoader classLoader) throws DeploymentException {
-        List handlerInfos = new ArrayList();
-        for (int i = 0; i < handlers.length; i++) {
-            ServiceRefHandlerType handler = handlers[i];
-            org.apache.geronimo.xbeans.j2ee.String[] portNameArray = handler.getPortNameArray();
-            List portNames = new ArrayList();
-            for (int j = 0; j < portNameArray.length; j++) {
-                portNames.add(portNameArray[j].getStringValue().trim());
-
-            }
-//            Set portNames = new HashSet(Arrays.asList(portNameArray));
-            String handlerClassName = handler.getHandlerClass().getStringValue().trim();
-            Class handlerClass;
-            try {
-                handlerClass = ClassLoading.loadClass(handlerClassName, classLoader);
-            } catch (ClassNotFoundException e) {
-                throw new DeploymentException("Could not load handler class", e);
-            }
-            Map config = new HashMap();
-            ParamValueType[] paramValues = handler.getInitParamArray();
-            for (int j = 0; j < paramValues.length; j++) {
-                ParamValueType paramValue = paramValues[j];
-                String paramName = paramValue.getParamName().getStringValue().trim();
-                String paramStringValue = paramValue.getParamValue().getStringValue().trim();
-                config.put(paramName, paramStringValue);
-            }
-            XsdQNameType[] soapHeaderQNames = handler.getSoapHeaderArray();
-            QName[] headerQNames = new QName[soapHeaderQNames.length];
-            for (int j = 0; j < soapHeaderQNames.length; j++) {
-                XsdQNameType soapHeaderQName = soapHeaderQNames[j];
-                headerQNames[j] = soapHeaderQName.getQNameValue();
-            }
-            Set soapRoles = new HashSet();
-            for (int j = 0; j < handler.getSoapRoleArray().length; j++) {
-                String soapRole = handler.getSoapRoleArray(j).getStringValue().trim();
-                soapRoles.add(soapRole);
-            }
-            ServiceReferenceBuilder.HandlerInfoInfo handlerInfoInfo = new ServiceReferenceBuilder.HandlerInfoInfo(new HashSet(portNames), handlerClass, config, headerQNames, soapRoles);
-            handlerInfos.add(handlerInfoInfo);
-        }
-        return handlerInfos;
-    }
-
-    public static Class assureEJBObjectInterface(String remote, ClassLoader cl) throws DeploymentException {
-        return assureInterface(remote, "javax.ejb.EJBObject", "Remote", cl);
-    }
-
-    public static Class assureEJBHomeInterface(String home, ClassLoader cl) throws DeploymentException {
-        return assureInterface(home, "javax.ejb.EJBHome", "Home", cl);
-    }
-
-    public static Class assureEJBLocalObjectInterface(String local, ClassLoader cl) throws DeploymentException {
-        return assureInterface(local, "javax.ejb.EJBLocalObject", "Local", cl);
-    }
-
-    public static Class assureEJBLocalHomeInterface(String localHome, ClassLoader cl) throws DeploymentException {
-        return assureInterface(localHome, "javax.ejb.EJBLocalHome", "LocalHome", cl);
-    }
-
-    public static Class assureInterface(String interfaceName, String superInterfaceName, String interfaceType, ClassLoader cl) throws DeploymentException {
-        if (interfaceName == null || interfaceName.equals("")) {
-            throw new DeploymentException("interface name cannot be blank");
-        }
-        Class clazz;
-        try {
-            clazz = cl.loadClass(interfaceName);
-        } catch (ClassNotFoundException e) {
-            throw new DeploymentException(interfaceType + " interface class not found: " + interfaceName);
-        }
-        if (!clazz.isInterface()) {
-            throw new DeploymentException(interfaceType + " interface is not an interface: " + interfaceName);
-        }
-        Class superInterface;
-        try {
-            superInterface = cl.loadClass(superInterfaceName);
-        } catch (ClassNotFoundException e) {
-            throw new DeploymentException("Class " + superInterfaceName + " could not be loaded");
-        }
-        if (!superInterface.isAssignableFrom(clazz)) {
-            throw new DeploymentException(interfaceType + " interface does not extend " + superInterfaceName + ": " + interfaceName);
-        }
-        return clazz;
-    }
-
     private static String getStringValue(org.apache.geronimo.xbeans.j2ee.String string) {
         if (string == null) {
             return null;
@@ -643,19 +81,6 @@
         return s == null ? null : s.trim();
     }
 
-    private static String getStringValue(XsdStringType string) {
-        if (string == null) {
-            return null;
-        }
-        String s = string.getStringValue();
-        return s == null ? null : s.trim();
-    }
-
-    private static String getStringValue(String string) {
-        return string == null ? null : string.trim();
-    }
-
-
     public static void setResourceEnvironment(ResourceEnvironmentBuilder builder, ResourceRefType[] resourceRefs, GerResourceRefType[] gerResourceRefs) {
         Map refMap = mapResourceRefs(gerResourceRefs);
         Set unshareableResources = new HashSet();
@@ -684,139 +109,7 @@
         builder.setApplicationManagedSecurityResources(applicationManagedSecurityResources);
     }
 
-    public static Map buildComponentContext(EARContext earContext,
-                                            Configuration ejbContext,
-                                            Module module,
-                                            UserTransaction userTransaction,
-                                            EnvEntryType[] envEntries,
-                                            EjbRefType[] ejbRefs,
-                                            GerEjbRefType[] gerEjbRefs,
-                                            EjbLocalRefType[] ejbLocalRefs,
-                                            GerEjbLocalRefType[] gerEjbLocalRef,
-                                            ResourceRefType[] resourceRefs,
-                                            GerResourceRefType[] gerResourceRef,
-                                            ResourceEnvRefType[] resourceEnvRefs,
-                                            GerResourceEnvRefType[] gerResourceEnvRef,
-                                            MessageDestinationRefType[] messageDestinationRefs,
-                                            ServiceRefType[] serviceRefs,
-                                            GerServiceRefType[] gerServiceRefs,
-                                            GerGbeanRefType[] gerGbeanRefs,
-                                            ClassLoader cl) throws DeploymentException {
-        ComponentContextBuilder builder = new ComponentContextBuilder();
-        RefContext refContext = earContext.getRefContext();
-        Configuration earConfiguration = earContext.getConfiguration();
-
-        if (userTransaction != null) {
-            builder.addUserTransaction(userTransaction);
-        }
-
-        AbstractNameQuery corbaGBean = earContext.getCORBAGBeanObjectName();
-        if (corbaGBean != null) {
-            builder.addORB(earConfiguration.getId(), corbaGBean);
-            builder.addHandleDelegateReference(earConfiguration.getId(), corbaGBean);
-        }
-
-        URI moduleURI = module.getModuleURI();
-
-        addEnvEntries(envEntries, builder, cl);
-
-        if (ejbContext == null) {
-            ejbContext = earConfiguration;
-        }
-
-// ejb-ref
-        addEJBRefs(earConfiguration, ejbContext, refContext, moduleURI, ejbRefs, mapEjbRefs(gerEjbRefs), cl, builder);
-
-// ejb-local-ref
-        addEJBLocalRefs(ejbContext, refContext, moduleURI, ejbLocalRefs, mapEjbLocalRefs(gerEjbLocalRef), cl, builder);
-
-// resource-ref
-        addResourceRefs(earConfiguration, refContext, resourceRefs, mapResourceRefs(gerResourceRef), cl, builder);
-
-// resource-env-ref
-        addResourceEnvRefs(earConfiguration, refContext, resourceEnvRefs, mapResourceEnvRefs(gerResourceEnvRef), cl, builder);
-
-        addMessageDestinationRefs(earConfiguration, refContext, messageDestinationRefs, cl, builder);
-
-//        Map serviceRefMap = new HashMap();
-//        Map serviceRefCredentialsNameMap = new HashMap();
-//        mapServiceRefs(gerServiceRefs, serviceRefMap, serviceRefCredentialsNameMap);
-        Map serviceRefMap = mapServiceRefs(gerServiceRefs);
-        addServiceRefs(earContext, module, serviceRefs, serviceRefMap, cl, builder);
-
-        addGBeanRefs(earContext, builder, refContext, gerGbeanRefs, cl);
-
-        return builder.getContext();
-    }
-
-    private static void addGBeanRefs(EARContext earContext, ComponentContextBuilder builder, RefContext refContext, GerGbeanRefType[] gerGbeanRefs, ClassLoader cl) throws DeploymentException {
-        if (null == gerGbeanRefs) {
-            return;
-        }
-
-
-        for (int i = 0; i < gerGbeanRefs.length; i++) {
-            GerGbeanRefType gerGbeanRef = gerGbeanRefs[i];
-            addGBeanRef(earContext, builder, refContext, gerGbeanRef, cl);
-        }
-    }
-
-    private static void addGBeanRef(EARContext earContext, ComponentContextBuilder builder, RefContext refContext, GerGbeanRefType gerGbeanRef, ClassLoader cl) throws DeploymentException{
-        GerPatternType[] gbeanLocatorArray = gerGbeanRef.getPatternArray();
-
-        String[] interfaceTypesArray = gerGbeanRef.getRefTypeArray();
-        Set interfaceTypes = new HashSet(Arrays.asList(interfaceTypesArray));
-        Set queries = new HashSet();
-        for (int i = 0; i < gbeanLocatorArray.length; i++) {
-            GerPatternType patternType = gbeanLocatorArray[i];
-            AbstractNameQuery abstractNameQuery = buildAbstractNameQuery(patternType, null, null, interfaceTypes);
-            queries.add(abstractNameQuery);
-        }
-
-        GBeanData gBeanData;
-        Configuration configuration = earContext.getConfiguration();
-        try {
-            gBeanData = configuration.findGBeanData(queries);
-        } catch (GBeanNotFoundException e) {
-            throw new DeploymentException("Could not resolve reference at deploy time for queries " + queries, e);
-        }
-
-        if (interfaceTypes.isEmpty()) {
-            interfaceTypes.add(gBeanData.getGBeanInfo().getClassName());
-        }
-        Class gBeanType;
-        try {
-            gBeanType = ClassLoading.loadClass(gBeanData.getGBeanInfo().getClassName(), cl);
-        } catch (ClassNotFoundException e) {
-            throw new DeploymentException("Cannot load GBean class", e);
-        }
-
-        String refName = gerGbeanRef.getRefName();
-
-        builder.bind(refName, new GBeanReference(configuration.getId(), queries, gBeanType));
-    }
-
-    private static Map mapEjbRefs(GerEjbRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerEjbRefType ref = refs[i];
-                refMap.put(ref.getRefName().trim(), ref);
-            }
-        }
-        return refMap;
-    }
 
-    private static Map mapEjbLocalRefs(GerEjbLocalRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerEjbLocalRefType ref = refs[i];
-                refMap.put(ref.getRefName().trim(), ref);
-            }
-        }
-        return refMap;
-    }
 
     private static Map mapResourceRefs(GerResourceRefType[] refs) {
         Map refMap = new HashMap();
@@ -829,29 +122,6 @@
         return refMap;
     }
 
-    private static Map mapResourceEnvRefs(GerResourceEnvRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerResourceEnvRefType ref = refs[i];
-                refMap.put(ref.getRefName().trim(), ref);
-            }
-        }
-        return refMap;
-    }
-
-    private static Map mapServiceRefs(GerServiceRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerServiceRefType ref = refs[i];
-                String serviceRefName = ref.getServiceRefName().trim();
-                refMap.put(serviceRefName, ref);
-            }
-        }
-        return refMap;
-    }
-
     public static AbstractNameQuery buildAbstractNameQuery(GerPatternType pattern, String type, String moduleType, Set interfaceTypes) {
         String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
         String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
@@ -890,6 +160,5 @@
         }
         return new AbstractNameQuery(configId, nameMap);
     }
-
 
 }

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,116 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.naming.reference.KernelReference;
+import org.apache.geronimo.xbeans.j2ee.EnvEntryType;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class EnvironmentEntryBuilder implements NamingBuilder {
+    private static final String J2EE_NAMESPACE = "http://java.sun.com/xml/ns/j2ee";
+
+    private static final QName ENV_ENTRY_QNAME = new QName(J2EE_NAMESPACE, "env-entry");
+    private static final QNameSet ENV_ENTRY_QNAME_SET = QNameSet.singleton(ENV_ENTRY_QNAME);
+
+    public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) {
+    }
+
+    public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
+    }
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+        XmlObject[] envEntriesUntyped = specDD.selectChildren(ENV_ENTRY_QNAME_SET);
+        for (int i = 0; i < envEntriesUntyped.length; i++) {
+            EnvEntryType envEntry = (EnvEntryType) envEntriesUntyped[i].copy().changeType(EnvEntryType.type);
+            String name = envEntry.getEnvEntryName().getStringValue().trim();
+            String type = envEntry.getEnvEntryType().getStringValue().trim();
+            String text = envEntry.getEnvEntryValue().getStringValue().trim();
+            try {
+                Object value;
+                if (text == 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 = new Character(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);
+                }
+                componentContext.put(ENV + name, value);
+            } catch (NumberFormatException e) {
+                throw new DeploymentException("Invalid env-entry value for name: " + name, e);
+            }
+        }
+
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return ENV_ENTRY_QNAME_SET;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EnvironmentEntryBuilder.class, NameFactory.MODULE_BUILDER);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,126 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.ClassLoading;
+import org.apache.geronimo.naming.reference.GBeanReference;
+import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanRefDocument;
+import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GBeanRefBuilder implements NamingBuilder {
+    private static final QName GBEAN_REF_QNAME = GerGbeanRefDocument.type.getDocumentElementName();
+    private static final QNameSet GBEAN_REF_QNAME_SET = QNameSet.singleton(GBEAN_REF_QNAME);
+
+    public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) {
+    }
+
+    public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
+    }
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+        if (plan == null) {
+            return;
+        }
+        XmlObject[] gbeanRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GBEAN_REF_QNAME_SET);
+        for (int i = 0; i < gbeanRefsUntyped.length; i++) {
+            XmlObject gbeanRefUntyped = gbeanRefsUntyped[i];
+            GerGbeanRefType gbeanRef = (GerGbeanRefType) gbeanRefUntyped.copy().changeType(GerGbeanRefType.type);
+            if (gbeanRef == null) {
+                throw new DeploymentException("Could not read gbeanRef " + gbeanRefUntyped + " as the correct xml type");
+            }
+            GerPatternType[] gbeanLocatorArray = gbeanRef.getPatternArray();
+
+            String[] interfaceTypesArray = gbeanRef.getRefTypeArray();
+            Set interfaceTypes = new HashSet(Arrays.asList(interfaceTypesArray));
+            Set queries = new HashSet();
+            for (int j = 0; j < gbeanLocatorArray.length; j++) {
+                GerPatternType patternType = gbeanLocatorArray[j];
+                AbstractNameQuery abstractNameQuery = ENCConfigBuilder.buildAbstractNameQuery(patternType, null, null, interfaceTypes);
+                queries.add(abstractNameQuery);
+            }
+
+            GBeanData gBeanData;
+            try {
+                gBeanData = localConfiguration.findGBeanData(queries);
+            } catch (GBeanNotFoundException e) {
+                throw new DeploymentException("Could not resolve reference at deploy time for queries " + queries, e);
+            }
+
+            if (interfaceTypes.isEmpty()) {
+                interfaceTypes.add(gBeanData.getGBeanInfo().getClassName());
+            }
+            ClassLoader cl = localConfiguration.getConfigurationClassLoader();
+            Class gBeanType;
+            try {
+                gBeanType = ClassLoading.loadClass(gBeanData.getGBeanInfo().getClassName(), cl);
+            } catch (ClassNotFoundException e) {
+                throw new DeploymentException("Cannot load GBean class", e);
+            }
+
+            String refName = gbeanRef.getRefName();
+
+            componentContext.put(ENV + refName, new GBeanReference(localConfiguration.getId(), queries, gBeanType));
+
+        }
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return GBEAN_REF_QNAME_SET;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(GBeanRefBuilder.class, NameFactory.MODULE_BUILDER);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.naming.reference.PersistenceContextReference;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceContextRefDocument;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceContextRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceContextTypeType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPropertyType;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.schema.NamespaceElementConverter;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class PersistenceContextRefBuilder implements NamingBuilder {
+    private static final QName PERSISTENCE_CONTEXT_REF_QNAME = GerPersistenceContextRefDocument.type.getDocumentElementName();
+    private static final QNameSet PERSISTENCE_CONTEXT_REF_QNAME_SET = QNameSet.singleton(PERSISTENCE_CONTEXT_REF_QNAME);
+
+    private final Environment defaultEnvironment = new Environment();
+
+    public PersistenceContextRefBuilder() {
+        defaultEnvironment.addDependency(new Dependency(new Artifact("org.apache.geronimo.modules", "geronimo-persistence-jpa10", (String)null, "jar"), ImportType.CLASSES));
+    }
+
+    public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) {
+        if (getPersistenceContextRefs(plan).length > 0) {
+            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+        }
+    }
+
+    public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
+    }
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+        XmlObject[] persistenceContextRefsUntyped = getPersistenceContextRefs(plan);
+        for (int i = 0; i < persistenceContextRefsUntyped.length; i++) {
+            XmlObject persistenceContextRefUntyped = persistenceContextRefsUntyped[i];
+            GerPersistenceContextRefType persistenceContextRef = (GerPersistenceContextRefType) persistenceContextRefUntyped.copy().changeType(GerPersistenceContextRefType.type);
+            if (persistenceContextRef == null) {
+                throw new DeploymentException("Could not read persistenceContextRef " + persistenceContextRefUntyped + " as the correct xml type");
+            }
+            String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName();
+            boolean transactionScoped = !persistenceContextRef.getPersistenceContextType().equals(GerPersistenceContextTypeType.EXTENDED);
+            GerPropertyType[] propertyTypes = persistenceContextRef.getPropertyArray();
+            Map properties = new HashMap();
+            for (int j = 0; j < propertyTypes.length; j++) {
+                GerPropertyType propertyType = propertyTypes[j];
+                String key = propertyType.getKey();
+                String value = propertyType.getValue();
+                properties.put(key, value);
+            }
+
+
+            Set interfaceTypes = Collections.singleton("org.apache.geronimo.persistence.PersistenceUnitGBean");
+            AbstractNameQuery persistenceUnitNameQuery;
+            if (persistenceContextRef.isSetPersistenceUnitName()) {
+                String persistenceUnitName = persistenceContextRef.getPersistenceUnitName();
+                persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), interfaceTypes);
+            } else {
+                GerPatternType gbeanLocator = persistenceContextRef.getPattern();
+
+                persistenceUnitNameQuery = ENCConfigBuilder.buildAbstractNameQuery(gbeanLocator, null, null, interfaceTypes);
+            }
+
+            try {
+                localConfiguration.findGBeanData(persistenceUnitNameQuery);
+            } catch (GBeanNotFoundException e) {
+                throw new DeploymentException("Could not resolve reference at deploy time for query " + persistenceUnitNameQuery, e);
+            }
+
+            PersistenceContextReference reference = new PersistenceContextReference(localConfiguration.getId(), persistenceUnitNameQuery, transactionScoped, properties);
+
+            componentContext.put(ENV + persistenceContextRefName, reference);
+
+        }
+    }
+
+    public QNameSet getSpecQNameSet() {
+        SchemaConversionUtils.registerNamespaceConversions(Collections.singletonMap(PERSISTENCE_CONTEXT_REF_QNAME.getLocalPart(), new NamespaceElementConverter(PERSISTENCE_CONTEXT_REF_QNAME.getNamespaceURI())));
+        return QNameSet.EMPTY;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return PERSISTENCE_CONTEXT_REF_QNAME_SET;
+    }
+
+    private XmlObject[] getPersistenceContextRefs(XmlObject plan) {
+        return plan == null? NO_REFS: plan.selectChildren(PersistenceContextRefBuilder.PERSISTENCE_CONTEXT_REF_QNAME_SET);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(PersistenceContextRefBuilder.class, NameFactory.MODULE_BUILDER);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/PersistenceContextRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.QNameSet;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class UnavailableRefBuilder implements NamingBuilder {
+    private final QNameSet unavailableQNameSet;
+    private QName unavailableQName;
+
+    public UnavailableRefBuilder(String namespaceURI, String localPart) {
+        unavailableQName = new QName(namespaceURI, localPart);
+        unavailableQNameSet = QNameSet.singleton(unavailableQName);
+    }
+    public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) throws DeploymentException {
+        checkUnavailable(specDD);
+    }
+
+    private void checkUnavailable(XmlObject specDD) throws DeploymentException {
+        XmlObject[] specRefs = specDD.selectChildren(unavailableQNameSet);
+        if (specRefs.length > 0) {
+            throw new DeploymentException("This server cannot deploy references of type " + unavailableQName);
+        }
+    }
+
+    public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
+        checkUnavailable(specDD);
+    }
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+        checkUnavailable(specDD);
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return unavailableQNameSet;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(UnavailableRefBuilder.class, NameFactory.MODULE_BUILDER);
+        infoBuilder.addAttribute("specNamespaceURI", String.class, true, true);
+        infoBuilder.addAttribute("specLocalPart", String.class, true, true);
+
+        infoBuilder.setConstructor(new String[] {"specNamespaceURI", "specLocalPart"});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Map;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class UserTransactionRefBuilder extends AbstractNamingBuilder {
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+//        EARContext rootContext = module.getRootEarContext();
+//        UserTransaction userTransaction = rootContext.getUserTransaction();
+//        if (userTransaction != null) {
+//            componentContext.put("UserTransaction", userTransaction);
+//            rootContext.setUserTransaction(null);
+//        }
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(UserTransactionRefBuilder.class, NameFactory.MODULE_BUILDER);
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UserTransactionRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/schema/geronimo-naming-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/schema/geronimo-naming-1.2.xsd?view=diff&rev=442387&r1=442386&r2=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/schema/geronimo-naming-1.2.xsd (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/schema/geronimo-naming-1.2.xsd Mon Sep 11 16:51:32 2006
@@ -36,9 +36,8 @@
     </xsd:annotation>
 
 
-    <xsd:element name="gbean-ref" type="gernaming:gbean-refType"/>
     <xsd:element name="ejb-ref" type="gernaming:ejb-refType"/>
-    <!--    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>-->
+    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>
     <xsd:element name="service-ref" type="gernaming:service-refType"/>
     <xsd:element name="resource-ref" type="gernaming:resource-refType"/>
     <xsd:element name="resource-env-ref" type="gernaming:resource-env-refType"/>
@@ -55,7 +54,7 @@
             </xsd:documentation>
         </xsd:annotation>
         <xsd:sequence>
-            <xsd:element name="gbean-ref" type="gernaming:gbean-refType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element ref="gernaming:abstract-naming-entry" minOccurs="0" maxOccurs="unbounded"/>
             <xsd:element name="ejb-ref" type="gernaming:ejb-refType" minOccurs="0" maxOccurs="unbounded"/>
             <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType" minOccurs="0" maxOccurs="unbounded"/>
             <xsd:element name="service-ref" type="gernaming:service-refType" minOccurs="0" maxOccurs="unbounded"/>
@@ -65,6 +64,13 @@
         </xsd:sequence>
     </xsd:group>
 
+    <xsd:element name="abstract-naming-entry" abstract="true" type="gernaming:abstract-naming-entryType"/>
+
+    <xsd:complexType name="abstract-naming-entryType" abstract="true">
+        <xsd:sequence>
+        </xsd:sequence>
+    </xsd:complexType>
+
     <!--ejb-link acts like ejb-link in spec descriptors-->
     <!--resource-link contains the name of the outbound-connectionfactory-instance -->
     <!--message-destination-link acts like message-destination-link in spec descriptors-->
@@ -106,13 +112,53 @@
         </xsd:sequence>
     </xsd:complexType>
 
+    <xsd:element name="gbean-ref" type="gernaming:gbean-refType" substitutionGroup="gernaming:abstract-naming-entry"/>
+
     <xsd:complexType name="gbean-refType">
+        <xsd:complexContent>
+            <xsd:extension base="gernaming:abstract-naming-entryType">
+                <xsd:sequence>
+                    <xsd:element name="ref-name" type="xsd:string"/>
+                    <xsd:element name="ref-type" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
+                    <xsd:choice minOccurs="0" maxOccurs="unbounded">
+                        <xsd:element name="pattern" type="gernaming:patternType"/>
+                    </xsd:choice>
+                </xsd:sequence>
+            </xsd:extension>
+        </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:element name="persistence-context-ref" type="gernaming:persistence-context-refType"
+                 substitutionGroup="gernaming:abstract-naming-entry"/>
+
+    <xsd:complexType name="persistence-context-refType">
+        <xsd:complexContent>
+            <xsd:extension base="gernaming:abstract-naming-entryType">
+                <xsd:sequence>
+                    <xsd:element name="persistence-context-ref-name" type="xsd:string"/>
+                    <xsd:choice>
+                        <xsd:element name="persistence-unit-name" type="xsd:string"/>
+                        <xsd:element name="pattern" type="gernaming:patternType"/>
+                    </xsd:choice>
+                    <xsd:element name="persistence-context-type" type="gernaming:persistence-context-typeType"
+                                 minOccurs="0"/>
+                    <xsd:element name="property" type="gernaming:propertyType" minOccurs="0" maxOccurs="unbounded"/>
+                </xsd:sequence>
+            </xsd:extension>
+        </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:simpleType name="persistence-context-typeType">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="transaction-scoped"/>
+            <xsd:enumeration value="extended"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+
+    <xsd:complexType name="propertyType">
         <xsd:sequence>
-            <xsd:element name="ref-name" type="xsd:string"/>
-            <xsd:element name="ref-type" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                <xsd:element name="pattern" type="gernaming:patternType"/>
-            </xsd:choice>
+            <xsd:element name="key" type="xsd:string"/>
+            <xsd:element name="value" type="xsd:string"/>
         </xsd:sequence>
     </xsd:complexType>
 

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,149 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.deployment;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EnvironmentEntryBuilderTest extends TestCase {
+    private Map componentContext = new HashMap();
+    private NamingBuilder environmentEntryBuilder = new EnvironmentEntryBuilder();
+
+    private static final String TEST = "<tmp xmlns=\"http://java.sun.com/xml/ns/j2ee\">" +
+            "<env-entry>" +
+            "<env-entry-name>string</env-entry-name>" +
+            "<env-entry-type>java.lang.String</env-entry-type>" +
+            "<env-entry-value>Hello World</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>char</env-entry-name>" +
+            "<env-entry-type>java.lang.Character</env-entry-type>" +
+            "<env-entry-value>H</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>byte</env-entry-name>" +
+            "<env-entry-type>java.lang.Byte</env-entry-type>" +
+            "<env-entry-value>12</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>short</env-entry-name>" +
+            "<env-entry-type>java.lang.Short</env-entry-type>" +
+            "<env-entry-value>12345</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>int</env-entry-name>" +
+            "<env-entry-type>java.lang.Integer</env-entry-type>" +
+            "<env-entry-value>12345678</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>long</env-entry-name>" +
+            "<env-entry-type>java.lang.Long</env-entry-type>" +
+            "<env-entry-value>1234567890123456</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>float</env-entry-name>" +
+            "<env-entry-type>java.lang.Float</env-entry-type>" +
+            "<env-entry-value>123.456</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>double</env-entry-name>" +
+            "<env-entry-type>java.lang.Double</env-entry-type>" +
+            "<env-entry-value>12345.6789</env-entry-value>" +
+            "</env-entry>" +
+
+            "<env-entry>" +
+            "<env-entry-name>boolean</env-entry-name>" +
+            "<env-entry-type>java.lang.Boolean</env-entry-type>" +
+            "<env-entry-value>TRUE</env-entry-value>" +
+            "</env-entry>" +
+            "</tmp>";
+
+    public void testEnvEntries() throws Exception {
+        String stringVal = "Hello World";
+        Character charVal = new Character('H');
+        Byte byteVal = new Byte((byte) 12);
+        Short shortVal = new Short((short) 12345);
+        Integer intVal = new Integer(12345678);
+        Long longVal = new Long(1234567890123456L);
+        Float floatVal = new Float(123.456);
+        Double doubleVal = new Double(12345.6789);
+        Boolean booleanVal = Boolean.TRUE;
+
+        XmlObject doc = XmlObject.Factory.parse(TEST);
+        XmlCursor cursor = doc.newCursor();
+        try {
+            cursor.toFirstChild();
+            doc = cursor.getObject();
+        } finally {
+            cursor.dispose();
+        }
+        environmentEntryBuilder.buildNaming(doc, null, null, null, null, componentContext);
+        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext);
+        Set actual = new HashSet();
+        for (NamingEnumeration e = context.listBindings("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"}));
+        assertEquals(expected, actual);
+        assertEquals(stringVal, context.lookup("env/string"));
+        assertEquals(charVal, context.lookup("env/char"));
+        assertEquals(byteVal, context.lookup("env/byte"));
+        assertEquals(shortVal, context.lookup("env/short"));
+        assertEquals(intVal, context.lookup("env/int"));
+        assertEquals(longVal, context.lookup("env/long"));
+        assertEquals(floatVal, context.lookup("env/float"));
+        assertEquals(doubleVal, context.lookup("env/double"));
+        assertEquals(booleanVal, context.lookup("env/boolean"));
+    }
+
+    public void testEmptyEnvironment() throws NamingException {
+        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext);
+        try {
+            Context env = (Context) context.lookup("env");
+            assertNotNull(env);
+        } catch (NamingException e) {
+            fail();
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java?view=auto&rev=442387
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java Mon Sep 11 16:51:32 2006
@@ -0,0 +1,69 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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 java.util.Map;
+
+import javax.naming.NameNotFoundException;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.AbstractName;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class PersistenceContextReference extends ConfigurationAwareReference {
+
+    private boolean transactionScoped;
+    private Map properties;
+
+    public PersistenceContextReference(Artifact configId, AbstractNameQuery abstractNameQuery, boolean transactionScoped, Map properties) {
+        super(configId, abstractNameQuery);
+        this.transactionScoped = transactionScoped;
+        this.properties = properties;
+    }
+
+    public String getClassName() {
+        return "javax.persistence.EntityManager";
+    }
+    
+    public Object getContent() throws NameNotFoundException {
+    Kernel kernel = getKernel();
+
+    AbstractName target;
+    try {
+        target = resolveTargetName();
+    } catch (GBeanNotFoundException e) {
+        throw (NameNotFoundException) new NameNotFoundException("Could not resolve name query: " + abstractNameQueries).initCause(e);
+    }
+
+    Object entityManager;
+    try {
+        entityManager = kernel.invoke(target, "getEntityManager", new Object[] {Boolean.valueOf(transactionScoped), properties}, new String[] {boolean.class.getName(), Map.class.getName()});
+    } catch (Exception e) {
+        throw (IllegalStateException) new IllegalStateException("Could not get entityManager").initCause(e);
+    }
+    if (entityManager == null) {
+        throw new IllegalStateException("entity manager not returned. Target " + target + " not started");
+    }
+    return entityManager;
+}
+}

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

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

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



Mime
View raw message