Package org.apache.openejb.jee.oejb2

Examples of org.apache.openejb.jee.oejb2.ServiceRefType


            if (mergeItem != null) {
                if (mergeItem.isFromWebFragment()) {
                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("service-ref", serviceRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
                } else if (mergeItem.isFromWebXml() && !isServiceRefInjectTargetsConfiguredInInitialWebXML(serviceRefName, mergeContext)) {
                    //Merge InjectTarget
                    ServiceRefType serviceRef = (ServiceRefType) mergeItem.getValue();
                    for (InjectionTargetType injectTarget : srcServiceRef.getInjectionTargetArray()) {
                        String serviceRefInjectTargetKey = createServiceRefInjectTargetKey(serviceRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
                                .getInjectionTargetName().getStringValue());
                        if (!mergeContext.containsAttribute(serviceRefInjectTargetKey)) {
                            serviceRef.addNewInjectionTarget().set(injectTarget);
                            mergeContext.setAttribute(serviceRefInjectTargetKey, Boolean.TRUE);
                        }
                    }
                }
            } else {
                ServiceRefType targetServiceRef = (ServiceRefType) webApp.addNewServiceRef().set(srcServiceRef);
                mergeContext.setAttribute(serviceRefKey, new MergeItem(targetServiceRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
                for (InjectionTargetType injectionTarget : targetServiceRef.getInjectionTargetArray()) {
                    mergeContext.setAttribute(createServiceRefInjectTargetKey(serviceRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
                            .getStringValue()), Boolean.TRUE);
                }
            }
        }
View Full Code Here


            throw new DeploymentException("Could not load " + classDescription + " class " + className, e);
        }
    }

    public void buildNaming(XmlObject serviceRef, GerServiceRefType gerServiceRefType, Module module, Map componentContext) throws DeploymentException {
        ServiceRefType serviceRefType =
            (ServiceRefType)convert(serviceRef, JEE_CONVERTER, ServiceRefType.type);
        buildNaming(serviceRefType, gerServiceRefType, module, componentContext);
    }
View Full Code Here

                jaxrpcClass = loadClass("javax.xml.rpc.Service", bundle);
            }
            if (jaxwsClass == null) {
                jaxwsClass = loadClass("javax.xml.ws.Service", bundle);
            }
            ServiceRefType serviceRefType = (ServiceRefType) convert(
                    serviceRef, JEE_CONVERTER, ServiceRefType.type);

            String name = getStringValue(serviceRefType.getServiceRefName());
            GerServiceRefType gerServiceRefType = (GerServiceRefType) serviceRefMap.get(name);
            serviceRefMap.remove(name);

            String serviceInterfaceName = getStringValue(serviceRefType
                    .getServiceInterface());
            Class serviceInterfaceClass = loadClass(serviceInterfaceName, bundle);

            InjectionTargetType[] injections = serviceRefType.getInjectionTargetArray();
            addInjections(name, injections, sharedContext);

            if (jaxrpcClass.isAssignableFrom(serviceInterfaceClass)) {
                // class jaxrpc handler
                ServiceRefBuilder jaxrpcBuilder = getJAXRCPBuilder();
View Full Code Here

                    try {

                        log.debug("processResource(): Does not exist in DD: " + resourceName);

                        // Doesn't exist in deployment descriptor -- add new
                        ServiceRefType serviceRef = annotatedApp.addNewServiceRef();

                        //------------------------------------------------------------------------------
                        // <service-ref> required elements:
                        //------------------------------------------------------------------------------

                        // service-ref-name
                        JndiNameType serviceRefName = serviceRef.addNewServiceRefName();
                        serviceRefName.setStringValue(resourceName);
                        serviceRef.setServiceRefName(serviceRefName);

                        // service-ref-interface
                        FullyQualifiedClassType serviceRefInterfaceClass = serviceRef.addNewServiceInterface();
                        serviceRefInterfaceClass.setStringValue(resourceType);
                        serviceRef.setServiceInterface(serviceRefInterfaceClass);

                        //------------------------------------------------------------------------------
                        // <service-ref> optional elements:
                        //------------------------------------------------------------------------------

                        // description
                        String descriptionAnnotation = annotation.description();
                        if (!descriptionAnnotation.equals("")) {
                            DescriptionType description = serviceRef.addNewDescription();
                            description.setStringValue(descriptionAnnotation);
                        }

                        // service-ref-type
                        if (!serviceRef.isSetServiceRefType()) {
                            FullyQualifiedClassType serviceRefTypeClass = serviceRef.addNewServiceRefType();
                            serviceRefTypeClass.setStringValue(resourceType);
                            serviceRef.setServiceRefType(serviceRefTypeClass);
                        }

                        // injectionTarget
                        if (method != null || field != null) {
                            InjectionTargetType injectionTarget = serviceRef.addNewInjectionTarget();
                            configureInjectionTarget(injectionTarget, method, field);
                        }
                       
                        // mappedName
                        if (!serviceRef.isSetMappedName() && annotation.mappedName().trim().length() > 0) {
                            XsdStringType mappedName = serviceRef.addNewMappedName();
                            mappedName.setStringValue(annotation.mappedName().trim());
                            serviceRef.setMappedName(mappedName);
                        }
                    }
                    catch (Exception anyException) {
                        log.debug("SwitchServiceRefBuilder: Exception caught while processing <service-ref>");
                    }
View Full Code Here

        //------------------------------------------------------------------------------------------
        // 1. <service-ref>
        //------------------------------------------------------------------------------------------

        ServiceRefType serviceRef = null;

        ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
        for (ServiceRefType currServiceRef : serviceRefs) {
            if (currServiceRef.getServiceRefName().getStringValue().trim().equals(webServiceRefName)) {
                serviceRef = currServiceRef;
                break;
            }
        }

        if (serviceRef == null) {
            // Doesn't exist in deployment descriptor -- add new
            serviceRef = annotatedApp.addNewServiceRef();

            // ------------------------------------------------------------------------------
            // <service-ref> required elements:
            // ------------------------------------------------------------------------------

            // service-ref-name
            JndiNameType serviceRefName = serviceRef.addNewServiceRefName();
            serviceRefName.setStringValue(webServiceRefName);
            serviceRef.setServiceRefName(serviceRefName);

            // service-ref-interface
            if (!webServiceRefValue.equals(Object.class)) {
                FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
                qualifiedClass.setStringValue(webServiceRefValue.getName());
                serviceRef.setServiceInterface(qualifiedClass);
            } else {
                FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
                qualifiedClass.setStringValue(webServiceRefType.getName());
                serviceRef.setServiceInterface(qualifiedClass);
            }
        }

        //------------------------------------------------------------------------------
        // <service-ref> optional elements:
        //------------------------------------------------------------------------------

        // service-ref-type
        if (!serviceRef.isSetServiceRefType() && !webServiceRefType.equals(Object.class)) {
            FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceRefType();
            qualifiedClass.setStringValue(webServiceRefType.getName());
            serviceRef.setServiceRefType(qualifiedClass);
        }

        // mapped-name
        if (!serviceRef.isSetMappedName() && annotation.mappedName().trim().length() > 0) {
            XsdStringType mappedName = serviceRef.addNewMappedName();
            mappedName.setStringValue(annotation.mappedName().trim());
            serviceRef.setMappedName(mappedName);
        }

        // WSDL document location
        if (!serviceRef.isSetWsdlFile()) {
            String wsdlLocation = annotation.wsdlLocation();

            if (wsdlLocation == null || wsdlLocation.trim().length() == 0) {
                WebServiceClient wsClient = null;
                if (Object.class.equals(webServiceRefValue)) {
                    wsClient = (WebServiceClient) webServiceRefType.getAnnotation(WebServiceClient.class);
                } else {
                    wsClient = (WebServiceClient) webServiceRefValue.getAnnotation(WebServiceClient.class);
                }
                if (wsClient == null) {
                    wsdlLocation = null;
                } else {
                    wsdlLocation = wsClient.wsdlLocation();
                }
            }

            if (wsdlLocation != null && wsdlLocation.trim().length() > 0) {
                XsdAnyURIType wsdlFile = serviceRef.addNewWsdlFile();
                wsdlFile.setStringValue(wsdlLocation);
                serviceRef.setWsdlFile(wsdlFile);
            }
        }

        // handler-chains
        if (!serviceRef.isSetHandlerChains()) {
            HandlerChain handlerChain = null;
            Class annotatedClass = null;
            if (method != null) {
                handlerChain = method.getAnnotation(HandlerChain.class);
                annotatedClass = method.getDeclaringClass();
            } else if (field != null) {
                handlerChain = field.getAnnotation(HandlerChain.class);
                annotatedClass = field.getDeclaringClass();
            }
           
            // if not specified on method or field, try to get it from Service class
            if (handlerChain == null) {
                if (Object.class.equals(webServiceRefValue)) {
                    handlerChain = (HandlerChain) webServiceRefType.getAnnotation(HandlerChain.class);
                    annotatedClass = webServiceRefType;
                } else {
                    handlerChain = (HandlerChain) webServiceRefValue.getAnnotation(HandlerChain.class);
                    annotatedClass = webServiceRefValue;
                }
            }
           
            if (handlerChain != null) {
                HandlerChainAnnotationHelper.insertHandlers(serviceRef, handlerChain, annotatedClass);
            }
        }
       
        if (method != null || field != null) {
            configureInjectionTarget(serviceRef.addNewInjectionTarget(), method, field);
        }

    }
View Full Code Here

        addPage(new ServiceRefWizardPage("Page0"));
    }

    @Override
    public boolean performFinish() {
        ServiceRefType serviceRef;
        if (element.getText().equals(elementTypes[SERVICE_REF])) {
            if (isEmpty(textList.get(0).getText())) {
                return false;
            }
            serviceRef = (ServiceRefType)eObject;
            if (serviceRef == null) {
                serviceRef = (ServiceRefType)getEFactory().create(ServiceRefType.class);
                JAXBElement plan = section.getPlan();
                JAXBModelUtils.getServiceRefs(plan).add(serviceRef);
            }
            serviceRef.setServiceRefName(textList.get(0).getText());
            if (isEmpty(textList.get(1).getText())) {
                serviceRef.setServiceCompletion(null);
            }
            else {
                ServiceCompletionType serviceComp = serviceRef.getServiceCompletion();
                if (serviceComp == null) {
                    serviceComp = (ServiceCompletionType)getEFactory().create(ServiceCompletionType.class);
                    serviceRef.setServiceCompletion(serviceComp);
                }
                serviceRef.getServiceCompletion().setServiceName(textList.get(1).getText());
            }
        }
        else if (element.getText().equals(elementTypes[PORT])) {
            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText())) {
                return false;
            }
            PortType port = (PortType)eObject;
            if (port == null) {
                port = (PortType)getEFactory().create(PortType.class);
                serviceRef = (ServiceRefType)section.getSelectedObject();
                serviceRef.getPort().add(port);
            }
            port.setPortName(textList.get(0).getText());
            port.setProtocol(textList.get(1).getText());
            port.setHost(textList.get(2).getText());
            port.setPort(Integer.valueOf(textList.get(3).getText()));
            port.setUri(textList.get(4).getText());
            port.setCredentialsName(textList.get(5).getText());
        }
        else if (element.getText().equals(elementTypes[PORT_COMPLETION])) {
            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText()) ||
                isEmpty(textList.get(6).getText())) {
                return false;
            }
            PortCompletionType portComp = (PortCompletionType)eObject;
            if (portComp == null) {
                portComp = (PortCompletionType)getEFactory().create(PortCompletionType.class);
                serviceRef = (ServiceRefType)section.getSelectedObject();
                serviceRef.getServiceCompletion().getPortCompletion().add(portComp);
                PortType port = (PortType)getEFactory().create(PortType.class);
                portComp.setPort (port);
            }
            portComp.getPort().setPortName(textList.get(0).getText());
            portComp.getPort().setProtocol(textList.get(1).getText());
View Full Code Here

        }

        protected void initControl () {
            if (eObject == null) {
                element.select(SERVICE_REF);
                ServiceRefType serviceRef = (ServiceRefType)section.getSelectedObject();
                // use of ports and port completions are mutually exclusive
                if (serviceRef == null) {
                    element.setEnabled(false);
                } else if (serviceRef.getServiceCompletion() == null) {
                    element.remove(PORT_COMPLETION);
                } else {
                    element.remove(PORT);
                }
            }
View Full Code Here

    public void removeItem(Object anItem) {
        if (ServiceRefType.class.isInstance(anItem)) {
            getObjectContainer().remove(anItem);
        }
        else if (PortType.class.isInstance(anItem)) {
          ServiceRefType serviceRef = (ServiceRefType)tree.getSelection()[0].getParentItem().getData();
            serviceRef.getPort().remove(anItem);
        }
        else if (PortCompletionType.class.isInstance(anItem)) {
          ServiceRefType serviceRef = (ServiceRefType)tree.getSelection()[0].getParentItem().getData();
            serviceRef.getServiceCompletion().getPortCompletion().remove(anItem);
        }
    }
View Full Code Here

            public Object[] getChildren(Object parentElement) {
                if (List.class.isInstance(parentElement)) {
                    return ((List)parentElement).toArray();
                }
                if (ServiceRefType.class.isInstance(parentElement)) {
                    ServiceRefType serviceRef = (ServiceRefType)parentElement;
                    Object[] portList = serviceRef.getPort().toArray();
                    Object[] compList = new Object[0];
                    if (serviceRef.getServiceCompletion() != null) {
                        compList = serviceRef.getServiceCompletion().getPortCompletion().toArray();
                    }
                    Object[] fullList = new Object[portList.length + compList.length];
                    System.arraycopy(portList, 0, fullList, 0, portList.length);
                    System.arraycopy(compList, 0, fullList, portList.length, compList.length);
                    return fullList;
View Full Code Here

    public ILabelProvider getLabelProvider() {
        return new LabelProvider() {
            @Override
            public String getText(Object element) {
                if (ServiceRefType.class.isInstance(element)) {
                  ServiceRefType serviceRef = (ServiceRefType)element;
                        String retString = "Service Ref: name = \"" + serviceRef.getServiceRefName() + "\"";
                        if (serviceRef.getServiceCompletion() != null) {
                            retString += ", service completion name = \"" + serviceRef.getServiceCompletion().getServiceName() + "\"";
                        }
                        return retString;
                }
                else if (PortType.class.isInstance(element)) {
                  PortType port = (PortType)element;
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.oejb2.ServiceRefType

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.