JBoss-OSGI SVN: r97539 - in projects/jboss-osgi/projects/spi/trunk: src/main/java/org/jboss/osgi/spi/capability and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 09:14:03 -0500 (Tue, 08 Dec 2009)
New Revision: 97539
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/EventAdminCapability.java
Modified:
projects/jboss-osgi/projects/spi/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
Add EventAdminCapability
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-12-08 14:13:08 UTC (rev 97538)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-12-08 14:14:03 UTC (rev 97539)
@@ -20,7 +20,7 @@
<artifactId>jboss-osgi-spi</artifactId>
<packaging>jar</packaging>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
<!-- Parent -->
<parent>
Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/EventAdminCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/EventAdminCapability.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/EventAdminCapability.java 2009-12-08 14:14:03 UTC (rev 97539)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.jboss.osgi.spi.capability;
+
+//$Id$
+
+import org.osgi.service.event.EventAdmin;
+
+/**
+ * Adds the OSGi compedium EventAdmin capability.
+ *
+ * It is ignored if the {@link EventAdmin} is already registered.
+ *
+ * Installed bundles: org.apache.felix.eventadmin.jar
+ *
+ * [TODO] Add to SPI
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Dec-2009
+ */
+public class EventAdminCapability extends Capability
+{
+ public EventAdminCapability()
+ {
+ super(EventAdmin.class.getName());
+
+ addDependency(new LogServiceCapability());
+
+ addBundle("bundles/org.apache.felix.eventadmin.jar");
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/EventAdminCapability.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-08 14:13:08 UTC (rev 97538)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-08 14:14:03 UTC (rev 97539)
@@ -211,7 +211,7 @@
if (url == null)
{
String prefix = System.getProperty("test.archive.directory", "target/test-libs");
- if (new File(prefix).exists())
+ if (location.startsWith(prefix) == false && new File(prefix).exists())
return getRealLocation(prefix + File.separator + location);
}
16 years, 7 months
JBoss-OSGI SVN: r97538 - in projects/jboss-osgi/trunk: distribution/docbook/en/images and 9 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 09:13:08 -0500 (Tue, 08 Dec 2009)
New Revision: 97538
Added:
projects/jboss-osgi/trunk/distribution/docbook/en/images/extender-approach.png
projects/jboss-osgi/trunk/distribution/docbook/en/images/interceptor-approach.png
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/EventAdminTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/event/
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/event/example-event.bnd
Removed:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java
Modified:
projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml
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/pom.xml
projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Add EventAdmin test case
Added: projects/jboss-osgi/trunk/distribution/docbook/en/images/extender-approach.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/distribution/docbook/en/images/extender-approach.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/jboss-osgi/trunk/distribution/docbook/en/images/interceptor-approach.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/distribution/docbook/en/images/interceptor-approach.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -277,4 +277,121 @@
</sect1>
+ <sect1 xml:id="SecLifecycleInterceptors">
+ <title>Lifecycle Interceptors</title>
+
+ <para>A common pattern in OSGi is that a bundle contains some piece of meta data that gets processed by some other infrastructure bundle
+ that is installed in the OSGi Framework. In such cases the well known <ulink url="http://www.osgi.org/blog/2007/02/osgi-extender-model.html">Extender Pattern</ulink>
+ is often being used. JBoss OSGi offeres a differnet approach to address this problem which is covered by the <ulink url="http://jbossosgi.blogspot.com/2009/10/extender-pattern-vs-lifecycle.html">
+ Extender Pattern vs. Lifecycle Interceptor</ulink> post in the <ulink url="http://jbossosgi.blogspot.com/">JBoss OSGi Diary</ulink>.</para>
+
+ <emphasis role="bold">Extending an OSGi Bundle</emphasis>
+
+ <orderedlist>
+ <listitem>Extender registers itself as BundleListener</listitem>
+ <listitem>Bundle gets installed/started</listitem>
+ <listitem>Framework fires a BundleEvent</listitem>
+ <listitem>Extender picks up the BundleEvent (e.g. STARTING)</listitem>
+ <listitem>Extender reads metadata from the Bundle and does its work</listitem>
+ </orderedlist>
+
+ <para>There is no extender specific API. It is a pattern rather than a piece of functionality provided by the Framework.
+ Typical examples of extenders are the Blueprint or Web Application Extender.</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" width="90%" fileref="images/extender-approach.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>Client code that installs, starts and uses the registered endpoint could look like this.</para>
+
+ <programlisting role="JAVA">
+ // Install and start the Web Application bundle
+ Bundle bundle = context.installBundle("mywebapp.war");
+ bundle.start();
+
+ // Access the Web Application
+ String response = getHttpResponse("http://localhost:8090/mywebapp/foo");
+ assertEquals("ok", response);
+ </programlisting>
+
+ <para>This seemingly trivial code snippet has a number of issues that are probably worth looking into in more detail</para>
+
+ <itemizedlist>
+ <listitem>The WAR might have missing or invalid web metadata (i.e. an invalid WEB-INF/web.xml descriptor)</listitem>
+ <listitem>The WAR Extender might not be present in the system</listitem>
+ <listitem>There might be multiple WAR Extenders present in the system</listitem>
+ <listitem>Code assumes that the endpoint is available on return of bundle.start()</listitem>
+ </itemizedlist>
+
+ <para>Most Blueprint or WebApp bundles are not useful if their Blueprint/Web metadata is not processed. Even if they are processed
+ but in the "wrong" order a user might see unexpected results (i.e. the webapp processes the first request before the underlying
+ Blueprint app is wired together).</para>
+
+ <para>As a consequence the extender pattern is useful in some cases but not all. It is mainly useful if a bundle can optionally
+ be extended in the true sense of the word.</para>
+
+ <emphasis role="bold">Intercepting the Bundle Lifecycle</emphasis>
+
+ <para>If the use case requires the notion of "interceptor" the extender pattern is less useful. The use case might be such that
+ you would want to intercept the bundle lifecycle at various phases to do mandatory metadata processing.</para>
+
+ <para>An interceptor could be used for annotation processing, byte code weaving, and other non-optional/optional metadata processing steps.
+ Typically interceptors have a relative order, can communicate with each other, veto progress, etc.</para>
+
+ <para>Lets look at how multiple interceptors can be used to create Web metadata and publish endpoints on the HttpService based on that metadata.</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" width="90%" fileref="images/interceptor-approach.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>Here is how it works</para>
+
+ <orderedlist>
+ <listitem>The Wep Application processor registers two LifecycleInterceptors with the LifecycleInterceptorService</listitem>
+ <listitem>The Parser interceptor declares no required input and WebApp metadata as produced output</listitem>
+ <listitem>The Publisher interceptor declares WebApp metadata as required input</listitem>
+ <listitem>The LifecycleInterceptorService reorders all registered interceptors according to their input/output requirements and relative order</listitem>
+ <listitem>The WAR Bundle gets installed and started</listitem>
+ <listitem>The Framework calls the LifecycleInterceptorService prior to the actual state change</listitem>
+ <listitem>The LifecycleInterceptorService calls each interceptor in the chain</listitem>
+ <listitem>The Parser interceptor processes WEB-INF/web.xml in the invoke(int state, InvocationContext context) method and attaches WebApp metadata to the InvocationContext</listitem>
+ <listitem>The Publisher interceptor is only called when the InvocationContext has WebApp metadata attached. If so, it publishes the endpoint from the WebApp metadata</listitem>
+ <listitem>If no interceptor throws an Exception the Framework changes the Bundle state and fires the BundleEvent. </listitem>
+ </orderedlist>
+
+ <para>Client code is identical to above.</para>
+
+ <programlisting role="JAVA">
+ // Install and start the Web Application bundle
+ Bundle bundle = context.installBundle("mywebapp.war");
+ bundle.start();
+
+ // Access the Web Application
+ String response = getHttpResponse("http://localhost:8090/mywebapp/foo");
+ assertEquals("ok", response);
+ </programlisting>
+
+ <para>The behaviour of that code however, is not only different but also provides a more natural user experience.</para>
+
+ <itemizedlist>
+ <listitem>Bundle.start() fails if WEB-INF/web.xml is invalid</listitem>
+ <listitem>An interceptor could fail if web.xml is not present</listitem>
+ <listitem>The Publisher interceptor could fail if the HttpService is not present</listitem>
+ <listitem>Multiple Parser interceptors would work mutually exclusiv on the presents of attached WebApp metadata</listitem>
+ <listitem>The endpoint is guaranteed to be available when Bundle.start() returns</listitem>
+ </itemizedlist>
+
+ <para>The general idea is that each interceptor takes care of a particular aspect of processing during state changes.
+ In the example above WebApp metadata might get provided by an interceptor that scans annotations or by another one that
+ generates the metadata in memory. The Publisher interceptor would not know nor care who attached the WebApp metadata object,
+ its task is to consume the WebApp metadata and publish endpoints from it.</para>
+
+ <para>For details on howto provide and register liefecycle interceptors have a look at the <link linkend="SecInterceptorExample">
+ Lifecycle Interceptor Example</link>.</para>
+ </sect1>
+
</chapter>
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-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -203,7 +203,7 @@
<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>
+ for DOM and SAX parsing.</para>
<para>The services are registered with the Framework under the name</para>
@@ -220,19 +220,15 @@
<sect1 xml:id="SecBundleXMLBinding">
<title>XML Binding Services</title>
- <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-xml-binding.jar</emphasis> bundle provides services
- from DOM and SAX parsing.</para>
+ <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-xml-binding.jar</emphasis> bundle provides an
+ <ulink url="http://www.jboss.org/community/wiki/JBossXB">JBossXB</ulink> unmarshaller service.</para>
- <para>The services are registered with the Framework under the name</para>
+ <para>The service is 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....">javax.xml.parsers.SAXParserFactory</ulink></emphasis></listitem>
- <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFa...">javax.xml.parsers.DocumentBuilderFactory</ulink></emphasis></listitem>
+ <listitem><emphasis role="bold"><ulink url="http://jbmuc.dyndns.org/jboss-osgi-1.0.0.Beta5/apidocs/org/jboss/osgi/jbo...">org.jboss.osgi.jbossxb.UnmarshallerService</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-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch080-provided-examples.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -22,37 +22,18 @@
-------------------------------------------------------
T E S T S
-------------------------------------------------------
- Running org.jboss.test.osgi.example.webapp.WebAppTestCase
- Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.202 sec
- Running org.jboss.test.osgi.example.blueprint.BlueprintTestCase
- Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.447 sec
- Running org.jboss.test.osgi.example.xml.jaxb.JAXBTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.722 sec
- Running org.jboss.test.osgi.example.microcontainer.MicrocontainerTestCase
- Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.444 sec
- Running org.jboss.test.osgi.example.xml.parser.SAXParserTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.452 sec
- Running org.jboss.test.osgi.example.http.HttpServiceTestCase
- Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.562 sec
- Running org.jboss.test.osgi.example.xml.parser.DOMParserTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.032 sec
- Running org.jboss.test.osgi.example.jndi.JNDITestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.836 sec
- Running org.jboss.test.osgi.example.jmx.JMXTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.058 sec
- Running org.jboss.test.osgi.example.simple.SimpleTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.772 sec
- Running org.jboss.test.osgi.example.simple.SimpleHuskyTestCase
- Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.262 sec
+ Running org.jboss.test.osgi.example.webapp.WebAppInterceptorTestCase
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.417 sec
+ ...
- Tests run: 21, Failures: 0, Errors: 0, Skipped: 0
+ Tests run: 24, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
- [INFO] Total time: 49 seconds
- [INFO] Finished at: Tue Oct 13 13:04:20 CEST 2009
- [INFO] Final Memory: 25M/47M
+ [INFO] Total time: 1 minute 31 seconds
+ [INFO] Finished at: Tue Dec 08 11:15:08 CET 2009
+ [INFO] Final Memory: 35M/139M
[INFO] ------------------------------------------------------------------------
</programlisting>
@@ -361,28 +342,13 @@
<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>
@@ -504,4 +470,127 @@
</programlisting>
</sect1>
+ <sect1 xml:id="SecXMLBindingServiceExample">
+ <title>XML Unmarshaller Service</title>
+
+ <para>The <emphasis role="bold">example-xml-binding.jar</emphasis> bundle unmarshalls an XML document through the UnmarshallerService.
+ This example is very similar to the <link linkend="SecJAXBServiceExample">JAXB Example</link>. However, it uses JBossXB to do the
+ unmarshalling.</para>
+
+ <programlisting role="JAVA">
+ ServiceReference sref = context.getServiceReference(UnmarshallerService.class.getName());
+ UnmarshallerService unmarshaller = (UnmarshallerService)context.getService(sref);
+
+ Bundle bundle = context.getBundle();
+ URL xsdurl = bundle.getEntry("booking.xsd");
+ URL xmlurl = bundle.getEntry("booking.xml");
+
+ unmarshaller.registerSchemaLocation("http://org.jboss.test.osgi.jbossxb.simple/booking.xsd", xsdurl.toExternalForm());
+ unmarshaller.addClassBinding(CourseBooking.NAMESPACE_XML_SIMPLE, CourseBooking.class);
+
+ CourseBooking booking = (CourseBooking)unmarshaller.unmarshal(xmlurl.toExternalForm());
+ </programlisting>
+ </sect1>
+
+ <sect1 xml:id="SecInterceptorExample">
+ <title>Lifecycle Interceptor</title>
+
+ <para>The interceptor example deployes a bundle that contains some metadata and an interceptor bundle that processes
+ the metadata and registeres an http endpoint from it. The idea is that the bundle does not process its own metadata.
+ Instead this work is delegated to some specialized metadata processor (i.e. the interceptor).</para>
+
+ <para>Each interceptor is itself registered as a service. This is the well known <ulink url="www.osgi.org/wiki/uploads/Links/whiteboard.pdf">
+ Whiteboard Pattern</ulink>.</para>
+
+ <programlisting role="JAVA">
+ public class InterceptorActivator implements BundleActivator
+ {
+ public void start(BundleContext context)
+ {
+ LifecycleInterceptor publisher = new PublisherInterceptor();
+ LifecycleInterceptor parser = new ParserInterceptor();
+
+ // Add the interceptors, the order of which is handles by the service
+ context.registerService(LifecycleInterceptor.class.getName(), publisher, null);
+ context.registerService(LifecycleInterceptor.class.getName(), parser, null);
+ }
+ }
+ </programlisting>
+
+ <programlisting role="JAVA">
+ public class ParserInterceptor extends AbstractLifecycleInterceptor
+ {
+ ParserInterceptor()
+ {
+ // Add the provided output
+ addOutput(HttpMetadata.class);
+ }
+
+ public void invoke(int state, InvocationContext context)
+ {
+ // Do nothing if the metadata is already available
+ HttpMetadata metadata = context.getAttachment(HttpMetadata.class);
+ if (metadata != null)
+ return;
+
+ // Parse and create metadta on STARTING
+ if (state == Bundle.STARTING)
+ {
+ VirtualFile root = context.getRoot();
+ VirtualFile propsFile = root.getChild("/http-metadata.properties");
+ if (propsFile != null)
+ {
+ log.info("Create and attach HttpMetadata");
+ metadata = createHttpMetadata(propsFile);
+ context.addAttachment(HttpMetadata.class, metadata);
+ }
+ }
+ }
+ ...
+ }
+ </programlisting>
+
+ <programlisting role="JAVA">
+ public class PublisherInterceptor extends AbstractLifecycleInterceptor
+ {
+ PublisherInterceptor()
+ {
+ // Add the required input
+ addInput(HttpMetadata.class);
+ }
+
+ public void invoke(int state, InvocationContext context)
+ {
+ // HttpMetadata is guaratied to be available because we registered
+ // this type as required input
+ HttpMetadata metadata = context.getAttachment(HttpMetadata.class);
+
+ // Register HttpMetadata on STARTING
+ if (state == Bundle.STARTING)
+ {
+ String servletName = metadata.getServletName();
+
+ // Load the endpoint servlet from the bundle
+ Bundle bundle = context.getBundle();
+ Class servletClass = bundle.loadClass(servletName);
+ HttpServlet servlet = (HttpServlet)servletClass.newInstance();
+
+ // Register the servlet with the HttpService
+ HttpService httpService = getHttpService(context, true);
+ httpService.registerServlet("/servlet", servlet, null, null);
+ }
+
+ // Unregister the endpoint on STOPPING
+ else if (state == Bundle.STOPPING)
+ {
+ log.info("Unpublish HttpMetadata: " + metadata);
+ HttpService httpService = getHttpService(context, false);
+ if (httpService != null)
+ httpService.unregister("/servlet");
+ }
+ }
+ }
+ </programlisting>
+ </sect1>
+
</chapter>
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/pom.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -67,7 +67,7 @@
<version.jboss.osgi.runtime.equinox>3.5.1</version.jboss.osgi.runtime.equinox>
<version.jboss.osgi.runtime.felix>2.0.2</version.jboss.osgi.runtime.felix>
<version.jboss.osgi.runtime.jbossas>1.0.2</version.jboss.osgi.runtime.jbossas>
- <version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
+ <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.webapp>0.7.2</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
<version.jboss.osgi.xml.binding>2.0.2.Beta3</version.jboss.osgi.xml.binding>
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -45,6 +45,9 @@
<!-- blueprint -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-blueprint.jar" files="${tests.resources.dir}/blueprint/example-blueprint.bnd" />
+ <!-- event -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-event.jar" files="${tests.resources.dir}/event/example-event.bnd" />
+
<!-- http -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-http.jar" files="${tests.resources.dir}/http/example-http.bnd" />
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -29,6 +29,7 @@
<include>*:jboss-osgi-webapp:jar</include>
<include>*:jboss-osgi-xml-binding:jar</include>
<include>*:org.apache.felix.configadmin:jar</include>
+ <include>*:org.apache.felix.eventadmin:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
<include>*:pax-web-extender-war:jar</include>
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/EventAdminTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/EventAdminTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/EventAdminTestCase.java 2009-12-08 14:13:08 UTC (rev 97538)
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+package org.jboss.test.osgi.example.event;
+
+//$Id$
+
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeNotNull;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.HuskyCapability;
+import org.jboss.osgi.husky.RuntimeContext;
+import org.jboss.osgi.spi.capability.EventAdminCapability;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
+import org.osgi.service.event.EventHandler;
+
+/**
+ * A test that deployes a bundle that containes a HttpServlet which is registered through the OSGi HttpService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Dec-2009
+ */
+public class EventAdminTestCase extends OSGiTest
+{
+ static String TOPIC = "org/jboss/test/osgi/example/event";
+
+ @RuntimeContext
+ public BundleContext context;
+
+ private OSGiRuntime runtime;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ if (context == null)
+ {
+ runtime = getDefaultRuntime();
+ runtime.addCapability(new HuskyCapability());
+ runtime.addCapability(new EventAdminCapability());
+
+ OSGiBundle bundle = runtime.installBundle("example-event.jar");
+ bundle.start();
+ }
+ }
+
+ @After
+ public void tearDown() throws BundleException
+ {
+ if (context == null)
+ runtime.shutdown();
+ }
+
+ @Test
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testEventHandler() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ assumeNotNull(context);
+
+ // Register the EventHandler
+ Dictionary param = new Hashtable();
+ param.put(EventConstants.EVENT_TOPIC, new String[] { TOPIC });
+ TestEventHandler eventHandler = new TestEventHandler();
+ context.registerService(EventHandler.class.getName(), eventHandler, param);
+
+ ServiceReference sref = context.getServiceReference(EventAdmin.class.getName());
+ EventAdmin eventAdmin = (EventAdmin)context.getService(sref);
+ eventAdmin.sendEvent(new Event(TOPIC, null));
+
+ assertEquals("Event received", 1, eventHandler.received.size());
+ assertEquals(TOPIC, eventHandler.received.get(0).getTopic());
+ }
+
+ static class TestEventHandler implements EventHandler
+ {
+ List<Event> received = new ArrayList<Event>();
+
+ public void handleEvent(Event event)
+ {
+ received.add(event);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/event/EventAdminTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java 2009-12-08 14:13:08 UTC (rev 97538)
@@ -1,63 +0,0 @@
-/*
- * 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.
- */
-package org.jboss.test.osgi.example.xml.jbossxb;
-
-//$Id$
-
-import java.net.URL;
-
-import org.jboss.osgi.jbossxb.UnmarshallerService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A bundle activator that uses the unmarshaller service
- *
- * @author thomas.diesler(a)jboss.com
- * @since 26-Nov-2009
- */
-public class XMLBindingActivator implements BundleActivator
-{
- public void start(BundleContext context) throws Exception
- {
- ServiceReference sref = context.getServiceReference(UnmarshallerService.class.getName());
- UnmarshallerService unmarshaller = (UnmarshallerService)context.getService(sref);
- unmarshaller.setSchemaValidation(true);
- unmarshaller.setNamespaceAware(true);
- unmarshaller.setValidation(true);
-
- Bundle bundle = context.getBundle();
- URL xsdurl = bundle.getEntry("booking.xsd");
- URL xmlurl = bundle.getEntry("booking.xml");
-
- unmarshaller.registerSchemaLocation("http://org.jboss.test.osgi.jbossxb.simple/booking.xsd", xsdurl.toExternalForm());
- unmarshaller.addClassBinding(CourseBooking.NAMESPACE_XML_SIMPLE, CourseBooking.class);
-
- unmarshaller.unmarshal(xmlurl.toExternalForm());
- }
-
- public void stop(BundleContext context) throws Exception
- {
- }
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/event/example-event.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/event/example-event.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/event/example-event.bnd 2009-12-08 14:13:08 UTC (rev 97538)
@@ -0,0 +1,8 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example/example-event.jar src/test/resources/example/event/example-event.bnd
+
+Bundle-SymbolicName: example-event
+Export-Package: org.jboss.test.osgi.example.event
+Import-Package: org.osgi.framework, org.osgi.service.event, org.jboss.osgi.husky, org.jboss.osgi.spi.capability, org.jboss.osgi.testing, org.junit
+
+# Tell Husky that there are test cases in this package
+Test-Package: org.jboss.test.osgi.example.event
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd 2009-12-08 14:13:08 UTC (rev 97538)
@@ -1,8 +1,6 @@
# bnd build -classpath target/test-classes -output target/test-libs/example-xml-binding.jar src/test/resources/simple/example-xml-binding.bnd
Bundle-SymbolicName: example-xml-binding
-Bundle-Activator: org.jboss.test.osgi.example.xml.jbossxb.XMLBindingActivator
-
Export-Package: org.jboss.test.osgi.example.xml.jbossxb
Import-Package: \
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-12-08 14:05:24 UTC (rev 97537)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-12-08 14:13:08 UTC (rev 97538)
@@ -75,6 +75,36 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.eventadmin</artifactId>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.metatype</artifactId>
<scope>provided</scope>
<exclusions>
16 years, 7 months
JBoss-OSGI SVN: r97531 - in projects/jboss-osgi/trunk: testsuite/example/scripts and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 05:16:14 -0500 (Tue, 08 Dec 2009)
New Revision: 97531
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CompanyType.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/ContactType.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CourseBooking.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/StudentType.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xsd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd
Modified:
projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch020-getting-started.xml
projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch030-runtime.xml
projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml
projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml
projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
Log:
Add XML Binding example
Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch020-getting-started.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch020-getting-started.xml 2009-12-08 09:33:12 UTC (rev 97530)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch020-getting-started.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -151,7 +151,7 @@
16:20:30,789 INFO [FrameworkEventsPluginImpl] Bundle STARTED: Bundle{jboss-osgi-jmx-1.0.2}
16:20:30,806 INFO [FrameworkEventsPluginImpl] Bundle STARTED: Bundle{jboss-osgi-common-core-2.2.13.GA}
...
- 16:20:30,824 INFO [DeploymentScannerImpl] <emphasis role="bold">JBossOSGi Runtime started in 1.64sec</emphasis>
+ <emphasis role="bold">16:20:30,824 INFO [DeploymentScannerImpl] JBossOSGi Runtime started in 1.64sec</emphasis>
</programlisting>
</sect1>
Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch030-runtime.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch030-runtime.xml 2009-12-08 09:33:12 UTC (rev 97530)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch030-runtime.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -80,6 +80,10 @@
Components can access the JNDI InitialContext as a service from the registry.
</listitem>
+ <listitem><emphasis role="bold">JTA Support</emphasis> -
+ Components can interact with the JTA TransactionManager and UserTransaction service.
+ </listitem>
+
<listitem><emphasis role="bold">SAX/DOM Parser Support</emphasis> -
The Runtime comes with an implementation of an <ulink url="http://www.osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html">XMLParserActivator</ulink>
which provides access to a SAXParserFactory and DocumentBuilderFactory.
@@ -97,6 +101,10 @@
ConfigAdmin support is provided by the <ulink url="http://felix.apache.org/site/apache-felix-configuration-admin-service.html">Apache Felix Configuration Admin Service</ulink>.
</listitem>
+ <listitem><emphasis role="bold">EventAdmin Support</emphasis> -
+ EventAdmin support is provided by the <ulink url="http://felix.apache.org/site/apache-felix-event-admin.html">Apache Felix Event Admin Service</ulink>.
+ </listitem>
+
<listitem><emphasis role="bold">Provisioning</emphasis> -
Bundle provisioning can be done through the JMX based Runtime Managment Interface.
</listitem>
@@ -151,7 +159,7 @@
12:10:50,042 INFO [jboss-osgi-hotdeploy] Start DeploymentScanner: [scandir=.../server/minimal/deploy,interval=2000ms]
12:10:50,047 INFO [FrameworkEventsPluginImpl] Bundle STARTED: Bundle{jboss-osgi-hotdeploy:1.0.2}
12:10:50,050 INFO [FrameworkEventsPluginImpl] Bundle STARTED: Bundle{system.bundle:0.0.0}
- 12:10:50,076 INFO [OSGiBootstrap] <emphasis role="bold">JBossOSGi Runtime booted in 1.357sec</emphasis>
+ <emphasis role="bold">12:10:50,076 INFO [OSGiBootstrap] JBossOSGi Runtime booted in 1.357sec</emphasis>
</programlisting>
<emphasis role="bold">Minimal Profile</emphasis>
@@ -174,6 +182,7 @@
<para>These additional bundles are installed:</para>
<itemizedlist>
+ <listitem><emphasis role="bold">org.apache.felix.eventadmin.jar</emphasis> - Apache Event Admin service</listitem>
<listitem><emphasis role="bold">jboss-osgi-common-core.jar</emphasis> - JBoss Common Core functionality</listitem>
<listitem><emphasis role="bold">jboss-osgi-jmx.jar</emphasis> - JBoss OSGi JMX service</listitem>
<listitem><emphasis role="bold">jboss-osgi-jndi.jar</emphasis> - JBoss OSGi JNDI service</listitem>
@@ -186,7 +195,7 @@
<para>These additional bundles are installed:</para>
<itemizedlist>
- <listitem><emphasis role="bold">org.apache.felix.configadmin.jar</emphasis> - Apache ConfigAdmin service</listitem>
+ <listitem><emphasis role="bold">org.apache.felix.configadmin.jar</emphasis> - Apache Config Admin service</listitem>
<listitem><emphasis role="bold">pax-web-jetty-bundle.jar</emphasis> - Pax Web HttpService</listitem>
<listitem><emphasis role="bold">pax-web-extender-war.jar</emphasis> - Pax Web WebApp Extender</listitem>
<listitem><emphasis role="bold">jboss-osgi-webconsole.jar</emphasis> - JBoss OSGi Web Console</listitem>
@@ -201,6 +210,7 @@
<itemizedlist>
<listitem><emphasis role="bold">jboss-osgi-apache-xerces.jar</emphasis> - Apache Xerces support</listitem>
<listitem><emphasis role="bold">jboss-osgi-jaxb.jar</emphasis> - JAXB support</listitem>
+ <listitem><emphasis role="bold">jboss-osgi-jta.jar</emphasis> - JTA support</listitem>
<listitem><emphasis role="bold">jboss-osgi-xml-binding.jar</emphasis> - XML Binding (JBossXB) support</listitem>
<listitem><emphasis role="bold">jboss-osgi-microcontainer.jar</emphasis> - Microcontainer support</listitem>
<listitem><emphasis role="bold">jboss-osgi-blueprint.jar</emphasis> - Blueprint Container support</listitem>
Modified: projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml 2009-12-08 09:33:12 UTC (rev 97530)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch050-developer-guide.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -19,7 +19,7 @@
<mediaobject>
<imageobject>
- <imagedata align="center" width="90%" fileref="images/jbossosgi-spi.png"/>
+ <imagedata fileref="images/jbossosgi-spi.png"/>
</imageobject>
</mediaobject>
@@ -145,7 +145,7 @@
<listitem>JBoss OSGi Runtime running in JBossAS</listitem>
</itemizedlist>
- <para>A test case that takes advantage of the SPI provided OSGi runtime abstration would transparently handle these scenarios.</para>
+ <para>A test case that takes advantage of the OSGi runtime abstration that transparently handles the various remote scenarios.</para>
<sect2 xml:id="SecWritingTestsSimpleTestCase">
@@ -157,27 +157,31 @@
</para>
<programlisting role="JAVA">
- public class SimpleTestCase
+ public class SimpleTestCase extends OSGiTest
{
@Test
public void testSimpleBundle() throws Exception
{
// Get the default runtime
- OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+ OSGiRuntime runtime = getDefaultRuntime();
- // Install the bundle
- OSGiBundle bundle = runtime.installBundle("example-simple.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundle.getState());
-
- // Start the bundle
- bundle.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
-
- // Uninstall the bundle
- bundle.uninstall();
-
- // Shutdown the runtime
- runtime.shutdown();
+ try
+ {
+ // Install the bundle
+ OSGiBundle bundle = runtime.installBundle("example-simple.jar");
+
+ // Start the bundle
+ bundle.start();
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
+
+ // Uninstall the bundle
+ bundle.uninstall();
+ }
+ finally
+ {
+ // Shutdown the runtime
+ runtime.shutdown();
+ }
}
}
</programlisting>
@@ -223,8 +227,8 @@
<title>Simple Husky Test Case</title>
- <para>The test case does everthing identical to <link linkend="SecWritingTestsSimpleTestCase">SimpleTestCase</link>
- (setUp and tearDown not shown again), but only executes the code in the test method when Husky injected the BundleContext.
+ <para>The test case does everthing identical to <link linkend="SecWritingTestsSimpleTestCase">SimpleTestCase</link>,
+ but only executes the code in the test method when Husky injected the BundleContext.
</para>
<programlisting role="JAVA">
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-12-08 09:33:12 UTC (rev 97530)
+++ projects/jboss-osgi/trunk/distribution/docbook/en/modules/ch070-provided-bundles.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -217,4 +217,22 @@
</sect1>
+ <sect1 xml:id="SecBundleXMLBinding">
+ <title>XML Binding Services</title>
+
+ <para>The JBoss OSGi <emphasis role="bold">jboss-osgi-xml-binding.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....">javax.xml.parsers.SAXParserFactory</ulink></emphasis></listitem>
+ <listitem><emphasis role="bold"><ulink url="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFa...">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/testsuite/example/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-12-08 09:33:12 UTC (rev 97530)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -92,6 +92,9 @@
<!-- xml/jaxb -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-xml-jaxb.jar" files="${tests.resources.dir}/xml/jaxb/example-xml-jaxb.bnd" />
+ <!-- xml/binding -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-xml-binding.jar" files="${tests.resources.dir}/xml/jbossxb/example-xml-binding.bnd" />
+
<!-- xml/parser -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-xml-parser.jar" files="${tests.resources.dir}/xml/parser/example-xml-parser.bnd" />
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CompanyType.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CompanyType.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CompanyType.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,126 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.07.21 at 10:48:55 AM CEST
+//
+
+
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+
+/**
+ * <p>Java class for companyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="companyType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="address" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
+ * <element ref="{}contact"/>
+ * </sequence>
+ * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "companyType", propOrder = {
+ "address",
+ "contact"
+})
+public class CompanyType {
+
+ @XmlElement(required = true)
+ protected Object address;
+ @XmlElement(required = true)
+ protected ContactType contact;
+ @XmlAttribute
+ protected String name;
+
+ /**
+ * Gets the value of the address property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ *
+ */
+ public Object getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the value of the address property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ *
+ */
+ public void setAddress(Object value) {
+ this.address = value;
+ }
+
+ /**
+ * Gets the value of the contact property.
+ *
+ * @return
+ * possible object is
+ * {@link ContactType }
+ *
+ */
+ public ContactType getContact() {
+ return contact;
+ }
+
+ /**
+ * Sets the value of the contact property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ContactType }
+ *
+ */
+ public void setContact(ContactType value) {
+ this.contact = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CompanyType.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/ContactType.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/ContactType.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/ContactType.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,119 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.07.21 at 10:48:55 AM CEST
+//
+
+
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for contactType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="contactType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="telephone" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="email" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "contactType", propOrder = {})
+public class ContactType {
+
+ @XmlAttribute(required = true)
+ protected String name;
+ @XmlAttribute(required = true)
+ protected String telephone;
+ @XmlAttribute(required = true)
+ protected String email;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the telephone property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTelephone() {
+ return telephone;
+ }
+
+ /**
+ * Sets the value of the telephone property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTelephone(String value) {
+ this.telephone = value;
+ }
+
+ /**
+ * Gets the value of the email property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Sets the value of the email property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setEmail(String value) {
+ this.email = value;
+ }
+
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/ContactType.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CourseBooking.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CourseBooking.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CourseBooking.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,233 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.07.21 at 10:48:55 AM CEST
+//
+
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * <p>Java class for courseBooking complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="courseBooking">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{}company"/>
+ * <element ref="{}student" maxOccurs="unbounded"/>
+ * </sequence>
+ * <attribute name="courseReference" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="courseDate" use="required" type="{http://www.w3.org/2001/XMLSchema}date" />
+ * <attribute name="invoiceReference" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="totalPrice" use="required" type="{http://www.w3.org/2001/XMLSchema}decimal" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@JBossXmlSchema(namespace = CourseBooking.NAMESPACE_XML_SIMPLE, elementFormDefault = XmlNsForm.QUALIFIED)
+@XmlRootElement(name = "booking")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "courseBooking", propOrder = { "company", "student" })
+public class CourseBooking
+{
+ public static final String NAMESPACE_XML_SIMPLE = "http://org.jboss.test.osgi.jbossxb.simple";
+
+ @XmlElement(required = true)
+ protected CompanyType company;
+ @XmlElement(required = true)
+ protected List<StudentType> student;
+ @XmlAttribute(required = true)
+ protected String courseReference;
+ @XmlAttribute(required = true)
+ @XmlSchemaType(name = "date")
+ protected XMLGregorianCalendar courseDate;
+ @XmlAttribute(required = true)
+ protected String invoiceReference;
+ @XmlAttribute(required = true)
+ protected BigDecimal totalPrice;
+
+ /**
+ * Gets the value of the company property.
+ *
+ * @return
+ * possible object is
+ * {@link CompanyType }
+ *
+ */
+ public CompanyType getCompany()
+ {
+ return company;
+ }
+
+ /**
+ * Sets the value of the company property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CompanyType }
+ *
+ */
+ public void setCompany(CompanyType value)
+ {
+ this.company = value;
+ }
+
+ /**
+ * Gets the value of the student property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the student property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getStudent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link StudentType }
+ *
+ *
+ */
+ public List<StudentType> getStudent()
+ {
+ if (student == null)
+ {
+ student = new ArrayList<StudentType>();
+ }
+ return this.student;
+ }
+
+ /**
+ * Gets the value of the courseReference property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCourseReference()
+ {
+ return courseReference;
+ }
+
+ /**
+ * Sets the value of the courseReference property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCourseReference(String value)
+ {
+ this.courseReference = value;
+ }
+
+ /**
+ * Gets the value of the courseDate property.
+ *
+ * @return
+ * possible object is
+ * {@link XMLGregorianCalendar }
+ *
+ */
+ public XMLGregorianCalendar getCourseDate()
+ {
+ return courseDate;
+ }
+
+ /**
+ * Sets the value of the courseDate property.
+ *
+ * @param value
+ * allowed object is
+ * {@link XMLGregorianCalendar }
+ *
+ */
+ public void setCourseDate(XMLGregorianCalendar value)
+ {
+ this.courseDate = value;
+ }
+
+ /**
+ * Gets the value of the invoiceReference property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getInvoiceReference()
+ {
+ return invoiceReference;
+ }
+
+ /**
+ * Sets the value of the invoiceReference property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setInvoiceReference(String value)
+ {
+ this.invoiceReference = value;
+ }
+
+ /**
+ * Gets the value of the totalPrice property.
+ *
+ * @return
+ * possible object is
+ * {@link BigDecimal }
+ *
+ */
+ public BigDecimal getTotalPrice()
+ {
+ return totalPrice;
+ }
+
+ /**
+ * Sets the value of the totalPrice property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigDecimal }
+ *
+ */
+ public void setTotalPrice(BigDecimal value)
+ {
+ this.totalPrice = value;
+ }
+
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/CourseBooking.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/StudentType.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/StudentType.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/StudentType.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,92 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.07.21 at 10:48:55 AM CEST
+//
+
+
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for studentType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="studentType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="firstName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="surname" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "studentType", propOrder = {})
+public class StudentType {
+
+ @XmlAttribute(required = true)
+ protected String firstName;
+ @XmlAttribute(required = true)
+ protected String surname;
+
+ /**
+ * Gets the value of the firstName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFirstName() {
+ return firstName;
+ }
+
+ /**
+ * Sets the value of the firstName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFirstName(String value) {
+ this.firstName = value;
+ }
+
+ /**
+ * Gets the value of the surname property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSurname() {
+ return surname;
+ }
+
+ /**
+ * Sets the value of the surname property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSurname(String value) {
+ this.surname = value;
+ }
+
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/StudentType.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.jbossxb.UnmarshallerService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A bundle activator that uses the unmarshaller service
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 26-Nov-2009
+ */
+public class XMLBindingActivator implements BundleActivator
+{
+ public void start(BundleContext context) throws Exception
+ {
+ ServiceReference sref = context.getServiceReference(UnmarshallerService.class.getName());
+ UnmarshallerService unmarshaller = (UnmarshallerService)context.getService(sref);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setValidation(true);
+
+ Bundle bundle = context.getBundle();
+ URL xsdurl = bundle.getEntry("booking.xsd");
+ URL xmlurl = bundle.getEntry("booking.xml");
+
+ unmarshaller.registerSchemaLocation("http://org.jboss.test.osgi.jbossxb.simple/booking.xsd", xsdurl.toExternalForm());
+ unmarshaller.addClassBinding(CourseBooking.NAMESPACE_XML_SIMPLE, CourseBooking.class);
+
+ unmarshaller.unmarshal(xmlurl.toExternalForm());
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingTestCase.java 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+package org.jboss.test.osgi.example.xml.jbossxb;
+
+//$Id$
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeNotNull;
+
+import java.net.URL;
+
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.HuskyCapability;
+import org.jboss.osgi.husky.RuntimeContext;
+import org.jboss.osgi.jbossxb.UnmarshallerService;
+import org.jboss.osgi.jbossxb.XMLBindingCapability;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Test XMLBindingService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 26-Nov-2009
+ */
+public class XMLBindingTestCase extends OSGiTest
+{
+ @RuntimeContext
+ public BundleContext context;
+
+ private OSGiRuntime runtime;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ if (context == null)
+ {
+ runtime = getDefaultRuntime();
+ runtime.addCapability(new HuskyCapability());
+ runtime.addCapability(new XMLBindingCapability());
+
+ OSGiBundle bundle = runtime.installBundle("example-xml-binding.jar");
+ bundle.start();
+ }
+ }
+
+ @After
+ public void tearDown() throws BundleException
+ {
+ if (context == null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testUnmarshaller() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ assumeNotNull(context);
+
+ ServiceReference sref = context.getServiceReference(UnmarshallerService.class.getName());
+ assertNotNull("UnmarshallerService available", sref);
+
+ UnmarshallerService unmarshaller = (UnmarshallerService)context.getService(sref);
+ unmarshaller.setSchemaValidation(true);
+ unmarshaller.setNamespaceAware(true);
+ unmarshaller.setValidation(true);
+
+ Bundle bundle = context.getBundle();
+ URL xsdurl = bundle.getEntry("booking.xsd");
+ assertNotNull("booking.xsd available", xsdurl);
+
+ URL xmlurl = bundle.getEntry("booking.xml");
+ assertNotNull("booking.xml available", xmlurl);
+
+ unmarshaller.registerSchemaLocation("http://org.jboss.test.osgi.jbossxb.simple/booking.xsd", xsdurl.toExternalForm());
+ unmarshaller.addClassBinding(CourseBooking.NAMESPACE_XML_SIMPLE, CourseBooking.class);
+
+ CourseBooking booking = (CourseBooking)unmarshaller.unmarshal(xmlurl.toExternalForm());
+ assertNotNull("booking not null", booking);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/jbossxb/XMLBindingTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xml (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xml 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<booking xmlns="http://org.jboss.test.osgi.jbossxb.simple" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://org.jboss.test.osgi.jbossxb.simple http://org.jboss.test.osgi.jbossxb.simple/booking.xsd"
+ courseReference="Course100" courseDate="2009-11-26" invoiceReference="Ref100" totalPrice="100">
+ <company name="ACME Consulting">
+ <address>10 Coyote Avenue, Arizona, USA</address>
+ <contact name="Duke" email="duke(a)acme.com" telephone="1234567890" />
+ </company>
+ <student firstName="Jane" surname="Dow" />
+ <student firstName="John" surname="Doe" />
+</booking>
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xsd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xsd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xsd 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This is taken from
+
+ "Java-XML mapping made easy with JAXB 2.0"
+ http://www.javaworld.com/javaworld/jw-06-2006/jw-0626-jaxb.html
+
+ $ xjc src/test/resources/xml/jaxb/booking.xsd -p org.jboss.test.osgi.example.xml.jaxb -d src/test/java
+
+-->
+<xsd:schema xmlns="http://org.jboss.test.osgi.jbossxb.simple"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://org.jboss.test.osgi.jbossxb.simple"
+ elementFormDefault="qualified" attributeFormDefault="unqualified"
+ version="1.0.0">
+
+ <xsd:element name="booking" type="courseBooking" />
+ <xsd:complexType name="courseBooking">
+ <xsd:sequence>
+ <xsd:element ref="company" />
+ <xsd:element ref="student" minOccurs="1" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="courseReference" type="xsd:string" use="required" />
+ <xsd:attribute name="courseDate" type="xsd:date" use="required" />
+ <xsd:attribute name="invoiceReference" type="xsd:string" use="required" />
+ <xsd:attribute name="totalPrice" type="xsd:decimal" use="required" />
+ </xsd:complexType>
+ <xsd:element name="student" type="studentType" />
+ <xsd:complexType name="studentType">
+ <xsd:attribute name="firstName" type="xsd:string" use="required" />
+ <xsd:attribute name="surname" type="xsd:string" use="required" />
+ </xsd:complexType>
+ <xsd:element name="company" type="companyType" />
+ <xsd:complexType name="companyType">
+ <xsd:sequence>
+ <xsd:element name="address" />
+ <xsd:element ref="contact" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ <xsd:element name="contact" type="contactType" />
+ <xsd:complexType name="contactType">
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ <xsd:attribute name="telephone" type="xsd:string" use="required" />
+ <xsd:attribute name="email" type="xsd:string" use="required" />
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/booking.xsd
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/xml/jbossxb/example-xml-binding.bnd 2009-12-08 10:16:14 UTC (rev 97531)
@@ -0,0 +1,22 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-xml-binding.jar src/test/resources/simple/example-xml-binding.bnd
+
+Bundle-SymbolicName: example-xml-binding
+Bundle-Activator: org.jboss.test.osgi.example.xml.jbossxb.XMLBindingActivator
+
+Export-Package: org.jboss.test.osgi.example.xml.jbossxb
+
+Import-Package: \
+ javax.xml.bind.annotation, \
+ javax.xml.datatype, \
+ org.jboss.osgi.husky, \
+ org.jboss.osgi.jbossxb, \
+ org.jboss.osgi.spi.capability, \
+ org.jboss.osgi.testing, \
+ org.jboss.xb.annotations, \
+ org.junit, \
+ org.osgi.framework
+
+Include-Resource: booking.xml, booking.xsd
+
+# Tell Husky that there are test cases in this package
+Test-Package: org.jboss.test.osgi.example.xml.jbossxb
16 years, 7 months
JBoss-OSGI SVN: r97530 - projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 04:33:12 -0500 (Tue, 08 Dec 2009)
New Revision: 97530
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
Log:
Add configadmin to web profile
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2009-12-08 09:09:53 UTC (rev 97529)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2009-12-08 09:33:12 UTC (rev 97530)
@@ -221,6 +221,8 @@
<include name="jboss-osgi-jndi.jar" />
<include name="org.apache.felix.eventadmin.jar" />
<!-- web -->
+ <include name="org.apache.felix.configadmin.jar" />
+ <include name="org.apache.felix.metatype.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="pax-web-jetty-bundle.jar" />
</fileset>
@@ -234,6 +236,8 @@
<include name="jboss-osgi-jndi.jar" />
<include name="org.apache.felix.eventadmin.jar" />
<!-- web -->
+ <include name="org.apache.felix.configadmin.jar" />
+ <include name="org.apache.felix.metatype.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="pax-web-jetty-bundle.jar" />
<!-- all -->
@@ -266,8 +270,6 @@
<include name="org.osgi.compendium.jar" />
</fileset>
<fileset condition="isFelix" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/deploy" override="true">
- <include name="org.apache.felix.configadmin.jar" />
- <include name="org.apache.felix.metatype.jar" />
<include name="jboss-osgi-microcontainer.jar" />
</fileset>
@@ -292,8 +294,6 @@
<include name="org.eclipse.osgi.util.jar" />
</fileset>
<fileset condition="isEquinox" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/deploy" override="true">
- <include name="org.apache.felix.configadmin.jar" />
- <include name="org.apache.felix.metatype.jar" />
<include name="jboss-osgi-microcontainer.jar" />
</fileset>
16 years, 7 months
JBoss-OSGI SVN: r97529 - in projects/jboss-osgi/trunk/testsuite/functional: src/test/java/org/jboss/test/osgi/performance/blueprint and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 04:09:53 -0500 (Tue, 08 Dec 2009)
New Revision: 97529
Modified:
projects/jboss-osgi/trunk/testsuite/functional/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java
Log:
Exclude org.jboss.metadata:jboss-metadata from ejb3-ext-api
Modified: projects/jboss-osgi/trunk/testsuite/functional/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-12-08 08:53:15 UTC (rev 97528)
+++ projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-12-08 09:09:53 UTC (rev 97529)
@@ -57,6 +57,12 @@
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<version>${version.jboss.ejb3}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
@@ -158,6 +164,7 @@
<configuration>
<excludes>
<exclude>${target.container.excludes}</exclude>
+ <exclude>org/jboss/test/osgi/performance/**</exclude>
<!-- [JBOSGI-206] Wire to an already uninstalled bundle -->
<exclude>org/jboss/test/osgi/jbosgi39/**</exclude>
<!-- [JBOSGI-108] Investigate statics on PackageAdmin.refresh -->
@@ -210,6 +217,7 @@
<configuration>
<excludes>
<exclude>${target.container.excludes}</exclude>
+ <exclude>org/jboss/test/osgi/performance/**</exclude>
</excludes>
</configuration>
</plugin>
@@ -256,6 +264,7 @@
<configuration>
<excludes>
<exclude>${target.container.excludes}</exclude>
+ <exclude>org/jboss/test/osgi/performance/**</exclude>
<!-- [JBOSGI-143] Add initial support for DynamicImport-Package -->
<exclude>org/jboss/test/osgi/jbosgi143/**</exclude>
<!-- [JBOSGI-151] Cannot resolve circular dependencies -->
@@ -309,6 +318,7 @@
<configuration>
<excludes>
<exclude>${target.container.excludes}</exclude>
+ <exclude>org/jboss/test/osgi/performance/**</exclude>
<!-- [JBOSGI-143] Add initial support for DynamicImport-Package -->
<exclude>org/jboss/test/osgi/jbosgi143/**</exclude>
<!-- [JBOSGI-151] Cannot resolve circular dependencies -->
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java 2009-12-08 08:53:15 UTC (rev 97528)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/performance/blueprint/BlueprintStressTestCase.java 2009-12-08 09:09:53 UTC (rev 97529)
@@ -32,7 +32,6 @@
import org.jboss.osgi.testing.OSGiTestHelper;
import org.jboss.test.osgi.performance.blueprint.bundle.ServiceA;
import org.jboss.test.osgi.performance.blueprint.bundle.ServiceB;
-import org.junit.Ignore;
import org.junit.Test;
import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -45,7 +44,6 @@
public class BlueprintStressTestCase
{
@Test
- @Ignore
public void testBlueprintBundleInstall() throws Exception
{
OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
16 years, 7 months
JBoss-OSGI SVN: r97527 - projects/jboss-osgi/projects/runtime/equinox/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-08 03:38:08 -0500 (Tue, 08 Dec 2009)
New Revision: 97527
Modified:
projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
Log:
Add dependency on equniox sources
Modified: projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-12-08 08:04:36 UTC (rev 97526)
+++ projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-12-08 08:38:08 UTC (rev 97527)
@@ -64,14 +64,32 @@
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>${version.eclipse.equinox}</version>
+ <classifier>sources</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
<version>${version.eclipse.equinox}</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.osgi.services</artifactId>
+ <version>${version.eclipse.equinox}</version>
+ <classifier>sources</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.osgi.util</artifactId>
<version>${version.eclipse.equinox}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.osgi.util</artifactId>
+ <version>${version.eclipse.equinox}</version>
+ <classifier>sources</classifier>
+ </dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
16 years, 7 months
JBoss-OSGI SVN: r97517 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service: support/a and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-07 16:07:48 -0500 (Mon, 07 Dec 2009)
New Revision: 97517
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/a/A.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/c/C.java
Log:
Test invoke dispatch on osgi service.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-07 17:23:56 UTC (rev 97516)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-07 21:07:48 UTC (rev 97517)
@@ -106,7 +106,7 @@
}
}
- private static Object invoke(Object target, String getter, String name) throws Throwable
+ private static Object getter(Object target, String getter, String name) throws Throwable
{
assertNotNull("Target " + name + " is not null", target);
Class<?> clazz = target.getClass();
@@ -114,6 +114,15 @@
return m.invoke(target);
}
+ private static Object setter(Object target, String setter, Object value, String name) throws Throwable
+ {
+ assertNotNull("Target " + name + " is not null", target);
+ assertNotNull("Value is not null", value);
+ Class<?> clazz = target.getClass();
+ Method m = clazz.getDeclaredMethod(setter, value.getClass());
+ return m.invoke(target, value);
+ }
+
public void testInjectionToMC() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C", C.class.getName());
@@ -140,7 +149,7 @@
checkComplete();
Object c = getBean("C");
- assertSame(a, invoke(c, "getA", "C"));
+ assertSame(a, getter(c, "getA", "C"));
ServiceReference ref1 = bundleContext1.getServiceReference(A.class.getName());
assertUsingBundles(ref1, LazyBundle.getBundle(getDeploymentUnit(bean)));
@@ -199,7 +208,7 @@
checkComplete();
Object c = getBean("C");
- assertSame(a, invoke(c, "getA", "C"));
+ assertSame(a, getter(c, "getA", "C"));
ServiceReference ref1 = bundleContext1.getServiceReference(A.class.getName());
assertUsingBundles(ref1, LazyBundle.getBundle(getDeploymentUnit(bean)));
@@ -230,6 +239,53 @@
}
}
+ public void testInvokeDispatch() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C", C.class.getName());
+ builder.addPropertyMetaData("msg", builder.createInject("A", "msg"));
+ builder.addInstall("calc", "A", int.class.getName(), 123);
+ BeanMetaData bmd = builder.getBeanMetaData();
+ Deployment bean = addBean("beanA", C.class, bmd, A.class);
+ try
+ {
+ Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle3");
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> aClass = bundle1.loadClass(A.class.getName());
+ Object a = aClass.newInstance();
+ setter(a, "setMsg", "HelloWorld!", "A");
+ Hashtable<String, Object> table = new Hashtable<String, Object>();
+ table.put("service.alias.1", "A");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), a, table);
+ assertNotNull(reg1);
+ try
+ {
+ checkComplete();
+
+ Object c = getBean("C");
+ assertSame(getter(a, "getMsg", "A"), getter(c, "getMsg", "C"));
+ assertEquals(123, getter(a, "getX", "A"));
+ }
+ finally
+ {
+ reg1.unregister();
+ }
+ }
+ finally
+ {
+ uninstall(bundle1);
+ }
+ }
+ finally
+ {
+ undeploy(bean);
+ }
+ }
+
public void testServiceFactoryInjection() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
@@ -265,13 +321,13 @@
checkComplete();
Object c1 = getBean("C1");
- a1 = invoke(c1, "getA", "C1");
- Object msg1 = invoke(a1, "getMsg", "A1");
+ a1 = getter(c1, "getA", "C1");
+ Object msg1 = getter(a1, "getMsg", "A1");
assertEquals(msg1, getBundle(bean1).getSymbolicName());
Object c2 = getBean("C2");
- a2 = invoke(c2, "getA", "C2");
- Object msg2 = invoke(a2, "getMsg", "A2");
+ a2 = getter(c2, "getA", "C2");
+ Object msg2 = getter(a2, "getMsg", "A2");
assertEquals(msg2, getBundle(bean2).getSymbolicName());
}
finally
@@ -279,7 +335,7 @@
reg1.unregister();
}
- List as = assertInstanceOf(invoke(d, "getAs", "A"), List.class);
+ List as = assertInstanceOf(getter(d, "getAs", "A"), List.class);
assertNotNull(as);
assertEquals(2, as.size());
assertTrue(as.contains(a1));
@@ -331,7 +387,7 @@
checkComplete();
Object c1 = getBean("C1");
- a = invoke(c1, "getA", "C1");
+ a = getter(c1, "getA", "C1");
ServiceReference refD = bundleContext1.getServiceReference(C.class.getName());
Bundle beanBundle = refD.getBundle();
@@ -344,7 +400,7 @@
KernelControllerContext cCC = getControllerContext("C1", null);
change(cCC, ControllerState.INSTANTIATED);
- List as = assertInstanceOf(invoke(d, "getAs", "A"), List.class);
+ List as = assertInstanceOf(getter(d, "getAs", "A"), List.class);
assertNotNull(as);
assertEmpty(as); // SF is still in use
}
@@ -353,7 +409,7 @@
reg1.unregister();
}
- List as = assertInstanceOf(invoke(d, "getAs", "A"), List.class);
+ List as = assertInstanceOf(getter(d, "getAs", "A"), List.class);
assertNotNull(as);
assertEquals(1, as.size());
assertTrue(as.contains(a));
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/a/A.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-07 17:23:56 UTC (rev 97516)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-07 21:07:48 UTC (rev 97517)
@@ -30,9 +30,25 @@
public class A
{
public String msg;
+ private int x;
public String getMsg()
{
return msg;
}
+
+ public void setMsg(String msg)
+ {
+ this.msg = msg;
+ }
+
+ public void calc(int x)
+ {
+ this.x = x;
+ }
+
+ public int getX()
+ {
+ return x;
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/c/C.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/c/C.java 2009-12-07 17:23:56 UTC (rev 97516)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/c/C.java 2009-12-07 21:07:48 UTC (rev 97517)
@@ -29,6 +29,7 @@
public class C
{
private A a;
+ private String msg;
public C()
{
@@ -48,4 +49,14 @@
{
this.a = a;
}
+
+ public String getMsg()
+ {
+ return msg;
+ }
+
+ public void setMsg(String msg)
+ {
+ this.msg = msg;
+ }
}
16 years, 7 months
JBoss-OSGI SVN: r97515 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-07 12:08:23 -0500 (Mon, 07 Dec 2009)
New Revision: 97515
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
Log:
Change ManagedBundle OName to 'name' instead of 'sname'
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-12-07 17:07:35 UTC (rev 97514)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-12-07 17:08:23 UTC (rev 97515)
@@ -44,7 +44,7 @@
public class ManagedBundle implements ManagedBundleMBean
{
public static final String PROPERTY_ID = "id";
- public static final String PROPERTY_SYMBOLIC_NAME = "sname";
+ public static final String PROPERTY_SYMBOLIC_NAME = "name";
public static final String PROPERTY_VERSION = "version";
private Bundle bundle;
@@ -59,14 +59,14 @@
public static ObjectName getObjectName(Bundle bundle)
{
long id = bundle.getBundleId();
- String symbolicName = bundle.getSymbolicName();
+ String name = bundle.getSymbolicName();
Version version = bundle.getVersion();
- return getObjectName(id, symbolicName, version);
+ return getObjectName(id, name, version);
}
- public static ObjectName getObjectName(long id, String sname, Version version)
+ public static ObjectName getObjectName(long id, String name, Version version)
{
- String oname = DOMAIN_NAME + ":" + PROPERTY_ID + "=" + id + "," + PROPERTY_SYMBOLIC_NAME + "=" + sname + "," + PROPERTY_VERSION + "=" + version;
+ String oname = DOMAIN_NAME + ":" + PROPERTY_ID + "=" + id + "," + PROPERTY_SYMBOLIC_NAME + "=" + name + "," + PROPERTY_VERSION + "=" + version;
return ObjectNameFactory.create(oname);
}
16 years, 7 months
JBoss-OSGI SVN: r97514 - projects/jboss-osgi/projects/runtime/remotejmx/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-07 12:07:35 -0500 (Mon, 07 Dec 2009)
New Revision: 97514
Added:
projects/jboss-osgi/projects/runtime/remotejmx/trunk/.project
Log:
Add eclipse .project
Added: projects/jboss-osgi/projects/runtime/remotejmx/trunk/.project
===================================================================
--- projects/jboss-osgi/projects/runtime/remotejmx/trunk/.project (rev 0)
+++ projects/jboss-osgi/projects/runtime/remotejmx/trunk/.project 2009-12-07 17:07:35 UTC (rev 97514)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jmx-invoker-adaptor-client</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
16 years, 7 months