Package org.apache.geronimo.j2ee.deployment

Examples of org.apache.geronimo.j2ee.deployment.RefContext


        }

    }

    public static void addEJBRefs(EARContext earContext, URI uri, EjbRefType[] ejbRefs, Map ejbRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
        RefContext refContext = earContext.getRefContext();
        J2eeContext j2eeContext = earContext.getJ2eeContext();
        for (int i = 0; i < ejbRefs.length; i++) {
            EjbRefType ejbRef = ejbRefs[i];

            String ejbRefName = getStringValue(ejbRef.getEjbRefName());

            String remote = getStringValue(ejbRef.getRemote());
            assureEJBObjectInterface(remote, cl);

            String home = getStringValue(ejbRef.getHome());
            assureEJBHomeInterface(home, cl);

            Reference ejbReference;
            boolean isSession = "Session".equals(getStringValue(ejbRef.getEjbRefType()));

            if (isSession && remote.equals("javax.management.j2ee.Management") && home.equals("javax.management.j2ee.ManagementHome")) {
                String mejbName = refContext.getMEJBName();
                ejbReference = refContext.getEJBRemoteRef(mejbName, isSession, home, remote);
            } else {

                String ejbLink = null;
                GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
                if (remoteRef != null && remoteRef.isSetEjbLink()) {
                    ejbLink = remoteRef.getEjbLink();
                } else if (ejbRef.isSetEjbLink()) {
                    ejbLink = getStringValue(ejbRef.getEjbLink());
                }

                if (ejbLink != null) {
                    ejbReference = refContext.getEJBRemoteRef(uri, ejbLink, isSession, home, remote);
                } else if (remoteRef != null) {
                    if (remoteRef.isSetTargetName()) {
                        ejbReference = refContext.getEJBRemoteRef(getStringValue(remoteRef.getTargetName()), isSession, home, remote);
                    } else if (remoteRef.isSetNsCorbaloc()) {
                        try {
                            ObjectName cssBean;
                            if (remoteRef.isSetCssName()) {
                                cssBean = ObjectName.getInstance(getStringValue(remoteRef.getCssName()));
                            } else if (remoteRef.isSetCssLink()) {
                                String cssLink = remoteRef.getCssLink().trim();
                                cssBean = refContext.locateComponent(cssLink, NameFactory.CORBA_CSS, j2eeContext, earContext, "css gbean");
                            } else {
                                GerCssType css = remoteRef.getCss();
                                cssBean = NameFactory.getComponentName(getStringValue(css.getDomain()),
                                    getStringValue(css.getServer()),
                                    getStringValue(css.getApplication()),
                                    getStringValue(css.getModule()),
                                    getStringValue(css.getName()),
                                    getStringValue(NameFactory.CORBA_CSS),
                                    j2eeContext);
                            }
                            ejbReference = refContext.getCORBARemoteRef(new URI(getStringValue(remoteRef.getNsCorbaloc())),
                                                                        getStringValue(remoteRef.getName()),
                                                                        ObjectName.getInstance(cssBean),
                                                                        home);
                        } catch (URISyntaxException e) {
                            throw new DeploymentException("Could not construct CORBA NameServer URI: " + remoteRef.getNsCorbaloc(), e);
                        } catch (MalformedObjectNameException e) {
                            throw new DeploymentException("Could not construct CSS container name: " + remoteRef.getCssName(), e);
                        }
                    } else {
                        String containerId = null;
                        try {
                            containerId = NameFactory.getEjbComponentNameString(getStringValue(remoteRef.getDomain()),
                                    getStringValue(remoteRef.getServer()),
                                    getStringValue(remoteRef.getApplication()),
                                    getStringValue(remoteRef.getModule()),
                                    getStringValue(remoteRef.getName()),
                                    getStringValue(remoteRef.getType()),
                                    j2eeContext);
                        } catch (MalformedObjectNameException e) {
                            throw new DeploymentException("Could not construct ejb object name: " + remoteRef.getName(), e);
                        }
                        ejbReference = refContext.getEJBRemoteRef(containerId, isSession, home, remote);

                    }
                } else {
                    ejbReference = refContext.getImplicitEJBRemoteRef(uri, ejbRefName, isSession, home, remote);
                }
            }
            builder.bind(ejbRefName, ejbReference);
        }
    }
View Full Code Here


            builder.bind(ejbRefName, ejbReference);
        }
    }

    public static void addEJBLocalRefs(EARContext earContext, URI uri, EjbLocalRefType[] ejbLocalRefs, Map ejbLocalRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
        RefContext refContext = earContext.getRefContext();
        J2eeContext j2eeContext = earContext.getJ2eeContext();
        for (int i = 0; i < ejbLocalRefs.length; i++) {
            EjbLocalRefType ejbLocalRef = ejbLocalRefs[i];

            String ejbRefName = getStringValue(ejbLocalRef.getEjbRefName());

            String local = getStringValue(ejbLocalRef.getLocal());
            assureEJBLocalObjectInterface(local, cl);

            String localHome = getStringValue(ejbLocalRef.getLocalHome());
            assureEJBLocalHomeInterface(localHome, cl);

            boolean isSession = "Session".equals(getStringValue(ejbLocalRef.getEjbRefType()));

            String ejbLink = null;
            GerEjbLocalRefType localRef = (GerEjbLocalRefType) ejbLocalRefMap.get(ejbRefName);
            if (localRef != null && localRef.isSetEjbLink()) {
                ejbLink = localRef.getEjbLink();
            } else if (ejbLocalRef.isSetEjbLink()) {
                ejbLink = getStringValue(ejbLocalRef.getEjbLink());
            }

            Reference ejbReference;
            if (ejbLink != null) {
                ejbReference = refContext.getEJBLocalRef(uri, ejbLink, isSession, localHome, local);
            } else if (localRef != null) {
                if (localRef.isSetTargetName()) {
                    ejbReference = refContext.getEJBLocalRef(getStringValue(localRef.getTargetName()), isSession, localHome, local);
                } else {
                    String containerId = null;
                    try {
                        containerId = NameFactory.getEjbComponentNameString(getStringValue(localRef.getDomain()),
                                getStringValue(localRef.getServer()),
                                getStringValue(localRef.getApplication()),
                                getStringValue(localRef.getModule()),
                                getStringValue(localRef.getName()),
                                getStringValue(localRef.getType()),
                                j2eeContext);
                    } catch (MalformedObjectNameException e) {
                        throw new DeploymentException("Could not construct ejb object name: " + localRef.getName(), e);
                    }
                    ejbReference = refContext.getEJBLocalRef(containerId, isSession, localHome, local);

                }
            } else {
                ejbReference = refContext.getImplicitEJBLocalRef(uri, ejbLink, isSession, localHome, local);
            }
            builder.bind(ejbRefName, ejbReference);
        }
    }
View Full Code Here

    }

    //TODO current implementation does not deal with portComponentRef links.
    public static void addServiceRefs(EARContext earContext, Module module, ServiceRefType[] serviceRefs, Map serviceRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {

        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 = null;
            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);
        }

    }
View Full Code Here

        return string == null ? null : string.trim();
    }


    public static void setResourceEnvironment(EARContext earContext, URI uri, ResourceEnvironmentBuilder builder, ResourceRefType[] resourceRefs, GerResourceRefType[] gerResourceRefs) throws DeploymentException {
        RefContext refContext = earContext.getRefContext();
        J2eeContext j2eeContext = earContext.getJ2eeContext();
        Map refMap = mapResourceRefs(gerResourceRefs);
        Set unshareableResources = new HashSet();
        Set applicationManagedSecurityResources = new HashSet();
        for (int i = 0; i < resourceRefs.length; i++) {
View Full Code Here

    private EARContext createEARContext(File outputPath, URI id)
            throws MalformedObjectNameException, DeploymentException {
        EARContext earContext = new EARContext(outputPath, id,
                ConfigurationModuleType.WAR, parentId, kernel, moduleContext
                        .getJ2eeApplicationName(), tcmName, ctcName, null,
                null, null, new RefContext(new EJBReferenceBuilder() {

                    public Reference createEJBLocalReference(String objectName,
                            boolean isSession, String localHome, String local)
                            throws DeploymentException {
                        return null;
View Full Code Here

                        j2eeContext.getJ2eeApplicationName(),
                        null,
                        connectionTrackerName,
                        null,
                        null,
                        null, new RefContext(ejbReferenceBuilder,
                                moduleBuilder,
                                serviceReferenceBuilder, kernel));

                action.install(moduleBuilder, earContext, module);
                earContext.getClassLoader(null);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.j2ee.deployment.RefContext

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.