[jboss-cvs] JBossAS SVN: r82726 - in projects/ejb3/trunk/docs/tutorial/resource_ref: META-INF and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 9 02:27:16 EST 2009


Author: jaikiran
Date: 2009-01-09 02:27:16 -0500 (Fri, 09 Jan 2009)
New Revision: 82726

Added:
   projects/ejb3/trunk/docs/tutorial/resource_ref/pom.xml
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENC.java
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENCBean.java
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/client/
   projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/client/Client.java
Modified:
   projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/ejb-jar.xml
   projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/jboss.xml
   projects/ejb3/trunk/docs/tutorial/resource_ref/build.xml
   projects/ejb3/trunk/docs/tutorial/resource_ref/tutorial-jbossmq-destinations-service.xml
Log:
Working version of resource ref tutorial for JBossAS-5.0 GA

Modified: projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/ejb-jar.xml	2009-01-09 07:05:48 UTC (rev 82725)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/ejb-jar.xml	2009-01-09 07:27:16 UTC (rev 82726)
@@ -12,8 +12,8 @@
       <session>
          <description>A session bean on looks up stuff in the ENC</description>
          <ejb-name>ENCBean</ejb-name>
-         <remote>org.jboss.tutorial.jboss_resource_ref.bean.TestENC</remote>
-         <ejb-class>org.jboss.tutorial.jboss_resource_ref.bean.TestENCBean</ejb-class>    
+         <business-remote>org.jboss.tutorial.resource_ref.bean.TestENC</business-remote>
+         <ejb-class>org.jboss.tutorial.resource_ref.bean.TestENCBean</ejb-class>    
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
 

Modified: projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/jboss.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/jboss.xml	2009-01-09 07:05:48 UTC (rev 82725)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/META-INF/jboss.xml	2009-01-09 07:27:16 UTC (rev 82726)
@@ -1,14 +1,11 @@
 <?xml version="1.0"?>
-<jboss
-        xmlns="http://www.jboss.com/xml/ns/javaee"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
-                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
-        version="3.0">
+<jboss xmlns:xs="http://www.jboss.org/j2ee/schema"
+       xs:schemaLocation="http://www.jboss.org/j2ee/schema jboss_5_0.xsd"
+             version="5.0"> 
     <enterprise-beans>
         <session>
             <ejb-name>ENCBean</ejb-name>
-            <jndi-name>ENCBean</jndi-name>
+            <jndi-name>ENCTest</jndi-name>
             <resource-ref>
                 <res-ref-name>jdbc/DefaultDS</res-ref-name>
                 <resource-name>DefaultDS</resource-name>

Modified: projects/ejb3/trunk/docs/tutorial/resource_ref/build.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/build.xml	2009-01-09 07:05:48 UTC (rev 82725)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/build.xml	2009-01-09 07:27:16 UTC (rev 82726)
@@ -8,26 +8,21 @@
 
    <property environment="env"/>
    <property name="src.dir" value="${basedir}/src"/>
-   <property name="jboss.home" value="${env.JBOSS_HOME}"/>   <property name="jboss.server.config" value="all"/>
+   <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-resource-ref.jar"/>
 
    <!-- Build classpath -->
    <path id="classpath">
       <!-- So that we can get jndi.properties for InitialContext -->
       <pathelement location="${basedir}"/>
-      <fileset dir="${jboss.home}/lib">
-         <include name="**/*.jar"/>
+   		<!-- Only the jbossall-client.jar should ideally be sufficient -->
+      <fileset dir="${jboss.home}/client">
+         <include name="**/jbossall-client.jar"/>
+      		<include name="**/mail.jar"/>
       </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/lib">
-         <include name="**/*.jar"/>
-      </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/ejb3.deployer">
-         <include name="*.jar"/>
-      </fileset>
-      <fileset dir="${jboss.home}/server/${jboss.server.config}/deploy/jboss-aop-jdk50.deployer">
-         <include name="*.jar"/>
-      </fileset>
       <pathelement location="${build.classes.dir}"/>
    </path>
 
@@ -56,7 +51,7 @@
    </target>
 
    <target name="ejbjar" depends="compile">
-      <jar jarfile="build/tutorial.jar">
+      <jar jarfile="build/${build.artifact}">
          <fileset dir="${build.classes.dir}">
             <include name="**/*.class"/>
          </fileset>
@@ -66,11 +61,12 @@
          </fileset>
       </jar>
       <copy file="tutorial-jbossmq-destinations-service.xml" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
-      <copy file="build/tutorial.jar" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
+   		<sleep seconds="5"/>
+      <copy file="build/${build.artifact}" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
    </target>
 
    <target name="run">
-      <java classname="org.jboss.tutorial.jboss_resource_ref.client.Client" fork="yes" dir=".">
+      <java classname="org.jboss.tutorial.resource_ref.client.Client" fork="yes" dir=".">
          <classpath refid="classpath"/>
       </java>
    </target>
@@ -84,7 +80,7 @@
 
    <target name="clean">
       <delete dir="${build.dir}"/>
-      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial.jar"/>
+      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/${build.artifact}"/>
       <delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial-jbossmq-destinations-service.xml"/>
    </target>
 

Added: projects/ejb3/trunk/docs/tutorial/resource_ref/pom.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/pom.xml	2009-01-09 07:27:16 UTC (rev 82726)
@@ -0,0 +1,39 @@
+<?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>
+		<jboss.ejb3.tutorial.deployables>${basedir}/tutorial-jbossmq-destinations-service.xml,${pom.build.directory}/${pom.artifactId}.${pom.packaging}</jboss.ejb3.tutorial.deployables>
+		<ejb3.tutorial.client>org.jboss.tutorial.resource_ref.client.Client</ejb3.tutorial.client>
+
+	</properties>
+	
+
+	<artifactId>jboss-ejb3-tutorial-resource_ref</artifactId>
+	<version>0.1.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Resource ref with EJB3 beans</name>
+	<url>http://labs.jboss.com/jbossejb3/</url>
+	<description>
+    	Tutorial about using resource-ref in EJB3
+  	</description>
+
+
+
+
+</project>


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

Added: projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENC.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENC.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENC.java	2009-01-09 07:27:16 UTC (rev 82726)
@@ -0,0 +1,38 @@
+/*
+ * 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.resource_ref.bean;
+
+import java.rmi.RemoteException;
+
+import javax.naming.NamingException;
+
+/**
+
+ at author  Scott.Stark at jboss.org
+ at version $Revision: 61136 $
+*/
+public interface TestENC
+{
+   public void accessENC() throws NamingException;
+   
+   public void remove();
+}


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

Added: projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENCBean.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENCBean.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/bean/TestENCBean.java	2009-01-09 07:27:16 UTC (rev 82726)
@@ -0,0 +1,96 @@
+/*
+ * 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.resource_ref.bean;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import javax.ejb.Remove;
+
+import org.apache.log4j.Logger;
+import org.jboss.ejb3.Container;
+
+/** A bean that does nothing but access resources from the ENC
+ to test ENC usage.
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 61136 $
+ */
+public class TestENCBean implements TestENC
+{
+   Logger log = Logger.getLogger(getClass());
+
+   public void accessENC() throws NamingException
+   {
+      // Obtain the enterprise beans environment naming context.
+      Context initCtx = new InitialContext();
+      Context myEnv = (Context) initCtx.lookup(Container.ENC_CTX_NAME + "/env");
+      
+      // This bean should have the full ENC setup of the ENCBean
+      testJdbcDataSource(initCtx, myEnv);
+      testMail(initCtx, myEnv);
+      testJMS(initCtx, myEnv);
+      testResourceEnvEntries(initCtx, myEnv);
+   }
+
+   private void testJdbcDataSource(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JDBC DataSource
+      Object obj = myEnv.lookup("jdbc/DefaultDS");
+      if ((obj instanceof javax.sql.DataSource) == false)
+         throw new NamingException("jdbc/DefaultDS is not a javax.sql.DataSource");
+      log.info("Found data source resource ref");
+   }
+
+   private void testMail(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JavaMail Session
+      Object obj = myEnv.lookup("mail/DefaultMail");
+      if ((obj instanceof javax.mail.Session) == false)
+         throw new NamingException("DefaultMail is not a javax.mail.Session");
+      log.info("Found mail resource ref");
+   }
+
+   private void testJMS(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JavaMail Session
+      Object obj = myEnv.lookup("jms/QueFactory");
+      if ((obj instanceof javax.jms.QueueConnectionFactory) == false)
+         throw new NamingException("mail/DefaultMail is not a javax.jms.QueueConnectionFactory");
+      log.info("Found jms queue resource ref");
+   }
+
+   private void testResourceEnvEntries(Context initCtx, Context myEnv) throws NamingException
+   {
+      Object obj = myEnv.lookup("res/aQueue");
+      if ((obj instanceof javax.jms.Queue) == false)
+         throw new NamingException("res/aQueue is not a javax.jms.Queue");
+      log.info("Found jms queue resource env ref");
+   }
+   
+   @Remove
+   public void remove()
+   {
+      
+   }
+}


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

Added: projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/client/Client.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/client/Client.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/src/org/jboss/tutorial/resource_ref/client/Client.java	2009-01-09 07:27:16 UTC (rev 82726)
@@ -0,0 +1,45 @@
+/*
+ * 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.resource_ref.client;
+
+import javax.naming.InitialContext;
+
+import org.jboss.tutorial.resource_ref.bean.TestENC;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 61136 $
+ */
+public class Client
+{
+   public static void main(String[] args) throws Exception
+   {
+      TestENC bean = (TestENC)new InitialContext().lookup("ENCTest");
+ 
+      bean.accessENC();
+      System.out.println("Successfully accessed bean resource references");
+      
+      bean.remove();
+   }
+}


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

Modified: projects/ejb3/trunk/docs/tutorial/resource_ref/tutorial-jbossmq-destinations-service.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/resource_ref/tutorial-jbossmq-destinations-service.xml	2009-01-09 07:05:48 UTC (rev 82725)
+++ projects/ejb3/trunk/docs/tutorial/resource_ref/tutorial-jbossmq-destinations-service.xml	2009-01-09 07:27:16 UTC (rev 82726)
@@ -1,18 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <server>
-  <mbean code="org.jboss.mq.server.jmx.Topic"
-	 name="jboss.mq.destination:service=Topic,name=testTopic">
-    <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
-  </mbean>
 
-  <mbean code="org.jboss.mq.server.jmx.Queue"
-	 name="jboss.mq.destination:service=Queue,name=testQueue">
-    <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
-  </mbean>
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.messaging.destination:service=Queue,name=testQueue"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <attribute name="JNDIName">queue/testQueue</attribute>
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
 
-  <mbean code="org.jboss.mq.server.jmx.Queue"
-	 name="jboss.mq.destination:service=Queue,name=A">
-    <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
-  </mbean>
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.messaging.destination:service=Queue,name=A"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <attribute name="JNDIName">queue/A</attribute>
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+   
+   <mbean code="org.jboss.jms.server.destination.TopicService"
+      name="jboss.messaging.destination:service=Topic,name=A"
+      xmbean-dd="xmdesc/Topic-xmbean.xml">
+      <attribute name="JNDIName">topic/testTopic</attribute>
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+
 </server>




More information about the jboss-cvs-commits mailing list