[jboss-cvs] JBossAS SVN: r82763 - in projects/ejb3/trunk/docs/tutorial: service and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 12 06:00:58 EST 2009


Author: jaikiran
Date: 2009-01-12 06:00:57 -0500 (Mon, 12 Jan 2009)
New Revision: 82763

Added:
   projects/ejb3/trunk/docs/tutorial/service/
   projects/ejb3/trunk/docs/tutorial/service/META-INF/
   projects/ejb3/trunk/docs/tutorial/service/META-INF/service-xmbean.xml
   projects/ejb3/trunk/docs/tutorial/service/build.xml
   projects/ejb3/trunk/docs/tutorial/service/jndi.properties
   projects/ejb3/trunk/docs/tutorial/service/log4j.xml
   projects/ejb3/trunk/docs/tutorial/service/pom.xml
   projects/ejb3/trunk/docs/tutorial/service/src/
   projects/ejb3/trunk/docs/tutorial/service/src/org/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOne.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneLocal.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneManagement.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneRemote.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThree.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThreeManagement.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwo.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwoManagement.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanService.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanServiceRemote.java
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/
   projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/Client.java
Log:
Working version of @Service tutorial for JBossAS-5.0 GA

Added: projects/ejb3/trunk/docs/tutorial/service/META-INF/service-xmbean.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/META-INF/service-xmbean.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/META-INF/service-xmbean.xml	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbean PUBLIC
+        "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
+        "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
+<mbean>
+
+    <description>EJB3 Service XMBean Example</description>
+    
+    <class>org.jboss.tutorial.service.bean.XMBeanService</class>
+   
+    <!-- Constructors -->
+    <constructor>
+        <description>The default constructor</description>
+        <name>XMBeanService</name>
+    </constructor>
+
+    <!-- Attributes -->
+    
+    <attribute access="read-write" getMethod="getAttribute" setMethod="setAttribute">
+        <description>Test attribute</description>
+        <name>IntAttribute</name>
+        <type>java.lang.Integer</type>
+    </attribute>
+
+    <!-- Operations -->
+    <operation>
+        <description>Say Hello</description>
+        <name>sayHello</name>
+        <return-type>java.lang.String</return-type>
+    </operation>
+</mbean>
+


Property changes on: projects/ejb3/trunk/docs/tutorial/service/META-INF/service-xmbean.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/build.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/build.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/build.xml	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+
+<!-- ======================================================================= -->
+<!-- JBoss build file                                                       -->
+<!-- ======================================================================= -->
+
+<project name="JBoss" default="ejbjar" basedir=".">
+
+   <property environment="env"/>
+   <property name="src.dir" value="${basedir}/src"/>
+   <property name="jboss.home" value="${env.JBOSS_HOME}"/>
+   <property name="jboss.server.config" value="default"/>
+   <property name="build.dir" value="${basedir}/build"/>
+   <property name="build.classes.dir" value="${build.dir}/classes"/>
+   <property name="build.artifact" value="jboss-ejb3-tutorial-service.jar"/>
+
+   <!-- Build classpath -->
+   <path id="classpath">
+      <!-- So that we can get jndi.properties for InitialContext -->
+      <pathelement location="${basedir}"/>
+   		<!-- Only the jbossall-client.jar should ideally be sufficient -->
+      <fileset dir="${jboss.home}/client">
+         <include name="**/jbossall-client.jar"/>
+      </fileset>
+   	  <pathelement location="${build.classes.dir}"/>
+   </path>
+
+   <property name="build.classpath" refid="classpath"/>
+
+   <!-- =================================================================== -->
+   <!-- Prepares the build directory                                        -->
+   <!-- =================================================================== -->
+   <target name="prepare">
+      <mkdir dir="${build.dir}"/>
+      <mkdir dir="${build.classes.dir}"/>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Compiles the source code                                            -->
+   <!-- =================================================================== -->
+   <target name="compile" depends="prepare">
+      <javac srcdir="${src.dir}"
+         destdir="${build.classes.dir}"
+         debug="on"
+         deprecation="on"
+         optimize="off"
+         includes="**">
+         <classpath refid="classpath"/>
+      </javac>
+   </target>
+
+   <target name="ejbjar" depends="compile">
+      <jar jarfile="build/${build.artifact}">
+         <fileset dir="${build.classes.dir}">
+            <include name="**/*.class"/>
+         </fileset>
+	  	<fileset dir=".">
+	        <include name="META-INF/service-xmbean.xml"/>
+	    </fileset> 
+      </jar>
+      <copy file="build/${build.artifact}" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
+   </target>
+
+   <target name="run" depends="ejbjar">
+      <java classname="org.jboss.tutorial.service.client.Client" fork="yes" dir=".">
+         <classpath refid="classpath"/>
+      </java>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Cleans up generated stuff                                           -->
+   <!-- =================================================================== -->
+   <target name="clean.db">
+      <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
+   </target>
+
+   <target name="clean">
+      <delete dir="${build.dir}"/>
+      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/${build.artifact}"/>
+   </target>
+
+
+</project>
+

Added: projects/ejb3/trunk/docs/tutorial/service/jndi.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/jndi.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/jndi.properties	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=localhost


Property changes on: projects/ejb3/trunk/docs/tutorial/service/jndi.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/log4j.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/log4j.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/log4j.xml	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 32809 2005-06-24 04:49:29Z bill $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+   
+<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Messagen -->
+         <!--
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+         -->
+         <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L)  -%m%n"/>
+      </layout>
+</appender>
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+   </root>
+
+</log4j:configuration>


Property changes on: projects/ejb3/trunk/docs/tutorial/service/log4j.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/pom.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/pom.xml	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  
+
+  
+   
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-tutorial-common</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <relativePath>../common/</relativePath>
+  </parent>
+
+  <properties>
+    <ejb3.tutorial.client>org.jboss.tutorial.service.client.Client</ejb3.tutorial.client>
+    
+  </properties>
+
+
+  <artifactId>jboss-ejb3-tutorial-service</artifactId>
+  <version>0.1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>@Service Bean (JBoss specific)</name>
+  <url>http://labs.jboss.com/jbossejb3/</url>
+  <description>
+    Tutorial about JBoss specific @Service beans
+  </description>
+  
+  
+  
+ 
+
+
+</project>


Property changes on: projects/ejb3/trunk/docs/tutorial/service/pom.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOne.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOne.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOne.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+ at Service(objectName = ServiceOne.OBJECT_NAME)
+ at Local(ServiceOneLocal.class)
+ at Remote(ServiceOneRemote.class)
+ at Management(ServiceOneManagement.class)
+public class ServiceOne implements ServiceOneLocal, ServiceOneRemote, ServiceOneManagement
+{
+   /**
+    * The ObjectName for {@link ServiceOne} 
+    */
+   public static final String OBJECT_NAME = "tutorial:service=ServiceOne";
+
+   int attribute;
+
+   public void setAttribute(int attribute)
+   {
+      this.attribute = attribute;
+   }
+
+   public int getAttribute()
+   {
+      return this.attribute;
+   }
+
+   public String sayHello()
+   {
+      return "Hello from service One";
+   }
+
+   // Lifecycle methods
+   public void create() throws Exception
+   {
+      System.out.println("ServiceOne - Created");
+   }
+
+   public void start() throws Exception
+   {
+      System.out.println("ServiceOne - Started");
+   }
+
+   public void stop()
+   {
+      System.out.println("ServiceOne - Stopped");
+   }
+
+   public void destroy()
+   {
+      System.out.println("ServiceOne - Destroyed");
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOne.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneLocal.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneLocal.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneLocal.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+public interface ServiceOneLocal
+{
+   public void setAttribute(int attribute);
+   public int getAttribute();
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneLocal.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneManagement.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneManagement.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneManagement.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+public interface ServiceOneManagement
+{
+   void setAttribute(int attribute);
+
+   int getAttribute();
+
+   String sayHello();
+
+   void create() throws Exception;
+
+   void start() throws Exception;
+
+   void stop();
+
+   void destroy();
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneManagement.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneRemote.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneRemote.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneRemote.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+public interface ServiceOneRemote
+{
+   public void setAttribute(int attribute);
+   public int getAttribute();
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceOneRemote.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThree.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThree.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThree.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.jboss.ejb3.annotation.Depends;
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+ at Service(objectName = ServiceThree.OBJECT_NAME)
+ at Management(ServiceThreeManagement.class)
+public class ServiceThree implements ServiceThreeManagement
+{
+   /**
+    * The ObjectName for {@link ServiceThree} 
+    */
+   public static final String OBJECT_NAME = "tutorial:service=ServiceThree";
+
+   @Depends(ServiceOne.OBJECT_NAME)
+   public ObjectName serviceOneName;
+
+   // The JBoss EJB3 version on JBossAS-5.0 GA does not support
+   // injection using @org.jboss.ejb3.annotation.Depends on a field/method.
+   // However, we do have plans to fix this in the later version.
+   // When fixed, the @Depends (with a JMX ObjectName value) can be used
+   // on a field or a method, to inject the MBean as follows
+   //   private ServiceTwoManagement service2;
+   //
+//      @Depends(ServiceTwo.OBJECT_NAME)
+//      public void setServiceTwo(ServiceTwoManagement service2)
+//      {
+//         this.service2 = service2;
+//      }
+
+   public String serviceOneHello() throws Exception
+   {
+      Object[] args = new Object[0];
+      String[] signature = new String[0];
+      System.out.println("ServiceThree - Calling ServiceOne.sayHello() via JMX server");
+      MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+      return (String) server.invoke(serviceOneName, "sayHello", args, signature);
+   }
+
+   public String serviceTwoHello()
+   {
+//            System.out.println("ServiceThree - Calling ServiceTwo.sayHello() via MBean proxy");
+//            return service2.sayHello();
+      System.out
+            .println("***** To be implemented : JBoss EJB3 version on JBossAS-5.0 GA does NOT support injection of MBean through @Depends");
+      return "*********** ServiceThree.serviceTwoHello() : To Be Implemented in later version *********";
+   }
+
+   // Interceptors
+   @AroundInvoke
+   public Object intercept(InvocationContext ctx) throws Exception
+   {
+      System.out.println("ServiceThree - Interceptor");
+      return ctx.proceed();
+   }
+
+   // Lifecycle methods
+   public void start() throws Exception
+   {
+      System.out.println("ServiceThree - Started");
+   }
+
+   public void stop()
+   {
+      System.out.println("ServiceThree - Stopped");
+   }
+
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThree.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThreeManagement.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThreeManagement.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThreeManagement.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+public interface ServiceThreeManagement
+{
+   String serviceOneHello() throws Exception;
+
+   String serviceTwoHello();
+
+   void start() throws Exception;
+
+   void stop() throws Exception;
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceThreeManagement.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwo.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwo.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwo.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+import org.jboss.ejb3.annotation.Depends;
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+ at Service(objectName = ServiceTwo.OBJECT_NAME)
+ at Management(ServiceTwoManagement.class)
+ at Depends(ServiceOne.OBJECT_NAME)
+public class ServiceTwo implements ServiceTwoManagement
+{
+   /**
+    * The ObjectName for {@link ServiceTwo} 
+    */
+   public static final String OBJECT_NAME = "tutorial:service=ServiceTwo";
+
+   public String sayHello()
+   {
+      return "Hello from service Two";
+   }
+
+   // Lifecycle methods
+   public void start() throws Exception
+   {
+      System.out.println("ServiceTwo - Started");
+   }
+
+   public void stop()
+   {
+      System.out.println("ServiceTwo - Stopped");
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwo.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwoManagement.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwoManagement.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwoManagement.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 61136 $
+ */
+public interface ServiceTwoManagement
+{
+   String sayHello();
+   void start() throws Exception;
+   void stop() throws Exception;
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/ServiceTwoManagement.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanService.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanService.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanService.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.Service;
+
+ at Service(objectName = XMBeanService.OBJECT_NAME, xmbean = "resource:META-INF/service-xmbean.xml")
+ at Remote(XMBeanServiceRemote.class)
+public class XMBeanService implements XMBeanServiceRemote
+{
+   /**
+    * The ObjectName for {@link XMBeanService} 
+    */
+   public static final String OBJECT_NAME = "tutorial:service=XMBeanService";
+
+   int attribute;
+
+   public void setIntAttribute(int attribute)
+   {
+      this.attribute = attribute;
+   }
+
+   public int getIntAttribute()
+   {
+      return this.attribute;
+   }
+
+   public String sayHello()
+   {
+      return "Hello from an XMBean";
+   }
+
+   public void remoteBusinessMethodToSetAttribute(int val)
+   {
+      this.setIntAttribute(val);
+   }
+}

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanServiceRemote.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanServiceRemote.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanServiceRemote.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.bean;
+
+
+public interface XMBeanServiceRemote
+{
+   void remoteBusinessMethodToSetAttribute(int val);
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/bean/XMBeanServiceRemote.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/Client.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/Client.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/Client.java	2009-01-12 11:00:57 UTC (rev 82763)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tutorial.service.client;
+
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.tutorial.service.bean.ServiceOne;
+import org.jboss.tutorial.service.bean.ServiceOneRemote;
+import org.jboss.tutorial.service.bean.ServiceThree;
+import org.jboss.tutorial.service.bean.XMBeanService;
+import org.jboss.tutorial.service.bean.XMBeanServiceRemote;
+
+public class Client
+{
+   public static void main(String[] args) throws Exception
+   {
+      InitialContext ctx = new InitialContext();
+      //Get hold of the MBean server invoker
+      RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
+
+      invokeService(ctx, server);
+
+      invokeXMBean(ctx, server);
+   }
+
+   public static void invokeService(InitialContext ctx, RMIAdaptor server) throws Exception
+   {
+      System.out.println("invoking remote business interface of ServiceOne...");
+      //Set attribute on singleton ServiceOne via remote interface
+      ServiceOneRemote serviceOne = (ServiceOneRemote) ctx.lookup("ServiceOne/remote");
+      serviceOne.setAttribute(100);
+      System.out.println("Set the attribute value through ServiceOneRemote to 100");
+      //Create object name for ServiceOne
+      ObjectName service1 = new ObjectName(ServiceOne.OBJECT_NAME);
+           
+      //Get attribute of singleton ServiceOne via JMX
+      int attr1 = (Integer) server.getAttribute(service1, "Attribute");
+      System.out.println("attribute value for (ServiceOne) singleton obtained via JMX is what we set via remote interface: " + attr1);
+
+      System.out.println("Invoking ServiceThree via JMX...");
+      //Create object name for ServiceThree
+      ObjectName service3 = new ObjectName(ServiceThree.OBJECT_NAME);
+           
+      //Call serviceOneHello() and serviceTwoHello() on ServiceThree
+      Object[] noArgs = new Object[0];//No arguments
+      String[] noSig = new String[0];//No parameters in signature
+
+      String service1Hello = (String) server.invoke(service3, "serviceOneHello", noArgs, noSig);
+      System.out.println(service1Hello);
+      String service2Hello = (String) server.invoke(service3, "serviceTwoHello", noArgs, noSig);
+      System.out.println(service2Hello);
+   }
+
+   public static void invokeXMBean(InitialContext ctx, RMIAdaptor server) throws Exception
+   {
+      System.out.println("invoking XMBean (configured through deployment descriptor)...");
+      XMBeanServiceRemote xmbeanRemote = (XMBeanServiceRemote) ctx.lookup("XMBeanService/remote");
+      xmbeanRemote.remoteBusinessMethodToSetAttribute(50);
+      System.out.println("Set the attribute value to 50");
+      
+      System.out.println("Invoking XMBean through JMX");
+      ObjectName service = new ObjectName(XMBeanService.OBJECT_NAME);
+      //Get attribute of singleton XMBeanService via JMX
+      int attr = (Integer) server.getAttribute(service, "IntAttribute");
+      System.out.println("attribute value for (XMBeanService deployment descriptor configured) singleton obtained via JMX is what we set via remote interface: " + attr);
+
+      //Call sayHello() on XMBeanService
+      Object[] noArgs = new Object[0];//No arguments
+      String[] noSig = new String[0];//No parameters in signature
+
+      String hello = (String) server.invoke(service, "sayHello", noArgs, noSig);
+      System.out.println(hello);
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/service/src/org/jboss/tutorial/service/client/Client.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list