Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.BundleDescriptor$InjectionInfoCacheKey


     */

    public void setElementValue(XMLElement element, String value) {
        if (WebServicesTagNames.WEB_SERVICE_DESCRIPTION_NAME.equals
            (element.getQName())) {
            BundleDescriptor parent;
            if (getParentNode() instanceof WebBundleRuntimeNode) {
                parent = ((WebBundleRuntimeNode) getParentNode()).getWebBundleDescriptor();
            } else {
                parent = (BundleDescriptor) getParentNode().getDescriptor();
            }
            WebServicesDescriptor webServices = parent.getWebServices();
            descriptor = webServices.getWebServiceByName(value);
        } else if( WebServicesTagNames.CLIENT_WSDL_PUBLISH_URL.equals
                   (element.getQName()) ) {
            if( descriptor == null ) {
                DOLUtils.getDefaultLogger().info
View Full Code Here


        }
   
        // let's get the main annotation of interest.
        javax.xml.ws.WebServiceProvider ann = (javax.xml.ws.WebServiceProvider) annInfo.getAnnotation();       
       
        BundleDescriptor bundleDesc;
       
        // let's see the type of web service we are dealing with...
        if (annElem.getAnnotation(javax.ejb.Stateless.class)!=null) {
            // this is an ejb !
            EjbContext ctx = (EjbContext) annCtx;
            bundleDesc = ctx.getDescriptor().getEjbBundleDescriptor();
            bundleDesc.setSpecVersion("3.0");
        } else {
            // this has to be a servlet since there is no @Servlet annotation yet
            WebBundleContext ctx = (WebBundleContext)annCtx;
            bundleDesc = ctx.getDescriptor();
            bundleDesc.setSpecVersion("2.5");           
        }       

        // For WSProvider, portComponentName is the fully qualified class name
        String portComponentName = ((Class) annElem).getName();
       
        // As per JSR181, the serviceName is either specified in the deployment descriptor
        // or in @WebSErvice annotation in impl class; if neither service name implclass+Service
        String svcName  = ann.serviceName();
        if(svcName == null) {
            svcName = "";
        }

        // Store binding type specified in Impl class
        String userSpecifiedBinding = null;
        javax.xml.ws.BindingType bindingAnn = (javax.xml.ws.BindingType)
                ((Class)annElem).getAnnotation(javax.xml.ws.BindingType.class);
        if(bindingAnn != null) {
            userSpecifiedBinding = bindingAnn.value();
        }
       
        // In case user gives targetNameSpace in the Impl class, that has to be used as
        // the namespace for service, port; typically user will do this in cases where
        // port_types reside in a different namespace than that of server/port.
        // Store the targetNameSpace, if any, in the impl class for later use
        String targetNameSpace = ann.targetNamespace();
        if(targetNameSpace == null) {
            targetNameSpace = "";
        }

        String portName = ann.portName();
        if(portName == null) {
            portName = "";
        }
       
        // Check if the same endpoint is already defined in webservices.xml
        WebServicesDescriptor wsDesc = bundleDesc.getWebServices();
        WebServiceEndpoint endpoint = wsDesc.getEndpointByName(portComponentName);
        WebService newWS;
        if(endpoint == null) {
            // Check if a service with the same name is already present
            // If so, add this endpoint to the existing service
            if (svcName.length()!=0) {
                newWS = wsDesc.getWebServiceByName(svcName);
            } else {
                newWS = wsDesc.getWebServiceByName(((Class)annElem).getSimpleName()+"Service");
            }
            if(newWS==null) {
                newWS = new WebService();
                // service name from annotation
                if (svcName.length()!=0) {
                    newWS.setName(svcName);
                } else {
                    newWS.setName(((Class)annElem).getSimpleName()+"Service");           
                }
                wsDesc.addWebService(newWS);
            }
            endpoint = new WebServiceEndpoint();
            // port-component-name is fully qualified class name
            endpoint.setEndpointName(portComponentName);
            newWS.addEndpoint(endpoint);           
            wsDesc.setSpecVersion(com.sun.enterprise.deployment.node.WebServicesDescriptorNode.SPEC_VERSION);           
        } else {
            newWS = endpoint.getWebService();
        }

        // If wsdl-service is specified in the descriptor, then the targetnamespace
        // in wsdl-service should match the @WebService.targetNameSpace, if any.
        // make that assertion here - and the targetnamespace in wsdl-service, if
        // present overrides everything else
        if(endpoint.getWsdlService() != null) {
            if( (targetNameSpace != null) && (targetNameSpace.length() != 0 ) &&
                (!endpoint.getWsdlService().getNamespaceURI().equals(targetNameSpace)) ) {
                throw new AnnotationProcessorException(
                        "Target Namespace inwsdl-service element does not match @WebService.targetNamespace",
                        annInfo);
            }
            targetNameSpace = endpoint.getWsdlService().getNamespaceURI();
        }
       
        // Set binding id id @BindingType is specified by the user in the impl class
        if((!endpoint.hasUserSpecifiedProtocolBinding()) &&
                    (userSpecifiedBinding != null) &&
                        (userSpecifiedBinding.length() != 0)){
            endpoint.setProtocolBinding(userSpecifiedBinding);
        }       

        // Use annotated values only if the deployment descriptor equivalent has not been specified       
        if(newWS.getWsdlFileUri() == null) {
            // take wsdl location from annotation
            if (ann.wsdlLocation()!=null && ann.wsdlLocation().length()!=0) {
                newWS.setWsdlFileUri(ann.wsdlLocation());
            }
        }

        annElem = annInfo.getAnnotatedElement();
       
        // we checked that the endpoint implements the provider interface above
        Class clz = (Class) annElem;
        Class serviceEndpointIntf = null;
        for (Class intf : clz.getInterfaces()) {
            if (javax.xml.ws.Provider.class.isAssignableFrom(intf)) {
                serviceEndpointIntf = intf;
                break;
            }
        }
        if (serviceEndpointIntf==null) {
            endpoint.setServiceEndpointInterface("javax.xml.ws.Provider");
        } else {
            endpoint.setServiceEndpointInterface(serviceEndpointIntf.getName());
        }

        if (ModuleType.WAR.equals(bundleDesc.getModuleType())) {
            if(endpoint.getServletImplClass() == null) {
                // Set servlet impl class here
                endpoint.setServletImplClass(((Class)annElem).getName());
            }
View Full Code Here

        } else if(parentDesc instanceof WebServiceEndpoint) {
            descriptor.setWebServiceEndpoint((WebServiceEndpoint)parentDesc);
        }

        // Get the bundle descriptor of which this belongs
        BundleDescriptor bundleDesc = null;
        parentNode = parentNode.getParentNode().getParentNode();
        if (parentNode instanceof WebBundleRuntimeNode) {
            // In the cases of used in
            // 1. webservice-endpoint for web component
            // 2. port-info for web component
View Full Code Here

            InputStream wsdlFileInputStream = archive_.getEntry(wsdlFileUri);

            if( wsdlFileInputStream != null ) {
               
                wsdlFileInputStream.close();
                BundleDescriptor bundle = webService.getBundleDescriptor();
                if( !isWsdlContent(wsdlFileUri, bundle) ) {
                    String msg = localStrings.getLocalString(
                        "enterprise.deployment.util.wsdlpackagedinwrongservicelocation",
                        "wsdl file {0} for web service {1} must be packaged in or below {2}",
                        new Object[] {wsdlFileUri, webService.getName(), bundle.getWsdlDir()});
                    DOLUtils.getDefaultLogger().severe(msg);
                    throw new RuntimeException(msg);                 
                }
            } else {
                // let's look in the wsdl directory
View Full Code Here

                    if( numMatches == 1 ) {
                        Iterator iter = intfInfo.ejbs.iterator();

                        EjbDescriptor target = (EjbDescriptor)iter.next();

                        BundleDescriptor targetModule =
                            target.getEjbBundleDescriptor();
                        BundleDescriptor sourceModule =
                            ejbRef.getReferringBundleDescriptor();

                        //
                        // It's much cleaner to derive the ejb-link value
                        // and set that instead of the descriptor.  This way,
                        // if there are multiple ejb-jars within the .ear that
                        // each have an ejb with the target bean's ejb-name,
                        // there won't be any ambiguity about which one is
                        // the correct target.  It's not so much a problem
                        // during this phase of the processing, but if the
                        // fully-qualified ejb-link name is required and is not
                        // written out, there could be non-deterministic
                        // behavior when the application is re-loaded.
                        // Let the ejb-link processing logic handle the
                        // conversion to ejb descriptor.
                        //

                        // If the ejb reference and the target ejb are defined
                        // within the same ejb-jar, the ejb-link will only
                        // be set to ejb-name.  This is done regardless of
                        // whether the ejb-jar is within an .ear or is
                        // stand-alone.  The ejb-link processing
                        // logic will always check the current ejb-jar
                        // first so there won't be any ambiguity. 
                        String ejbLinkName = target.getName();
                        if( sourceModule != targetModule ) {

                            // Since there are at least two modules, we
                            // must be within an application.
                            String relativeUri = getApplication().
                                getRelativeUri(sourceModule, targetModule);
                            ejbLinkName = relativeUri + "#" + ejbLinkName;
                        }

                        ejbRef.setLinkName(ejbLinkName);

                    } else {
                        String msg = "Cannot resolve reference " + ejbRef +
                            " because there are " + numMatches + " ejbs " +
                            " in the application with interface " +
                            interfaceToMatch;

                        DOLUtils.getDefaultLogger().severe(msg);
                        throw new RuntimeException(msg);
                    }
                }                         
            }
        }

        // now all cases fall back here, we need to resolve through the link-name   
        if (ejbRef.getLinkName()==null) {


            // if no link name if present, and this is a local ref, this is always an
            // error because we must resolve all local refs and we cannot resolve it
            // throw either the jndi name or the link name
            if (ejbRef.isLocal()) {
                DOLUtils.getDefaultLogger().severe("Cannot resolve reference " + ejbRef);
                throw new RuntimeException("Cannot resolve reference " + ejbRef);
            } else {
                // this is a remote interface, jndi will eventually contain the referenced
                // ejb ref, apply default jndi name if there is none
                if (ejbRef.getJndiName() == null ||
                        ejbRef.getJndiName().length() == 0) {
                    String jndiName = getDefaultEjbJndiName(
                        ejbRef.isEJB30ClientView() ?
                        ejbRef.getEjbInterface() : ejbRef.getEjbHomeInterface());
                    ejbRef.setJndiName(jndiName);
                    DOLUtils.getDefaultLogger().fine("Applying default to ejb reference: " + ejbRef);
                }

                return;
            }                         
        }       
       
        // Beginning of ejb-link resolution
       
        // save anticipated types for checking if interfaces are compatible
        String homeClassName = ejbRef.getEjbHomeInterface();
        String intfClassName = ejbRef.getEjbInterface();

        // save anticipated type for checking if bean type is compatible
        String type = ejbRef.getType();
       
        EjbDescriptor ejbReferee=null;
           
        String linkName = ejbRef.getLinkName();
        int ind = linkName.lastIndexOf('#');
        if ( ind != -1 ) {
            // link has a relative path from referring EJB JAR,
            // of form "../products/product.jar#ProductEJB"
            String ejbName = linkName.substring(ind+1);
            String jarPath = linkName.substring(0, ind);           
            BundleDescriptor referringJar = ejbRef.getReferringBundleDescriptor();
            if (referringJar==null) {
                ejbRef.setReferringBundleDescriptor(getBundleDescriptor());
                referringJar = getBundleDescriptor();
            }          
           
            if (getApplication()!=null) {              
                BundleDescriptor refereeJar =
                    getApplication().getRelativeBundle(referringJar, jarPath);
                if( (refereeJar != null) &&
                    refereeJar instanceof EjbBundleDescriptor ) {
                    // this will throw an exception if ejb is not found
                    ejbReferee =
                       ((EjbBundleDescriptor)refereeJar).getEjbByName(ejbName);
                }
            }
        }
        else {

            // Handle an unqualified ejb-link, which is just an ejb-name.

            // If we're in an application and currently processing an
            // ejb-reference defined within an ejb-jar, first check
            // the current ejb-jar for an ejb-name match.  From a spec
            // perspective, the deployer can't depend on this behavior,
            // but it's still better to have deterministic results.  In
            // addition, in the case of automatic-linking, the fully-qualified
            // "#" ejb-link syntax is not used when the ejb reference and
            // target ejb are within the same ejb-jar.  Checking the
            // ejb-jar first will ensure the correct linking behavior for
            // that case.
            if ( (getApplication() != null) && (ejbBundleDescriptor != null)
                 && ejbBundleDescriptor.hasEjbByName(linkName) ) {

                ejbReferee = ejbBundleDescriptor.getEjbByName(linkName);

            } else if ( (getApplication() != null&&
                        getApplication().hasEjbByName(linkName)) {
               
                ejbReferee =
                    getApplication().getEjbByName(ejbRef.getLinkName());
                   
            } else if (ejb!=null) {
                try {
                    ejbReferee = ejb.getEjbBundleDescriptor().getEjbByName(ejbRef.getLinkName());
                } catch (IllegalArgumentException e) {
                    // this may happen when we have no application and the ejb ref
                    // cannot be resolved to a ejb in the bundle. The ref will
                    // probably be resolved when the application is assembled.
                    DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: "+linkName);
                    return;
                }
                   
            }
        }

        if (ejbReferee==null)
        { 

            // we could not resolve through the ejb-link. if this is a local ref, this
            // is an error, if this is a remote ref, this should be also an error at
            // runtime but maybe the jndi name will be specified by deployer so
            // a warning should suffice
            if (ejbRef.isLocal()) {
                DOLUtils.getDefaultLogger().severe("Unresolved <ejb-link>: "+linkName);
                throw new RuntimeException("Error: Unresolved <ejb-link>: "+linkName);
            } else {
                DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: "+linkName);
                return;
            }
        } else {

            if( ejbRef.isEJB30ClientView() ) {

                BundleDescriptor referringBundle =
                    ejbRef.getReferringBundleDescriptor();

                // If we can verify that the current ejb 3.0 reference is defined
                // in any Application Client module or in a stand-alone web module
                // it must be remote business.
View Full Code Here

    public void createWSEndpointMBean(String ctxRoot,
     WebServiceEndpoint wsDescriptor,
        String serverName) throws MBeanException {


        BundleDescriptor bd = wsDescriptor.getBundleDescriptor();
        boolean isEjb = false;

        if ( bd instanceof EjbBundleDescriptor) {
            isEjb = true;
        }

        String epName = wsDescriptor.getEndpointName();
        String appName =  getApplicationName(bd);
        String regName = bd.getApplication().getRegistrationName();
        String moduleName = getModuleName(bd);

        if (ctxRoot != null ) {
            ServletWebServiceEndpointMdl managedResource =
                new ServletWebServiceEndpointMdl(epName, moduleName, regName,
                    serverName, bd.getApplication().isVirtual(), isEjb);
            String cRoot = null;
            if (( ctxRoot.length() > 0) && (ctxRoot.charAt(0) != '/')){
                cRoot = "/" + ctxRoot;
            } else {
                cRoot = ctxRoot;
            }
            instantiateAndRegisterRuntimeMBean(managedResource.getMBeanName(),
             managedResource, appName, WebModuleSupport.VIRTUAL_SERVER_PREFIX
             + DEFAULT_VIRTUAL_SERVER + cRoot, epName);
        } else {
            EJBWebServiceEndpointMdl managedResource =
            new EJBWebServiceEndpointMdl(epName, moduleName,regName, serverName,
             bd.getApplication().isVirtual(),isEjb);
            instantiateAndRegisterRuntimeMBean(managedResource.getMBeanName(),
            managedResource, appName, moduleName, epName);
        }
    }
View Full Code Here

    public void deleteWSEndpointMBean(String ctxRoot,
        WebServiceEndpoint wsDescriptor, String serverName)
        throws MBeanException {

        String epName = wsDescriptor.getEndpointName();
        BundleDescriptor bd = wsDescriptor.getBundleDescriptor();

        String moduleName = getModuleName(bd);
        String appName = getApplicationName(bd);

        try {
View Full Code Here

     * 2. For enterprise-app.ear |__ ejb.jar
     *                           |__ web.war
     *  applicationName will be 'web.war'
     */
    private void setApplicationName(WebServiceEndpoint endpointDesc) {
        BundleDescriptor bundleDescriptor = endpointDesc.getBundleDescriptor();
        this.applicationName =
                (bundleDescriptor.getModuleDescriptor().isStandalone())?
                        bundleDescriptor.getApplication().getRegistrationName():
                        bundleDescriptor.getModuleDescriptor().getArchiveUri();
    }
View Full Code Here

     * Related Issue: 6519371.
     */
    private void createEndpoint(WebServiceEndpoint endpoint,
                                DescriptorEndpointInfo ep) throws Exception {
       
        BundleDescriptor bundledesc = endpoint.getBundleDescriptor();
        ClassLoader cl = bundledesc.getClassLoader();
        // set the app classloader to be used while creating the WSEndpoint
        ClassLoader origCl = Utility.setContextClassLoader(cl);
        try {
            WsUtil wsu = new WsUtil();
            Class serviceEndpointClass =
                    Class.forName(endpoint.getServletImplClass(), true, cl);
            // Get the proper binding using BindingID
            String givenBinding = endpoint.getProtocolBinding();

            // Get list of all wsdls and schema
            SDDocumentSource primaryWsdl = null;
            Collection docs = null;
            if(endpoint.getWebService().hasWsdlFile()) {
                BaseManager mgr;
                if(bundledesc.getApplication().isVirtual()) {
                    mgr = DeploymentServiceUtils.getInstanceManager(DeployableObjectType.WEB);
                } else {
                    mgr = DeploymentServiceUtils.getInstanceManager(DeployableObjectType.APP);
                }
                String deployedDir =
                    mgr.getLocation(bundledesc.getApplication().getRegistrationName());
                File pkgedWsdl;
                if(deployedDir != null) {
                    if(bundledesc.getApplication().isVirtual()) {
                        pkgedWsdl = new File(deployedDir+File.separator+
                                    endpoint.getWebService().getWsdlFileUri());
                    } else {
                        pkgedWsdl = new File(deployedDir+File.separator+
                                bundledesc.getModuleDescriptor().getArchiveUri().replaceAll("\\.", "_") +
                                File.separator + endpoint.getWebService().getWsdlFileUri());
                    }
                } else {
                    pkgedWsdl = new File(endpoint.getWebService().getWsdlFileUrl().getFile());
                }
                if(pkgedWsdl.exists()) {
                    primaryWsdl = SDDocumentSource.create(pkgedWsdl.toURL());
                    docs = wsu.getWsdlsAndSchemas(pkgedWsdl);
                }
            }

            // Get catalog info
            java.net.URL catalogURL = null;
            File catalogFile = new File(bundledesc.getDeploymentDescriptorDir() +
                    File.separator + "jax-ws-catalog.xml");
            if(catalogFile.exists()) {
                catalogURL = catalogFile.toURL();
            }

View Full Code Here

                DeploymentUtils.getDescriptor(standaloneModuleName, am);

            // Get the bundle descriptor for the given module
            // and determine its' type

            BundleDescriptor bd = null;
            java.util.Set bds = appD.getBundleDescriptors();
            for(Iterator it=bds.iterator(); it.hasNext(); ) {
                bd = (BundleDescriptor)it.next();
                if ((bd.getModuleDescriptor().getArchiveUri()).equals(subModuleName) ||
                     bd.getModuleID().equals(subModuleName) ||
         bd.getName().equals(subModuleName)) {
                        moduleType = bd.getModuleType();
      // set dd location
      ddLocation = am.getLocation(standaloneModuleName) +
        File.separator +
        FileUtils.makeFriendlyFileName(
          bd.getModuleDescriptor().getArchiveUri());
      break;
                }
            }

        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.BundleDescriptor$InjectionInfoCacheKey

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.