private void linkServiceRefs(
     DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx)
     throws NamingException {
   if (unit instanceof VFSDeploymentUnit) {
     VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
     ClassLoader loader = unit.getClassLoader();
     UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot());
     for (ServiceReferenceMetaData sref : serviceRefs) {
       String refName = sref.getServiceRefName();
       new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
     }
   }
 }
Example #2
0
 private static UnifiedServiceRefMetaData getServiceRef(
     final DeploymentUnit unit, 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);
   wsRefRegistry.add(serviceRefMD.getName(), serviceRefUMDM);
   return serviceRefUMDM;
 }
  protected ServiceReferenceMetaData createServiceRef(WebServiceRef annotation, E element) {
    ServiceReferenceMetaData ref = new ServiceReferenceMetaData();
    String name = annotation.name();
    if (name.length() == 0) name = getName(element);
    ref.setServiceRefName(name);
    if (annotation.mappedName().length() > 0) ref.setMappedName(annotation.mappedName());
    ref.setAnnotatedElement(element);
    if (annotation.wsdlLocation().length() > 0) ref.setWsdlFile(annotation.wsdlLocation());
    if (annotation.type() != Object.class) {
      ref.setServiceRefType(annotation.type().getName());
    } else ref.setServiceRefType(getType(element));

    if (annotation.value() != Service.class) {
      ref.setServiceInterface(annotation.value().getName());
    } else if (element instanceof Field) {
      final Class<?> targetClass = ((Field) element).getType();
      if (Service.class.isAssignableFrom(targetClass))
        ref.setServiceInterface(targetClass.getName());
    } else if (element instanceof Method) {
      final Class<?> targetClass = ((Method) element).getParameterTypes()[0];
      if (Service.class.isAssignableFrom(targetClass))
        ref.setServiceInterface(targetClass.getName());
    } else {
      ref.setServiceInterface(Service.class.getName());
    }

    String injectionName = getInjectionName(element);
    Set<ResourceInjectionTargetMetaData> injectionTargets =
        ProcessorUtils.getInjectionTargets(injectionName, element);
    if (injectionTargets != null) ref.setInjectionTargets(injectionTargets);

    return ref;
  }
 /**
  * Constructs a {@link ServiceRefMetadataImpl} from a {@link ServiceReferenceMetaData}
  *
  * @param serviceRef
  * @throws NullPointerException If the passed <code>serviceRef</code> is null
  */
 public ServiceRefMetadataImpl(ServiceReferenceMetaData serviceRef) {
   super(serviceRef.getId());
   this.initialize(serviceRef);
 }