[jboss-cvs] JBossAS SVN: r58973 - in trunk/ejb3/src: main/org/jboss/injection main/org/jboss/injection/lang/reflect resources/test/ejbthree712
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 11 08:08:11 EST 2006
Author: wolfc
Date: 2006-12-11 08:07:59 -0500 (Mon, 11 Dec 2006)
New Revision: 58973
Added:
trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanPropertyFactory.java
Modified:
trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanProperty.java
trunk/ejb3/src/resources/test/ejbthree712/ejb-jar.xml
Log:
EJBTHREE-712: inject EJBContext via xml
Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2006-12-11 13:00:10 UTC (rev 58972)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2006-12-11 13:07:59 UTC (rev 58973)
@@ -23,6 +23,7 @@
import org.jboss.ejb3.Container;
import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
import org.jboss.injection.lang.reflect.FieldBeanProperty;
import org.jboss.injection.lang.reflect.MethodBeanProperty;
import org.jboss.logging.Logger;
@@ -36,6 +37,7 @@
import javax.annotation.Resource;
import javax.annotation.Resources;
import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
import javax.ejb.TimerService;
import javax.transaction.UserTransaction;
import javax.xml.ws.WebServiceContext;
@@ -104,6 +106,27 @@
{
for (ResourceEnvRef envRef : refs)
{
+ // EJBTHREE-712
+ // TODO: refactor with handlePropertyAnnotation
+ String resTypeName = envRef.getResType();
+ try
+ {
+ if(resTypeName != null)
+ {
+ Class<?> resType = Class.forName(resTypeName);
+ if(EJBContext.class.isAssignableFrom(resType))
+ {
+ AccessibleObject ao = InjectionUtil.findInjectionTarget(container.getClassloader(), envRef.getInjectionTarget());
+ container.getInjectors().add(new EJBContextPropertyInjector(BeanPropertyFactory.create(ao)));
+ continue;
+ }
+ }
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new EJBException(e);
+ }
+
String encName = "env/" + envRef.getResRefName();
if (container.getEncInjectors().containsKey(encName)) continue;
if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
Modified: trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanProperty.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanProperty.java 2006-12-11 13:00:10 UTC (rev 58972)
+++ trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanProperty.java 2006-12-11 13:07:59 UTC (rev 58973)
@@ -32,6 +32,7 @@
*/
public interface BeanProperty
{
+ // TODO: should not be exposed
AccessibleObject getAccessibleObject();
Class<?> getDeclaringClass();
Added: trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanPropertyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanPropertyFactory.java 2006-12-11 13:00:10 UTC (rev 58972)
+++ trunk/ejb3/src/main/org/jboss/injection/lang/reflect/BeanPropertyFactory.java 2006-12-11 13:07:59 UTC (rev 58973)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.injection.lang.reflect;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * BeanProperty factory.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BeanPropertyFactory
+{
+ private BeanPropertyFactory()
+ {
+ // do not instantiate
+ }
+
+ public static BeanProperty create(AccessibleObject ao)
+ {
+ if(ao instanceof Field)
+ return new FieldBeanProperty((Field) ao);
+ if(ao instanceof Method)
+ return new MethodBeanProperty((Method) ao);
+
+ throw new IllegalArgumentException("can't handle " + ao.getClass().getName());
+ }
+}
Modified: trunk/ejb3/src/resources/test/ejbthree712/ejb-jar.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree712/ejb-jar.xml 2006-12-11 13:00:10 UTC (rev 58972)
+++ trunk/ejb3/src/resources/test/ejbthree712/ejb-jar.xml 2006-12-11 13:07:59 UTC (rev 58973)
@@ -15,6 +15,7 @@
<resource-env-ref>
<resource-env-ref-name>ctx</resource-env-ref-name>
<resource-env-ref-type>javax.ejb.SessionContext</resource-env-ref-type>
+ <!--mapped-name>java:comp/EJBContext</mapped-name-->
<injection-target>
<injection-target-class>org.jboss.ejb3.test.ejbthree712.InjectionTesterBean</injection-target-class>
<injection-target-name>ctx</injection-target-name>
More information about the jboss-cvs-commits
mailing list