Search in sources :

Example 1 with SunApplication

use of org.apache.openejb.jee.sun.SunApplication in project tomee by apache.

the class SunConversion method deploy.

public AppModule deploy(final AppModule appModule) {
    final SunApplication sunApplication = getSunApplication(appModule);
    if (sunApplication != null) {
        for (final Web web : sunApplication.getWeb()) {
            final String webUri = web.getWebUri();
            for (final WebModule webModule : appModule.getWebModules()) {
                if (webUri.equals(webModule.getModuleId())) {
                    webModule.setContextRoot(web.getContextRoot());
                    break;
                }
            }
        }
        for (final ClientModule clientModule : appModule.getClientModules()) {
            final ApplicationClient applicationClient = clientModule.getApplicationClient();
            if (applicationClient == null) {
                continue;
            }
            // map ejb-refs
            final Map<String, org.apache.openejb.jee.EjbRef> refMap = applicationClient.getEjbRefMap();
            // map ejb-ref jndi name declaration to deploymentId
            for (final EjbRef ref : sunApplication.getEjbRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getEjbRefName();
                    refName = normalize(refName);
                    org.apache.openejb.jee.EjbRef ejbRef = refMap.get(refName);
                    // try to match from lookup name
                    for (final Map.Entry<String, org.apache.openejb.jee.EjbRef> aRef : refMap.entrySet()) {
                        if (refName.equals(aRef.getValue().getLookupName())) {
                            ejbRef = aRef.getValue();
                            break;
                        }
                    }
                    if (ejbRef == null) {
                        ejbRef = new org.apache.openejb.jee.EjbRef();
                        ejbRef.setEjbRefName(refName);
                        refMap.put(refName, ejbRef);
                        applicationClient.getEjbRef().add(ejbRef);
                    }
                    ejbRef.setMappedName(ref.getJndiName());
                }
            }
            // map resource-env-refs and message-destination-refs
            final Map<String, JndiReference> resEnvMap = new TreeMap<String, JndiReference>();
            resEnvMap.putAll(applicationClient.getResourceEnvRefMap());
            resEnvMap.putAll(applicationClient.getMessageDestinationRefMap());
            for (final ResourceRef ref : sunApplication.getResourceRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getResRefName();
                    refName = normalize(refName);
                    final JndiReference resEnvRef = resEnvMap.get(refName);
                    if (resEnvRef != null) {
                        resEnvRef.setMappedName(ref.getJndiName());
                    }
                }
            }
            for (final ResourceEnvRef ref : sunApplication.getResourceEnvRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getResourceEnvRefName();
                    refName = normalize(refName);
                    final JndiReference resEnvRef = resEnvMap.get(refName);
                    if (resEnvRef != null) {
                        resEnvRef.setMappedName(ref.getJndiName());
                    }
                }
            }
            for (final MessageDestinationRef ref : sunApplication.getMessageDestinationRef()) {
                if (ref.getJndiName() != null) {
                    String refName = ref.getMessageDestinationRefName();
                    refName = normalize(refName);
                    final JndiReference resEnvRef = resEnvMap.get(refName);
                    if (resEnvRef != null) {
                        resEnvRef.setMappedName(ref.getJndiName());
                    }
                }
            }
            for (final MessageDestination destination : sunApplication.getMessageDestination()) {
                if (destination.getJndiName() != null) {
                    String name = destination.getMessageDestinationName();
                    name = normalize(name);
                    final JndiReference ref = resEnvMap.get(name);
                    if (ref != null) {
                        ref.setMappedName(destination.getJndiName());
                    }
                }
            }
            final Map<String, ServiceRef> serviceRefMap = applicationClient.getServiceRefMap();
            for (final org.apache.openejb.jee.sun.ServiceRef ref : sunApplication.getServiceRef()) {
                String refName = ref.getServiceRefName();
                refName = normalize(refName);
                final ServiceRef serviceRef = serviceRefMap.get(refName);
                if (serviceRef != null) {
                    final Map<String, PortComponentRef> ports = new TreeMap<String, PortComponentRef>();
                    for (final PortComponentRef portComponentRef : serviceRef.getPortComponentRef()) {
                        ports.put(portComponentRef.getServiceEndpointInterface(), portComponentRef);
                    }
                    for (final PortInfo portInfo : ref.getPortInfo()) {
                        final PortComponentRef portComponentRef = ports.get(portInfo.getServiceEndpointInterface());
                        if (portComponentRef != null) {
                            final WsdlPort wsdlPort = portInfo.getWsdlPort();
                            if (wsdlPort != null) {
                                final QName qname = new QName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalpart());
                                portComponentRef.setQName(qname);
                            }
                            for (final StubProperty stubProperty : portInfo.getStubProperty()) {
                                final String name = stubProperty.getName();
                                final String value = stubProperty.getValue();
                                portComponentRef.getProperties().setProperty(name, value);
                            }
                        }
                    }
                    final String wsdlOverride = ref.getWsdlOverride();
                    if (wsdlOverride != null && wsdlOverride.length() > 0) {
                        final String serviceId = extractServiceId(wsdlOverride);
                        serviceRef.setMappedName(serviceId);
                    }
                }
            }
        }
    }
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        convertModule(ejbModule, appModule.getCmpMappings());
    }
    for (final ClientModule clientModule : appModule.getClientModules()) {
        convertModule(clientModule);
    }
    for (final WebModule webModule : appModule.getWebModules()) {
        convertModule(webModule);
    }
    return appModule;
}
Also used : WsdlPort(org.apache.openejb.jee.sun.WsdlPort) PortInfo(org.apache.openejb.jee.sun.PortInfo) MessageDestinationRef(org.apache.openejb.jee.sun.MessageDestinationRef) JndiReference(org.apache.openejb.jee.JndiReference) EjbRef(org.apache.openejb.jee.sun.EjbRef) ResourceEnvRef(org.apache.openejb.jee.sun.ResourceEnvRef) ApplicationClient(org.apache.openejb.jee.ApplicationClient) SunApplicationClient(org.apache.openejb.jee.sun.SunApplicationClient) MessageDestination(org.apache.openejb.jee.sun.MessageDestination) QName(javax.xml.namespace.QName) StubProperty(org.apache.openejb.jee.sun.StubProperty) SunApplication(org.apache.openejb.jee.sun.SunApplication) TreeMap(java.util.TreeMap) PortComponentRef(org.apache.openejb.jee.PortComponentRef) Web(org.apache.openejb.jee.sun.Web) ResourceRef(org.apache.openejb.jee.sun.ResourceRef) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) ServiceRef(org.apache.openejb.jee.ServiceRef)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 QName (javax.xml.namespace.QName)1 ApplicationClient (org.apache.openejb.jee.ApplicationClient)1 JndiReference (org.apache.openejb.jee.JndiReference)1 PortComponentRef (org.apache.openejb.jee.PortComponentRef)1 ServiceRef (org.apache.openejb.jee.ServiceRef)1 EjbRef (org.apache.openejb.jee.sun.EjbRef)1 MessageDestination (org.apache.openejb.jee.sun.MessageDestination)1 MessageDestinationRef (org.apache.openejb.jee.sun.MessageDestinationRef)1 PortInfo (org.apache.openejb.jee.sun.PortInfo)1 ResourceEnvRef (org.apache.openejb.jee.sun.ResourceEnvRef)1 ResourceRef (org.apache.openejb.jee.sun.ResourceRef)1 StubProperty (org.apache.openejb.jee.sun.StubProperty)1 SunApplication (org.apache.openejb.jee.sun.SunApplication)1 SunApplicationClient (org.apache.openejb.jee.sun.SunApplicationClient)1 Web (org.apache.openejb.jee.sun.Web)1 WsdlPort (org.apache.openejb.jee.sun.WsdlPort)1