Package org.apache.openejb.jee.oejb3

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


        sessionBean.setEjbClass("org.superbiz.MySessionBean");
        sessionBean.setRemote("org.superbiz.MySession");
        ejbJar.addEnterpriseBean(sessionBean);

        OpenejbJar openejbJar = new OpenejbJar();
        EjbDeployment ejbDeployment = new EjbDeployment();
        openejbJar.addEjbDeployment(ejbDeployment);
       
        ejbDeployment.setEjbName("MySessionBean");

        EjbModule ejbModule =  new EjbModule(ejbJar, openejbJar);

        EjbJarInfo ejbJarInfo = new EjbJarInfo();
        PortInfo portInfo = new PortInfo();
View Full Code Here


        // Setup the descriptor information

        EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        ejbModule.getEjbJar().addEnterpriseBean(new StatelessBean(FooBean.class));

        EjbDeployment ejbDeployment = new EjbDeployment(null, "FooBean", "FooBean");
        ejbDeployment.getJndi().add(new Jndi("thename", "Local"));
        ejbDeployment.getJndi().add(new Jndi("anothername", "Remote"));
        ejbDeployment.getJndi().add(new Jndi("loldstyle", "LocalHome"));
        ejbDeployment.getJndi().add(new Jndi("roldstyle", "RemoteHome"));
        ejbModule.getOpenejbJar().addEjbDeployment(ejbDeployment);

        assembler.createApplication(config.configureApplication(ejbModule));

        InitialContext initialContext = new InitialContext();
View Full Code Here

                    final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(caller, caller));

                    // set it to bean so it can get UserTransaction injection
                    bean.setTransactionType(TransactionType.BEAN);

                    final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean);

                    // important in case any other deploment id formats are specified
                    ejbDeployment.setDeploymentId(caller);
                }

                appModule.getEjbModules().add(new EjbModule(ejbJar, openejbJar));

View Full Code Here

            List<String> removed = new ArrayList<String>();

            for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {

                String ejbName = bean.getEjbName();
                EjbDeployment ejbDeployment = deployments.get(ejbName);


                pruneRefs(bean, ejbDeployment);


//                if (bean.getEjbName().equals("BasicSingletonBean")) {
//                    continue;
//                }
                if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
                    continue;
                }

                ejbJar.removeEnterpriseBean(ejbName);
                openejbJar.removeEjbDeployment(ejbDeployment);
                removed.add(ejbName);

                AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
                if (assemblyDescriptor != null){
                    for (MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
                        for (Method method : copy(permission.getMethod())) {
                            if (method.getEjbName().equals(ejbName)) {
                                permission.getMethod().remove(method);
                            }
                        }
                        if (permission.getMethod().size() == 0) {
                            assemblyDescriptor.getMethodPermission().remove(permission);
                        }
                    }

                    for (ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
                        for (Method method : copy(transaction.getMethod())) {
                            if (method.getEjbName().equals(ejbName)) {
                                transaction.getMethod().remove(method);
                            }
                        }
                        if (transaction.getMethod().size() == 0) {
                            assemblyDescriptor.getContainerTransaction().remove(transaction);
                        }
                    }

                    for (InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
                        if (binding.getEjbName().equals(ejbName)) {
                            assemblyDescriptor.getInterceptorBinding().remove(binding);
                        }
                    }
                }
            }

            // Drop any ejb ref to with an ejb-link to a removed ejb
            for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
                bean.getEjbLocalRefMap().keySet().removeAll(removed);
                bean.getEjbRefMap().keySet().removeAll(removed);
            }

            for (Interceptor interceptor : ejbJar.getInterceptors()) {
                pruneRefs(interceptor, new EjbDeployment());
            }

        }
        return appModule;
    }
View Full Code Here

        EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        EjbJar ejbJar = ejbModule.getEjbJar();
        OpenejbJar openejbJar = ejbModule.getOpenejbJar();

        StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
        deployment.getProperties().put("openejb.client.connection.strategy", "test");

        assembler.createApplication(config.configureApplication(ejbModule));

        Properties props = new Properties();
        props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
View Full Code Here

        EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        EjbJar ejbJar = ejbModule.getEjbJar();
        OpenejbJar openejbJar = ejbModule.getOpenejbJar();

        StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
        deployment.getProperties().put("openejb.client.connection.strategy", "test");

        assembler.createApplication(config.configureApplication(ejbModule));

        Properties props = new Properties();
        props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
View Full Code Here

            if (sessionBean.getSessionType() == SessionType.STATEFUL) continue;
            if (sessionBean.getSessionType() == SessionType.MANAGED) continue;
            if (sessionBean.getServiceEndpoint() == null) continue;


            EjbDeployment deployment = deploymentsByEjbName.get(sessionBean.getEjbName());
            if (deployment == null) continue;

            Class<?> ejbClass;
            try {
                ejbClass = ejbModule.getClassLoader().loadClass(sessionBean.getEjbClass());
            } catch (ClassNotFoundException e) {
                throw new OpenEJBException("Unable to load ejb class: " + sessionBean.getEjbClass(), e);
            }

            // for now, skip all non jaxws beans
            if (!JaxWsUtils.isWebService(ejbClass)) continue;

            // create webservices dd if not defined
            if (webservices == null) {
                webservices = new Webservices();
                ejbModule.setWebservices(webservices);
            }
           
            webserviceDescription = webservices.getWebserviceDescriptionMap().get(JaxWsUtils.getServiceName(ejbClass));
            if (webserviceDescription == null) {
                webserviceDescription = new WebserviceDescription();
                if (JaxWsUtils.isWebService(ejbClass)) {
                    webserviceDescription.setWebserviceDescriptionName(JaxWsUtils.getServiceName(ejbClass));
                } else {
                    // todo create webserviceDescription name using some sort of jaxrpc data
                }
                webservices.getWebserviceDescription().add(webserviceDescription);
            }

            // add a port component if we don't alrady have one
            PortComponent portComponent = portMap.get(sessionBean.getEjbName());
            if (portComponent == null) {
                portComponent = new PortComponent();
                if (webserviceDescription.getPortComponentMap().containsKey(JaxWsUtils.getPortQName(ejbClass).getLocalPart())) {
                    // when to webservices.xml is defined and when we want to
                    // publish more than one port for the same implementation by configuration
                    portComponent.setPortComponentName(sessionBean.getEjbName());
       
    } else { // JAX-WS Metadata specification default
        portComponent.setPortComponentName(JaxWsUtils.getPortQName(ejbClass).getLocalPart());
       
    }
                webserviceDescription.getPortComponent().add(portComponent);

                ServiceImplBean serviceImplBean = new ServiceImplBean();
                serviceImplBean.setEjbLink(sessionBean.getEjbName());
                portComponent.setServiceImplBean(serviceImplBean);

                // Checking if MTOM must be enabled
                if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding()) ||
                        SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding())) {
                    portComponent.setEnableMtom(true);
                }
               
            }

            // default portId == deploymentId
            if (portComponent.getId() == null) {
                portComponent.setId(deployment.getDeploymentId());
            }
            if (webserviceDescription.getId() == null) {
                webserviceDescription.setId(deployment.getDeploymentId());
            }

            // set service endpoint interface
            if (portComponent.getServiceEndpointInterface() == null) {
                portComponent.setServiceEndpointInterface(sessionBean.getServiceEndpoint());
View Full Code Here

                return appModule;
            }

            Map<String, EjbDeployment> ejbDeployments = openejbJar.getDeploymentsByEjbName();
            for (EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
                EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());

                if (ejbDeployment == null) {
                    continue;
                }

                String mappedName = enterpriseBean.getMappedName();

                if (mappedName != null && mappedName.length() > 0) {
                    ejbDeployment.getJndi().add(new Jndi(mappedName, "Remote"));
                }
            }
        }

        return appModule;
View Full Code Here

        if (sunEjbJar == null) return;
        if (sunEjbJar.getEnterpriseBeans() == null) return;

        Map<String,Map<String, WebserviceEndpoint>> endpointMap = new HashMap<String,Map<String, WebserviceEndpoint>>();
        for (Ejb ejb : sunEjbJar.getEnterpriseBeans().getEjb()) {
            EjbDeployment deployment = openejbJar.getDeploymentsByEjbName().get(ejb.getEjbName());
            if (deployment == null) {
                // warn no matching deployment
                continue;
            }

            // ejb jndi name is the deploymentId
            if (ejb.getJndiName() != null) {
                deployment.setDeploymentId(ejb.getJndiName());
            }

            // map ejb-ref jndi name declaration to deploymentId
            Map<String, EjbLink> linksMap = deployment.getEjbLinksMap();
            for (EjbRef ref : ejb.getEjbRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getEjbRefName();
                    refName = normalize(refName);
                    EjbLink link = linksMap.get(refName);
                    if (link == null) {
                        link = new EjbLink();
                        link.setEjbRefName(refName);
                        linksMap.put(refName, link);
                        deployment.getEjbLink().add(link);
                    }
                    link.setDeployentId(ref.getJndiName());
                }
            }

            Map<String, ResourceLink> resourceLinksMap = deployment.getResourceLinksMap();
            for (ResourceRef ref : ejb.getResourceRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getResRefName();
                    refName = normalize(refName);
                    ResourceLink link = resourceLinksMap.get(refName);
                    if (link == null) {
                        link = new ResourceLink();
                        link.setResRefName(refName);
                        resourceLinksMap.put(refName, link);
                        deployment.getResourceLink().add(link);
                    }
                    link.setResId(ref.getJndiName());
                }
            }

            for (ResourceEnvRef ref : ejb.getResourceEnvRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getResourceEnvRefName();
                    refName = normalize(refName);
                    ResourceLink link = resourceLinksMap.get(refName);
                    if (link == null) {
                        link = new ResourceLink();
                        link.setResRefName(refName);
                        resourceLinksMap.put(refName, link);
                        deployment.getResourceLink().add(link);
                    }
                    link.setResId(ref.getJndiName());
                }
            }

            for (MessageDestinationRef ref : ejb.getMessageDestinationRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getMessageDestinationRefName();
                    refName = normalize(refName);
                    ResourceLink link = resourceLinksMap.get(refName);
                    if (link == null) {
                        link = new ResourceLink();
                        link.setResRefName(refName);
                        resourceLinksMap.put(refName, link);
                        deployment.getResourceLink().add(link);
                    }
                    link.setResId(ref.getJndiName());
                }
            }

            EnterpriseBean bean = ejbJar.getEnterpriseBeansByEjbName().get(ejb.getEjbName());
            if (bean != null) {
                Map<String, ServiceRef> serviceRefMap = bean.getServiceRefMap();
                for (org.apache.openejb.jee.sun.ServiceRef ref : ejb.getServiceRef()) {
                    String refName = ref.getServiceRefName();
                    refName = normalize(refName);
                    ServiceRef serviceRef = serviceRefMap.get(refName);
                    if (serviceRef != null) {
                        Map<String,PortComponentRef> ports = new TreeMap<String,PortComponentRef>();
                        for (PortComponentRef portComponentRef : serviceRef.getPortComponentRef()) {
                            ports.put(portComponentRef.getServiceEndpointInterface(), portComponentRef);
                        }

                        for (PortInfo portInfo : ref.getPortInfo()) {
                            PortComponentRef portComponentRef = ports.get(portInfo.getServiceEndpointInterface());
                            if (portComponentRef != null) {
                                WsdlPort wsdlPort = portInfo.getWsdlPort();
                                if (wsdlPort != null) {
                                    QName qname = new QName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalpart());
                                    portComponentRef.setQName(qname);
                                }
                                for (StubProperty stubProperty : portInfo.getStubProperty()) {
                                    String name = stubProperty.getName();
                                    String value = stubProperty.getValue();
                                    portComponentRef.getProperties().setProperty(name, value);
                                }
                            }
                        }

                        String wsdlOverride = ref.getWsdlOverride();
                        if (wsdlOverride != null && wsdlOverride.length() > 0) {
                            String serviceId = extractServiceId(wsdlOverride);
                            serviceRef.setMappedName(serviceId);
                        }
                    }
                }
            }

            if (ejb.getMdbResourceAdapter() != null) {
                // resource adapter id is the MDB container ID
                String resourceAdapterId = ejb.getMdbResourceAdapter().getResourceAdapterMid();
                deployment.setContainerId(resourceAdapterId);
            }

            endpointMap.put(ejb.getEjbName(), ejb.getWebserviceEndpointMap());
        }
View Full Code Here

            entity.getNamedQuery().add(namedQuery);
        }
       
        // todo: there should be a common interface between ejb query object and openejb query object
        OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
        if (ejbDeployment != null) {
            for (org.apache.openejb.jee.oejb3.Query query : ejbDeployment.getQuery()) {
                NamedQuery namedQuery = new NamedQuery();
                org.apache.openejb.jee.oejb3.QueryMethod queryMethod = query.getQueryMethod();

                // todo deployment id could change in one of the later conversions... use entity name instead, but we need to save it off
                StringBuilder name = new StringBuilder();
View Full Code Here

TOP

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

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.