Package org.apache.openejb.jee.oejb3

Examples of org.apache.openejb.jee.oejb3.ResourceLink


            // mdb message destination id
            if (autoCreateResources && bean instanceof MessageDrivenBean) {
                final MessageDrivenBean mdb = (MessageDrivenBean) bean;

                final ResourceLink resourceLink = ejbDeployment.getResourceLink("openejb/destination");
                if (resourceLink != null) {
                    try {
                        final String destinationId = getResourceEnvId(bean.getEjbName(), resourceLink.getResId(), mdb.getMessageDestinationType(), appResources);
                        resourceLink.setResId(destinationId);
                    } catch (final OpenEJBException e) {
                        // The MDB doesn't need the auto configured "openejb/destination" env entry
                        ejbDeployment.removeResourceLink("openejb/destination");
                    }
                }
View Full Code Here


        } catch (final Throwable t) {
            // no-op
        }

        try {
            ResourceLink link = ejbDeployment.getResourceLink(refName);
            if (link == null) {
                String id = mappedName.length() == 0 ? ref.getName() : mappedName;
                if (id.startsWith("java:")) {
                    id = id.substring("java:".length());
                }
                try {
                    final AppModule appModule = ejbModule.getAppModule();
                    if (appModule != null) {
                        final String newId = findResourceId(appModule.getModuleId() + '/' + id.replace("java:", "").replaceAll("^comp/env/", ""),
                            refType,
                            new Properties(),
                            appResources);
                        if (newId != null) { // app scoped resources, try to find it without creating it first
                            id = getResourceId(ejbModule.getModuleId(), newId, refType, appResources);
                        } else {
                            id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources);
                        }
                    } else {
                        id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources);
                    }
                } catch (final OpenEJBException e) { // changing the message to be explicit
                    throw new OpenEJBException("Can't find resource for " + ref.getOrigin() + ". (" + e.getMessage() + ")", e.getCause());
                }
                logger.info("Auto-linking resource-ref '" + refName + "' in bean " + ejbDeployment.getDeploymentId() + " to Resource(id=" + id + ")");

                link = new ResourceLink();
                link.setResId(id);
                link.setResRefName(refName);
                ejbDeployment.addResourceLink(link);
            } else {
                final String id = getResourceId(ejbDeployment.getDeploymentId(), link.getResId(), refType, appResources);
                link.setResId(id);
                link.setResRefName(refName);
            }
        } catch (final OpenEJBException ex) {
            if (!(ref instanceof ContextRef)) {
                throw ex;
            }
View Full Code Here

        // skip references such as SessionContext which are automatically handled by the server
        if (isIgnoredReferenceType(refType, classLoader)) {
            return;
        }

        ResourceLink link = ejbDeployment.getResourceLink(refName);
        if (link == null) {

            String id = mappedName.length() == 0 ? refName : mappedName;
            id = getResourceEnvId(ejbDeployment.getDeploymentId(), id, refType, appResources);
            if (id == null) {
                // could be a session context ref
                return;
            }
            logger.info("Auto-linking resource-env-ref '" + refName + "' in bean " + ejbDeployment.getDeploymentId() + " to Resource(id=" + id + ")");

            link = new ResourceLink();
            link.setResId(id);
            link.setResRefName(refName);
            ejbDeployment.addResourceLink(link);
        } else {
            final String id = getResourceEnvId(ejbDeployment.getDeploymentId(), link.getResId(), refType, appResources);
            link.setResId(id);
            link.setResRefName(refName);
        }
    }
View Full Code Here

    }

    private void pruneRefs(final JndiConsumer bean, final EjbDeployment ejbDeployment) {
        for (final ResourceRef ref : copy(bean.getResourceRef())) {
            if (ref.getResType().startsWith("javax.jms.")) {
                final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                ejbDeployment.getResourceLink().remove(resourceLink);
                bean.getResourceRef().remove(ref);
            }
        }

        for (final ResourceEnvRef ref : bean.getResourceEnvRef()) {
            final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
            ejbDeployment.getResourceLink().remove(resourceLink);
        }
        bean.getResourceEnvRef().clear();

        for (final MessageDestinationRef ref : bean.getMessageDestinationRef()) {
            final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
            ejbDeployment.getResourceLink().remove(resourceLink);
        }
        bean.getMessageDestinationRef().clear();

        bean.getPersistenceContextRef().clear();
View Full Code Here

            bean.mdbInterface = mdb.getMessagingType();
        } else {
            bean.mdbInterface = "javax.jms.MessageListener";
        }

        ResourceLink resourceLink = d.getResourceLink("openejb/destination");
        if (resourceLink != null) {
            bean.destinationId = resourceLink.getResId();
        }

        if (mdb.getMessageDestinationType() != null) {
            bean.activationProperties.put("destinationType", mdb.getMessageDestinationType());
        }
View Full Code Here

    }

    private void pruneRefs(JndiConsumer bean, EjbDeployment ejbDeployment) {
        for (ResourceRef ref : copy(bean.getResourceRef())) {
            if (ref.getResType().startsWith("javax.jms.")){
                ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                ejbDeployment.getResourceLink().remove(resourceLink);
                bean.getResourceRef().remove(ref);
            }
        }

        for (ResourceEnvRef ref : bean.getResourceEnvRef()) {
            ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
            ejbDeployment.getResourceLink().remove(resourceLink);
        }
        bean.getResourceEnvRef().clear();

        for (MessageDestinationRef ref : bean.getMessageDestinationRef()) {
            ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
            ejbDeployment.getResourceLink().remove(resourceLink);
        }
        bean.getMessageDestinationRef().clear();

        bean.getPersistenceContextRef().clear();
View Full Code Here

                enterpriseBean.setId(ejbDeployment.getDeploymentId());

                // Copy all links over to mappedName

                for (ResourceRef ref : enterpriseBean.getResourceRef()) {
                    ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                    if (resourceLink != null && resourceLink.getResId() != null /* don't overwrite with null */) {
                        ref.setMappedName(resourceLink.getResId());
                    }
                }

                for (ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
                    ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                    if (resourceLink != null && resourceLink.getResId() != null /* don't overwrite with null */) {
                        ref.setMappedName(resourceLink.getResId());
                    }
                }

                for (MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
                    ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
                    if (resourceLink != null && resourceLink.getResId() != null /* don't overwrite with null */) {
                        ref.setMappedName(resourceLink.getResId());
                    }
                }

                for (EjbRef ref : enterpriseBean.getEjbRef()) {
                    EjbLink ejbLink = ejbDeployment.getEjbLink(ref.getName());
View Full Code Here

            bean.mdbInterface = mdb.getMessagingType();
        } else {
            bean.mdbInterface = "javax.jms.MessageListener";
        }

        ResourceLink resourceLink = d.getResourceLink("openejb/destination");
        if (resourceLink != null) {
            bean.destinationId = resourceLink.getResId();
        }

        if (mdb.getMessageDestinationType() != null) {
            bean.activationProperties.put("destinationType", mdb.getMessageDestinationType());
        }
View Full Code Here

                    destination = ejbDeployment.getDeploymentId();
                    mdb.getActivationConfig().addProperty("destination", destination);
                }

                // destination identifier
                ResourceLink link = ejbDeployment.getResourceLink("openejb/destination");
                if (link == null && mdb.getMessageDestinationLink() == null) {
                    link = new ResourceLink();
                    link.setResId(destination);
                    link.setResRefName("openejb/destination");
                    ejbDeployment.addResourceLink(link);
                }

                // destination type
                String destinationType = properties.getProperty("destinationType");
View Full Code Here

                    if (mdb.getMessageDestinationType() != null && !destinationTypes.containsKey(destination)) {
                        destinationTypes.put(destination, mdb.getMessageDestinationType());
                    }

                    // destination identifier
                    ResourceLink resourceLink = ejbDeployment.getResourceLink("openejb/destination");
                    if (resourceLink == null) {
                        resourceLink = new ResourceLink();
                        resourceLink.setResRefName("openejb/destination");
                        ejbDeployment.addResourceLink(resourceLink);
                    }
                    resourceLink.setResId(destinationId);
                }
            }
        }

        // resolve all message destination refs with links and assign a ref id to the reference
        for (final EjbModule ejbModule : appModule.getEjbModules()) {
            final AssemblyDescriptor assembly = ejbModule.getEjbJar().getAssemblyDescriptor();
            if (assembly == null) {
                continue;
            }

            final URI moduleUri = ejbModule.getModuleUri();
            final OpenejbJar openejbJar = ejbModule.getOpenejbJar();

            for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
                final EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
                if (ejbDeployment == null) {
                    throw new OpenEJBException("No ejb deployment found for ejb " + bean.getEjbName());
                }

                for (final MessageDestinationRef ref : bean.getMessageDestinationRef()) {
                    // skip destination refs with a resource link already assigned
                    if (ref.getMappedName() == null && ejbDeployment.getResourceLink(ref.getName()) == null) {
                        final String destinationId = resolveDestinationId(ref, moduleUri, destinationResolver, destinationTypes);
                        if (destinationId != null) {
                            // build the link and add it
                            final ResourceLink resourceLink = new ResourceLink();
                            resourceLink.setResId(destinationId);
                            resourceLink.setResRefName(ref.getName());
                            ejbDeployment.addResourceLink(resourceLink);
                        }

                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.oejb3.ResourceLink

Copyright © 2018 www.massapicom. 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.