Package org.jboss.wsf.spi.metadata.j2ee.serviceref

Examples of org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData


    * when rebuild is called (actually getPort(...))
    * @param epMetaData
    */
   private void bufferServiceRefContributions(EndpointMetaData epMetaData)
   {
      UnifiedServiceRefMetaData serviceRefMetaData = ServiceObjectFactoryJAXWS.getServiceRefAssociation();

      if(serviceRefMetaData!=null)
      {
         for(UnifiedPortComponentRefMetaData portComp : serviceRefMetaData.getPortComponentRefs())
         {
            epMetaData.getServiceRefContrib().add(portComp);
         }
      }
   }
View Full Code Here


    * when rebuild is called (actually getPort(...))
    * @param epMetaData
    */
   private void bufferServiceRefContributions(EndpointMetaData epMetaData)
   {
      UnifiedServiceRefMetaData serviceRefMetaData = ServiceObjectFactoryJAXWS.getServiceRefAssociation();

      if(serviceRefMetaData!=null)
      {
         for(UnifiedPortComponentRefMetaData portComp : serviceRefMetaData.getPortComponentRefs())
         {
            epMetaData.getServiceRefContrib().add(portComp);
         }
      }
   }
View Full Code Here

      try
      {
         Reference ref = (Reference)obj;

         // Unmarshall the ServiceRefMetaData
         UnifiedServiceRefMetaData serviceRef = null;
         RefAddr metaRefAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
         ByteArrayInputStream bais = new ByteArrayInputStream((byte[])metaRefAddr.getContent());
         try
         {
            ObjectInputStream ois = new ObjectInputStream(bais);
            serviceRef = (UnifiedServiceRefMetaData)ois.readObject();
            ois.close();
         }
         catch (IOException ex)
         {
            NamingException ne = new NamingException("Cannot unmarshall service ref meta data");
            ne.setRootCause(ex);
            throw ne;
         }

         // Unmarshall the WSSecurityConfiguration
         WSSecurityConfiguration securityConfig = null;
         RefAddr wsseRefAddr = ref.get(ServiceReferenceable.SECURITY_CONFIG);
         if (wsseRefAddr != null)
         {
            bais = new ByteArrayInputStream((byte[])wsseRefAddr.getContent());
            try
            {
               ObjectInputStream ois = new ObjectInputStream(bais);
               securityConfig = (WSSecurityConfiguration)ois.readObject();
               ois.close();
            }
            catch (IOException e)
            {
               throw new NamingException("Cannot unmarshall security config, cause: " + e.toString());
            }
         }

         ServiceImpl jaxrpcService = null;
         URL wsdlLocation = serviceRef.getWsdlLocation();
         if (wsdlLocation != null)
         {
            if (log.isDebugEnabled())
               log.debug("Create jaxrpc service from wsdl");

            // Create the actual service object
            QName serviceName = serviceRef.getServiceQName();
            JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
            jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping, securityConfig, serviceRef);
         }
         else
         {
            if (log.isDebugEnabled())
               log.debug("Create jaxrpc service with no wsdl");
            jaxrpcService = new ServiceImpl(new QName(Constants.NS_JBOSSWS_URI, "AnonymousService"));
         }

         ServiceMetaData serviceMetaData = jaxrpcService.getServiceMetaData();

         // Set any service level properties
         if (serviceRef.getCallProperties().size() > 0)
         {
            Properties callProps = new Properties();
            serviceMetaData.setProperties(callProps);
            for (UnifiedCallPropertyMetaData prop : serviceRef.getCallProperties())
               callProps.setProperty(prop.getPropName(), prop.getPropValue());
         }

         // The web service client using a port-component-link, the contet is the URL to
         // the PortComponentLinkServlet that will return the actual endpoint address
         RefAddr pcLinkRef = ref.get(ServiceReferenceable.PORT_COMPONENT_LINK);
         if (pcLinkRef != null)
         {
            String pcLink = (String)pcLinkRef.getContent();
            log.debug("Resolving port-component-link: " + pcLink);

            // First try to obtain the endpoint address loacally
            String endpointAddress = null;
            try
            {
               SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
               EndpointRegistry epRegistry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
               Endpoint endpoint = epRegistry.resolve( new PortComponentResolver(pcLink) );
               if (endpoint == null)
                  throw new WSException("Cannot resolve port-component-link: " + pcLink);

               ServerEndpointMetaData sepMetaData = endpoint.getAttachment(ServerEndpointMetaData.class);
               endpointAddress = sepMetaData.getEndpointAddress();
            }
            catch (Throwable ex)
            {
               // ignore, we are probably a remote client
            }

            // We may be remote in the esoteric case where an appclient uses the port-comonent-link feature
            if (endpointAddress == null)
            {
               String servletPath = (String)ref.get(ServiceReferenceable.PORT_COMPONENT_LINK_SERVLET).getContent();
               servletPath += "?pcLink=" + URLEncoder.encode(pcLink, "UTF-8");
               InputStream is = new URL(servletPath).openStream();
               BufferedReader br = new BufferedReader(new InputStreamReader(is));
               endpointAddress = br.readLine();
               is.close();
            }

            if (log.isDebugEnabled())
               log.debug("Resolved to: " + endpointAddress);
            if (serviceMetaData.getEndpoints().size() == 1)
            {
               EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
               epMetaData.setEndpointAddress(endpointAddress);
            }
            else
            {
               log.warn("Cannot set endpoint address for port-component-link, unsuported number of endpoints");
            }
         }

         narrowPortSelection(serviceRef, serviceMetaData);

         /********************************************************
          * Setup the Proxy that implements the service-interface
          ********************************************************/

         // load the service interface class
         ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
         Class siClass = contextCL.loadClass(serviceRef.getServiceInterface());
         if (Service.class.isAssignableFrom(siClass) == false)
            throw new JAXRPCException("The service interface does not implement javax.xml.rpc.Service: " + siClass.getName());

         // load all service endpoint interface classes
         for (UnifiedPortComponentRefMetaData pcr : serviceRef.getPortComponentRefs())
         {
            Class seiClass = contextCL.loadClass(pcr.getServiceEndpointInterface());
            if (Remote.class.isAssignableFrom(seiClass) == false)
               throw new IllegalArgumentException("The SEI does not implement java.rmi.Remote: " + seiClass.getName());
         }
View Full Code Here

         // Get the target class name
         String targetClassName = (String)ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();

         // Unmarshall the UnifiedServiceRef
         UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
         String serviceRefName = serviceRef.getServiceRefName();
         QName serviceQName = serviceRef.getServiceQName();

         String serviceImplClass = serviceRef.getServiceImplClass();
         if (serviceImplClass == null)
            serviceImplClass = (String)ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();

         // If the target defaults to javax.xml.ws.Service, use the service as the target
         if (Service.class.getName().equals(targetClassName))
            targetClassName = serviceImplClass;
        
         log.debug("[name=" + serviceRefName + ",service=" + serviceImplClass + ",target=" + targetClassName + "]");

         // Load the service class
         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
         Class serviceClass = ctxLoader.loadClass(serviceImplClass);
         Class targetClass = (targetClassName != null ? ctxLoader.loadClass(targetClassName) : null);

         if (Service.class.isAssignableFrom(serviceClass) == false)
            throw new IllegalArgumentException("WebServiceRef type '" + serviceClass + "' is not assignable to javax.xml.ws.Service");
        
         log.debug("Loaded Service '" + serviceClass.getName() + "' from: " + serviceClass.getProtectionDomain().getCodeSource());

         // Receives either a javax.xml.ws.Service or a dynamic proxy
         Object target;

         // Get the URL to the wsdl
         URL wsdlURL = serviceRef.getWsdlLocation();
         try
         {
            // Associate the ServiceRefMetaData with this thread
            serviceRefAssociation.set(serviceRef);
View Full Code Here

      }
   }

   private UnifiedServiceRefMetaData unmarshallServiceRef(Reference ref) throws ClassNotFoundException, NamingException
   {
      UnifiedServiceRefMetaData sref;
      RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
      ByteArrayInputStream bais = new ByteArrayInputStream((byte[])refAddr.getContent());
      try
      {
         ObjectInputStream ois = new ObjectInputStream(bais);
View Full Code Here

      try
      {
         Reference ref = (Reference)obj;

         // Unmarshall the ServiceRefMetaData
         UnifiedServiceRefMetaData serviceRef = null;
         RefAddr metaRefAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
         ByteArrayInputStream bais = new ByteArrayInputStream((byte[])metaRefAddr.getContent());
         try
         {
            ObjectInputStream ois = new ObjectInputStream(bais);
            serviceRef = (UnifiedServiceRefMetaData)ois.readObject();
            ois.close();
         }
         catch (IOException ex)
         {
            NamingException ne = new NamingException("Cannot unmarshall service ref meta data");
            ne.setRootCause(ex);
            throw ne;
         }

         // Unmarshall the WSSecurityConfiguration
         WSSecurityConfiguration securityConfig = null;
         RefAddr wsseRefAddr = ref.get(ServiceReferenceable.SECURITY_CONFIG);
         if (wsseRefAddr != null)
         {
            bais = new ByteArrayInputStream((byte[])wsseRefAddr.getContent());
            try
            {
               ObjectInputStream ois = new ObjectInputStream(bais);
               securityConfig = (WSSecurityConfiguration)ois.readObject();
               ois.close();
            }
            catch (IOException e)
            {
               throw new NamingException("Cannot unmarshall security config, cause: " + e.toString());
            }
         }

         ServiceImpl jaxrpcService = null;
         URL wsdlLocation = serviceRef.getWsdlLocation();
         if (wsdlLocation != null)
         {
            if (log.isDebugEnabled())
               log.debug("Create jaxrpc service from wsdl");

            // Create the actual service object
            QName serviceName = serviceRef.getServiceQName();
            JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
            jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping, securityConfig, serviceRef);
         }
         else
         {
            if (log.isDebugEnabled())
               log.debug("Create jaxrpc service with no wsdl");
            jaxrpcService = new ServiceImpl(new QName(Constants.NS_JBOSSWS_URI, "AnonymousService"));
         }

         ServiceMetaData serviceMetaData = jaxrpcService.getServiceMetaData();

         // Set any service level properties
         if (serviceRef.getCallProperties().size() > 0)
         {
            Properties callProps = new Properties();
            serviceMetaData.setProperties(callProps);
            for (UnifiedCallPropertyMetaData prop : serviceRef.getCallProperties())
               callProps.setProperty(prop.getPropName(), prop.getPropValue());
         }

         // The web service client using a port-component-link, the contet is the URL to
         // the PortComponentLinkServlet that will return the actual endpoint address
         RefAddr pcLinkRef = ref.get(ServiceReferenceable.PORT_COMPONENT_LINK);
         if (pcLinkRef != null)
         {
            String pcLink = (String)pcLinkRef.getContent();
            log.debug("Resolving port-component-link: " + pcLink);

            // First try to obtain the endpoint address loacally
            String endpointAddress = null;
            try
            {
               SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
               EndpointRegistry epRegistry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
               Endpoint endpoint = epRegistry.resolve( new PortComponentResolver(pcLink) );
               if (endpoint == null)
                  throw new WSException("Cannot resolve port-component-link: " + pcLink);

               ServerEndpointMetaData sepMetaData = endpoint.getAttachment(ServerEndpointMetaData.class);
               endpointAddress = sepMetaData.getEndpointAddress();
            }
            catch (Throwable ex)
            {
               // ignore, we are probably a remote client
            }

            // We may be remote in the esoteric case where an appclient uses the port-comonent-link feature
            if (endpointAddress == null)
            {
               String servletPath = (String)ref.get(ServiceReferenceable.PORT_COMPONENT_LINK_SERVLET).getContent();
               servletPath += "?pcLink=" + URLEncoder.encode(pcLink, "UTF-8");
               InputStream is = new URL(servletPath).openStream();
               BufferedReader br = new BufferedReader(new InputStreamReader(is));
               endpointAddress = br.readLine();
               br.close();
               is.close();
            }

            if (log.isDebugEnabled())
               log.debug("Resolved to: " + endpointAddress);
            if (serviceMetaData.getEndpoints().size() == 1)
            {
               EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
               epMetaData.setEndpointAddress(endpointAddress);
            }
            else
            {
               log.warn("Cannot set endpoint address for port-component-link, unsuported number of endpoints");
            }
         }

         narrowPortSelection(serviceRef, serviceMetaData);

         /********************************************************
          * Setup the Proxy that implements the service-interface
          ********************************************************/

         // load the service interface class
         ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
         Class siClass = contextCL.loadClass(serviceRef.getServiceInterface());
         if (Service.class.isAssignableFrom(siClass) == false)
            throw new JAXRPCException("The service interface does not implement javax.xml.rpc.Service: " + siClass.getName());

         // load all service endpoint interface classes
         for (UnifiedPortComponentRefMetaData pcr : serviceRef.getPortComponentRefs())
         {
            String seiName = pcr.getServiceEndpointInterface();
            if (seiName != null)
            {
               Class seiClass = contextCL.loadClass(seiName);
View Full Code Here

            }
        });
    }

    private UnifiedServiceRefMetaData getServiceReference(final DeploymentUnit deploymentUnit, final String name, final String type, final String value, final String wsdlLocation) {
        final UnifiedServiceRefMetaData reference = new UnifiedServiceRefMetaData(getUnifiedVirtualFile(deploymentUnit));
        reference.setServiceRefName(name);
        // TODO handle mappedName

        if (wsdlLocation != null && wsdlLocation.length() > 0) {
            reference.setWsdlFile(wsdlLocation);
        }
        reference.setServiceRefType(type);
        reference.setServiceInterface(value);

        final boolean isJAXRPC = reference.getMappingFile() != null // TODO: is mappingFile check required?
                || "javax.xml.rpc.Service".equals(reference.getServiceInterface());
        reference.setType(isJAXRPC ? ServiceRefHandler.Type.JAXRPC : ServiceRefHandler.Type.JAXWS);
        return reference;
    }
View Full Code Here

    private <E extends AnnotationTarget> BindingDescription  processWebServiceRef(
            final AbstractWebServiceRefAnnotation<E> processor, final AnnotationInstance annotation,
            final E annotated, final UnifiedVirtualFile vfs, final Module duModule, final String name,
            final String className, final AbstractComponentDescription componentDescription) {
        UnifiedServiceRefMetaData ref = processor.process(annotation, annotated, vfs);
        // FIXME SPIProviderResolver won't require a TCCL in the future
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        final Referenceable referenceable;
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
            final ServiceRefHandler serviceRefHandler = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
            referenceable = serviceRefHandler.createReferenceable(ref);
        } finally {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
        }
        // setup binding description
        BindingDescription bindingDescription = new BindingDescription(processor.getName(annotated), componentDescription);
        bindingDescription.setDependency(true);
        bindingDescription.setBindingType(ref.getServiceRefType());
        bindingDescription.setReferenceSourceDescription(new WebServiceRefSourceDescription(referenceable, duModule));
        //setup injection target description
        final InjectionTargetDescription targetDescription = new InjectionTargetDescription();
        targetDescription.setName(name);
        targetDescription.setClassName(className);
        targetDescription.setType(processor.getInjectionType());
        targetDescription.setValueClassName(ref.getServiceRefType());
        bindingDescription.getInjectionTargetDescriptions().add(targetDescription);

        return bindingDescription;
    }
View Full Code Here

            return Collections.<BindingConfiguration> emptyList();
        }

        final List<BindingConfiguration> bindingDescriptions = new LinkedList<BindingConfiguration>();
        for (final ServiceReferenceMetaData serviceRefMD : serviceRefsMD) {
            final UnifiedServiceRefMetaData serviceRefUMDM = getServiceRef(unit, componentDescription, serviceRefMD);
            final WSRefValueSource valueSource = new WSRefValueSource(serviceRefUMDM);
            final BindingConfiguration bindingConfiguration = new BindingConfiguration(serviceRefUMDM.getServiceRefName(), valueSource);
            bindingDescriptions.add(bindingConfiguration);
            final String serviceRefTypeName = serviceRefUMDM.getServiceRefType();
            final Class<?> serviceRefType = getClass(classLoader, serviceRefTypeName);
            processInjectionTargets(resourceInjectionTarget, valueSource, classLoader, deploymentReflectionIndex, serviceRefMD, serviceRefType);
        }
        return bindingDescriptions;
    }
View Full Code Here

        return bindingDescriptions;
    }

    private static UnifiedServiceRefMetaData getServiceRef(final DeploymentUnit unit, final ComponentDescription componentDescription, final ServiceReferenceMetaData serviceRefMD) throws DeploymentUnitProcessingException {
        // construct service ref
        final UnifiedServiceRefMetaData serviceRefUMDM = new UnifiedServiceRefMetaData(getUnifiedVirtualFile(unit));
        translate(serviceRefMD, serviceRefUMDM);
        processWSFeatures(unit, serviceRefMD.getInjectionTargets(), serviceRefUMDM);
        // register it
        final WSReferences wsRefRegistry = getWSRefRegistry(unit);
        final String cacheKey = getCacheKey(componentDescription, serviceRefUMDM);
View Full Code Here

TOP

Related Classes of org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData

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.