JBossWS SVN: r12143 - common/trunk/src/main/java/org/jboss/wsf/common/injection.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-05-04 05:05:43 -0400 (Tue, 04 May 2010)
New Revision: 12143
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/injection/InjectionHelper.java
Log:
[JBAS-7888] @EJB injectable resources are always populated to global JNDI environment, so using this global JNDI for lookup
Modified: common/trunk/src/main/java/org/jboss/wsf/common/injection/InjectionHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/injection/InjectionHelper.java 2010-05-04 08:58:56 UTC (rev 12142)
+++ common/trunk/src/main/java/org/jboss/wsf/common/injection/InjectionHelper.java 2010-05-04 09:05:43 UTC (rev 12143)
@@ -28,6 +28,7 @@
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.ws.WebServiceContext;
@@ -109,7 +110,7 @@
injectResourceAnnotatedAccessibleObjects(instance, injections, ctx);
// inject @EJB annotated methods and fields
- injectEJBAnnotatedAccessibleObjects(instance, injections, ctx);
+ injectEJBAnnotatedAccessibleObjects(instance, injections);
}
/**
@@ -323,10 +324,11 @@
* @see org.jboss.wsf.common.injection.finders.EJBMethodFinder
* @see javax.ejb.EJB
*/
- private static void injectEJBAnnotatedAccessibleObjects(final Object instance, final InjectionsMetaData injections, final Context ctx)
+ private static void injectEJBAnnotatedAccessibleObjects(final Object instance, final InjectionsMetaData injections)
{
final Collection<Field> ejbAnnotatedFields = EJB_FIELD_FINDER.process(instance.getClass());
final Collection<Method> ejbAnnotatedMethods = EJB_METHOD_FINDER.process(instance.getClass());
+ final Context ctx = InjectionHelper.getDefaultContext();
// Inject @EJB annotated fields
for (Field field : ejbAnnotatedFields)
@@ -496,4 +498,26 @@
return result.isEmpty() ? null : result.iterator().next();
}
+ /**
+ * Returns default JNDI context.
+ *
+ * @return default JNDI context
+ */
+ private static Context getDefaultContext()
+ {
+ Context ctx = null;
+
+ try
+ {
+ ctx = new InitialContext();
+ }
+ catch (NamingException ne)
+ {
+ final String message = "Cannot create default JNDI context";
+ InjectionException.rethrow(message, ne);
+ }
+
+ return ctx;
+ }
+
}