[jboss-cvs] JBossAS SVN: r78886 - in branches/JBPAPP_4_2_0_GA_CP/ejb3: src/main/org/jboss/injection and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 26 09:42:25 EDT 2008
Author: galder.zamarreno at jboss.com
Date: 2008-09-26 09:42:25 -0400 (Fri, 26 Sep 2008)
New Revision: 78886
Added:
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTime.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/unit/
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTest.java
Modified:
branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsFieldInjector.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsMethodInjector.java
Log:
[JBPAPP-1215] Fixed and added EJB3 service injection test case.
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2008-09-26 13:28:25 UTC (rev 78885)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2008-09-26 13:42:25 UTC (rev 78886)
@@ -2063,6 +2063,19 @@
<build-simple-jar name="ejbthree1239"/>
</target>
+
+ <target name="ejbthree1504"
+ description="Builds all jar files."
+ depends="compile-classes">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/ejbthree1504.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree1504/*.class"/>
+ </fileset>
+ </jar>
+ </target>
<target name="jbas4489"
description="Builds a simple jar files."
@@ -3793,6 +3806,7 @@
ejbthree959, ejbthree963, ejbthree994, ejbthree1023, ejbthree1025, ejbthree1062,
ejbthree1109,
ejbthree1239,
+ ejbthree1504,
jbpapp999,
jbpapp1186,
jbas4489, epcpropagation, jaccpropagation,
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsFieldInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsFieldInjector.java 2008-09-26 13:28:25 UTC (rev 78885)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsFieldInjector.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -23,13 +23,14 @@
import java.lang.reflect.Field;
import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import org.jboss.ejb3.BeanContext;
import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public class DependsFieldInjector implements Injector
@@ -61,7 +62,7 @@
}
else
{
- MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+ MBeanServer server = MBeanServerLocator.locateJBoss();
value = MBeanProxyExt.create(clazz, on, server);
}
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsMethodInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsMethodInjector.java 2008-09-26 13:28:25 UTC (rev 78885)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/DependsMethodInjector.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -24,13 +24,14 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import org.jboss.ejb3.BeanContext;
import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public class DependsMethodInjector implements Injector
@@ -62,7 +63,8 @@
}
else
{
- MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+
value = MBeanProxyExt.create(clazz, on, server);
}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTime.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTime.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTime.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.ejbthree1504;
+
+/**
+ * SystemTime.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface SystemTime
+{
+ long getCurrentTimeMillis();
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.ejbthree1504;
+
+import org.jboss.annotation.ejb.Management;
+import org.jboss.annotation.ejb.Service;
+import org.jboss.logging.Logger;
+
+/**
+ * SystemTimeService that returns the current time in milliseconds. It also
+ * implements MBeanRegistration to set the object name with which the MBean is
+ * registered dynamically.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ at Service(objectName=SystemTimeService.ORIGINAL_NAME)
+ at Management(SystemTime.class)
+public class SystemTimeService implements SystemTime
+{
+ public static final String ORIGINAL_NAME = "org.jboss.ejb3:service=SystemTime";
+ public static final String DYNAMIC_NAME = "org.jboss.ejb3:service=SystemTime,type=dynamic";
+
+ private static final Logger log = Logger.getLogger(SystemTimeService.class);
+
+ public long getCurrentTimeMillis()
+ {
+ long currentTimeMillis = System.currentTimeMillis();
+
+ log.info("Current time millis is: " + currentTimeMillis);
+
+ return currentTimeMillis;
+ }
+}
\ No newline at end of file
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.ejbthree1504;
+
+import java.util.Date;
+
+/**
+ * TimeTeller.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface TimeTeller
+{
+ Date whatsTheTime(String origin) throws Exception;
+}
\ No newline at end of file
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.ejbthree1504;
+
+import java.util.Date;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.ejb.Depends;
+import org.jboss.logging.Logger;
+
+/**
+ * TimeTellerBean.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ at Stateless
+ at Remote(TimeTeller.class)
+public class TimeTellerBean implements TimeTeller
+{
+ private static final Logger log = Logger.getLogger(TimeTellerBean.class);
+
+ @Depends(SystemTimeService.ORIGINAL_NAME) private SystemTime systemTimeService;
+
+ public Date whatsTheTime(String origin) throws Exception
+ {
+ log.debug("Call via SystemTime EJB3 service implementation");
+ long currentTimeMillis = systemTimeService.getCurrentTimeMillis();
+ Date date = new Date(currentTimeMillis);
+ log.info("current time is: "+ date + " and origin: " + origin);
+ return date;
+ }
+
+}
Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTest.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTest.java (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTest.java 2008-09-26 13:42:25 UTC (rev 78886)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.ejbthree1504.unit;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1504.TimeTeller;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * TimeTellerTest. To run this test, make sure -Dcom.sun.management.jmxremote
+ * has been added to AS/EAP startup VM options.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class TimeTellerTest extends JBossTestCase
+{
+ public TimeTellerTest(String name)
+ {
+ super(name);
+ }
+
+ public void testStandardCallViaLocalService() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ TimeTeller timeTeller = (TimeTeller) ctx.lookup("TimeTellerBean/remote");
+ assertNotNull(timeTeller.whatsTheTime("boo"));
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(TimeTellerTest.class, "ejbthree1504.jar");
+ }
+}
More information about the jboss-cvs-commits
mailing list