FileDocCategorySizeDatePackage
WebServiceRefHandler.javaAPI DocJBoss 4.2.15502Fri Jul 13 20:53:46 BST 2007org.jboss.injection

WebServiceRefHandler

public class WebServiceRefHandler extends Object implements InjectionHandler
Handle @WebServiceRef annotations
author
Thomas.Diesler@jboss.com

Fields Summary
private static final Logger
log
private Map
srefMap
Constructors Summary
Methods Summary
private voidbindRefOnType(java.lang.Class type, InjectionContainer container, javax.xml.ws.WebServiceRef wsref)

      String name = wsref.name();
      if (name.equals(""))
         name = InjectionUtil.getEncName(type).substring(4);
      
      if (!container.getEncInjectors().containsKey(name))
      {
         String encName = "env/" + name;
         ServiceRefMetaData sref = getServiceRefForName(name);
         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
      }
   
private org.jboss.ws.integration.ServiceRefMetaDatagetServiceRefForName(java.lang.String name)

      ServiceRefMetaData sref = srefMap.get(name);
      if (sref == null)
      {
         log.debug("No override for @WebServiceRef.name: " + name);
         sref = new ServiceRefDelegate().newServiceRefMetaData();
         sref.setServiceRefName(name);
      }
      return sref;
   
public voidhandleClassAnnotations(java.lang.Class type, InjectionContainer container)

      WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
      if (wsref != null)
      {
         bindRefOnType(type, container, wsref);
      }

      WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
      if (refs != null)
      {
         for (WebServiceRef refItem : refs.value())
         {
            bindRefOnType(type, container, refItem);
         }
      }
   
public voidhandleFieldAnnotations(java.lang.reflect.Field field, InjectionContainer container, java.util.Map injectors)

      WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
      if (wsref == null) return;

      String name = wsref.name();
      if (name.equals(""))
         name = InjectionUtil.getEncName(field).substring(4);

      String encName = "env/" + name;
      Context encCtx = container.getEnc();
      if (!container.getEncInjectors().containsKey(name))
      {
         ServiceRefMetaData sref = getServiceRefForName(name);
         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
      }

      injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
   
public voidhandleMethodAnnotations(java.lang.reflect.Method method, InjectionContainer container, java.util.Map injectors)

      WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
      if (wsref == null) return;

      if (!method.getName().startsWith("set"))
         throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);

      String name = wsref.name();
      if (name.equals(""))
         name = InjectionUtil.getEncName(method).substring(4);
      
      String encName = "env/" + name;
      Context encCtx = container.getEnc();
      if (!container.getEncInjectors().containsKey(name))
      {
         ServiceRefMetaData sref = getServiceRefForName(name);
         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
      }

      injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
   
public voidloadXml(org.jboss.metamodel.descriptor.EnvironmentRefGroup xml, InjectionContainer container)


        
   
      if (xml == null) return;
      if (xml.getServiceRefs() == null) return;
      for (ServiceRefMetaData sref : xml.getServiceRefs())
      {
         log.debug("@WebServiceRef override: " + sref);
         if (srefMap.get(sref.getServiceRefName()) != null)
               throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
         
         srefMap.put(sref.getServiceRefName(), sref);
      }