[jboss-cvs] JBoss Messaging SVN: r6969 - in trunk: docs/user-manual/en and 18 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 21 14:05:06 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-05-21 14:05:06 -0400 (Thu, 21 May 2009)
New Revision: 6969

Added:
   trunk/examples/core/embedded-microcontainer/
   trunk/examples/core/embedded-microcontainer/build.xml
   trunk/examples/core/embedded-microcontainer/server0/
   trunk/examples/core/embedded-microcontainer/server0/jbm-configuration.xml
   trunk/examples/core/embedded-microcontainer/server0/jbm-jboss-beans.xml
   trunk/examples/core/embedded-microcontainer/src/
   trunk/examples/core/embedded-microcontainer/src/org/
   trunk/examples/core/embedded-microcontainer/src/org/jboss/
   trunk/examples/core/embedded-microcontainer/src/org/jboss/core/
   trunk/examples/core/embedded-microcontainer/src/org/jboss/core/example/
   trunk/examples/core/embedded-microcontainer/src/org/jboss/core/example/EmbeddedMicroContainerExample.java
   trunk/examples/core/embedded-remote/
   trunk/examples/core/embedded-remote/build.xml
   trunk/examples/core/embedded-remote/src/
   trunk/examples/core/embedded-remote/src/org/
   trunk/examples/core/embedded-remote/src/org/jboss/
   trunk/examples/core/embedded-remote/src/org/jboss/core/
   trunk/examples/core/embedded-remote/src/org/jboss/core/example/
   trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedRemoteExample.java
   trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedServer.java
Modified:
   trunk/.classpath
   trunk/docs/user-manual/en/jar-dependencies.xml
   trunk/examples/common/src/org/jboss/common/example/SpawnedVMSupport.java
   trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   trunk/tests/src/org/jboss/messaging/tests/unit/microcontainer/JBMBootstrapServerTest.java
Log:
Embedded examples validating minimal classpath + jar-dependencies chapter

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/.classpath	2009-05-21 18:05:06 UTC (rev 6969)
@@ -15,6 +15,8 @@
 	<classpathentry kind="src" path="tests/joram-tests/src"/>
 	<classpathentry kind="src" path="tests/joram-tests/config"/>
 	<classpathentry kind="src" path="examples/core/embedded/src"/>
+	<classpathentry kind="src" path="examples/core/embedded-microcontainer/src"/>
+	<classpathentry kind="src" path="examples/core/embedded-remote/src"/>
 	<classpathentry kind="src" path="examples/core/perf/src"/>
 	<classpathentry kind="src" path="examples/jms/application-layer-failover/src"/>
 	<classpathentry kind="src" path="examples/jms/automatic-failover/src"/>

Modified: trunk/docs/user-manual/en/jar-dependencies.xml
===================================================================
--- trunk/docs/user-manual/en/jar-dependencies.xml	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/docs/user-manual/en/jar-dependencies.xml	2009-05-21 18:05:06 UTC (rev 6969)
@@ -48,23 +48,136 @@
                         <entry>Log4j or JBoss Logger depending on the logging configuration</entry>
                     </row>
                     <row>
-                        <entry><link linkend="logging">jbm-logging.jar</link></entry>
-                        <entry>Wrapper to other Logger Frameworks</entry>
-                        <entry>Log4j or JBoss Logger depending on the logging configuration</entry>
-                    </row>
-                    <row>
                         <entry><link linkend="security">jbm-jbossas-security.jar</link></entry>
                         <entry>Classes used to start a standalone server</entry>
-                        <entry>Only JDK if using <literal>JAAS</literal> or JBoss libraries if using <literal>JBossASSecurityManager</literal></entry>
+                        <entry>No dependencies if using <literal>JAAS</literal> or JBoss security libraries if using
+                                <literal>JBossASSecurityManager</literal></entry>
                     </row>
                     <row>
-                        <entry><link linkend="configuring-transports">jbm-transports.jar</link></entry>
+                        <entry><link linkend="configuring-transports"
+                            >jbm-transports.jar</link></entry>
                         <entry>Socket and HTTP Transport plugins</entry>
-                        <entry>Netty jars</entry>
+                        <entry>netty.jar</entry>
                     </row>
-                    
+                    <row>
+                        <entry><link linkend="appserver-integration">jbm-ra.rar</link></entry>
+                        <entry>Java Connector Plugin, used to Application Server integration</entry>
+                        <entry>jbm-core-client.jar, jbm-jms.jar (are contained on the rar)</entry>
+                    </row>
+                    <row>
+                        <entry><link linkend="appserver-integration">jbm-ra.jar</link></entry>
+                        <entry>It contains the resource adapter implementation. Use jbm-ra.rar
+                            instead.</entry>
+                        <entry>jbm-core-client.jar, jbm-jms.jar</entry>
+                    </row>
+                    <row>
+                        <entry>netty.jar</entry>
+                        <entry>NIO Socket library used by JBoss Messaging</entry>
+                        <entry>No dependencies</entry>
+                    </row>
                 </tbody>
             </tgroup>
         </table>
     </section>
+    <section>
+        <title>Micro Container</title>
+        <para><trademark>JBoss Micro Container</trademark> is the kernel around JBoss Application
+            Server, and it relies on a few other projects.</para>
+        <para>JBoss Micro Container distributes a series of Jars that are used on other injection
+            frameworks. The following list only shows what is required by JBoss Messaging</para>
+        <table frame="topbot">
+            <title>JBoss Micro Container jars</title>
+            <tgroup cols="3">
+                <colspec colname="c1" colnum="1"/>
+                <colspec colname="c2" colnum="2"/>
+                <colspec colname="c3" colnum="3"/>
+                <thead>
+                    <row>
+                        <entry>Name</entry>
+                        <entry>Description</entry>
+                        <entry>Dependencies</entry>
+                    </row>
+                </thead>
+                <tbody>
+                    <row>
+                        <entry>jboss-kernel.jar</entry>
+                        <entry>The Micro Container Kernel</entry>
+                        <entry>Listed on <xref linkend="jar-dependencies.micro-container-thirdparty"
+                        /></entry>
+                    </row>
+                    <row>
+                        <entry>jboss-dependency.jar</entry>
+                        <entry>Dependency Framework from JBoss MicroContainer</entry>
+                        <entry>Listed on <xref linkend="jar-dependencies.micro-container-thirdparty"
+                        /></entry>
+                    </row>
+                </tbody>
+            </tgroup>
+        </table>
+        
+        
+        <para>The following table lists the thirdparty libraries used by JBoss Micro
+        Container.</para>
+        
+        
+        <table frame="topbot" id="jar-dependencies.micro-container-thirdparty">
+            <title>Jars used by the JBoss Micro Container</title>
+            <tgroup cols="2">
+                <colspec colname="c1" colnum="1"/>
+                <colspec colname="c2" colnum="2"/>
+                <thead>
+                    <row>
+                        <entry>Name</entry>
+                        <entry>Description</entry>
+                    </row>
+                </thead>
+                <tbody>
+                    <row>
+                        <entry>jboss-common-logging-spi.jar</entry>
+                        <entry>Logging integration library</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-reflect.jar</entry>
+                        <entry>Reflection framework</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-commong-core.jar</entry>
+                        <entry>Common application server</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-mdr.jar</entry>
+                        <entry>Meta data classes</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-xml-binding.jar</entry>
+                        <entry>XML Readers</entry>
+                    </row>
+                    <row>
+                        <entry>jaxb-api.jar</entry>
+                        <entry>Sun's jaxb api</entry>
+                    </row>
+                    <row>
+                        <entry>jaxb-api.jar</entry>
+                        <entry>Sun's jaxb api</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-aop.jar</entry>
+                        <entry>JBoss AOP</entry>
+                    </row>
+                    <row>
+                        <entry>jboss-aop.jar</entry>
+                        <entry>JBoss AOP</entry>
+                    </row>
+                    <row>
+                        <entry>trove.jar</entry>
+                        <entry>Native collections used by AOP</entry>
+                    </row>
+                    <row>
+                        <entry>javassist.jar</entry>
+                        <entry>Bytecode manipulations used by AOP</entry>
+                    </row>
+                </tbody>
+            </tgroup>
+        </table>
+    </section>
 </chapter>

Modified: trunk/examples/common/src/org/jboss/common/example/SpawnedVMSupport.java
===================================================================
--- trunk/examples/common/src/org/jboss/common/example/SpawnedVMSupport.java	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/examples/common/src/org/jboss/common/example/SpawnedVMSupport.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -48,7 +48,6 @@
 
    // Static --------------------------------------------------------
 
-
    public static Process spawnVM(final String className,
                                  final String[] vmargs,
                                  final boolean logOutput,
@@ -57,23 +56,35 @@
                                  final String configDir,
                                  final String... args) throws Exception
    {
+      String classPath = System.getProperty("java.class.path");
+      
+      return spawnVM(classPath, vmargs, logOutput, success, failure, configDir, args);
+   }
+
+   public static Process spawnVM(String classPath,
+                                 final String className,
+                                 final String[] vmargs,
+                                 final boolean logOutput,
+                                 final String success,
+                                 final String failure,
+                                 final String configDir,
+                                 final String... args) throws Exception
+   {
       StringBuffer sb = new StringBuffer();
 
       sb.append("java").append(' ');
-      
+
       for (String vmarg : vmargs)
       {
          if (System.getProperty("os.name").contains("Windows"))
          {
-            vmarg = vmarg.replaceAll("/", "\\\\");    
+            vmarg = vmarg.replaceAll("/", "\\\\");
          }
          sb.append(vmarg).append(' ');
       }
-      
-      String classPath = System.getProperty("java.class.path");
       String pathSeparater = System.getProperty("path.separator");
       classPath = classPath + pathSeparater + ".";
-      //System.out.println("classPath = " + classPath);
+      // System.out.println("classPath = " + classPath);
       // I guess it'd be simpler to check if the OS is Windows...
       if (System.getProperty("os.name").contains("Windows"))
       {
@@ -86,8 +97,8 @@
       String libPath = "-Djava.library.path=" + System.getProperty("java.library.path", "./native/bin");
       if (System.getProperty("os.name").contains("Windows"))
       {
-          libPath = libPath.replaceAll("/", "\\\\");
-          libPath = "\"" + libPath + "\"";
+         libPath = libPath.replaceAll("/", "\\\\");
+         libPath = "\"" + libPath + "\"";
       }
       sb.append("-Djava.library.path=").append(libPath).append(" ");
 
@@ -103,18 +114,30 @@
 
       log.info("command line: " + commandLine);
 
-      Process process = Runtime.getRuntime().exec(commandLine, new String[]{}, new File(configDir));
+      Process process = Runtime.getRuntime().exec(commandLine, new String[] {}, new File(configDir));
 
       log.trace("process: " + process);
 
       CountDownLatch latch = new CountDownLatch(1);
 
-      ProcessLogger outputLogger = new ProcessLogger(logOutput, process.getInputStream(), className, false, success, failure, latch);
+      ProcessLogger outputLogger = new ProcessLogger(logOutput,
+                                                     process.getInputStream(),
+                                                     className,
+                                                     false,
+                                                     success,
+                                                     failure,
+                                                     latch);
       outputLogger.start();
 
       // Adding a reader to System.err, so the VM won't hang on a System.err.println as identified on this forum thread:
       // http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151815
-      ProcessLogger errorLogger = new ProcessLogger(true, process.getErrorStream(), className, true, success, failure, latch);
+      ProcessLogger errorLogger = new ProcessLogger(true,
+                                                    process.getErrorStream(),
+                                                    className,
+                                                    true,
+                                                    success,
+                                                    failure,
+                                                    latch);
       errorLogger.start();
 
       if (!latch.await(30, TimeUnit.SECONDS))
@@ -151,7 +174,13 @@
 
       boolean failed = false;
 
-      ProcessLogger(final boolean print, final InputStream is, final String className, boolean sendToErr, String success, String failure, CountDownLatch latch) throws ClassNotFoundException
+      ProcessLogger(final boolean print,
+                    final InputStream is,
+                    final String className,
+                    boolean sendToErr,
+                    String success,
+                    String failure,
+                    CountDownLatch latch) throws ClassNotFoundException
       {
          this.is = is;
          this.print = print;
@@ -198,7 +227,7 @@
          }
          catch (IOException e)
          {
-            //ok, stream closed
+            // ok, stream closed
          }
 
       }


Property changes on: trunk/examples/core/embedded-microcontainer
___________________________________________________________________
Name: svn:ignore
   + build


Added: trunk/examples/core/embedded-microcontainer/build.xml
===================================================================
--- trunk/examples/core/embedded-microcontainer/build.xml	                        (rev 0)
+++ trunk/examples/core/embedded-microcontainer/build.xml	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+      <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+      ]>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., 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.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Embedded Example">
+
+   <import file="../../common/build.xml"/>
+
+   <!-- We use a minimal classpath on this example -->
+   <path id="local.classpath">
+      <fileset dir="${jbm.jars.dir}">
+        <include name="jbm-core.jar"/>
+        <include name="jbm-transports.jar"/>
+        <include name="jbm-bootstrap.jar"/>
+        <include name="jbm-jbossas-security.jar"/>	
+      </fileset>
+   	  <fileset dir="${jars.dir}">
+        <include name="netty/lib/*jar"/>
+        <include name="jboss/microcontainer/lib/jboss-dependency.jar"/>
+        <include name="jboss/microcontainer/lib/jboss-kernel.jar"/>
+
+   	  	<include name="jboss/jboss-common-logging-spi/lib/*.jar"/>
+   	  	<include name="jboss/jboss-reflect/lib/jboss-reflect.jar"/>
+   	  	<include name="jboss/common-core/lib/jboss-common-core.jar"/>
+   	  	<include name="jboss/jboss-mdr/lib/jboss-mdr.jar"/>
+   	  	<include name="jboss/jbossxb/lib/jboss-xml-binding.jar"/>
+   	  	<include name="sun-jaxb/lib/jaxb-api.jar"/>
+   	  	<include name="jboss/aop/lib/jboss-aop.jar"/>
+   	  	<include name="trove/lib/trove.jar"/>
+   	  	<include name="javassist/lib/javassist.jar"/>
+   	  	<exclude name="**/*-sources.jar"/>
+   	  	
+   	  	
+   	 
+        <!-- <include name="**/*.jar"/>
+         -->
+   	  </fileset>
+    <pathelement location="${classes.dir}"/>	   	
+    <pathelement location="./server0"/>	   	
+   </path>
+
+	<target name="run" depends="compile">
+	   <java classname="org.jboss.core.example.EmbeddedMicroContainerExample" fork="true" resultproperty="example-result">
+	      <jvmarg value="-Xms50M"/>      
+	      <jvmarg value="-Xmx50M"/>
+	      <classpath refid="local.classpath"/>
+	   </java>
+      
+   </target>
+</project>

Added: trunk/examples/core/embedded-microcontainer/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/core/embedded-microcontainer/server0/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/core/embedded-microcontainer/server0/jbm-configuration.xml	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,20 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-configuration.xsd">
+
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>    
+         <param key="jbm.remoting.netty.tcpnodelay" value="false" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpsendbuffersize" value="1048576" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpreceivebuffersize" value="1048576" type="Boolean"/>
+      </acceptor>
+   </acceptors>
+   
+   <security-enabled>false</security-enabled>
+   
+   <persistence-enabled>false</persistence-enabled>
+ 
+</configuration>

Added: trunk/examples/core/embedded-microcontainer/server0/jbm-jboss-beans.xml
===================================================================
--- trunk/examples/core/embedded-microcontainer/server0/jbm-jboss-beans.xml	                        (rev 0)
+++ trunk/examples/core/embedded-microcontainer/server0/jbm-jboss-beans.xml	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+    <!-- MBean server -->
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean>
+
+   <!-- The core configuration -->
+   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+   <!-- The security manager -->
+   <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+
+   <!-- The core server -->
+   <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="JBMSecurityManager"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+
+</deployment>

Added: trunk/examples/core/embedded-microcontainer/src/org/jboss/core/example/EmbeddedMicroContainerExample.java
===================================================================
--- trunk/examples/core/embedded-microcontainer/src/org/jboss/core/example/EmbeddedMicroContainerExample.java	                        (rev 0)
+++ trunk/examples/core/embedded-microcontainer/src/org/jboss/core/example/EmbeddedMicroContainerExample.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,122 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * 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.core.example;
+
+import java.util.Date;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.integration.bootstrap.JBMBootstrapServer;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+
+
+/**
+ * 
+ * This exammple shows how to run a JBoss Messaging core client and server embedded in your
+ * own application
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class EmbeddedMicroContainerExample
+{
+
+   public static void main(String[] args)
+   {
+
+      JBMBootstrapServer jbm = null;
+      try
+      {
+         
+         jbm = new JBMBootstrapServer("./server0/jbm-jboss-beans.xml");
+         jbm.run();
+         
+         // Step 4. As we are not using a JNDI environment we instantiate the objects directly         
+         ClientSessionFactory sf = new ClientSessionFactoryImpl (new TransportConfiguration(NettyConnectorFactory.class.getName()));
+         
+         // Step 5. Create a core queue
+         ClientSession coreSession = sf.createSession(false, false, false);
+         
+         final String queueName = "queue.exampleQueue";
+         
+         coreSession.createQueue(queueName, queueName, true);
+         
+         coreSession.close();
+                  
+         ClientSession session = null;
+   
+         try
+         {
+   
+            // Step 6. Create the session, and producer
+            session = sf.createSession();
+                                   
+            ClientProducer producer = session.createProducer(queueName);
+   
+            // Step 7. Create and send a message
+            ClientMessage message = session.createClientMessage(false);
+            
+            final String propName = "myprop";
+            
+            message.putStringProperty(propName, "Hello sent at " + new Date());
+            
+            System.out.println("Sending the message.");
+            
+            producer.send(message);
+
+            // Step 8. Create the message consumer and start the connection
+            ClientConsumer messageConsumer = session.createConsumer(queueName);
+            session.start();
+   
+            // Step 9. Receive the message. 
+            ClientMessage messageReceived = messageConsumer.receive(1000);
+            
+            System.out.println("Received TextMessage:" + messageReceived.getProperty(propName));
+         }
+         finally
+         {
+            // Step 10. Be sure to close our resources!
+            if (session != null)
+            {
+               session.close();
+            }
+
+            if (jbm != null)
+            {
+               jbm.shutDown();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         System.exit(-1);
+      }
+   }
+
+ 
+}


Property changes on: trunk/examples/core/embedded-remote
___________________________________________________________________
Name: svn:ignore
   + build


Added: trunk/examples/core/embedded-remote/build.xml
===================================================================
--- trunk/examples/core/embedded-remote/build.xml	                        (rev 0)
+++ trunk/examples/core/embedded-remote/build.xml	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+      <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+      ]>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., 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.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Embedded Example">
+
+   <import file="../../common/build.xml"/>
+
+   <!-- We use a minimal classpath on this example -->
+   <path id="local.classpath">
+      <fileset dir="${jbm.jars.dir}">
+        <include name="jbm-core-client.jar"/>
+        <include name="jbm-transports.jar"/>
+      </fileset>
+   	  <fileset dir="${jars.dir}">
+        <include name="netty/lib/*jar"/>
+        <exclude name="**/*-sources.jar"/>
+   	  </fileset>
+      <pathelement location="${classes.dir}"/>	   	
+   </path>
+	
+   <path id="remote.classpath">
+    <fileset dir="${jbm.jars.dir}">
+      <include name="jbm-core.jar"/>
+      <include name="jbm-transports.jar"/>
+    </fileset>
+ 	  <fileset dir="${jars.dir}">
+      <include name="netty/lib/*jar"/>
+      <exclude name="**/*-sources.jar"/>
+ 	  </fileset>
+    <pathelement location="${classes.dir}"/>	   	
+   </path>
+
+   <target name="run" depends="compile">
+   	
+   	   <pathconvert refid="remote.classpath" property="remote-classpath"/>
+   	
+   	   <echo message="path = ${remote-classpath}"/>
+
+	   <java classname="org.jboss.core.example.EmbeddedNettyExample" fork="true" resultproperty="example-result">
+	      <jvmarg value="-Xms50M"/>      
+	      <jvmarg value="-Xmx50M"/>
+	   	  <sysproperty key="remote-classpath" value="${remote-classpath}"/>
+	      <classpath refid="local.classpath"/>
+	   </java>
+      
+   </target>
+</project>

Added: trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedRemoteExample.java
===================================================================
--- trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedRemoteExample.java	                        (rev 0)
+++ trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedRemoteExample.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,144 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * 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.core.example;
+
+import java.util.Date;
+
+import org.jboss.common.example.SpawnedVMSupport;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+
+
+/**
+ * 
+ * This exammple shows how to run a JBoss Messaging core client and server embedded in your
+ * own application
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class EmbeddedRemoteExample
+{
+
+   public static void main(String[] args)
+   {
+
+      Process process = null;
+      try
+      {
+         
+         // Step 1. start a server remotely
+         // Step 2 and 3 on EmbeddedServer
+         process = startRemoteEmbedded();
+         
+         // Step 4. As we are not using a JNDI environment we instantiate the objects directly         
+         ClientSessionFactory sf = new ClientSessionFactoryImpl (new TransportConfiguration(NettyConnectorFactory.class.getName()));
+         
+         // Step 5. Create a core queue
+         ClientSession coreSession = sf.createSession(false, false, false);
+         
+         final String queueName = "queue.exampleQueue";
+         
+         coreSession.createQueue(queueName, queueName, true);
+         
+         coreSession.close();
+                  
+         ClientSession session = null;
+   
+         try
+         {
+   
+            // Step 6. Create the session, and producer
+            session = sf.createSession();
+                                   
+            ClientProducer producer = session.createProducer(queueName);
+   
+            // Step 7. Create and send a message
+            ClientMessage message = session.createClientMessage(false);
+            
+            final String propName = "myprop";
+            
+            message.putStringProperty(propName, "Hello sent at " + new Date());
+            
+            System.out.println("Sending the message.");
+            
+            producer.send(message);
+
+            // Step 8. Create the message consumer and start the connection
+            ClientConsumer messageConsumer = session.createConsumer(queueName);
+            session.start();
+   
+            // Step 9. Receive the message. 
+            ClientMessage messageReceived = messageConsumer.receive(1000);
+            System.out.println("Received TextMessage:" + messageReceived.getProperty(propName));
+         }
+         finally
+         {
+            // Step 10. Be sure to close our resources!
+            if (session != null)
+            {
+               session.close();
+            }
+
+            if (process != null)
+            {
+               process.destroy();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         System.exit(-1);
+      }
+   }
+
+   /**
+    * @return
+    * @throws Exception
+    */
+   private static Process startRemoteEmbedded() throws Exception
+   {
+      Process process;
+      String remoteClasspath= System.getProperty("remote-classpath");
+      
+      if (remoteClasspath == null)
+      {
+         System.out.println("remote-classpath system property needs to be specified");
+         System.exit(-1);
+      }
+      
+      process = SpawnedVMSupport.spawnVM(remoteClasspath, EmbeddedServer.class.getName(), new String[]{}, true, 
+                               "STARTED::",
+                               "FAILED::",
+                               ".",
+                               new String[]{});
+      return process;
+   }
+
+}

Added: trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedServer.java
===================================================================
--- trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedServer.java	                        (rev 0)
+++ trunk/examples/core/embedded-remote/src/org/jboss/core/example/EmbeddedServer.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.core.example;
+
+import java.util.HashSet;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.server.Messaging;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+
+/**
+ * A EmbeddedServer
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class EmbeddedServer
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public static void main(String arg[])
+   {
+      try
+      {
+         // Step 2. Create the Configuration, and set the properties accordingly
+         Configuration configuration = new ConfigurationImpl();
+         configuration.setPersistenceEnabled(false);
+         configuration.setSecurityEnabled(false);
+         
+         TransportConfiguration transpConf = new TransportConfiguration(NettyAcceptorFactory.class.getName());
+         
+         HashSet<TransportConfiguration> setTransp = new HashSet<TransportConfiguration>();
+         setTransp.add(transpConf);
+         
+         configuration.setAcceptorConfigurations(setTransp);
+         
+         // Step 3. Create and start the server
+         MessagingServer server = Messaging.newMessagingServer(configuration);
+         server.start();
+         System.out.println("STARTED::");
+      }
+      catch (Exception e)
+      {
+         System.out.println("FAILED::");
+         e.printStackTrace();
+      }
+
+      
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -137,13 +137,13 @@
     * @param args the arguments
     * @throws Exception for any error
     */
-   public JBMBootstrapServer(String[] args) throws Exception
+   public JBMBootstrapServer(String ... args) throws Exception
    {
       super();
       this.args = args;
    }
 
-   public JBMBootstrapServer(final String[] args, KernelConfig kernelConfig) throws Exception
+   public JBMBootstrapServer(KernelConfig kernelConfig, final String ... args) throws Exception
    {
       super(kernelConfig);
       this.args = args;

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -141,7 +141,7 @@
       }
 
       PropertyKernelConfig propertyKernelConfig = new PropertyKernelConfig(System.getProperties());
-      bootstrap = new JBMBootstrapServer(containerConfig, propertyKernelConfig);
+      bootstrap = new JBMBootstrapServer(propertyKernelConfig, containerConfig);
       System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
       bootstrap.run();
       started = true;

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/microcontainer/JBMBootstrapServerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/microcontainer/JBMBootstrapServerTest.java	2009-05-21 13:56:55 UTC (rev 6968)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/microcontainer/JBMBootstrapServerTest.java	2009-05-21 18:05:06 UTC (rev 6969)
@@ -48,7 +48,7 @@
    }
    public void testRun() throws Exception
    {
-      JBMBootstrapServer bootstrap = new JBMBootstrapServer(new String[]{beans1});
+      JBMBootstrapServer bootstrap = new JBMBootstrapServer(beans1);
       bootstrap.run();
       assertTrue(DummyBean.started);
       bootstrap.shutDown();
@@ -59,7 +59,7 @@
    {
       Properties properties = new Properties();
       properties.setProperty("test", "foo");
-      JBMBootstrapServer bootstrap = new JBMBootstrapServer(new String[]{beans1}, new PropertyKernelConfig(properties));
+      JBMBootstrapServer bootstrap = new JBMBootstrapServer(new PropertyKernelConfig(properties), beans1);
       bootstrap.run();
       assertTrue(DummyBean.started);
       bootstrap.shutDown();




More information about the jboss-cvs-commits mailing list