You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2007/01/06 09:11:06 UTC
svn commit: r493432 - /incubator/servicemix/site/hello-world-se.html
Author: chirino
Date: Sat Jan 6 00:11:05 2007
New Revision: 493432
URL: http://svn.apache.org/viewvc?view=rev&rev=493432
Log:
Latest export from confluence
Modified:
incubator/servicemix/site/hello-world-se.html
Modified: incubator/servicemix/site/hello-world-se.html
URL: http://svn.apache.org/viewvc/incubator/servicemix/site/hello-world-se.html?view=diff&rev=493432&r1=493431&r2=493432
==============================================================================
--- incubator/servicemix/site/hello-world-se.html (original)
+++ incubator/servicemix/site/hello-world-se.html Sat Jan 6 00:11:05 2007
@@ -530,7 +530,7 @@
<P>Again, the key here is to make sure you see BUILD SUCCESSFUL. This means that the project skeleton created by the archetype was compiled, packaged and tested successfully. Now we just need to add some custom functionality. </P>
-<H2><A name="HelloWorld-SE-CreatingtheJBIServiceEngine"></A>Creating the JBI Service Engine</H2>
+<H2><A name="HelloWorld-SE-CreatingtheJBIComponent"></A>Creating the JBI Component </H2>
<P>Before we create any custom functionality, let's first examine some of the items generated by the servicemix-service-engine Maven archetype in this simple component we're developing. These classes extend class from either the <SPAN class="nobr"><A href="http://java.sun.com/integration/1.0/docs/sdk/api/index.html" title="Visit page outside Confluence" rel="nofollow">JBI spec APIs<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> or from the <SPAN class="nobr"><A href="http://fisheye3.cenqua.com/browse/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common" title="Visit page outside Confluence" rel="nofollow"><TT>servicemix-common</TT><SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> package. </P>
@@ -650,6 +650,8 @@
<PRE class="code-java"><SPAN class="code-keyword">public</SPAN> class MyEndpoint <SPAN class="code-keyword">extends</SPAN> ProviderEndpoint <SPAN class="code-keyword">implements</SPAN> ExchangeProcessor</PRE>
</DIV></DIV>
+<P>By the way, making this change will require the import of the full class (<TT>org.apache.servicemix.common.endpoints.ProviderEndpoint</TT>). </P>
+
<P>Third, because the <TT>ProviderEndpoint.process()</TT> method already handles an In-Out MEP, <TT>MyEndpoint</TT> will simply need to override the <TT>ProviderEndpoint.processInOut()</TT> method. Below is the content for implementing this method. Copy/paste this method: </P>
<DIV class="code"><DIV class="codeContent">
@@ -660,6 +662,14 @@
}</PRE>
</DIV></DIV>
+<P>Adding this method will require the import of the following classes: </P>
+
+<UL>
+ <LI><TT>org.apache.servicemix.jbi.jaxp.SourceTransformer</TT></LI>
+ <LI><TT>org.apache.servicemix.jbi.jaxp.StringSource</TT></LI>
+</UL>
+
+
<P>This method is the logic for the Hello World component. We're not doing anything complex here at all in order to keep this tutorial very simple. Now it's time to test the component. </P>
<H2><A name="HelloWorld-SE-TestingtheHelloWorldComponent"></A>Testing the Hello World Component</H2>
@@ -685,54 +695,226 @@
<P>Below is the output that will print to the console: </P>
<DIV class="preformatted"><DIV class="preformattedContent">
-<PRE>
+<PRE>[INFO] Scanning for projects...
+[INFO] ----------------------------------------------------------------------------
+[INFO] Building A custom project
+[INFO] task-segment: [install]
+[INFO] ----------------------------------------------------------------------------
+[INFO] [xbean:mapping {execution: default}]
+Checking: org.apache.servicemix.samples.helloworld.MyComponent
+Checking: org.apache.servicemix.samples.helloworld.MyEndpoint
+[INFO] Generating META-INF properties file: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/META-INF/services/org/apache/xbean/spring/http/
+org.apache.servicemix.samples.helloworld/1.0 for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+[INFO] Generating Spring 2.0 handler mapping: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/META-INF/spring.handlers
+for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+[INFO] Generating Spring 2.0 schema mapping: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/META-INF/spring.schemas
+for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+[INFO] Generating HTML documentation file: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/hello-world-su.xsd.html
+for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+[INFO] Generating XSD file: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/hello-world-su.xsd
+for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+[INFO] Generating WIKI documentation file: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/hello-world-su.xsd.wiki
+for namespace: http://org.apache.servicemix.samples.helloworld/1.0
+Warning, could not load class: org.apache.servicemix.samples.helloworld.MyEndpoint
+[INFO] ...done.
+Downloading: http://repo.mergere.com/maven2/xml-security/xmlsec/1.3.0/xmlsec-1.3.0.pom
+[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
+Downloading: http://repo.mergere.com/maven2/wss4j/wss4j/1.5.0/wss4j-1.5.0.pom
+[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
+[INFO] [jbi:generate-jbi-component-descriptor]
+[INFO] Generating jbi.xml
+[INFO] [resources:resources]
+[INFO] Using default encoding to copy filtered resources.
+[INFO] [compiler:compile]
+[INFO] Nothing to compile - all classes are up to date
+[INFO] [resources:testResources]
+[INFO] Using default encoding to copy filtered resources.
+[INFO] [compiler:testCompile]
+[INFO] Nothing to compile - all classes are up to date
+[INFO] [surefire:test]
+[INFO] Surefire report directory: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/surefire-reports
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.apache.servicemix.samples.helloworld.MySpringComponentTest
+<hello>Hello World! Message [<hello>Ski Colorado!</hello>] contains [28] bytes</hello>.
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.656 sec
+
+Results :
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+[INFO] [jar:jar]
+[INFO] Building jar: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/hello-world-su-1.0-SNAPSHOT.jar
+[INFO] [jbi:jbi-component]
+[INFO] Generating installer /Users/bsnyder/src/hello-world-smx/hello-world-su/target/hello-world-su-1.0-SNAPSHOT-installer.zip
+[INFO] Building jar: /Users/bsnyder/src/hello-world-smx/hello-world-su/target/hello-world-su-1.0-SNAPSHOT-installer.zip
+[INFO] [install:install]
+[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-su/target/hello-world-su-1.0-SNAPSHOT.jar
+to /Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/hello-world-su/1.0-SNAPSHOT/hello-world-su-1.0-SNAPSHOT.jar
+[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/hello-world-su.xsd
+to /Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/hello-world-su/1.0-SNAPSHOT/hello-world-su-1.0-SNAPSHOT.xsd
+[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-su/target/xbean/hello-world-su.xsd.html
+to /Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/hello-world-su/1.0-SNAPSHOT/hello-world-su-1.0-SNAPSHOT-schema.html
+[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-su/target/hello-world-su-1.0-SNAPSHOT-installer.zip
+to /Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/hello-world-su/1.0-SNAPSHOT/hello-world-su-1.0-SNAPSHOT-installer.zip
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESSFUL
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 18 seconds
+[INFO] Finished at: Fri Jan 05 23:27:03 MST 2007
+[INFO] Final Memory: 13M/25M
+[INFO] ------------------------------------------------------------------------
</PRE>
</DIV></DIV>
-<P>Notice that not only do we see that the build was successful, but also note the bold text of the message that was printed (<B><hello>Hello World! Message [<hello>Ski Colorado!</hello>] contains [28] bytes.</hello></B>). This is the message we were expecting to be output. If you see this, you just wrote a JBI service engine component and tested it successfully. </P>
-
-
-<HR>
-
-<H3><A name="HelloWorld-SE-CreatingtheMavenSubprojectsFortheServiceUnitandServiceAssembly"></A>Creating the Maven Subprojects For the Service Unit and Service Assembly</H3>
+<P>Notice that not only do we see that the build was successful, but also note the text in the output above that was printed by the test (<B><hello>Hello World! Message [<hello>Ski Colorado!</hello>] contains [28] bytes.</hello></B>). This is the message we were expecting to be output from the test. So if you see this, you just wrote a JBI component and tested it successfully. Now this SU needs to be wrapped in a SA so it can be deployed to the JBI container. </P>
-<P>The archetypes for SUs and SAs do not contain much code, but rather help with tasks related to Maven. Later, we will only need to adapt the POMs to our project. Below are the steps for to achieve this: </P>
+<H2><A name="HelloWorld-SE-WrappingtheServiceUnitinaServiceAssembly"></A>Wrapping the Service Unit in a Service Assembly </H2>
-<P>1) From within the <TT>hello-world-smx</TT> directory, execute the following commands to create the project for the SU: </P>
+<P>The component we created above and packaged as a SU cannot be directly deployed to a JBI container until it's wrapped in a SA. This can be done by creating a SA with a dependency on the SA. From within the <TT>hello-world-smx</TT> directory, execute the following commands to create the project for the SA: </P>
<DIV class="code"><DIV class="codeContent">
-<PRE class="code-java">$ mvn archetype:create \
+<PRE class="code-java">$ pwd
+/Users/bsnyder/src/hello-world-smx/hello-world-su
+$ cd ..
+$ mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
- -DarchetypeArtifactId=servicemix-service-unit \
+ -DarchetypeArtifactId=servicemix-service-assembly \
-DarchetypeVersion=3.1-incubating-SNAPSHOT \
-DgroupId=org.apache.servicemix.samples.helloworld \
- -DartifactId=hello-world-su</PRE>
+ -DartifactId=hello-world-sa</PRE>
+</DIV></DIV>
+
+<P>Upon successful execution of the <TT>archetype:create</TT> goals, look for the BUILD SUCCESSFUL output as displayed below: </P>
+
+<DIV class="preformatted"><DIV class="preformattedContent">
+<PRE>[INFO] Scanning for projects...
+[INFO] Searching repository for plugin with prefix: 'archetype'.
+[INFO] ----------------------------------------------------------------------------
+[INFO] Building Maven Default Project
+[INFO] task-segment: [archetype:create] (aggregator-style)
+[INFO] ----------------------------------------------------------------------------
+[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
+[INFO] Setting property: velocimacro.messages.on => 'false'.
+[INFO] Setting property: resource.loader => 'classpath'.
+[INFO] Setting property: resource.manager.logwhenfound => 'false'.
+[INFO] **************************************************************
+[INFO] Starting Jakarta Velocity v1.4
+[INFO] RuntimeInstance initializing.
+[INFO] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
+[INFO] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
+[INFO] Resource Loader Instantiated: org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
+[INFO] ClasspathResourceLoader : initialization starting.
+[INFO] ClasspathResourceLoader : initialization complete.
+[INFO] ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
+[INFO] Default ResourceManager initialization complete.
+[INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Literal
+[INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
+[INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
+[INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Include
+[INFO] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
+[INFO] Created: 20 parsers.
+[INFO] Velocimacro : initialization starting.
+[INFO] Velocimacro : adding VMs from VM library template : VM_global_library.vm
+[ERROR] ResourceManager : unable to find resource 'VM_global_library.vm' in any resource loader.
+[INFO] Velocimacro : error using VM library template VM_global_library.vm : org.apache.velocity.exception.ResourceNotFoundException:
+Unable to find resource 'VM_global_library.vm'
+[INFO] Velocimacro : VM library template macro registration complete.
+[INFO] Velocimacro : allowInline = true : VMs can be defined inline in templates
+[INFO] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
+[INFO] Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed.
+[INFO] Velocimacro : initialization complete.
+[INFO] Velocity successfully started.
+[INFO] [archetype:create]
+[INFO] Defaulting package to group ID: org.apache.servicemix.samples.helloworld
+[INFO] ----------------------------------------------------------------------------
+[INFO] Using following parameters for creating Archetype: servicemix-service-assembly:3.1-incubating-SNAPSHOT
+[INFO] ----------------------------------------------------------------------------
+[INFO] Parameter: groupId, Value: org.apache.servicemix.samples.helloworld
+[INFO] Parameter: packageName, Value: org.apache.servicemix.samples.helloworld
+[INFO] Parameter: basedir, Value: /Users/bsnyder/src/hello-world-smx
+[INFO] Parameter: package, Value: org.apache.servicemix.samples.helloworld
+[INFO] Parameter: version, Value: 1.0-SNAPSHOT
+[INFO] Parameter: artifactId, Value: hello-world-sa
+[WARNING] org.apache.velocity.runtime.exception.ReferenceException: reference : template = archetype-resources/pom.xml [line 71,column 18] :
+${servicemix-version} is not a valid reference.
+[INFO] ********************* End of debug info from resources from generated POM ***********************
+[INFO] Archetype created in dir: /Users/bsnyder/src/hello-world-smx/hello-world-sa
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESSFUL
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 2 seconds
+[INFO] Finished at: Fri Jan 05 23:40:32 MST 2007
+[INFO] Final Memory: 4M/8M
+[INFO] ------------------------------------------------------------------------
+</PRE>
</DIV></DIV>
-<P>2) From within the <TT>hello-world-smx</TT> directory, execute the following commands to create the project for the SA:</P>
+<P>The <TT>hello-world-smx</TT> directory should now contain the following two directories: </P>
<DIV class="code"><DIV class="codeContent">
-<PRE class="code-java">$ mvn archetype:create \
- -DarchetypeGroupId=org.apache.servicemix.tooling \
- -DarchetypeArtifactId=servicemix-service-assembly \
- -DarchetypeVersion=3.1-incubating-SNAPSHOT \
- -DgroupId=org.apache.servicemix.samples.helloworld \
- -DartifactId=hello-world-sa</PRE>
+<PRE class="code-java">$ ls
+hello-world-sa hello-world-su</PRE>
</DIV></DIV>
-<P>Upon successful execution of the <TT>archetype:create</TT> goals, look for the <TT>BUILD SUCCESSFUL</TT> output. The <TT>hello-world-smx</TT> directory should now contain the following directories: </P>
+<P>If you see the above directories, proceed to the next step below. If instead you see the BUILD FAILED output, you'll need to analyze the rest of the output to troubleshoot the issue. Assistance with any issue you might experience is available from the ServiceMix community via the <A href="mailing-lists.html" title="Mailing Lists">ServiceMix mailing lists archive</A>. </P>
+
+<P>Now that we have a project for the SA, we need to edit the POM so that the project depends upon the JBI component we created above. This can be done by editing the POM for the SA to add a dependency upon the <TT>hello-world-su</TT> as listed below: </P>
<DIV class="code"><DIV class="codeContent">
-<PRE class="code-java">hello-world-sa
-hello-world-se
-hello-world-su</PRE>
+<PRE class="code-java"><dependency>
+ <groupId>org.apache.servicemix.samples.helloworld</groupId>
+ <artifactId>hello-world-su</artifactId>
+ <version>1.0-SNAPSHOT</version>
+</dependency></PRE>
</DIV></DIV>
-<P>If you see the above directories, proceed to the next section. </P>
+<P>Upon adding this dependency to the POM, build the project using the command below: </P>
-<P>If instead you see the <TT>BUILD FAILED</TT> output, you'll need to analyze the rest of the output to troubleshoot the issue. Assistance with any issue you might experience is available from the ServiceMix community via the <A href="mailing-lists.html" title="Mailing Lists">ServiceMix mailing lists archive</A>. </P>
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">$ cd hello-world-sa
+$ mvn install</PRE>
+</DIV></DIV>
+
+<DIV class="preformatted"><DIV class="preformattedContent">
+<PRE>[INFO] Scanning for projects...
+[INFO] ----------------------------------------------------------------------------
+[INFO] Building A custom project
+[INFO] task-segment: [install]
+[INFO] ----------------------------------------------------------------------------
+Downloading: http://repo.mergere.com/maven2/xml-security/xmlsec/1.3.0/xmlsec-1.3.0.pom
+[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
+Downloading: http://repo.mergere.com/maven2/wss4j/wss4j/1.5.0/wss4j-1.5.0.pom
+[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
+[INFO] [jbi:generate-jbi-service-assembly-descriptor]
+[INFO] Generating jbi.xml
+[INFO] [resources:resources]
+[INFO] Using default encoding to copy filtered resources.
+[INFO] [compiler:compile]
+[INFO] No sources to compile
+[INFO] [resources:testResources]
+[INFO] Using default encoding to copy filtered resources.
+[INFO] [compiler:testCompile]
+[INFO] No sources to compile
+[INFO] [surefire:test]
+[INFO] No tests to run.
+[INFO] [jbi:jbi-service-assembly]
+[INFO] [jar:jar]
+[INFO] Building jar: /Users/bsnyder/src/hello-world-smx/hello-world-sa/target/hello-world-sa-1.0-SNAPSHOT.jar
+[INFO] [install:install]
+[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-sa/target/hello-world-sa-1.0-SNAPSHOT.jar to /Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/hello-world-sa/1.0-SNAPSHOT/hello-world-sa-1.0-SNAPSHOT.zip
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESSFUL
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 10 seconds
+[INFO] Finished at: Fri Jan 05 23:53:19 MST 2007
+[INFO] Final Memory: 12M/22M
+[INFO] ------------------------------------------------------------------------
+</PRE>
+</DIV></DIV>
-<H3><A name="HelloWorld-SE-IncorporatingtheSubprojectsIntoaTopLevelPOM"></A>Incorporating the Subprojects Into a Top Level POM</H3>
+<H2><A name="HelloWorld-SE-IncorporatingtheProjectsIntoaTopLevelPOM"></A>Incorporating the Projects Into a Top Level POM</H2>
<P>Now that we have created the SU and SA projects, a top level <TT>pom.xml</TT> must be manually created and made aware of each subproject. In the <TT>hello-world-se</TT> directory create a file named <TT>pom.xml</TT> containing the following content:</P>
@@ -1039,7 +1221,7 @@
<DIV id="site-footer">
Added by <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=georg_dembowski">Georg Dembowski</A>,
last edited by <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=bsnyder">Bruce Snyder</A> on Jan 07, 2007
- (<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=13823&originalId=15256">view change</A>)
+ (<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=13823&originalId=15257">view change</A>)
(<A href="http://goopen.org/confluence/pages/editpage.action?pageId=13823">edit page</A>)
</DIV>