Examples of GerResourceRefType


Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

        ClassLoader cl = module.getEarContext().getClassLoader();

        for (ResourceRefType resourceRef: resourceRefsUntyped) {
            String name = resourceRef.getResRefName().getStringValue().trim();
            String type = resourceRef.getResType().getStringValue().trim();
            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);
            }
            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
                    getJndiContextMap(componentContext).put(ENV + 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_CLASS.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);

                    try {
                        localConfiguration.findGBean(containerId);
                    } catch (GBeanNotFoundException e) {
                        throw new UnresolvedReferenceException("Resource", false, containerId.toString(), localConfiguration.getId().toString());
                    }

                    Reference ref = new ResourceReference(localConfiguration.getId(), containerId, iface);
                    getJndiContextMap(componentContext).put(ENV + 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());
                }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

            if (!URL.class.getName().equals(type)
                    && !"javax.mail.Session".equals(type)
                    && !JAXR_CONNECTION_FACTORY_CLASS.equals(type)) {

                GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(resourceRefType.getResRefName().getStringValue());
                AbstractNameQuery containerId = getResourceContainerId(getStringValue(resourceRefType.getResRefName()), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, null, gerResourceRef);

                if ("Unshareable".equals(getStringValue(resourceRefType.getResSharingScope()))) {
                    unshareableResources.add(containerId);
                }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

    private Map mapResourceRefs(XmlObject[] refs) {
        Map refMap = new HashMap();
        if (refs != null) {
            for (int i = 0; i < refs.length; i++) {
                GerResourceRefType ref = (GerResourceRefType) refs[i].copy().changeType(GerResourceRefType.type);
                refMap.put(ref.getRefName().trim(), ref);
            }
        }
        return refMap;
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

                // some other builder handled this entry already
                continue;
            }
            addInjections(name, resourceRef.getInjectionTargetArray(), componentContext);
            String type = resourceRef.getResType().getStringValue().trim();
            GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(name);
            log.debug("trying to resolve " + name + ", type " + type + ", resourceRef " + gerResourceRef);
            if(!refMap.containsKey(name)){
                unresolvedRefs.add(name);
            }
            Class iface;
            try {
                iface = cl.loadClass(type);
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("could not load class " + type, e);
            }
            if (iface == URL.class) {
                if (gerResourceRef == null || !gerResourceRef.isSetUrl()) {
                    throw new DeploymentException("No url supplied to resolve: " + name);
                }
                String url = gerResourceRef.getUrl().trim();
                //TODO expose jsr-77 objects for these guys
                try {
                    //check for malformed URL
                    new URL(url);
                } catch (MalformedURLException e) {
                    throw new DeploymentException("Could not convert " + url + " to URL", e);
                }
                getJndiContextMap(componentContext).put(ENV + name, new URLReference(url));
                unresolvedRefs.remove(name);
            } else if (ORB.class.isAssignableFrom(iface)) {
                CorbaGBeanNameSource corbaGBeanNameSource = (CorbaGBeanNameSource) corbaGBeanNameSourceCollection.getElement();
                if (corbaGBeanNameSource == null) {
                    throw new DeploymentException("No orb setup but there is a orb reference");
                }
                AbstractNameQuery corbaName = corbaGBeanNameSource.getCorbaGBeanName();
                if (corbaName != null) {
                    Artifact[] moduleId = module.getConfigId();
                    Map context = getJndiContextMap(componentContext);
                    context.put(ENV + name, new ORBReference(moduleId, corbaName));
                    unresolvedRefs.remove(name);
                    EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), corbaEnvironment);
                }
            } else {
                //determine jsr-77 type from interface
                String j2eeType;


                if (JAVAX_MAIL_SESSION_CLASS.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);

                    module.getEarContext().findGBean(containerId);

                    Object ref = new ResourceReferenceFactory<ResourceException>(module.getConfigId(), containerId, iface);
                    getJndiContextMap(componentContext).put(ENV + name, ref);
                    // we thought that this might be an unresolved
                    // name because it wasn't in the refMap, but now
                    // we've found it so we can take it out of the
                    // unresolvedRefs list
                    unresolvedRefs.remove(name);
                } catch (GBeanNotFoundException e) {

                    StringBuffer errorMessage = new StringBuffer("Unable to resolve resource reference '");
                    errorMessage.append(name);
                    errorMessage.append("' (");
                    if (e.hasMatches()) {
                        errorMessage.append("Found multiple matching resources.  Try being more specific in a resource-ref mapping in your Geronimo deployment plan.\n");
                        for (AbstractName match : e.getMatches()) {
                            errorMessage.append(match).append("\n");
                        }
                    } 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("\nSearch conducted in current module and dependencies:\n");
                    for (Dependency dependency : module.getEnvironment().getDependencies()) {
                        errorMessage.append(dependency).append("\n");
                    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

            if (!URL.class.getName().equals(type)
                    && !"javax.mail.Session".equals(type)
                    && !JAXR_CONNECTION_FACTORY_CLASS.equals(type)) {

                GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(resourceRefType.getResRefName().getStringValue());
                AbstractNameQuery containerId = getResourceContainerId(getStringValue(resourceRefType.getResRefName()), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, null, gerResourceRef);

                if ("Unshareable".equals(getStringValue(resourceRefType.getResSharingScope()))) {
                    unshareableResources.add(containerId);
                }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

    private Map<String, GerResourceRefType> mapResourceRefs(XmlObject[] refs) {
        Map<String, GerResourceRefType> refMap = new HashMap<String, GerResourceRefType>();
        if (refs != null) {
            for (XmlObject ref1 : refs) {
                GerResourceRefType ref = (GerResourceRefType) ref1.copy().changeType(GerResourceRefType.type);
                refMap.put(ref.getRefName().trim(), ref);
            }
        }
        return refMap;
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

        for (int i = webApp.getResourceRefArray().length - 1; i >= 0; i--) {
            webApp.removeResourceRef(i);
        }
        for (int i = 0; i < jdbcPoolRefs.size(); i++) {
            ReferenceData referenceData = (ReferenceData) jdbcPoolRefs.get(i);
            GerResourceRefType resourceRef = webApp.addNewResourceRef();
            resourceRef.setRefName(referenceData.getRefName());
            resourceRef.setPattern(createPattern(referenceData.getRefLink()));
        }
        for (int i = 0; i < jmsConnectionFactoryRefs.size(); i++) {
            ReferenceData referenceData = (ReferenceData) jmsConnectionFactoryRefs.get(i);
            GerResourceRefType resourceRef = webApp.addNewResourceRef();
            resourceRef.setRefName(referenceData.getRefName());
            resourceRef.setPattern(createPattern(referenceData.getRefLink()));
        }
        for (int i = 0; i < javaMailSessionRefs.size(); i++) {
            ReferenceData referenceData = (ReferenceData) javaMailSessionRefs.get(i);
            GerResourceRefType resourceRef = webApp.addNewResourceRef();
            resourceRef.setRefName(referenceData.getRefName());
            resourceRef.setPattern(createPattern(referenceData.getRefLink()));
        }
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

                continue;
            }
            String type = getStringValue(resourceRef.getResType());
            type = inferAndCheckType(module, bundle, resourceRef.getInjectionTarget(), name, type);
            GerResourceRefType gerResourceRef = refMap.get(name);
            if (log.isDebugEnabled()) {
                log.debug("trying to resolve " + name + ", type " + type + ", resourceRef " + gerResourceRef);
            }
            Object value = null;
            if (gerResourceRef == null) {
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

            if (!URL.class.getName().equals(type)
                    && !"javax.mail.Session".equals(type)
                    && !JAXR_CONNECTION_FACTORY_CLASS.equals(type)) {

                GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(resourceRef.getResRefName());
                AbstractNameQuery containerId = getResourceContainerId(getStringValue(resourceRef.getResRefName()), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, null, gerResourceRef);

                if (ResSharingScope.UNSHAREABLE.equals(resourceRef.getResSharingScope())) {
                    unshareableResources.add(containerId);
                }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType

    private Map<String, GerResourceRefType> mapResourceRefs(XmlObject[] refs) {
        Map<String, GerResourceRefType> refMap = new HashMap<String, GerResourceRefType>();
        if (refs != null) {
            for (XmlObject ref1 : refs) {
                GerResourceRefType ref = (GerResourceRefType) ref1.copy().changeType(GerResourceRefType.type);
                refMap.put(getJndiName(ref.getRefName().trim()), ref);
            }
        }
        return refMap;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.