[jboss-cvs] JBossAS SVN: r74109 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 4 16:21:34 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-06-04 16:21:34 -0400 (Wed, 04 Jun 2008)
New Revision: 74109

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
Log:
JBAS-5579, workaround TimerService resource-env-ref

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-06-04 20:12:06 UTC (rev 74108)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-06-04 20:21:34 UTC (rev 74109)
@@ -35,7 +35,6 @@
 import javax.ejb.EJBException;
 import javax.ejb.TimerService;
 import javax.transaction.UserTransaction;
-import javax.xml.ws.WebServiceContext;
 
 import org.jboss.ejb3.Container;
 import org.jboss.injection.EJBContextPropertyInjector;
@@ -50,7 +49,6 @@
 import org.jboss.injection.TimerServicePropertyInjector;
 import org.jboss.injection.UserTransactionPropertyInjector;
 import org.jboss.injection.ValueEncInjector;
-import org.jboss.injection.WebServiceContextPropertyInjector;
 import org.jboss.injection.lang.reflect.BeanProperty;
 import org.jboss.injection.lang.reflect.FieldBeanProperty;
 import org.jboss.injection.lang.reflect.MethodBeanProperty;
@@ -201,16 +199,9 @@
                if(resTypeName != null)
                {
                   Class<?> resType = Class.forName(resTypeName);
-                  if(EJBContext.class.isAssignableFrom(resType))
+                  if(TimerService.class.isAssignableFrom(resType))
                   {
-                     InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()
-                     {
-                        public EJBContextPropertyInjector create(BeanProperty property)
-                        {
-                           return new EJBContextPropertyInjector(property);
-                        }
-                     };
-                     InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                     log.warn("Ignoring invalide TimerService resource-env-ref");
                      continue;
                   }
                   else if (resType.equals(UserTransaction.class))
@@ -357,93 +348,6 @@
          log.trace("method " + method + " has @Resource");
          
          handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
-         /*
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            encName = InjectionUtil.getEncName(method);
-         }
-         else
-         {
-            encName = "env/" + encName;
-         }
-
-         method.setAccessible(true);
-
-         if (!method.getName().startsWith("set"))
-            throw new RuntimeException("@Resource can only be used with a set method: " + method);
-         if (method.getParameterTypes().length != 1)
-            throw new RuntimeException("@Resource can only be used with a set method of one parameter: " + method);
-
-         Class type = method.getParameterTypes()[0];
-         if (!ref.type().equals(Object.class))
-         {
-            type = ref.type();
-         }
-         if (type.equals(UserTransaction.class))
-         {
-            injectors.put(method, new UserTransactionMethodInjector(method, container));
-         }
-         else if (type.equals(TimerService.class))
-         {
-            injectors.put(method, new TimerServiceMethodInjector(method, (Container) container)); // only EJBs
-         }
-         else if (EJBContext.class.isAssignableFrom(type))
-         {
-            injectors.put(method, new EJBContextMethodInjector(method));
-         }
-         else if (type.equals(WebServiceContext.class))
-         {
-            // FIXME: For now we skip it, and rely on the WS stack to perform the injection
-         }
-         else if (type.equals(String.class)
-                 || type.equals(Character.class)
-                 || type.equals(Byte.class)
-                 || type.equals(Short.class)
-                 || type.equals(Integer.class)
-                 || type.equals(Long.class)
-                 || type.equals(Boolean.class)
-                 || type.equals(Double.class)
-                 || type.equals(Float.class)
-                 || type.isPrimitive()
-                 )
-         {
-
-            // don't add an injector if no XML <env-entry is present as there will be no value to inject
-            if (container.getEncInjectors().containsKey(encName))
-            {
-               injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
-            }
-            else if (ref.mappedName() != null && ref.mappedName().length() > 0)
-            {
-               // Use the mappedName as the string value
-               String s = ref.mappedName().trim();
-               try
-               {
-                  Object value = ValueConvertor.convertValue(type, s);
-                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
-                  injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
-               }
-               catch(Throwable t)
-               {
-                  throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
-               }
-            }
-         }
-         else
-         {
-            if (!container.getEncInjectors().containsKey(encName))
-            {
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                 throw new RuntimeException("You did not specify a @Resource.mappedName() on " + method + " and there is no binding for that enc name in XML");
-               }
-               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
-            }
-            injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
-         }
-         */
       }
       
       public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
@@ -454,91 +358,6 @@
          log.trace("field " + field + " has @Resource");
          
          handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
-         /*
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            encName = InjectionUtil.getEncName(field);
-         }
-         else
-         {
-            encName = "env/" + encName;
-         }
-
-         field.setAccessible(true);
-
-         Class type = field.getType();
-         if (!ref.type().equals(Object.class))
-         {
-            type = ref.type();
-         }
-         if (type.equals(UserTransaction.class))
-         {
-            injectors.put(field, new UserTransactionFieldInjector(field, container));
-         }
-         else if (type.equals(TimerService.class))
-         {
-            injectors.put(field, new TimerServiceFieldInjector(field, (Container) container)); // only EJBs
-         }
-         else if (EJBContext.class.isAssignableFrom(type))
-         {
-            injectors.put(field, new EJBContextFieldInjector(field));
-         }
-         else if (type.equals(WebServiceContext.class))
-         {
-            // FIXME: For now we skip it, and rely on the WS stack to perform the injection
-         }
-         else if (type.equals(String.class)
-                 || type.equals(Character.class)
-                 || type.equals(Byte.class)
-                 || type.equals(Short.class)
-                 || type.equals(Integer.class)
-                 || type.equals(Long.class)
-                 || type.equals(Boolean.class)
-                 || type.equals(Double.class)
-                 || type.equals(Float.class)
-                 || type.isPrimitive()
-                 )
-         {
-            // don't add an injector if no XML <env-entry is present as there will be no value to inject
-            if (container.getEncInjectors().containsKey(encName))
-            {
-               injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
-            }
-            else if (ref.mappedName() != null && ref.mappedName().length() > 0)
-            {
-               // Use the mappedName as the string value
-               String s = ref.mappedName().trim();
-               try
-               {
-                  Object value = ValueConvertor.convertValue(type, s);
-                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
-                  injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
-               }
-               catch(Throwable t)
-               {
-                  throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
-               }
-            }
-            else
-            {
-               log.warn("Not injecting " + field.getName() + ", no matching enc injector " + encName + " found");
-            }
-         }
-         else
-         {
-            if (!container.getEncInjectors().containsKey(encName))
-            {
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                 throw new RuntimeException("You did not specify a @Resource.mappedName() on " + field + " and there is no binding for enc name " + encName + " in XML");
-               }
-               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
-            }
-            injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
-         }
-         */
       }
 
       private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)




More information about the jboss-cvs-commits mailing list