[jboss-cvs] JBossAS SVN: r95996 - in projects/jboss-osgi/trunk: testsuite/example/src/test/java/org/jboss/test/osgi/example/jta and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 4 09:12:19 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-11-04 09:12:18 -0500 (Wed, 04 Nov 2009)
New Revision: 95996

Modified:
   projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml
   projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch080-provided-examples.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java
Log:
Add JTA coverage to userguide

Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml	2009-11-04 13:14:13 UTC (rev 95995)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml	2009-11-04 14:12:18 UTC (rev 95996)
@@ -5,22 +5,37 @@
 
   <title>Provided Bundles and Services</title>
   
-  <sect1 xml:id="SecBundleXerces">  
-    <title>XML Parser Services</title>
+  <sect1 xml:id="SecBundleBlueprint">  
+    <title>Blueprint Container Service</title>
     
-    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-apache-xerces.jar</emphasis> bundle provides services 
-    from DOM and SAX parsing.</para>
-
-    <para>The services are registered with the Framework under the name</para>
+    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-blueprint.jar</emphasis> bundle provides 
+    an early access of a Blueprint extender service.</para> 
     
+    <para>The <ulink url="http://jbossosgi.blogspot.com/2009/04/osgi-blueprint-service-rfc-124.html">Blueprint Container</ulink> 
+    service allows bundles to contain standard blueprint descriptors, which can be used for component wiring 
+    and injection of blueprint components. The idea is to use a plain POJO programming model and let 
+    Blueprint do the wiring for you. There should be no need for OSGi API to "pollute" your application logic.</para>
+    
+    <para>The Blueprint API is divided into the <emphasis role="bold">Blueprint Container</emphasis> and 
+    <emphasis role="bold">Blueprint Reflection</emphasis> packages.</para> 
+    
     <itemizedlist>
-      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html">javax.xml.parsers.SAXParserFactory</ulink></emphasis></listitem>
-      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html">javax.xml.parsers.DocumentBuilderFactory</ulink></emphasis></listitem>
+      <listitem><emphasis role="bold"><ulink url="http://jbmuc.dyndns.org/jboss-osgi-1.0.0.Beta4/apidocs/org/osgi/service/blueprint/container/package-summary.html">org.osgi.service.blueprint.container</ulink></emphasis></listitem>
+      <listitem><emphasis role="bold"><ulink url="http://jbmuc.dyndns.org/jboss-osgi-1.0.0.Beta4/apidocs/org/osgi/service/blueprint/reflect/package-summary.html">org.osgi.service.blueprint.reflect</ulink></emphasis></listitem>
     </itemizedlist>
     
-    <para>Please see <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html">XMLParserActivator</ulink>
-    for details.</para>
+  </sect1>
+  
+  <sect1 xml:id="SecHttpService">  
+    <title>HttpService</title>
     
+    <para>The <emphasis role="bold">pax-web-jetty-bundle.jar</emphasis> bundle from the OPS4J 
+    <ulink url="http://wiki.ops4j.org/display/paxweb/Pax+Web">Pax Web</ulink> project provides access to the 
+    <ulink url="http://www.osgi.org/javadoc/r4v42/org/osgi/service/http/package-frame.html">HttpService</ulink>.</para> 
+    
+    <para>An example of how a bundle uses the HttpService to register servlet and resources is given in 
+    <link linkend="SecHTTPServiceExample">HttpService Example</link>.</para>
+    
   </sect1>
   
   <sect1 xml:id="SecBundleJAXB">  
@@ -111,6 +126,30 @@
     
   </sect1>
   
+  <sect1 xml:id="SecBundleJTA">  
+    <title>JTA Service</title>
+    
+    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-jta.jar</emphasis> bundle registers two services with framework.</para>
+
+    <itemizedlist>
+      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javaee/5/docs/api/javax/transaction/TransactionManager.html">javax.transaction.TransactionManager</ulink></emphasis></listitem>
+      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javaee/5/docs/api/javax/transaction/UserTransaction.html">javax.transaction.UserTransaction</ulink></emphasis></listitem>
+    </itemizedlist>
+    
+    <para>Among others the JTA Service can be configured with these properties.</para>
+    
+    <table>
+      <tr><th>Key</th><th>Value</th><th>Description</th></tr>
+      <tr valign="top">
+        <td>com.arjuna.ats.arjuna.objectstore.objectStoreDir</td>
+        <td>${server.data.dir}/tx-object-store</td>
+        <td>The property that sets the transaction object store directory</td>
+      </tr>
+    </table>
+    
+    <para>For details please refer to the <ulink url="http://www.jboss.org/jbosstm/docs/index.html">JBossTM documentation</ulink>.</para>
+  </sect1>
+  
   <sect1 xml:id="SecBundleMicrocontainer">  
     <title>Microcontainer Service</title>
     
@@ -137,39 +176,6 @@
     </programlisting>
   </sect1>
   
-  <sect1 xml:id="SecBundleBlueprint">  
-    <title>Blueprint Container Service</title>
-    
-    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-blueprint.jar</emphasis> bundle provides 
-    an early access of a Blueprint extender service.</para> 
-    
-    <para>The <ulink url="http://jbossosgi.blogspot.com/2009/04/osgi-blueprint-service-rfc-124.html">Blueprint Container</ulink> 
-    service allows bundles to contain standard blueprint descriptors, which can be used for component wiring 
-    and injection of blueprint components. The idea is to use a plain POJO programming model and let 
-    Blueprint do the wiring for you. There should be no need for OSGi API to "pollute" your application logic.</para>
-    
-    <para>The Blueprint API is divided into the <emphasis role="bold">Blueprint Container</emphasis> and 
-    <emphasis role="bold">Blueprint Reflection</emphasis> packages.</para> 
-    
-    <itemizedlist>
-      <listitem><emphasis role="bold"><ulink url="http://jbmuc.dyndns.org/jboss-osgi-1.0.0.Beta4/apidocs/org/osgi/service/blueprint/container/package-summary.html">org.osgi.service.blueprint.container</ulink></emphasis></listitem>
-      <listitem><emphasis role="bold"><ulink url="http://jbmuc.dyndns.org/jboss-osgi-1.0.0.Beta4/apidocs/org/osgi/service/blueprint/reflect/package-summary.html">org.osgi.service.blueprint.reflect</ulink></emphasis></listitem>
-    </itemizedlist>
-    
-  </sect1>
-  
-  <sect1 xml:id="SecHttpService">  
-    <title>HttpService</title>
-    
-    <para>The <emphasis role="bold">pax-web-jetty-bundle.jar</emphasis> bundle from the OPS4J 
-    <ulink url="http://wiki.ops4j.org/display/paxweb/Pax+Web">Pax Web</ulink> project provides access to the 
-    <ulink url="http://www.osgi.org/javadoc/r4v42/org/osgi/service/http/package-frame.html">HttpService</ulink>.</para> 
-    
-    <para>An example of how a bundle uses the HttpService to register servlet and resources is given in 
-    <link linkend="SecHTTPServiceExample">HttpService Example</link>.</para>
-    
-  </sect1>
-  
   <sect1 xml:id="SecWebAppExtender">  
     <title>WebApp Extender</title>
     
@@ -193,4 +199,22 @@
     
   </sect1>
   
+  <sect1 xml:id="SecBundleXerces">  
+    <title>XML Parser Services</title>
+    
+    <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-apache-xerces.jar</emphasis> bundle provides services 
+    from DOM and SAX parsing.</para>
+
+    <para>The services are registered with the Framework under the name</para>
+    
+    <itemizedlist>
+      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html">javax.xml.parsers.SAXParserFactory</ulink></emphasis></listitem>
+      <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html">javax.xml.parsers.DocumentBuilderFactory</ulink></emphasis></listitem>
+    </itemizedlist>
+    
+    <para>Please see <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html">XMLParserActivator</ulink>
+    for details.</para>
+    
+  </sect1>
+  
 </chapter>

Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch080-provided-examples.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch080-provided-examples.xml	2009-11-04 13:14:13 UTC (rev 95995)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch080-provided-examples.xml	2009-11-04 14:12:18 UTC (rev 95996)
@@ -6,7 +6,7 @@
   <title>Provided Examples</title>
   
   <sect1 xml:id="SecBuildAndRunExamples">  
-    <title>Building the Examples</title>
+    <title>Build and Run the Examples</title>
     
     <para>JBoss OSGi comes with a number of examples that demonstrate supported functionality
     and show best practices. All examples are part of the binary distribution and tightly 
@@ -95,46 +95,97 @@
     <para>The simple example is covered in: <link linkend="SecWritingTests">Writing Test Cases</link></para>
   </sect1>
   
-  <sect1 xml:id="SecXMLParserServiceExample">  
-    <title>SAX/DOM Parser Service Example</title>
+  <sect1 xml:id="SecBlueprintContainerExample">  
+    <title>Blueprint Container</title>
+    
+    <para>The <emphasis role="bold">example-blueprint.jar</emphasis> bundle contains a number of 
+    components that are wired together and registerd as OSGi service through the Blueprint Container 
+    Service.</para>
+    
+    <para>The example uses this simple blueprint descriptor</para>
 
-    <para>The <emphasis role="bold">example-xml-parser.jar</emphasis> bundle gets a DocumentBuilderFactory/SAXParserFactory
-    respectivly and unmarshalls an XML document using that parser.
-    </para>
+    <programlisting role="XML"><![CDATA[
+    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" ...>
+      
+      <bean id="beanA" class="org.jboss.test.osgi.example.blueprint.bundle.BeanA">
+        <property name="mbeanServer" ref="mbeanService"/>
+      </bean>
+      
+      <service id="serviceA" ref="beanA" interface="org.jboss.test.osgi.example.blueprint.bundle.ServiceA">
+      </service>
+      
+      <service id="serviceB" interface="org.jboss.test.osgi.example.blueprint.bundle.ServiceB">
+        <bean class="org.jboss.test.osgi.example.blueprint.bundle.BeanB">
+           <property name="beanA" ref="beanA"/>
+        </bean>
+      </service>
+      
+      <reference id="mbeanService" interface="javax.management.MBeanServer"/>
     
+    </blueprint>
+    ]]></programlisting>
+
+    <para>The Blueprint Container registers two services <emphasis role="bold">ServiceA</emphasis> and
+    <emphasis role="bold">ServiceB</emphasis>. ServiceA is backed up by <emphasis role="bold">BeanA</emphasis>,
+    ServiceB is backed up by the anonymous <emphasis role="bold">BeanB</emphasis>. BeanA is injected into
+    BeanB and the <emphasis role="bold">MBeanServer</emphasis> gets injected into BeanA. Both beans are plain POJOs. 
+    There is <emphasis role="bold">no BundleActivator</emphasis> neccessary to register the services.</para>
+
+    <para>The example test verifies the correct wiring like this</para>
+    
     <programlisting role="JAVA">
-      ServiceReference sref = context.getServiceReference(DocumentBuilderFactory.class.getName());
-      if (sref == null)
-         throw new IllegalStateException("DocumentBuilderFactory not available");
-      
-      DocumentBuilderFactory factory = (DocumentBuilderFactory)context.getService(sref);
-      factory.setValidating(false);
-      
-      DocumentBuilder domBuilder = factory.newDocumentBuilder();
-      URL resURL = context.getBundle().getResource("example-xml-parser.xml");
-      Document dom = domBuilder.parse(resURL.openStream());
-      assertNotNull("Document not null", dom);
+     @Test
+     public void testServiceA() throws Exception
+     {
+        ServiceReference sref = context.getServiceReference(ServiceA.class.getName());
+        assertNotNull("ServiceA not null", sref);
+        
+        ServiceA service = (ServiceA)context.getService(sref);
+        MBeanServer mbeanServer = service.getMbeanServer();
+        assertNotNull("MBeanServer not null", mbeanServer);
+     }
     </programlisting>
     
     <programlisting role="JAVA">
-      ServiceReference sref = context.getServiceReference(SAXParserFactory.class.getName());
-      if (sref == null)
-         throw new IllegalStateException("SAXParserFactory not available");
+     @Test
+     public void testServiceB() throws Exception
+     {
+        ServiceReference sref = context.getServiceReference(ServiceB.class.getName());
+        assertNotNull("ServiceB not null", sref);
+        
+        ServiceB service = (ServiceB)context.getService(sref);
+        BeanA beanA = service.getBeanA();
+        assertNotNull("BeanA not null", beanA);
+     }
+    </programlisting>
+  </sect1>
+  
+  <sect1 xml:id="SecHTTPServiceExample">  
+    <title>HttpService</title>
+    
+    <para>The <emphasis role="bold">example-http.jar</emphasis> bundle contains a Service 
+    that registeres a servlet and a resource with the <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/service/http/HttpService.html">HttpService</ulink>.
+    </para>
+    
+    <programlisting role="JAVA">
+      ServiceTracker tracker = new ServiceTracker(context, HttpService.class.getName(), null);
+      tracker.open();
       
-      SAXParserFactory factory = (SAXParserFactory)context.getService(sref);
-      factory.setValidating(false);
-      
-      SAXParser saxParser = factory.newSAXParser();
-      URL resURL = context.getBundle().getResource("example-xml-parser.xml");
-      
-      SAXHandler saxHandler = new SAXHandler();
-      saxParser.parse(resURL.openStream(), saxHandler);
-      assertEquals("content", saxHandler.getContent());
+      HttpService httpService = (HttpService)tracker.getService();
+      if (httpService == null)
+         throw new IllegalStateException("HttpService not registered");
+  
+     Properties initParams = new Properties();
+     initParams.setProperty("initProp", "SomeValue");
+     httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
+     httpService.registerResources("/file", "/res", null);
     </programlisting>
+    
+    <para>The test then verifies that the registered servlet context and the registered resource can be accessed.</para>
   </sect1>
   
   <sect1 xml:id="SecJAXBServiceExample">  
-    <title>JAXB Service Example</title>
+    <title>JAXB Service</title>
 
     <para>The <emphasis role="bold">example-xml-jaxb.jar</emphasis> bundle gets the JAXBContext from the JAXBService
     and unmarshalls an XML document using JAXB
@@ -156,7 +207,7 @@
   </sect1>
   
   <sect1 xml:id="SecJMXServiceExample">  
-    <title>JMX Service Example</title>
+    <title>JMX Service</title>
 
     <para>The <emphasis role="bold">example-jmx.jar</emphasis> bundle tracks the MBeanServer service and registers
     a pojo with JMX. It then verifies the JMX access.
@@ -216,7 +267,7 @@
   </sect1>
   
   <sect1 xml:id="SecJNDIServiceExample">  
-    <title>JNDI Service Example</title>
+    <title>JNDI Service</title>
 
     <para>The <emphasis role="bold">example-jndi.jar</emphasis> bundle gets the InitialContext service and registers
     a string with JNDI. It then verifies the JNDI access.
@@ -261,32 +312,103 @@
     
   </sect1>
   
-  <sect1 xml:id="SecHTTPServiceExample">  
-    <title>HttpService Example</title>
-    
-    <para>The <emphasis role="bold">example-http.jar</emphasis> bundle contains a Service 
-    that registeres a servlet and a resource with the <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/service/http/HttpService.html">HttpService</ulink>.
+  <sect1 xml:id="SecJTAServiceExample">  
+    <title>JTA Service</title>
+
+    <para>The <emphasis role="bold">example-jta.jar</emphasis> bundle gets the 
+    <ulink url="http://java.sun.com/javaee/5/docs/api/javax/transaction/UserTransaction.html">javax.transaction.UserTransaction</ulink> service 
+    and registers a transactional user object (i.e. one that implements <ulink url="http://java.sun.com/javaee/5/docs/api/javax/transaction/Synchronization.html">
+    Synchronization</ulink>) with the <ulink url="http://java.sun.com/javaee/5/docs/api/javax/transaction/TransactionManager.html">javax.transaction.TransactionManager</ulink>
+    service. It then verifies that modifications on the user object are transactional.
     </para>
     
     <programlisting role="JAVA">
-      ServiceTracker tracker = new ServiceTracker(context, HttpService.class.getName(), null);
-      tracker.open();
+      Transactional txObj = new Transactional();
       
-      HttpService httpService = (HttpService)tracker.getService();
-      if (httpService == null)
-         throw new IllegalStateException("HttpService not registered");
-  
-     Properties initParams = new Properties();
-     initParams.setProperty("initProp", "SomeValue");
-     httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
-     httpService.registerResources("/file", "/res", null);
+      ServiceReference userTxRef = context.getServiceReference(UserTransaction.class.getName());
+      assertNotNull("UserTransaction service not null", userTxRef);
+      
+      UserTransaction userTx = (UserTransaction)context.getService(userTxRef);
+      assertNotNull("UserTransaction not null", userTx);
+      
+      userTx.begin();
+      try
+      {
+         ServiceReference tmRef = context.getServiceReference(TransactionManager.class.getName());
+         assertNotNull("TransactionManager service not null", tmRef);
+         
+         TransactionManager tm = (TransactionManager)context.getService(tmRef);
+         assertNotNull("TransactionManager not null", tm);
+         
+         Transaction tx = tm.getTransaction();
+         assertNotNull("Transaction not null", tx);
+         
+         tx.registerSynchronization(txObj);
+         
+         txObj.setMessage("Donate $1.000.000");
+         assertNull("Uncommited message null", txObj.getMessage());
+         
+         userTx.commit();
+      }
+      catch (Exception e)
+      {
+         userTx.setRollbackOnly();
+      }
+
+      assertEquals("Donate $1.000.000", txObj.getMessage());
     </programlisting>
     
-    <para>The test then verifies that the registered servlet context and the registered resource can be accessed.</para>
+    <programlisting role="JAVA">
+   class Transactional implements Synchronization
+   {
+      private String volatileMessage;
+      private String message;
+      
+      public void beforeCompletion()
+      {
+      }
+      
+      public void afterCompletion(int status)
+      {
+         if (status == Status.STATUS_COMMITTED)
+            message = volatileMessage;
+      }
+      
+      public String getMessage()
+      {
+         return message;
+      }
+
+      public void setMessage(String message)
+      {
+         this.volatileMessage = message;
+      }
+   }
+    </programlisting>
+    
   </sect1>
   
+  <sect1 xml:id="SecMicrocontainerServiceExample">  
+    <title>Microcontainer Service</title>
+    
+    <para>The <emphasis role="bold">example-microcontainer.jar</emphasis> bundle calls a service 
+    from an MC bean and vica versa. The MC bean gets the MBeanServer injected and registeres itself as an MBean.</para>
+    
+    <para>The test accesses the registered MBean.</para>
+
+    <programlisting role="JAVA">
+    @Test
+    public void testServiceRoundTrip() throws Exception
+    {
+      SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, MBEAN_NAME, runtime.getMBeanServer());
+      assertEquals("hello", someBean.echo("hello"));
+      assertEquals("hello", someBean.callSomeService("hello"));
+    }
+    </programlisting>
+  </sect1>
+  
   <sect1 xml:id="SecWebAppExample">  
-    <title>WebApp Example</title>
+    <title>Web Application</title>
     
     <para>The <emphasis role="bold">example-webapp.war</emphasis> archive is an OSGi Bundle and a Web Application Archive (WAR)
     at the same time. Similar to <link linkend="SecHTTPServiceExample">HTTP Service Example</link> it registers a servlet and resources with 
@@ -344,88 +466,42 @@
 
   </sect1>
   
-  <sect1 xml:id="SecMicrocontainerServiceExample">  
-    <title>Microcontainer Service Example</title>
+  <sect1 xml:id="SecXMLParserServiceExample">  
+    <title>XML Parser Service</title>
+
+    <para>The <emphasis role="bold">example-xml-parser.jar</emphasis> bundle gets a DocumentBuilderFactory/SAXParserFactory
+    respectivly and unmarshalls an XML document using that parser.
+    </para>
     
-    <para>The <emphasis role="bold">example-microcontainer.jar</emphasis> bundle calls a service 
-    from an MC bean and vica versa. The MC bean gets the MBeanServer injected and registeres itself as an MBean.</para>
-    
-    <para>The test accesses the registered MBean.</para>
-
     <programlisting role="JAVA">
-    @Test
-    public void testServiceRoundTrip() throws Exception
-    {
-      SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, MBEAN_NAME, runtime.getMBeanServer());
-      assertEquals("hello", someBean.echo("hello"));
-      assertEquals("hello", someBean.callSomeService("hello"));
-    }
+      ServiceReference sref = context.getServiceReference(DocumentBuilderFactory.class.getName());
+      if (sref == null)
+         throw new IllegalStateException("DocumentBuilderFactory not available");
+      
+      DocumentBuilderFactory factory = (DocumentBuilderFactory)context.getService(sref);
+      factory.setValidating(false);
+      
+      DocumentBuilder domBuilder = factory.newDocumentBuilder();
+      URL resURL = context.getBundle().getResource("example-xml-parser.xml");
+      Document dom = domBuilder.parse(resURL.openStream());
+      assertNotNull("Document not null", dom);
     </programlisting>
-  </sect1>
-  
-  <sect1 xml:id="SecBlueprintContainerExample">  
-    <title>Blueprint Container Example</title>
     
-    <para>The <emphasis role="bold">example-blueprint.jar</emphasis> bundle contains a number of 
-    components that are wired together and registerd as OSGi service through the Blueprint Container 
-    Service.</para>
-    
-    <para>The example uses this simple blueprint descriptor</para>
-
-    <programlisting role="XML"><![CDATA[
-    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" ...>
+    <programlisting role="JAVA">
+      ServiceReference sref = context.getServiceReference(SAXParserFactory.class.getName());
+      if (sref == null)
+         throw new IllegalStateException("SAXParserFactory not available");
       
-      <bean id="beanA" class="org.jboss.test.osgi.example.blueprint.bundle.BeanA">
-        <property name="mbeanServer" ref="mbeanService"/>
-      </bean>
+      SAXParserFactory factory = (SAXParserFactory)context.getService(sref);
+      factory.setValidating(false);
       
-      <service id="serviceA" ref="beanA" interface="org.jboss.test.osgi.example.blueprint.bundle.ServiceA">
-      </service>
+      SAXParser saxParser = factory.newSAXParser();
+      URL resURL = context.getBundle().getResource("example-xml-parser.xml");
       
-      <service id="serviceB" interface="org.jboss.test.osgi.example.blueprint.bundle.ServiceB">
-        <bean class="org.jboss.test.osgi.example.blueprint.bundle.BeanB">
-           <property name="beanA" ref="beanA"/>
-        </bean>
-      </service>
-      
-      <reference id="mbeanService" interface="javax.management.MBeanServer"/>
-    
-    </blueprint>
-    ]]></programlisting>
-
-    <para>The Blueprint Container registers two services <emphasis role="bold">ServiceA</emphasis> and
-    <emphasis role="bold">ServiceB</emphasis>. ServiceA is backed up by <emphasis role="bold">BeanA</emphasis>,
-    ServiceB is backed up by the anonymous <emphasis role="bold">BeanB</emphasis>. BeanA is injected into
-    BeanB and the <emphasis role="bold">MBeanServer</emphasis> gets injected into BeanA. Both beans are plain POJOs. 
-    There is <emphasis role="bold">no BundleActivator</emphasis> neccessary to register the services.</para>
-
-    <para>The example test verifies the correct wiring like this</para>
-    
-    <programlisting role="JAVA">
-     @Test
-     public void testServiceA() throws Exception
-     {
-        ServiceReference sref = context.getServiceReference(ServiceA.class.getName());
-        assertNotNull("ServiceA not null", sref);
-        
-        ServiceA service = (ServiceA)context.getService(sref);
-        MBeanServer mbeanServer = service.getMbeanServer();
-        assertNotNull("MBeanServer not null", mbeanServer);
-     }
+      SAXHandler saxHandler = new SAXHandler();
+      saxParser.parse(resURL.openStream(), saxHandler);
+      assertEquals("content", saxHandler.getContent());
     </programlisting>
-    
-    <programlisting role="JAVA">
-     @Test
-     public void testServiceB() throws Exception
-     {
-        ServiceReference sref = context.getServiceReference(ServiceB.class.getName());
-        assertNotNull("ServiceB not null", sref);
-        
-        ServiceB service = (ServiceB)context.getService(sref);
-        BeanA beanA = service.getBeanA();
-        assertNotNull("BeanA not null", beanA);
-     }
-    </programlisting>
   </sect1>
   
 </chapter>

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java	2009-11-04 13:14:13 UTC (rev 95995)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java	2009-11-04 14:12:18 UTC (rev 95996)
@@ -93,20 +93,29 @@
       // Stop here if the context is not injected
       assumeNotNull(context);
       
-      ServiceReference sref = context.getServiceReference(UserTransaction.class.getName());
-      assertNotNull("UserTransaction service not null", sref);
+      Transactional txObj = new Transactional();
       
-      UserTransaction userTx = (UserTransaction)context.getService(sref);
+      ServiceReference userTxRef = context.getServiceReference(UserTransaction.class.getName());
+      assertNotNull("UserTransaction service not null", userTxRef);
+      
+      UserTransaction userTx = (UserTransaction)context.getService(userTxRef);
       assertNotNull("UserTransaction not null", userTx);
       
-      Transactional txObj = new Transactional();
-      
       userTx.begin();
       try
       {
-         txObj.register(context);
+         ServiceReference tmRef = context.getServiceReference(TransactionManager.class.getName());
+         assertNotNull("TransactionManager service not null", tmRef);
          
-         txObj.setMessage("Hello World");
+         TransactionManager tm = (TransactionManager)context.getService(tmRef);
+         assertNotNull("TransactionManager not null", tm);
+         
+         Transaction tx = tm.getTransaction();
+         assertNotNull("Transaction not null", tx);
+         
+         tx.registerSynchronization(txObj);
+         
+         txObj.setMessage("Donate $1.000.000");
          assertNull("Uncommited message null", txObj.getMessage());
          
          userTx.commit();
@@ -116,7 +125,7 @@
          userTx.setRollbackOnly();
       }
 
-      assertEquals("Hello World", txObj.getMessage());
+      assertEquals("Donate $1.000.000", txObj.getMessage());
    }
 
    class Transactional implements Synchronization
@@ -143,19 +152,5 @@
       {
          this.volatileMessage = message;
       }
-
-      void register(BundleContext context) throws Exception
-      {
-         ServiceReference sref = context.getServiceReference(TransactionManager.class.getName());
-         assertNotNull("TransactionManager service not null", sref);
-         
-         TransactionManager tm = (TransactionManager)context.getService(sref);
-         assertNotNull("TransactionManager not null", tm);
-         
-         Transaction tx = tm.getTransaction();
-         assertNotNull("Transaction not null", tx);
-         
-         tx.registerSynchronization(this);
-      }
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list