Search in sources :

Example 1 with PortRefInfo

use of org.apache.openejb.assembler.classic.PortRefInfo in project tomee by apache.

the class JndiEncInfoBuilder method buildServiceRefInfos.

private void buildServiceRefInfos(final JndiConsumer jndiConsumer, final JndiEncInfo moduleJndiEnc, final JndiEncInfo compJndiEnc) {
    for (final ServiceRef ref : jndiConsumer.getServiceRef()) {
        final ServiceReferenceInfo info = new ServiceReferenceInfo();
        info.referenceName = ref.getName();
        info.location = buildLocationInfo(ref);
        info.targets.addAll(buildInjectionInfos(ref));
        insert(info, appInfo.globalJndiEnc.serviceRefs, appInfo.appJndiEnc.serviceRefs, moduleJndiEnc.serviceRefs, compJndiEnc.serviceRefs);
        if (SystemInstance.get().hasProperty("openejb.geronimo")) {
            continue;
        }
        info.id = ref.getMappedName();
        info.serviceQName = ref.getServiceQname();
        info.serviceType = ref.getServiceInterface();
        info.referenceType = ref.getServiceRefType();
        info.wsdlFile = ref.getWsdlFile();
        info.jaxrpcMappingFile = ref.getJaxrpcMappingFile();
        info.handlerChains.addAll(ConfigurationFactory.toHandlerChainInfo(ref.getAllHandlers()));
        for (final PortComponentRef portComponentRef : ref.getPortComponentRef()) {
            final PortRefInfo portRefInfo = new PortRefInfo();
            portRefInfo.qname = portComponentRef.getQName();
            portRefInfo.serviceEndpointInterface = portComponentRef.getServiceEndpointInterface();
            portRefInfo.enableMtom = portComponentRef.isEnableMtom();
            portRefInfo.properties.putAll(portComponentRef.getProperties());
            info.portRefs.add(portRefInfo);
        }
    }
}
Also used : PortComponentRef(org.apache.openejb.jee.PortComponentRef) PortRefInfo(org.apache.openejb.assembler.classic.PortRefInfo) ServiceRef(org.apache.openejb.jee.ServiceRef) ServiceReferenceInfo(org.apache.openejb.assembler.classic.ServiceReferenceInfo)

Example 2 with PortRefInfo

use of org.apache.openejb.assembler.classic.PortRefInfo in project tomee by apache.

the class TomcatJndiBuilder method mergeRef.

public void mergeRef(final NamingResourcesImpl naming, final ServiceReferenceInfo ref) {
    if (isLookupRef(naming, ref)) {
        return;
    }
    ContextResource resource = naming.findResource(ref.referenceName.replaceAll("^comp/env/", ""));
    boolean addEntry = false;
    if (resource == null) {
        resource = new ContextResource();
        resource.setName(ref.referenceName.replaceAll("^comp/env/", ""));
        addEntry = true;
    }
    resource.setProperty(Constants.FACTORY, WsFactory.class.getName());
    resource.setProperty(NamingUtil.NAME, ref.referenceName.replaceAll("^comp/env/", ""));
    if (ref.referenceType != null) {
        resource.setType(ref.referenceType);
    } else {
        resource.setType(ref.serviceType);
    }
    if (ref.location != null) {
        resource.setProperty(NamingUtil.JNDI_NAME, ref.location.jndiName);
        resource.setProperty(NamingUtil.JNDI_PROVIDER_ID, ref.location.jndiProviderId);
    } else {
        // ID
        if (ref.id != null) {
            resource.setProperty(NamingUtil.WS_ID, ref.id);
        }
        // Service QName
        if (ref.serviceQName != null) {
            resource.setProperty(NamingUtil.WS_QNAME, ref.serviceQName.toString());
        }
        // Service Class
        resource.setProperty(NamingUtil.WS_CLASS, ref.serviceType);
        // Port QName
        if (ref.portQName != null) {
            resource.setProperty(NamingUtil.WS_PORT_QNAME, ref.portQName.toString());
        }
        // add the wsdl url
        final URL wsdlURL = getWsdlUrl(ref);
        if (wsdlURL != null) {
            resource.setProperty(NamingUtil.WSDL_URL, wsdlURL.toString());
        }
        // add port refs
        if (!ref.portRefs.isEmpty()) {
            final List<PortRefData> portRefs = new ArrayList<>(ref.portRefs.size());
            for (final PortRefInfo portRefInfo : ref.portRefs) {
                final PortRefData portRef = new PortRefData();
                portRef.setQName(portRefInfo.qname);
                portRef.setServiceEndpointInterface(portRefInfo.serviceEndpointInterface);
                portRef.setEnableMtom(portRefInfo.enableMtom);
                portRef.getProperties().putAll(portRefInfo.properties);
                portRefs.add(portRef);
            }
            setResource(resource, "port-refs", portRefs);
        }
        // add the handle chains
        if (!ref.handlerChains.isEmpty()) {
            try {
                final List<HandlerChainData> handlerChains = WsBuilder.toHandlerChainData(ref.handlerChains, standardContext.getLoader().getClassLoader());
                setResource(resource, "handler-chains", handlerChains);
                setResource(resource, "injections", injections);
            } catch (final OpenEJBException e) {
                throw new IllegalArgumentException("Error creating handler chain for web service-ref " + ref.referenceName.replaceAll("^comp/env/", ""));
            }
        }
    }
    // if there was a service entry, remove it
    final ContextService service = naming.findService(ref.referenceName.replaceAll("^comp/env/", ""));
    final String serviceName = service != null ? service.getName() : null;
    if (serviceName != null) {
        ContextAccessController.setWritable(namingContextListener.getName(), standardContext.getNamingToken());
        if (!addEntry) {
            namingContextListener.removeService(serviceName);
        }
        ContextAccessController.setReadOnly(namingContextListener.getName());
    }
    // add the new resource entry
    if (addEntry) {
        naming.addResource(resource);
    }
    // or replace the exisitng resource entry
    if (replaceEntry) {
        ContextAccessController.setWritable(namingContextListener.getName(), standardContext.getNamingToken());
        if (!addEntry) {
            namingContextListener.removeResource(resource.getName());
        }
        namingContextListener.addResource(resource);
        ContextAccessController.setReadOnly(namingContextListener.getName());
    }
}
Also used : HandlerChainData(org.apache.openejb.core.webservices.HandlerChainData) OpenEJBException(org.apache.openejb.OpenEJBException) WsFactory(org.apache.tomee.common.WsFactory) ContextService(org.apache.tomcat.util.descriptor.web.ContextService) ArrayList(java.util.ArrayList) PortRefInfo(org.apache.openejb.assembler.classic.PortRefInfo) URL(java.net.URL) ContextResource(org.apache.tomcat.util.descriptor.web.ContextResource) PortRefData(org.apache.openejb.core.webservices.PortRefData)

Aggregations

PortRefInfo (org.apache.openejb.assembler.classic.PortRefInfo)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 ServiceReferenceInfo (org.apache.openejb.assembler.classic.ServiceReferenceInfo)1 HandlerChainData (org.apache.openejb.core.webservices.HandlerChainData)1 PortRefData (org.apache.openejb.core.webservices.PortRefData)1 PortComponentRef (org.apache.openejb.jee.PortComponentRef)1 ServiceRef (org.apache.openejb.jee.ServiceRef)1 ContextResource (org.apache.tomcat.util.descriptor.web.ContextResource)1 ContextService (org.apache.tomcat.util.descriptor.web.ContextService)1 WsFactory (org.apache.tomee.common.WsFactory)1