tag:blogger.com,1999:blog-18175870409670094652024-03-23T14:13:40.448+01:00Go2OracleAlexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-1817587040967009465.post-67307992029253895282013-05-10T07:07:00.001+02:002022-05-17T08:07:48.384+02:00SOA Suite Knowledge – Polyglot Service Implementation with Groovy<p><em><font size="2"><a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">Polyglot programming</a>, defined most simply, is the use of multiple languages in software development. Implementing services on the </font><a href="http://en.wikipedia.org/wiki/Service_Component_Architecture"><font size="2">SCA</font></a><font size="2"> Container is already a intended polyglot development approach. Oracle SOA Suite have the SCA service implementation types of BPEL, Human Workflow, Mediator, Rule and Spring Components. These components are mixing the General-Purpose Language (GPL) Java with <i><a href="http://en.wikipedia.org/wiki/Domain-specific_language">Domain-Specific Languages (DSL)</a></i><i> like XSD, WSDL or <a href="http://en.wikipedia.org/wiki/Schematron">Schematron</a>. But </i></font></em><em><font size="2">Spring Components are also enabler of service implementations with other JVM GPL languages beside Java.</font> </em></p> <p><font size="2">In my opinion Neal Ford was absolutely right when he coined the term “</font><a href="http://memeagora.blogspot.de/2006/12/polyglot-programming.html"><font size="2">Polyglot Programming</font></a><font size="2">” and predicts “<em>Applications of the future will take advantage of the polyglot nature of the language world … The times of writing an application in a single general purpose language is over</em>” already in 2006. In order to produce polyglot implementations you need environments where polyglot-ism is required or at least encouraged. Oracle SOA Suite is such a polyglot supporting environment and you are doing polyglot development all the time (e.g. XML, WSDL, SQL, Java). But also on the GPL side the developers or not limited on Java. <a href="http://docs.oasis-open.org/opencsa/sca-j/sca-springci-spec/v1.1/sca-springci-spec-v1.1.html">SCA Spring Components</a> are supported since <a href="http://www.oracle.com/technetwork/middleware/soasuite/soa-11gr1-ps2-new-features-097680.html">Patch Set 2</a> and the </font><a href="http://en.wikipedia.org/wiki/Spring_Framework"><font size="2">Spring Framework</font></a><font size="2"> supports </font><a href="http://en.wikipedia.org/wiki/Dynamic_programming_language"><font size="2">dynamic languages</font></a><font size="2"> since version 2 (</font><a href="http://en.wikipedia.org/wiki/BeanShell"><font size="2">BeanShell</font></a><font size="2">, </font><a href="http://en.wikipedia.org/wiki/JRuby"><font size="2">JRuby</font></a><font size="2"> and </font><a href="http://en.wikipedia.org/wiki/Groovy_%28programming_language%29"><font size="2">Groovy</font></a><font size="2">). </font></p> <p><font size="2"><a href="http://groovy.codehaus.org/">Groovy</a> is a </font><a href="http://en.wikipedia.org/wiki/Dynamic_programming_language"><font size="2">General-Purpose Dynamic Language</font></a><font size="2"> and has the best and seamless integration with Java (beside Spring integration Groovy supports also <a href="http://groovy.codehaus.org/Embedding+Groovy">direct</a> and </font><a href="http://www.drdobbs.com/jvm/jsr-223-scripting-for-the-java-platform/215801163"><font size="2">JSR 223</font></a> integration<font size="2">). Therefore, u<font style="font-weight: normal">sing Groovy has a low threshold for Java developers; it is easy because Groovy has a Java-like syntax. Most Java code is also syntactically valid Groovy. So it’s an iterative learning approach for Java developers switching to Groovy. </font><font style="font-weight: normal">My first contact with Groovy was at the JAX conference in 2008. It was a Groovy newbie session from Dierk König (well-known book author of "<a href="http://www.manning.com/koenig/">Groovy in Action</a>"). And for the first time in a long while of Java programming I had an awakening and still addicting interest on this development language. </font></font></p> <p><font size="2">The Groovy language is meant to complement Java and is adding a wide range of features that are sadly lacking in Java (for example </font><a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29"><font size="2">Closures</font></a><font size="2">, </font><a href="http://en.wikipedia.org/wiki/Dynamic_typing#Dynamic_typing"><font size="2">Dynamic Typing</font></a><font size="2"> and </font><a href="http://en.wikipedia.org/wiki/Metaprogramming"><font size="2">Metaprogramming</font></a><font size="2"> – just to name a few). Concurrency and parallelism is increasingly important in the era of </font><a href="http://en.wikipedia.org/wiki/Multi-core_processor"><font size="2">multi-core CPUs</font></a><font size="2"> with a growing number of CPU cores.<strong> </strong></font><a href="http://gpars.codehaus.org/"><font size="2">GPars</font></a><font size="2"> is part of Groovy and offers a intuitive and safe way to handle tasks concurrently. Groovy makes it also easy </font><a href="http://www.infoq.com/presentations/Writing-DSL-in-Groovy-Scott-Davis"><font size="2">to create DSLs</font></a><font size="2"> (to simplify the “solution”). Optional parentheses, optional semicolons, method pointers and Metaprogramming let the code viewed as “executable pseudo code” (and easy readable by non-programmers). One of my personal favorites on using Groovy is the easy XML handling, both for consuming and producing XML content with its XML builders and parsers. Therefore I encourage you to take a deeper look on Groovy. </font></p> <p><font style="font-weight: normal"><font size="2">In my opinion Groovy envision also a bright future because the Spring development team </font><a href="http://blog.springsource.org/2013/01/16/next-stop-spring-framework-4-0/"><font size="2">announced</font></a><font size="2"> to put a strong focus on Groovy on the upcoming Spring Framework 4.0. Spring 4 will about properly supporting Groovy 2 as a first-class implementation language for Spring-based application architectures - not just for selected scripted beans but rather for an entire application codebase, as a direct alternative to the standard Java language (quoting on Jürgen Höller from SpringSource who is the Spring Framework co-founder and project leader). The Spring Framework is the </font><a href="http://www.springsource.org/"><font size="2">most popular application development framework for enterprise Java</font></a><font size="2"> and will become therefore the driving force for getting more Java developers in touch with Groovy (and let them feel what is the “right language for the job”). </font></font></p> <p><font size="2">The latest version of Oracle SOA Suite (v11.1.1.7) comes with <a href="http://static.springsource.org/spring/docs/2.5.x/reference/index.html">Spring v2.5.6</a> and has also the </font><font size="2">Groovy</font><font size="2"> v1.6.3. libraries on board. These versions are outdated, because Spring v.2.5.6 was <a href="http://www.springsource.org/node/813">released in November 2008</a> and Spring is already on the 3.x version. Groovy v1.6.3 was <a href="http://groovy.dzone.com/announcements/groovy-163-has-been-released">released in Mai 2009</a> and Groovy is today on version 2.x. Anyway, since Oracle SOA Suite PS5 (11.1.1.6) it’s possible to do Spring Bean implementation using Groovy. Oracle itself is also using Groovy, for example the </font><a href="http://docs.oracle.com/cd/E12839_01/integration.1111/e10228/reporter.htm"><font size="2">Rule Reporter</font></a><font size="2"> is written in Groovy or </font><a href="http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/ADF_Insider_Groovy/ADF_Insider_Groovy.html"><font size="2">Oracle ADF</font></a><font size="2"> is using Groovy as well. But the </font><a href="http://docs.oracle.com/cd/E29597_01/dev.1111/e10224/sca_spring.htm#BCGEEEII"><font size="2">official documentation</font></a><font size="2"> on how to write SOA Suite Spring Beans with Groovy should be improved, because you need more details to make our polyglot implementation running. Motivating for using Groovy and showing the details are the reasons for this blog. Now lets go to the details. </font></p> <p><font size="2">First you have to do some configure steps. I show you the steps with the out-of-the-box coming Groovy library v1.6.3. But you also could </font><a href="http://groovy.codehaus.org/Download"><font size="2">download the latest Groovy version</font></a><font size="2"> and make use of the newest Groovy features (I did a successful test with Groovy v2.1.3). </font></p> <p><font size="2">1.) Copy the $MW_HOME/oracle_common/modules/groovy-all-1.6.3.jar library to the $ORACLE_HOME/soa/modules/oracle.soa.ext_11.1.1 folder<br><br>You can add JAR files and custom classes to a SOA composite application. A SOA extension library for adding extension JARSs and classes to a SOA composite application is available in the $ORACLE_HOME/soa/modules/oracle.soa.ext_11.1.1 directory. The Groovy library has become known to SOA composite applications.</font></p> <p><font size="2">2.) Run ANT at the $ORACLE_HOME/soa/modules/oracle.soa.ext_11.1.1 folder<br><br>Running ANT on the "soa.ext" folder will update the oracle.soa.ext.jar library with a changed MANIFEST.MF file, adding a reference to Groovy.</font></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYM_IzhUk1SMXHABy6UVWueFJtST6K4sDNf90fdMDEQdKatTj-7RgXwmXx8QKOeGl7PvrOIAMu1XtJjcUVajx6RVPXsvx1IX5lDQi_hv1jaoo-RpTB6JR7f8OVTz2OYMEvVQeOautjQfNw/s1600-h/image26.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5rYlYAs81xFpH5Z0hmMqlATrA8ZmgtSYfxCve0lRMvHSmtZC3xz6CoOj-9tlOvOrOEnE85QcsZcD1YCDgYg4bFbARv2oUj0-wgSEJ7dPbVAZU1UhEKbWmbzr_qHfokiM_wpMOZF0Udobq/?imgmax=800" width="504" height="316"></a><br><font size="2"><u>Warning:</u> This procedure is not cluster-friendly. If you're running a cluster, you must copy the file and run ANT on each physical server that forms the domain.</font></p> <p><font size="2">3.) Add the Groovy library to the Weblogic system classpath. Open the setDomainEnv configuration file and put the Groovy library on the POST_CLASSPATH setting.</font> </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDB-k2AmwbYQo593x0zUGhPGpCsj2tOAcaJB92linPD_rHBS1JmnjbXEbtw3cUMCL-l2mtLl6vMEw54VaoH6HNmVtwajBkRceK6_5NweObrkGpqMVDqjA-IUXNm_VNKw3nP_5f5Vg-06tw/s1600-h/image53.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3vFQoFadbDBROCb9SFv2t_yGZ-GG7nx5j1O9sJyvLatsS3aUxyn4bW-mU7KXYD3ZR9E41my5cAdhsQre9AUnaC7zO_g7oSuwFGN0oYqb4RS0GWbsnetGnvhHKp9hVqOVNMDmgf-9BIiSA/?imgmax=800" width="503" height="415"></a></p> <p><font size="2">4.) Restart the Weblogic application server</font></p> <p><font size="2">Once the configuration is done, the Spring Bean Groovy coding could start. I’m reusing the Calculator example from an older blog about </font><a href="http://suchier.blogspot.de/2011/03/oracle-sca-spring-bean-contract-first.html"><font size="2">Spring Bean Contract-First</font></a><font size="2">. Therefore I copy the Calculator WSDL on the project folder, create a Web Service Adapter and pointing on the Calculator WSDL file. Afterwards I create an Spring Bean component and wire the Spring Bean with the Web Service Adapter (contract-first approach). The JDeveloper wizard creates the necessary Java files for the Spring Bean.</font> </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnHGzqW8Ofec7mGYlHHpF7VlLOPFk-py0E_ji6LRPQPq3SalKXt8MFFdQRW3y2vUWD5bGAW1purZU1DLXbWsocwPfrCmv-6GgyUrRhAwACsxVVveZqy5WROcq8FkC7eyT9lB1w0ziDO9Wu/s1600-h/image12.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-LRge0uVvkpw/UYx_m75axVI/AAAAAAAAAYw/HznnXonwMTs/image_thumb6.png?imgmax=800" width="489" height="137"></a></p> <p><font size="2">I’m doing only one change on the setter methods of the generated type classes for the response (AddResponseType, SubtractResponseType, MultiplyResponseType and DivideResponseType). The setter should return “this”. This approach is commonly called a builder pattern or a </font><a href="http://en.wikipedia.org/wiki/Fluent%5Finterface"><font size="2">fluent interface</font></a><font size="2">. You don’t need to care about the returned object if you don't want, so it doesn't change the "normal" setter usage syntax. But this approach allows you also to return the changed class (I’m using this approach together with the <em>end return</em> Groovy feature) and to chain setters together.</font></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIqvb9358C6SRcwDlTAFIzpLCUF4wtwKsaoalOYkg-77tV0NljCNzFMHB1B_QgUI5jnC47BPNgXSNyGA7gzjHW_5JyTZJID_8N-AoovY4DwoDmae1Ud3xZdC4LmJXxrJBU8i2YcA3SwYGE/s1600-h/image24.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-XNt0syQAzMk/UYx_o7nMebI/AAAAAAAAAZA/FAa2p4X1zE0/image_thumb14.png?imgmax=800" width="411" height="484"></a></p> <p><font size="2">Next step is the Groovy implementation of the generated Java ICalculatorService interface. I’m placing the GroovyCalculator class on the same package name like the Java interface but on the <em><project>\SCA-INF\src</em> folder instead of the<em> <project>\src</em> folder (details below).</font> </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoT0uegVvZ6elvpwFvC1Khk11VJ4pe49sVDoXcyI5J4AACW__2l1rMIHoOR-HZ2esqjHrx1kSFKA3xaRPC_K4upgcI4ILq48j9cCZmUgMuLiT6t1ym4f5CnBkENNxqT7_dAIdNoNCsFM_X/s1600-h/image333.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-tGiZxU7Y_pM/UYx_re2Y7VI/AAAAAAAAAZQ/cKGc3cMAJYo/image33_thumb2.png?imgmax=800" width="503" height="383"></a></p> <p><font size="2">The implementation is coming in Groovy style. Semicolons and the default public visibility declaration disappeared. Variables are dynamically typed (keyword <em>def</em>). The mathematical operations are Closures (support for Closures in Java is planned for <a href="http://en.wikipedia.org/wiki/Java_version_history#Java_SE_8">Java 8</a>; recently postponed to March 2014). The last expression result will be returned (so-called <em>end return</em>), therefore the keyword <em>return</em> is in Groovy optional. In general, Groovy code is less verbose, and more expressive and compact.</font></p> <p><font size="2">You have to make sure that the Groovy class is coming on the SCA-INF/classes folder at the SOA archive (<em>SAR</em>) JAR file. Therefore you have to place the Groovy class file on the SCA-INF/src sub-folder and instruct JDeveloper to copy also files with groovy extension on the Output Directory (Project Properties –> Compiler –> Copy File Types to Output Directory).</font> </p> <p><a href="http://lh4.ggpht.com/-x9j0Tix9WJw/UYx_s7swmII/AAAAAAAAAZY/H6aLHJO_TFQ/s1600-h/ProjectProperties42.png"><img title="ProjectProperties" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="ProjectProperties" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib3SqNF7Es2hh6ycLcQaBfLIRFo2UiNYDshfzb-uXfvNxy-MuMcpd8AOkUCEU_ZNAITE9XDLEiakvModGqpeyF3CuEq-KVJFYmON2lNVmNZOBQXPHxNJFy09jqWyj5wI6XgjNYfNouft2M/?imgmax=800" width="503" height="386"></a></p> <p><font size="2">The final step involves defining dynamic-language-backed bean definition on the Spring Bean Context file (the wiring-XML-file). One for each bean that you want to configure (this is no different to normal Java bean configuration). However, instead of specifying the fully qualified classname of the class that is to be instantiated and configured by the container, you use the <em><lang:language/></em> <font face="Arial">element to define the dynamic language-backed bean. For Groovy you have to use the </font></font><tt><font size="2" face="Arial"><em><lang:groovy/></em> element (which instructs Spring to use the specific Groovy-Factory).</font> </tt></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6CQQCiLOM_EItHDTPt6wHXjm1ANwoJGqUPbpfzpU5IM8LJ2zwj3iRQxyWvIOb-4MKmbLfllANmwylaoQNsmkcG8gFN8IlsRZLcYY9EQCMZZ86HymCdW-Kl5oLi2YAvwhHlONlPrFEuNGt/s1600-h/image402.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM1j9iqhz0MOQnhUk1yF5BrbGyG8e6mHIUNi08s69EE9JlrIzBKnEcif0TOd2UQt1UY4DvVIrbcrdcXOTltrnUXip1fFpI0fDkmok-1Q-vOOTaNnBYjloOlP4Ric5iQSObv6BkzJY-13Sh/?imgmax=800" width="503" height="176"></a> <p><font size="2">Afterwards the SCA Composite could be deployed and tested. </font><font size="2">The Groovy script will be automatically compiled during the deployment on the application server. It is worth to mention that Spring supports also <a href="http://static.springsource.org/spring/docs/2.5.x/reference/dynamic-language.html#dynamic-language-refreshable-beans">refreshable beans</a> and <a href="http://static.springsource.org/spring/docs/2.5.x/reference/dynamic-language.html#dynamic-language-beans-inline">inline scripting</a>. </font></p> <p>Refreshable beans allow code changes without the need to shut down a running service or redeploy the service. The dynamic-language-backed bean so amended will pick up the new state and logic from the changed dynamic language source file. Be careful, in my opinion it’s a powerful but dangerous feature. One reason for inline scripting could be a quick Mock Bean implementation (take a look on the Mock example below).</p> <p><a href="http://lh3.ggpht.com/-srLVQCOOWLA/UZHnZhEzbaI/AAAAAAAAAao/gtU8tACvh1Q/s1600-h/MockBean%25255B3%25255D.png"><img title="MockBean" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="MockBean" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiToz-_pJP-ufuLKYxMYBZHtREDTXBoqycTVqIxR0CR7_SMt900yZWwnheYskM37NQebDEVynTuJGt1a1u94Wl6-xp5WoxEp95Bpwawhql6VH91BkLrmgoDL222mBpBcm6cFCIykWjnNYpv/?imgmax=800" width="505" height="376"></a></p> <p><font size="2">The Mock implementation is always returning <a href="http://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy">42</a> as a result. </font></p> <p><font size="2">Groovy coding errors will result in a ScriptCompilationException giving you more details about the occurred issue (reason, line, column). For example …</font></p> <p><em><font size="2">There was an error deploying the composite on SOAServer: Error occurred during deployment of component: CalculatorSB to service engine: implementation.spring, for composite: Calculator05Groovy: SCA Engine deployment failure.: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroovyCalculatorBean': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GroovyCalculatorBean': Could not determine scripted object type for GroovyScriptFactory: script source locator [classpath:calculator/example/suchier/GroovyCalculator.groovy]; nested exception is org.springframework.scripting.ScriptCompilationException: Could not compile script; nested exception is org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, GroovyCalculator: 17: unexpected token: this @ line 17, column 84.<br></font></em></p> <p><font size="2">Often I’m using <a href="http://www.soapui.org/">SoapUI</a> beside Enterprise Manager Fusion Control for doing first tests. Here is the test SoapUI output for a valid division.</font></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5GXFqPpB5qwF-TYi0WW7CqBjvUIESThCU4DtNqiqc9PxwmsbS7Rv93JGfXAtaGywGnaE7vJlrw-cr_i4qSpa4ZQHfOGFu-IZ18bc0I1gAPkMsLWAr0bPcHtbXFsO8dvyo3VGcVn6b7noN/s1600-h/image23.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-7Q7K_a5L_9M/UYx_yt9Uh2I/AAAAAAAAAaA/TgUx0R__pEg/image_thumb18.png?imgmax=800" width="503" height="323"></a></p> <p><font size="2">This is the output for a division by zero. The exception is throw on the Groovy class, but is also a standard based SOAP fault.</font></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_2Ir3DDJxtCvqTuFGPNcMFakYfgaS5hxHn5an1_pl8YbH49Xo9G4nVL-V1iuRGWLd05GXQxUezyuOw7mC0p-2INWpIwAfAlo8EfPRyF_diKPiY85wempWLumP7ZYY8tLeRn2lo3xxGZgx/s1600-h/image16.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://lh5.ggpht.com/-u72kyRYK3MM/UYyAlbXTxwI/AAAAAAAAAaU/V-wYO2nQxUg/image_thumb11.png?imgmax=800" width="504" height="325"></a></p> <p>The source code is available as 7-zip <a href="https://dl.dropboxusercontent.com/u/32501249/Blog/Calculator05Groovy.7z">here</a>.</p> <p>That’s it. <font size="2">This is not a bash-the-other-languages blog. But my personal favorite language beside Java is Groovy and there many reasons to take a look on Groovy also as a SOA Suite developer. Now you have the details to start Groovy based polyglot service implementation on Oracle SOA Suite. </font><font size="2">If you are a Groovy beginner, I would recommend to take a look at the excellent books “<a href="http://www.manning.com/koenig/">Groovy in Action</a>” (from Dierk Koenig) and “<a href="http://pragprog.com/book/sdgrvr/groovy-recipes">Groovy Recipes</a>” (from Scott Davis).</font></p> Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0tag:blogger.com,1999:blog-1817587040967009465.post-48396745929031270482013-03-04T17:01:00.001+01:002022-05-17T08:08:05.348+02:00SOA Suite Knowledge – MTOM enabled Web Services<p><i>You might have heard about MTOM/XOP. Possibly you have a broad idea of what MTOM/XOP is doing. Than you start from the same initial situation like me some months ago. Let me give you a jump start on what MTOM/XOP means in general and in particular on the </i><a href="http://docs.oracle.com/cd/E24329_01/web.1211/e24965/mtom.htm"><i>Oracle platform</i></a><i>.</i> <p><a href="http://www.w3.org/TR/soap12-mtom/">MTOM</a> is the <a href="http://en.wikipedia.org/wiki/World_Wide_Web_Consortium">W3C</a> standardized <u>M</u>essage <u>T</u>ransmission <u>O</u>ptimization <u>M</u>echanism which is used in combination with the concrete referencing mechanism <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XOP</a> which stands for <u>X</u>ML-binary <u>O</u>ptimized <u>P</u>ackaging. MTOM/XOP is a way to handle opaque data with XML like binary data of images, audio or video. MTOM/XOP does not use any compression and decompression technique. There is another standard called <a href="http://www.oracle.com/technetwork/articles/javase/fastinfoset-soa-142549.html">Fast Infoset</a> that addresses the compression issue. But large application data which need to be compressed for efficacy could be also handled by MTOM/XOP (more about it on the given example below). <p>XML parsers will fail when you place binary data in a text node of a XML document. The binary data could contain reserved XML characters like ‘<’, ‘>’ or ‘&’ which will break the parser on the “other side”. CDATA wrapping allows these reserved XML characters but the parser is looking for a ‘]]>’ (which marks a CDATA section end) and there is the risk that the binary data have such a byte sequence. Base 64 encoding (xsd:base64Binary) is a solution because each byte is mapped to a valid 64 character “alphabet” which guarantees that a byte is not misinterpreted as anything that would break an XML parser. Unfortunately, base 64 encoded binary data are on average 33% larger (number of bytes) than the raw data. The alternative of hexadecimal encoding (xsd:hexBinary) even expands the binary data by a factor of 2. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeWSR56mzkTm_WIxHo6wmfTNhQGwomSE8sA0PWSXKzp2rZvQqVlYzGvmw_Zd4rUrBeeXxi8CowlTQbmgNF7C22OVq3aic3-b-NU7AlWNmx8aoIq6bT890DMXyA9dWWWW8qYEBmzJ1IdR2K/s1600-h/NoticeBox%25255B5%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NoticeBox" border="0" alt="NoticeBox" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4P0s-AQASV1tpeqBZlytkevszG4_npC5QGEemcoAgKaFQEgj5Ggh_hVZUQN6Oag72RMHcA6t33F3eJuj_6ynE6XWER8xb-IHgzLXb-neO1PIuHvH6oxRCXGa6ocEJQBYWspIJjURb_PZJ/?imgmax=800" width="454" height="107"></a></p> <p>Another idea to handle opaque data is to place them outside of the SOAP message. This technique is well-known in the Java world as “<u>S</u>OAP <u>w</u>ith <u>A</u>ttachments” (SwA). The SOAP message contains a reference to the binary data which are placed at the <u>M</u>ultipurpose <u>I</u>nternet <u>M</u>ail <u>E</u>xtension (MIME) attachment. <p><a href="http://lh6.ggpht.com/-jGSF6cnbHmU/UTTE3EK9s3I/AAAAAAAAASE/gH2Kt84xpJI/s1600-h/SOAPMessagePackage%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="SOAPMessagePackage" border="0" alt="SOAPMessagePackage" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrcBbOXFAsHnC4UhYXvUeTHrUseO9sZ511DmBnK5iJHAQF0VTy9kmDv_yOWtZR9RjOdbqpa48QAGDDihwG3Hf5IZ5q0vxRzThlbapRu9WLkAEnebyJWbYJD5UpjwQcEIeFn1t7LyDshUGx/?imgmax=800" width="188" height="240"></a> <p>But the binary attachment is not part of the SOAP Envelope at all. It’s leaving it up to the message processor to retrieve the actual binary data. Standards like WS-Security couldn’t work anymore, because WS-Security can’t be used to secure attachments. Furthermore the Microsoft world was using <a href="http://msdn.microsoft.com/library/en-us/dnglobspec/html/draft-nielsen-dime-02.txt">DIME</a> (<u>D</u>irect <u>I</u>nternet <u>M</u>essage <u>E</u>ncapsulation) encoded attachments. It’s not a good idea that Web Service providers have to support both attachment technologies, SwA and DIME. <p>Since 2005 the agreed solution is MTOM/XOP. It has the efficiency of SwA, but it does so without having to break the binary data outside of the SOAP Envelope. XOP allows binary data to be included as part of the XML Infoset. When data is within the XML Infoset, it means that it operates within the constraints of the SOAP processing model. In other words, you can control the processing of the XML Infoset using SOAP headers with policies. <p>MTOM/XOP uses a XOP:include element to tell the processor to replace the content with the referenced binary data which are “stored” outside of the XML document at the MIME attachment part. The logic of discrete storage and retrieval of binary data becomes inherent to the XML parser. The SOAP parser could treat the binary data in a uniform way and as part of the XML document, with no special retrieval logic. Fortunately sender and receiver are not aware that any MIME artifacts were used to transport the base64Binary or hexBinary data. <p>Let’s take a look on how to enable MTOM/XOP on SOA Suite 11g. The real world requirement is to build a cache warming-up dictionary service for the Web Presentation Tier which has no database access. Therefore the SCA Container running on the Service Tier provides a Dictionary Entity Service which should be able to transport large datasets to the Web Presentation Tier intermediated by an OSB. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizalBjVE0XcmMe8rjXQjWgotHMcjZ0g85Ym4ceKkHNMFLGgKFEa3NCU8KqCPA3vvB3XF93yydVKXQ9sMG3MWHCbpwhSYBjaK-x13q4hkjY7Vr9lmHJT2XtPr8dBuS2bkv-kKoNcNRi6YzQ/s1600-h/clip_image005%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image005" border="0" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig1n5SwFARwscoYcKKWbyveyGXOGWG6IO79jk9FajyD05WNpLF-9Zf2y2L3K3CcX3QPY8uHpvdwKTBBAns5E9Vgx5babxnRosAA2ndJbtscBn3kEZFmDA71s7OedZpUrQpxHOOFEH5qA6Z/?imgmax=800" width="512" height="177"></a> <p>A first top-down WSDL-first implementation would cause the client to send a request for Dictionary ID ranges (request example); afterwards the service retrieves the requested dictionary data from the database and sends the response back to the client as normal dictionary entry structure (response example). <p>Request Example: <p><a href="http://lh3.ggpht.com/-FQTclWxFqtY/UTTE6HWyBTI/AAAAAAAAASk/Yytpex-lkqQ/s1600-h/clip_image007%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image007" border="0" alt="clip_image007" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXBoOqC7KOLbmlvVUILLd4mTS2PcUhd7S6Pj-PzzAjiXLfFhWWcg9dgJS2ZPhFws12iy84EKAqtU4-zYrrtJlX9T_9361otTRm8cBS7ko1iCl2S4CpgODIg8wjmZSBEuwJmcHyHsLDr4EN/?imgmax=800" width="501" height="146"></a> <p>Response Example: <p><a href="http://lh4.ggpht.com/-PPv39XZuLYs/UTTE7wA4VvI/AAAAAAAAAS0/OtXOEU5Lw1o/s1600-h/clip_image009%25255B5%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image009" border="0" alt="clip_image009" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWAO1q7NOM2syiXKTAAcsaUpsDfzLLei2Nz1viMryiE5RRNMg_13stlHbWt1ZFgyNpcuc8dOoxb2rUuglWqS68pc-gnLFO7HnvSUwOgKl80jlzDp4UqHwy0n95r7b-IsutjrDsOgcfudlm/?imgmax=800" width="501" height="360"></a> <p>It’s obviously that a large range of Dictionary IDs would cause a large SOAP Response message. But in our case we have a Spring Bean implementation using the simple JDBCTemplate approach. The result of the database request is a list of maps (line 11 and 12) which is mapped on the service response (line 32 to 38). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu6MZdRqEzGrsxtLGb6RIUj0vquOx-lbzXVRNSqu6cnhV8hPaRcG6VqUux3oWkcRCzFrWaK4t_O5yX8TY3PTkgxU1F6-30TNgks62Xkk1qV7-_7QNmlQ4D9MpAY1FvsNW-RSQwYWdLq-9Y/s1600-h/clip_image011%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image011" border="0" alt="clip_image011" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpfwgwtR4J70VxcRUI_46p7RU44TpQVq5gujBG02t7_4DzR17jOwtNlqZ_ROMssPg9YM6wAVufLh4D0yeydn3Wtj-OBGwW-y2fmBXrpTLd6tfn07Hl6PTN1XIEsbTHVs-_nS2arDRwsuCZ/?imgmax=800" width="518" height="237"></a> <p>How about that the service return the raw list instead of the collection of dictionary entry type? Isn’t it a technical motivated private service where the known Java client on the Web Presentation Tier has to navigate through the list anyway? Yes, it is. <p>The service should become MTOM enabled in order to handle the binary data as part of the message. The same request structure should return a byte array with the data list returned from the database. Two meta data information should be returned additionally, how much dictionary entries are returned and the byte size of the array. <p>The XSD structure is simple. Element Size and RecNum are optional and of type long. And here we use the base64Binary type for the list of dictionary entries (Element return). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDZChBvXsyVNi50YV2itMu-ad68fcCWfmICUdVI9asybsxFCz9RwxdyN_2RLall6mgj-gqGE6eXBd1tvNdS8xFzZntznQFe_TxK9cBcZXrxY0k6XP3e6HJ2c4_LMiP8eHUZnFmnSbiti8/s1600-h/clip_image013%25255B5%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image013" border="0" alt="clip_image013" src="http://lh3.ggpht.com/-XcM8sGhjpvI/UTTFAFCKHSI/AAAAAAAAATc/eTuZT2ft1qE/clip_image013_thumb%25255B2%25255D.jpg?imgmax=800" width="515" height="172"></a> <p>MTOM will be enabled with a right mouse click on the Web Service Adapter placed at the Exposed Services swim lane. The menu option “Configure WS Policies …” will open the Web Service Policies configuration wizard. You only have to enable the MTOM policy (oracle/wsmtom_policy). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAvn7G3S3o1i9kVQYzKM8zlFaNP62p8MlL2piIh8QtG5c1iWiVN8UQO4zgzXEXMr0w7ktfyKF4tIWx4F9CEeLKAiRTlaTCe3QYeEM0qUjTnQ-QdV81lNWJKXUCOGsDSfp47ZgCbJTMMmsu/s1600-h/clip_image015%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image015" border="0" alt="clip_image015" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidsAWqMN8SEMP3-BdDKclngi1jEhaitU32evssBJGckmQMER4Vde3h1Vl7TxI2-krQMYSVX1LlmBBqVHDZOnTlsxepbS2CLD1PPmQxSwUGtRBDnCDnPTo99UBUBWrtxNhj4uUtdMQsUMFM/?imgmax=800" width="592" height="459"></a> <p>The Web Service Adapter on the graphical SCA Editor will have a lock icon at the right upper corner after adding the policy. Behind the scene the wizard will add only one additional configuration line on the Web Service binding (line 4) at the composite.xml file. <p><a href="http://lh6.ggpht.com/-VxQPZ8Tsoww/UTTFC_4-IoI/AAAAAAAAAT0/XKpDvzgLglw/s1600-h/clip_image017%25255B5%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image017" border="0" alt="clip_image017" src="http://lh3.ggpht.com/-3rwKK14WQng/UTTFDV-lF6I/AAAAAAAAAT4/6isDomsy034/clip_image017_thumb%25255B2%25255D.gif?imgmax=800" width="528" height="86"></a> <p>When you deploy the MTOM enabled service and take a look at the WSDL URL you will realize that Oracle SOA Suite added a MTOM policy to the WSDL (line 6 to 8). Additionally the WSDL binding has a policy reference to the MTOM policy (line 100). The wsdl:required="false" declaration means that also not MTOM enabled clients should work. Tools such as soapUI or SoapSonar should be able to invoke the service which makes sense because the service offers operations without MTOM involvement. From my experiences with soapUI it’s not working because both MTOM request properties (“Enable MTOM” and “Force MTOM”) have to be enabled always. Otherwise the service responses with an internal sever error (“Non-MTOM message has been received when MTOM message was expected.”). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiq7ffJXnd0QPKc1SrTnl5lG55cS1iXxPLbXj8JnqRki9N0sz2SHdPW8Nn5jcEJIvSTMwkqlBpi5Hn_ViG5_9R9c5FXclsZ-kdeOekXQ2daZ_ZKLoOqVJli0cVF8OPbvFlS4cglMbMx3lg/s1600-h/clip_image019%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image019" border="0" alt="clip_image019" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoKPAeh5UN7X0XgIKNc_-adLZXTXVyz4hEUOEQ7pwyzt4NcwSSj_3OA9wDrodAaiwsTzJOU9wetOhM180aya4pm27uyUdsanSXeD4cZ6txihZBHP2C2H4aPHp_qHeVHNwDbADVr_8d_aHZ/?imgmax=800" width="516" height="342"></a> <p>Oracle SOA Suite will create a byte[] equivalence for the XSD type base64Binary. So byte[] is the object representation of XSD types base64Binary and hexBinary. The only need is to convert the Spring database result list to a byte array (by using the classes ObjectOutputStream and ByteArrayOutputStream inside of a DataMTOMUtil helper class at line 34). The two meta data values are quickly and easily determined (line 37 and 38). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP5-kBNuRTEAK1zlOZT-JfpxM2MBR53bzwmfBtRCIBFfsuofMJvX86kUZ7f2dYHHxYOWzUuxmByVaDZHHCIhLKOyUaZmg3j1AJY2fuTGSN20pEHfsgKbpnSUpZo6q6DxfCcMtFsRFcCLib/s1600-h/clip_image021%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image021" border="0" alt="clip_image021" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLBKqwWulB51AYCFeHHVXeXMIOfz1eg8-jECNe8jHdqHonuecaVx_zBJeAK1FncvOxGs-XJyQKLBAtux5rfvnmBIYT1ASJjHLhCdRjOcQ9ghpLwKWo4ojQYBIjUuMPE6bjYzJuEmGz1LPy/?imgmax=800" width="517" height="295"></a> <p>The same request will now result in a more interesting response containing the XOP:include. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1GMtnMBVY39IFO2Vjs78d112M_DLWtf0wVvM-vbsPlGldIJGnjkstSOnILd1jLl7DfpWZ1TMrgmIki82pf0YLOmLnGcCEh5HBb3kOv4PXhNNCiLRSf60F9s2CHVj2R5Aj8CHsFriOegzU/s1600-h/clip_image023%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image023" border="0" alt="clip_image023" src="http://lh3.ggpht.com/-ithSvYNghxk/UTTFIvgIQEI/AAAAAAAAAUs/Jn8vrHz_UqA/clip_image023_thumb%25255B1%25255D.gif?imgmax=800" width="516" height="282"></a> <p>So the two meta data information of size and record numbers are like expected. But the dictionary result is now placed with context type “application/octet-stream” (=binary attachment) at the MIME part attachment with a given content ID. <a href="http://www.soapui.org/">soapUI</a> is showing you a raw view on the complete SOAP message. <p><a href="http://lh3.ggpht.com/-SfkDoQIKkRM/UTTFJejJU0I/AAAAAAAAAU0/lgKeE6wXHAE/s1600-h/clip_image025%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image025" border="0" alt="clip_image025" src="http://lh6.ggpht.com/-loko3qwnlDE/UTTFKOiVNXI/AAAAAAAAAU8/oR4yv2tCnJc/clip_image025_thumb%25255B1%25255D.jpg?imgmax=800" width="523" height="244"></a> <p>As you could see, the HTTP message has the content type “multipart/related” which is used for compound documents. The type is “application/xop+xml”. The dictionary list is send as binary part of the MIME message with the content type “application/octet-stream” and the same content ID which is placed at the href attribute (<a href="cid:6df6245c6aff457d8d51db92b6707170">cid:6df6245c6aff457d8d51db92b6707170</a>). <p>You will realize an interesting effect when the binary data are below a size of 1024 byte. In this case the Web Service framework will not create a separate attachment. Instead the binary data are placed directly on the XML message. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF9JdBIxEPKOtgprndbBPa4syQqhyphenhyphenAxhrqxMbQ0mPtaXR9XeE6ryPB8W3Es_I5hdEH8XllMZaYLZbingFxgTkhJS7j99sDV3J0ScyaaV58vtI2zDlYaW_byM5szG-JFjeXw1yF0T4l1rfe/s1600-h/clip_image027%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image027" border="0" alt="clip_image027" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw21eMoQqRLAdgVj_oKovS8FmScb2-HnTd6UlzFD6qfKvGnlx3bOsnkW-U3TcRWgqEU1xNEof1KJlG50rb5UDejgTfDm-Ach4_g0fSJ9f0FlUs7B9kQkaGYbbxp7Ub4cjGcMJRS-xpDdyB/?imgmax=800" width="513" height="389"></a> <p>The MTOM threshold of 1024 byte is a default value. When the potential attachment bytes are less than that threshold size, the data will be inlined. The MTOM threshold determines the break-even point between sending data inline or as attachment. <p>I already mentioned that MTOM/XOP will not do any kind of data compression. But it’s obvious that data compression will have a great benefit on our solution. The objToByteArray method is using standard OutputStream classes. It’s a quick implementation to use the java.util.zip.GZIPOutputStream for additional compression (line 10). <p><a href="http://lh6.ggpht.com/-3bJ3Ag6ckrM/UTTFMnD_UgI/AAAAAAAAAVU/ADLaUaEYaDg/s1600-h/clip_image029%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image029" border="0" alt="clip_image029" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeLZsgR0iYBdo-Uvv7xsD1KSoAYorbY1TVwvoH6H3rmxLvYCJQVuUQ1JuEhtimB_hlJmHP-8NWGaT_vhHum1ehs1zjSU-At2mXubK1G6JZ_X_XLlqS7BZpyvnyJHD6999fsyOeHqBCJvbi/?imgmax=800" width="518" height="408"></a> <p>The standard package java.util.zip provides classes for reading and writing standard GZIP format which is a popular compression algorithm. The client side creation is simply using the JDeveloper Web Service Proxy wizard. The wizard creates a Web Service client skeleton which is also MTOM/XOP enabled. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7gxEPuHG0jg4nODm_TCHJkP6QhRxPTQRqLaUB6VHCW9s7C0vI1_apz-8p2D6hZEOONTLOBHrZALwCjvI7AvcBVlLURU03wQjZ91ORG5_qOAJgJe7XjmVimQTMo7Yyc2rgqmPMWlY2BrsB/s1600-h/clip_image031%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="clip_image031" border="0" alt="clip_image031" src="http://lh5.ggpht.com/-kV6dAfV-Iio/UTTFPMQoDHI/AAAAAAAAAVs/hcdUSk2VLYY/clip_image031_thumb%25255B1%25255D.jpg?imgmax=800" width="443" height="325"></a> <p>Regarding MTOM/XOP you only have to enable the “oracle/wsmtom_policy” during the Web Service client creation. <p><a href="http://lh4.ggpht.com/-f1SvZ2wgJiU/UTTFQJevXeI/AAAAAAAAAV0/DnB9dC_YmI0/s1600-h/clip_image033%25255B4%25255D.gif"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="clip_image033" border="0" alt="clip_image033" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ61hJfmaL_vrJ-PEnbJZGb-63fQieLJFHiO_cJXpPW5TyqBypvf4aaC8mcMxDh9suVcvkQXU9aHw4FMZXUDg_Qsv7nBVmk-MJ9gjLiV6uc9AXJSFXVQLKooTy7KVc0xMG3oR0h1J6Xr_q/?imgmax=800" width="442" height="341"></a> <p>Finally you place your code snippets at the created Web Service client skeleton. In our case the conversation of a byte array back to a List object (line 31) and the mapping to the dictionary structure (line 33 to 38). The code has also to consider the GZIP decompression (line 7). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTTemrVgS2ERkgNtaZ-JE3q1h1SkuVxWGA4Sat9_8RoTFneJ4N10K1ynEtMKjW_1lcGS_kQutX4Ph0V8olxEoWVwY7F6eghuIbEwSmRc-vCD9cAHDPB1ywwpW8J_p0wfXufwKRX3nD4xVA/s1600-h/clip_image035%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image035" border="0" alt="clip_image035" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlR9lL0708LWiWRefM-H4TtelF1TO0jfmpvxb9Ok5a_FWsoLmCdCo6Ly_zPwfNAnfuOIMMrT1z5KkPlIZwzHTeN2Umz9Hf5JAzGpRn2rRW854ZuoQBxyQYtLs3eSQ6-4yK2JQ6Ee2R2SyK/?imgmax=800" width="500" height="425"></a> <p>What is the effect of data compression? I executed the service with several dictionary ranges and put the values on a spreadsheet. Additionally I added the size for base64 encoding (which would be used without MTOM/XOP).</p> <p> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="20%"> <p>Dictionary Rec Num</p></td> <td valign="top" width="21%"> <p>Dictionary List Size Uncompressed (byte)</p></td> <td valign="top" width="20%"> <p>Dictionary List Size GZip Compressed (byte)</p></td> <td valign="top" width="20%"> <p>Dictionary List Size Uncompressed Base64 (byte)</p></td> <td valign="top" width="16%"> <p>Dictionary List Size Compressed Base64 (byte)</p></td></tr> <tr> <td valign="top" width="20%"> <p>1</p></td> <td valign="top" width="21%"> <p>646</p></td> <td valign="top" width="20%"> <p>493</p></td> <td valign="top" width="20%"> <p>864</p></td> <td valign="top" width="16%"> <p>660</p></td></tr> <tr> <td valign="top" width="20%"> <p>14</p></td> <td valign="top" width="21%"> <p>2706</p></td> <td valign="top" width="20%"> <p>740</p></td> <td valign="top" width="20%"> <p>3608</p></td> <td valign="top" width="16%"> <p>988</p></td></tr> <tr> <td valign="top" width="20%"> <p>194</p></td> <td valign="top" width="21%"> <p>36383</p></td> <td valign="top" width="20%"> <p>3737</p></td> <td valign="top" width="20%"> <p>48512</p></td> <td valign="top" width="16%"> <p>4984</p></td></tr> <tr> <td valign="top" width="20%"> <p>1783</p></td> <td valign="top" width="21%"> <p>307619</p></td> <td valign="top" width="20%"> <p>13830</p></td> <td valign="top" width="20%"> <p>410160</p></td> <td valign="top" width="16%"> <p>18440</p></td></tr> <tr> <td valign="top" width="20%"> <p>11574</p></td> <td valign="top" width="21%"> <p>2188494</p></td> <td valign="top" width="20%"> <p>89687</p></td> <td valign="top" width="20%"> <p>2917992</p></td> <td valign="top" width="16%"> <p>119584</p></td></tr></tbody></table></p> <p>The compression rate is significant. Take a look at the last line. When I would transport 11574 records without MTOM on the base64Binary element I have to base 64 encoding of the data. In this way I need 2.78 MB byte (2917992 byte) which is 25% more than the original dictionary list size of 2.09 MB (2188494 byte). A GZIP compression will bring down the original dictionary list size at 0.09 MB (89687 byte). This is the final size which travels on the MTOM/XOP MIME attachment which is around 4.1% of the original size. <p>Therefore service is able to transport much more data in a given time with the GZIP compression. Base64 encoding will add additional size and is not a good option (even when you compress the dictionary list because it’s still around 25% larger). So MTOM/XOP with GZIP compression is the best solution. <p>The solution shown happens in memory. The <a href="http://docs.oracle.com/cd/E24329_01/web.1211/e24965/mtom.htm">Oracle documentation</a> describes also a streaming approach which may be interesting in case of very large binary data. But the documentation also mentions limitations regarding message encryption which is not working on streaming MTOM. Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0tag:blogger.com,1999:blog-1817587040967009465.post-57848451439011376332012-11-15T11:41:00.001+01:002022-05-17T08:08:18.109+02:00SOA Suite Performance – Right Garbage Collection Tuning - Part 2<p>My last <a href="http://suchier.blogspot.de/2012/08/soa-suite-performance-dont-fight.html">blog</a> pointed out the importance of the machine power and that it’s impossible to regain performance on the higher architectural layers when the machine power isn’t adequate. This time I want to focus on another very important performance adjusting screw – the JVM and especially Garbage Collection (GC). <p>GC tuning is in most cases an indispensable prerequisite for good performance on non-trivial projects from a certain size (and Oracle SOA Suite project are designated to this category). Unfortunately, it's also for SOA Suite projects not an easy and one-off task. Most likely it will take some optimization iterations where you measure your GC behavior, tune the GC stetting and measure again. And even when you find the right GC settings for the moment you have to monitor GC behavior over the time because raising number of SCA Composites, more SCA Service calls or higher data volume will change the GC behavior. It’s also safe to keep basic GC logging in the production system. <p>Good thing about GC tuning is that there are plenty of good articles and blogs describing how to do meaningful GC tuning. I neither want to repeat all the available stuff nor I want to go through all 50+ parameters of the Sun Hotspot JVM. Instead I want to give some helpful GC hints on the JVM which are important during our own JVM tuning for SOA Suite, rarely mentioned or difficult to find. So make yourself familiar with the JVM basics if this didn’t happen so far. <p>First of all when you want to do JVM tuning you need a GC analyzing tool like <a href="https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPJMETER">HPjmeter</a> to visualize GC behavior. Some tools could perform real-time monitoring but it’s sufficient to offline analyze the GC log files. Raw GC log file analyzing without a tool is a time-consuming task and needs a certain experience level. </p> <p>Basic GC logging parameters: <i>–verbose:gc –XX:+PrintGCDetails –XX:+PrintGCTimeStamps – Xloggc:<file></i>. </p> <p>The <i>–XX:+PrintGCDetails </i>option provides the details needed for GC tuning. The <i>–XX:+PrintGCTimeStamps </i>setting causes that time stamps are printed at GC. The time stamp for a GC event is indicating the amount of elapsed time since the JVM launched (approximately matching with the Weblogic Server Activation Time which is shown on the Weblogic Console). When it is desirable to know the exact wall clock time over a time stamp representing the time since JVM launch, you could use the <i>-XX:+PrintGCDateStamps</i> setting which enables the printing of a localized date and time stamp indicating the current date and time. </p> <p>The most obvious and important parameter is the right JVM Memory sizing which has to be aligned to the physical memory. Make sure the JVM always has 100% of the memory it needs, do not over-committing memory because the JVM Memory is an active space where objects are constantly being created and garbage collected (memory over-committing is the process of allocating more JVM Memory than there is physical memory on the system). Such an active memory space requires its memory to be available all the time. I was reading about a recommendation not to use more than 80% of the available RAM which is not taken by the operating system or other processes. Too small JVM Heap memory sizing will lead in worst case to an out-of-memory error already during startup or many Full GC Collections from the beginning. Too large JVM Heap memory sizing will pause your application for several tens of seconds. As a general rule of thumb, as the JVM Heap size grows, so does the overhead of GC for the JVM process. In order to give you a ballpark figure, if you have below 50 SCA Composites, I would recommend starting with 4 GB JVM memory (<i>-Xmx4g</i>) on your Weblogic Managed Servers. During your optimization, try to reduce the JVM Heap size if possible to get shorter GC times and to avoid wasting memory. If the JVM Heap always settles to 85% free, you might set the Heap size smaller. <p><u>Note:</u> A common misunderstanding is to assume that the <i>–Xmx</i> value is equal to the Java Process memory needed, but the JVM Memory (or Java Process Memory) is greater than JVM Max Heap (greater than <i>–Xmx</i>) and this is due to the other additional JVM areas outside of the JVM Heap that make up the memory space of the total Java process such as JVM Perm Size (<i>-XX:MaxPermSize</i>), [number of concurrent threads]*(<i>-Xss</i>), and the “Other JVM Memory” section. The <i>–Xss</i> option is the Java thread stack size setting. Each thread has its own stack, its own program counter, and its own local variables. The default size is Operating System and JVM dependent, and it can range from 256k to 1024k. Each thread is given exactly the amount specified. There is no starting or maximum stack size. Since the default <i>–Xss</i> stetting is often too high, tuning it down can help save on memory used and given back to the Operating System. Tune down to a range that doesn’t cause StackOverflow errors. The “Other JVM Memory” is additional memory required for JIT Code Cache, NIO buffers, classloaders, Socket Buffers (receive/send), JNI and GC internal info. <p><a href="http://lh5.ggpht.com/-FirNBtTZ4yw/UKTGpPV8hTI/AAAAAAAAAO8/MgvqsQV6vOU/s1600-h/clip_image002%25255B3%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://lh3.ggpht.com/-nKAX4s7fQy4/UKTGqwe_kuI/AAAAAAAAAPE/X5tr2V59BNc/clip_image002_thumb.jpg?imgmax=800" width="210" height="240"></a> <p>Therefore the final JVM Memory calculation has to happen with this formula: <p><i>JVM Memory = JVM Max Heap (-Xmx) + JVM Perm Size (-XX:MaxPermSize) + [number of concurrent threads] * (-Xss) + “Other JVM Memory”</i> <p>Typically “Other JVM Memory” is not significant however can be quite large if the application uses lots of NIO buffers, and socket buffers. Otherwise it’s safe assuming about 5% of the total JVM Process memory.<i></i> <p>Check that you have an activation of "<i>-server</i>" JVM Hotspot JIT. It delivers best performance for SOA Suite running servers after a fair amount of time to warm up (keep in mind that the Domain configuration wizard configures “<i>-client</i>” when you create a Domain in development mode). The server mode has differences on the compiler and memory defaults tuned to maximize peak operating speed for long-running server applications (doing more code analysis and complex optimizations). The old rule for Server JVMs to put initial Heap size (<i>-Xms</i>) equal to maximum Heap size (<i>-Xmx</i>) is still valid. Otherwise you get Heap increase on the fly which always requires a Stop-The-World (STW) GC, even if the resizing is very tiny. <p>Equalization of memory values is also a good approach for the Permanent Space which is allocated outside of the Java Heap. Permanent Space is used for storing meta-data describing classes that are not part of the Java language. The <i>-XX:PermSize</i> setting specifies the initial size that will be allocated during startup of the JVM. If necessary, the JVM will allocate up to <i>-XX:MaxPermSize</i> setting. JVM efficiency is improved by setting PermSize equal to MaxPermSize. This Non-Heap memory area is pretty stable to my observations. Observe PermSpace usage and adjust accordingly by using tools like JConsole or VisualVM. <p>Keep always in mind that you should consider to scale-out an application to multiple JVMs (=Weblogic Managed Servers) even on the same host (so-called vertical clustering). Horizontal clustering is clustering across hardware boundaries for both load balance and failover as first objective. Even though for a 64 bit system, there is theoretically no upper memory limit but the constraint of available physical memory. But again, too large heap sizes certainly can cause GC STW problems. Smaller JVM heap sizes running on more JVMs is the solution implemented with vertical and horizontal clustering. There is no “gold rule”, optimal JVM heap size and number of JVMs (= Managed Servers) could only be found through performance testing simulating average and peak load scenarios (use tools like the supplied Oracle Enterprise Manager Fusion Control, professional tools like <a href="http://www8.hp.com/us/en/software-solutions/software.html?compURI=1175451#.UJUL9cWHKz8">HP LoadRunner</a> or open source tools like <a href="http://jmeter.apache.org/">Apache JMeter</a> and <a href="http://www.soapui.org/">soapUI</a>). <p>Most important besides the right JVM memory sizing is the choice of the right GC strategy or also called GC scheme. You have to decide between the optimization goals of maximum throughput and minimum pause time. You couldn’t have both. So if you have a domain doing online processing where users are waiting for quick response you would like to optimize for minimum pause time. On the other hand, if you have a domain doing batch processing and your SCA Services are not involved on an interactive application you could effort longer pause time, than you would like to optimize for maximum throughput (that’s also a reason why I recommend on my last <a href="http://suchier.blogspot.de/2012/08/soa-suite-performance-dont-fight.html">blog</a> a domain split in a scenario were you have to do online processing and batch processing). <p>The acceptable rate for Garbage Collection is for sure application-specific but the <a href="http://docs.oracle.com/cd/E17904_01/web.1111/e13814/jvm_tuning.htm#i1132720">Oracle documentation</a> mentions that a <a href="http://docs.oracle.com/cd/E17904_01/web.1111/e13814/jvm_tuning.htm#i1131863">best practice</a> is to tune the time spent doing GC to within 5% of execution time (which is already a high value in my opinion). Full Garbage Collection should in general not take longer than 3 to 5 seconds. <p>Let’s take a look on the GC scheme settings. Today most of the environments operate on (several) Multi Core/CPUs. I assume that your SOA Suite machine(s) have Multi Core/CPUs and therefore we could neglect the special settings for Single Core/CPU environments. Here are the two important Sun JVM Flags to choose the right GC strategy:</p> <p> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="33%"> </td> <td valign="top" width="31%"> <p><b>Maximum Throughput<br>(pause-times are not an issue)</b></p></td> <td valign="top" width="35%"> <p><b>Minimum Pause Time</b> <p><b>(pause-times are minimized)</b></p></td></tr> <tr> <td valign="top" width="33%"> <p>Sun JVM Flag</p></td> <td valign="top" width="31%"> <p><b>-XX:+UseParallelGC</b></p></td> <td valign="top" width="35%"> <p><b>-XX:+UseConcMarkSweepGC</b></p></td></tr> <tr> <td valign="top" width="33%"> <p>Young Generation <p>(Eden Space + Survivor Spaces) <p>(Scavenges)</p></td> <td valign="top" width="31%"> <p>Parallel Young GC <p>(stop-the-world parallel mark-and-copy)</p></td> <td valign="top" width="35%"> <p>Parallel Young GC <p>(stop-the-world parallel mark-and-copy)</p></td></tr> <tr> <td valign="top" width="33%"> <p>Old Generation <p>(Tenured Space)</p></td> <td valign="top" width="31%"> <p>Parallel Old GC <p>(stop-the-world parallel mark-and-compact)</p></td> <td valign="top" width="35%"> <p>CMS GC <p>(concurrent mark-and-sweep)</p></td></tr></tbody></table></p> <p>Parallel GC scheme is stopping the application execution and is using as many threads as possible (and therefore all available CPU resources) to clean up memory. GC STW happens. Concurrent GC scheme attempts to minimize the complete halting of the application execution as much as possible by performing the GC logic in parallel within threads that run concurrently with the application logic threads. Anyway, even Concurrent Mark-and-Sweep (CMS) will cause GC STW but less and shorter than a Parallel GC. Take a look at the GC log file, only the “CMS-initial-mark” and “CMS-remark” phase is causing GC STW. The marking and remarking pauses are directly proportional to the amount of objects in the Old Generation (Tenured Space). Longer pauses indicate a lot of tiny objects. <p>The JVM offers also two settings to control how many GC threads are used in the JVM. <i>The –XX:ParallelGCThreads</i> setting controls the number of threads used in the Parallel GC. The <i>-XX:ConcGCThreads</i> setting let you control the number of threads Concurrent Garbage Collectors will use. <p>On smaller multiprocessor machines with less than or exactly 8 CPU Cores you will configure the number of parallel threads equal to the CPU Cores. <p><i>–XX:ParallelGCThreads = [number of CPU Cores]</i> <p>For example, if there are two Dual-Core Processors you will have a setting of 4 threads. If there are using 4 Dual-Core Processors or 2 Quad-Core processors you will have a setting of 8 threads. <p>On medium to large multiprocessor machines don't set the number of GC threads to be the same as the CPU Cores (there are diminishing returns). This is the formula to do the thread configuration for machines with more than 8 CPU Cores. <p><i>–XX:ParallelGCThreads = 8 + (([number of CPU Cores] – 8) * 5)/8 </i> <p>You get 1 parallel GC thread per CPU Core for up to 8 CPU Cores. With more CPU Cores the formula reduces the number of threads. For example for 16 CPU Cores you get: 8+((16-8)*5)/8 = 13 GC threads. <p>The number of threads for the CMS process is dependent on the number of the threads for the parallel GC. <p><i>-XX:ConcGCThreads = ([number of ParallelGCThreads] + 3) / 4</i> <p>But be rather conservative and not too aggressive with the thread setting especially when you are doing vertical clustering. In a virtual environment the calculation is based on the number of CPU Cores assigned to the Guest OS. <p>Also be aware that CMS leads over the time to some Heap fragmentation which will cause the JVM to switch to a Mark-and-Compact collector. A mix of both small and large objects would fragment the Heap sooner. The JVM needs to find a block of contiguous space for the size of the object and this will slow down the JVM. There is a JVM parameter that could be used to detect fragmentation (-XX:PrintFLSStatistics=2) but it slows down the GC significant. Consider that most likely a SOA Suite Batch Domain has to handle larger objects than an Online Application Processing Domain. <p>The new Garbage-First (G1) Garbage Collector (testable since Java SE 6 update 14 Early Access Package and officially available since Java SE 7 Update 4) will be the long-term replacement for CMS and targets medium to large multiprocessor machines and large Heap sizes. Unlike CMS, G1 compacts to battle fragmentation and to achieve more-consistent long-term operation. But the first Weblogic Server version which supports JDK 7 is 12c. <p>When you do the JVM sizing you should know how large the JVM Heap sections are and when GC is triggered. Only with this knowledge you could do meaningful sizing and react on the number given by the GC log files. <p>These formulas are helpful to calculate the JVM Heap memory sizes: <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="198"> <p><b>Space</b></p></td> <td valign="top" width="600"> <p><b>Calculation</b></p></td></tr> <tr> <td valign="top" width="198"> <p>Eden Space</p></td> <td valign="top" width="600"> <p>NewSize – ((NewSize / (SurvivorRatio +2)) * 2)</p></td></tr> <tr> <td valign="top" width="198"> <p>Survivor Space (To)</p></td> <td valign="top" width="600"> <p>(NewSize – Eden) / 2</p></td></tr> <tr> <td valign="top" width="198"> <p>Survivor Space (From)</p></td> <td valign="top" width="600"> <p>(NewSize – Eden) / 2</p></td></tr> <tr> <td valign="top" width="198"> <p>Tenured Space</p></td> <td valign="top" width="600"> <p>HeapSize – Young Generation</p></td></tr></tbody></table> <p>These formulas give you the real sizes of the generational JVM spaces. The Survivor Spaces serves as the destination of the next copying collection of any living objects in Eden Space and the other Survivor Space. Keep in mind that one Survivor Space is empty at any given time. Now it’s on you to monitor the GC behavior, do the right GC scheme setting, to calculate the optimized heap sizes and number of threads, doing the best non-heap size settings. <p>Let me show you an example on how successful GC optimization could improve your overall performance on SOA Suite Services running at a Weblogic Domain with two Managed Servers (SOA Suite 11g PS4, WLS 10.3.5, JDK 1.6.0_27 running on Solaris). <p>The story started with a default ParallelGC scheme setting (default GC values for JDK 6: -XX:+UseParallelGC, ParallelGCThreads=#CPU, SurvivorRatio=32, PermSize=64m, no GC logging) and a JVM heap size of 4 GB. <p><i>-server –Xms4g –Xmx4g –Xss512k -XX:PermSize=768m -XX:MaxPermSize=768m –verbose:gc –XX:+PrintGCDetails –XX:+PrintGCTimeStamps – Xloggc:/gc.out</i> <p>The initial 4 GB JVM Heap size setting was discussed with Oracle and the Permanent Space setting is coming from first observation. The 64bit JDK6 stack size on Solaris is 1024k. We reduced the thread stack size on 512k. <p>After running some HP LoadRunner Average Load Tests, the HP JMeter GC STW diagram was showing GC STW activities between 23 and 35 seconds. <p><a href="http://lh5.ggpht.com/-hzMr6lYEaMU/UKTGsZyfX9I/AAAAAAAAAPM/NHc5iGWyUNo/s1600-h/clip_image004%25255B8%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgbRu1uBgxtOvW-E31p2_OO3jJaRU66yux0IGos0a-3-Wfectz2KCvh6CG9jpXcx_8tx32U9A3RRMW3prTKJRI0x00uVHmp_OdTKMhrjJgaUiDxcwRGFWJRa436NpcanO-pJptso2BxyhA/?imgmax=800" width="512" height="308"></a> <p>This was unacceptable for an Online Processing Domain where a user is waiting for response. SCA Services shouldn’t be blocked by 35 seconds freezing the execution. In order to optimize for minimal pause time the GC scheme changed on CMS (<i>–XX:+UseConcMarkSweepGC</i>). <p><i>-server –Xms4g –Xmx4g –Xmn2g –Xss512k –XX:PermSize=768m –XX:MaxPermSize=768m –XX:+UseConcMarkSweepGC –XX+UseParNewGC –XX:+CMSParallelRemarkEnabled – XX:+UseCMSInitiatingOccupancyOnly –XX:CMSInitiatingOccupancyFraction=55 –XX:+CMS ClassUnloadingEnabled –XX:ParallelGCThreads=8 –XX:SurvivorRatio=4 –verbose:gc –XX:+PrintGCDetails –XX:+PrintGCTimeStamps – Xloggc:/gc.out </i> <p>The <i>-Xmn2g</i> setting configures the Young Generation Heap size. A parallel Young Generation collector (<i>–XX+UseParNewGC</i>) is best used with the CMS low pause collector that collects the Tenured Space. The <i>–XX:+CMSParallelRemarkEnabled </i>setting enables multiple parallel threads to participate in the remark phase of CMS. Since this is a STW phase, performance is improved if the collector uses multiple CPU Cores while collecting the Tenured Space. The <i>–XX:CMSInitiatingOccupancyFraction</i> setting on 55 means that CMS GC starts at 55% memory allocation (default is 68%). The <i>– XX:+UseCMSInitiatingOccupancyOnly </i>setting forces CMS to accept the<i> –XX:CMSInitiatingOccupancyFraction </i>setting and not starting the CMS collection before the threshold is reached (disables internal JVM heuristics, without this setting the JVM may not obey CMS initiating occupancy fraction setting). The <i>-XX:+CMSClassUnloadingEnabled</i> setting activates the class unloading option. It helps to decrease the probability of “Java.lang.OutOfMemoryError: PermGen space” errors. <p>Here is the calculation on the JVM Heap memory size with the given parameter. <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="124"> <p><b>Space</b></p></td> <td valign="top" width="400"> <p><b>Calculation</b></p></td> <td valign="top" width="146"> <p><b>MB</b></p></td> <td valign="top" width="128"> <p><b>KB</b></p></td></tr> <tr> <td valign="top" width="124"> <p>Eden Space</p></td> <td valign="top" width="400"> <p>2048m – ((2048m / (4 +2)) * 2)</p></td> <td valign="top" width="146"> <p>1365.3</p></td> <td valign="top" width="128"> <p>1398101.33</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (To)</p></td> <td valign="top" width="400"> <p>(2048m – 1365.3m) / 2</p></td> <td valign="top" width="146"> <p>341.35</p></td> <td valign="top" width="128"> <p>349525.335</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (From)</p></td> <td valign="top" width="400"> <p>(2048m – 1365.33m) / 2</p></td> <td valign="top" width="146"> <p>341.35</p></td> <td valign="top" width="128"> <p>349525.335</p></td></tr> <tr> <td valign="top" width="124"> <p>Tenured Space</p></td> <td valign="top" width="400"> <p>4096m – 2048m</p></td> <td valign="top" width="146"> <p>2048</p></td> <td valign="top" width="128"> <p>2097152</p></td></tr></tbody></table> <p>So the Tenured Space (Old Generation) cleanup starts at a filling size of 1153433.6 KB (1126.4 MB). <p>Further average and performance load tests reported that the GC STW activities went down on a maximum of around 10 seconds for most CMS GC STW, but 10 seconds are still too long and STW activities happened much too often. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkfEYKfMWCOET72EslnyFlmvNvXwMaY7rO2gNzNP3Yv9Esjkn_Olrmaxb_bc9962nwUumkwChfKjm9k2LIpGlyfSLBDE1XqtSoCVYPqS8W_AwU4cwT5lJmCARIAWmXNb7awtzoa_hyf9uZ/s1600-h/clip_image006%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://lh6.ggpht.com/-DugQqU_cAJk/UKTGyYOAKHI/AAAAAAAAAPk/KeZK0-K403E/clip_image006_thumb%25255B1%25255D.jpg?imgmax=800" width="517" height="289"></a> <p>We analyzed the GC logs which reported Concurrent Mode Failures like the following GC entry. <p><i>238276.333: [GC 238276.334: [ParNew: 1709331K->1709331K(1747648K), 0.0001286 secs]238276.334: [CMS238276.640: [CMS-concurrent-mark: 13.637/14.048 secs]</i> <p><i>(concurrent mode failure): 1663134K->1619082K(2097152K), 53.1504117 secs] 3372466K->1619082K(3844800K)</i> <p>Concurrent Mode Failure means that a requested ParNew collection didn’t run because GC perceives that the CMS collector will fail to free up enough memory space in time from Tenured Space. Therefore worst case surviving Young Generation objects couldn’t be promoted to the Tenured Space. Due it this fact, the concurrent mode of CMS is interrupted and a time-consuming Mark-Sweep-Compact Full GC STW is invoked. <p>On GC log file entry mentioned above the ParNew request happens at JVM Clock Time 238276.333 whereas the Young Generation had a fill level of 1709331 KB (1669.27 MB) out of 1747648 KB (1706,69 MB). This means a filling level of 97.8% out of 1747648 KB (rounded: 1706 MB = 1365 MB Eden Space + 341 MB One Survivor Space). The GC STW happens at Clock Time 238276.334 and took 53.15 seconds. The Tenured Space occupancy dropped from 1663134 KB (1624 MB) to 1619082 KB (1581 MB). This means that 97.5% of all objects survived the Tenured Space clean-up. Only 43 MB of the Tenured Space is getting freed. <p>So the Young Generation had around 1669 MB before GC which could only free 43 MB on the Old Generation. The Tenured Space seems not big enough to keep all the promoted objects. There is an Oracle recommendation when changing from a Parallel GC scheme to a Concurrent GC scheme. Oracle recommends increasing the Tenured Space by at least 20% to 30% in order to accommodate fragmentation. <p>We decided to keep the overall JVM Heap size stable and instead to decrease the Young Generation in order to give the Old Generation more space (<i>-Xmn2g</i> to <i>– Xmn1g</i>). <p><i>-server –Xms4g –Xmx4g –Xmn1g –Xss512k –XX:PermSize=768m –XX:MaxPermSize=768m –XX:+UseConcMarkSweepGC –XX+UseParNewGC –XX:+CMSParallelRemarkEnabled – XX:+UseCMSInitiatingOccupancyOnly –XX:CMSInitiatingOccupancyFraction=55 –XX:+CMS ClassUnloadingEnabled –XX:ParallelGCThreads=8 –XX:SurvivorRatio=4 –verbose:gc –XX:+PrintGCDetails –XX:+PrintGCTimeStamps – Xloggc:/gc.out</i> <p>Here is the new calculation on the JVM Heap memory size after changing Young Generation on 1 GB. <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="124"> <p><b>Space</b></p></td> <td valign="top" width="400"> <p><b>Calculation</b></p></td> <td valign="top" width="146"> <p><b>MB</b></p></td> <td valign="top" width="128"> <p><b>KB</b></p></td></tr> <tr> <td valign="top" width="124"> <p>Eden Space</p></td> <td valign="top" width="400"> <p>1024m – ((1024m / (4 +2)) * 2)</p></td> <td valign="top" width="146"> <p>682.66</p></td> <td valign="top" width="128"> <p>699050.66</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (To)</p></td> <td valign="top" width="400"> <p>(1024m – 682.66m) / 2</p></td> <td valign="top" width="146"> <p>170,67</p></td> <td valign="top" width="128"> <p>174766.08</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (From)</p></td> <td valign="top" width="400"> <p>(1024m – 682.66m) / 2</p></td> <td valign="top" width="146"> <p>170,67</p></td> <td valign="top" width="128"> <p>174766.08</p></td></tr> <tr> <td valign="top" width="124"> <p>Tenured Space</p></td> <td valign="top" width="400"> <p>4096m – 1024m</p></td> <td valign="top" width="146"> <p>3072</p></td> <td valign="top" width="128"> <p>3145728</p></td></tr></tbody></table> <p>Afterwards we triggered a new Average Load Test. The GC STW activities went down to a maximum of 4.3 seconds, but much more important is the fact that GC STW significantly less frequently happens. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis-VAVt6abISZ9kmLmu2lNgBrTsTijAHEufboFqnzpQSeWc3aZ0BnxLOJTYJfi5L9r12rdSTDQrug8qfq0P4GXTP3QWd_fI3RyjPot_aD77z9S3PE_7KbuXivylFcwUIDuJtqAjV1NJn-l/s1600-h/clip_image008%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHrfVo7ke3fsm2UM6MyvwMEmFzlc8T83VfdPtAWbh48MGpeoTxIMFFjOpZ1kkYvPUu1ucWp8RSsw4CKnW7ii-KbExACsH92xdhrgkLdsAgmj2P5DQtn1-DFBhghnEVpPdFqAnWlqtadmjY/?imgmax=800" width="520" height="292"></a> <p>This was good for the Average Load Tests, but a Peak Performance Test was showing an accumulation of CMS GC STW activities during the Performance Test (around Clock Time 200000). <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCB6tYAC3VgtSwAxZZI2vaELl8Efe0nBlZCTAeo2UIk9unqAp4G-PUQwrqOi5ZSMxamfLQo8ru0QudGes7ZCeWhMHspok2vPVSGQrpFq99tRhZrx_xMNCu-diYpnvMU6hL_vny2n91VCEO/s1600-h/clip_image010%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://lh4.ggpht.com/-79CxHiy4Jj8/UKTG5OZjZrI/AAAAAAAAAQE/HFpR8vlxWRY/clip_image010_thumb%25255B1%25255D.jpg?imgmax=800" width="524" height="295"></a> <p>We decided to do a resizing and slightly increased Young Generation (from <i>–Xmn1g </i>to <i>–Xmn1280m</i>) in order to allow objects to be held longer in Young Generation with the hope that they will be collected there and are not promoted to Old Generation. As mentioned by Oracle Doc ID 748473.1, most of the BPEL engine’s objects are short lived. Therefore the Young Generation shouldn’t be too small. <p>The Survivor Spaces allow the JVM to copy live objects back and forth between the two spaces for up to 15 times to give them a chance to die young. The <i>–XX:MaxTenuringThreshold</i> setting governs how many times the objects are copied between the Survivor Spaces (the default value is 15 for the parallel collector and is 4 for CMS). Afterwards the objects are old enough to be tenured (copied to the Tenured Space). So we increased also the Survivor Spaces (from <i>–XX:SurvivorRatio=4</i> to <i>–XX:SurvivorRatio=3</i>, see calculation below). Additionally we increase the <i>–XX:CMSInitiatingOccupancyFraction</i> setting on 80% in order to make use of the large Old Generation capacity. <p><i>-server –Xms4g –xmx4g –Xmn1280m –Xss512k –XX:PermSize=768m –XX:MaxPermSize=768m –XX:+UseConcMarkSweepGC –XX+UseParNewGC –XX:+CMSParallelRemarkEnabled – XX:+UseCMSInitiatingOccupancyOnly –XX:CMSInitiatingOccupancyFraction=80 –XX:+CMS ClassUnloadingEnabled –XX:ParallelGCThreads=8 –XX:SurvivorRatio=3 –verbose:gc –XX:+PrintGCDetails –XX:+PrintGCTimeStamps – Xloggc:/gc.out</i> <p>This means the following new JVM Heap sizes: <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="124"> <p><b>Space</b></p></td> <td valign="top" width="400"> <p><b>Calculation</b></p></td> <td valign="top" width="146"> <p><b>MB</b></p></td> <td valign="top" width="128"> <p><b>KB</b></p></td></tr> <tr> <td valign="top" width="124"> <p>Eden Space</p></td> <td valign="top" width="400"> <p>1280m – ((1280m / (3 +2)) * 2)</p></td> <td valign="top" width="146"> <p>768</p></td> <td valign="top" width="128"> <p>786432</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (To)</p></td> <td valign="top" width="400"> <p>(1280m – 768m) / 2</p></td> <td valign="top" width="146"> <p>256</p></td> <td valign="top" width="128"> <p>262144</p></td></tr> <tr> <td valign="top" width="124"> <p>Survivor Space (From)</p></td> <td valign="top" width="400"> <p>(1280m – 768m) / 2</p></td> <td valign="top" width="146"> <p>256</p></td> <td valign="top" width="128"> <p>262144</p></td></tr> <tr> <td valign="top" width="124"> <p>Tenured Space</p></td> <td valign="top" width="400"> <p>4096m – 1280m</p></td> <td valign="top" width="146"> <p>2816</p></td> <td valign="top" width="128"> <p>2883584</p></td></tr></tbody></table> <p>Now the Old Generation cleanup starts at a filling size of 2252.8 MB. Take a look at the following GC STW diagram which confirms the GC tuning effort. The diagram reports a well-tuned JVM with relatively large number of short Parallel Scavenges with less frequent, but more expensive, full CMS GC. <p><a href="http://lh6.ggpht.com/-dKoKQm3ouJs/UKTG6-vGhGI/AAAAAAAAAQM/prBjmtOBcVQ/s1600-h/clip_image012%25255B4%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://lh4.ggpht.com/-GDXbA7shKmU/UKTG83S4gxI/AAAAAAAAAQU/ja7URP_ylp8/clip_image012_thumb%25255B1%25255D.jpg?imgmax=800" width="524" height="295"></a> <p>More GC fine tuning and better GC behavior is for sure possible. But we are quite satisfied with the reached performance results. The SCA Services have much better response times on Average and Peak Performance Tests. <p>Finally you have to keep a closer eye on the Code Cache of the JVMs running your Weblogic Servers with SOA Suite. It has nothing to do with GC, but here is the explanation why it’s important. As you all know, Java code is getting compiled to bytecode for the JVM. Bytecode has to be converted to native instructions and library calls for the target platform. The interpreted mode always converts bytecode “as it used” which slows down the execution performance. Whereas the Just-In-Time (JIT) compilation keeps preparative compiled code segments (performance-critical “Hotspots”) in a Code Cache, the cached native compiled code is getting reused later without needing to be recompiled (for example in loops). That’s the reason why the JVM over time obtain near-native execution speed after the code has been run a few times. <p>So it’s performance critical when you have warnings like … <p>Java HotSpot(TM) Client VM warning: CodeCache is full. Compiler has been disabled. <p>Java HotSpot(TM) Client VM warning: Try increasing the code cache size using -XXReservedCodeCacheSize= <p>You can imagine how bad it would be if JIT’ing is switched off because the Code Cache is getting full (default Code Cache size with <i>–server</i> option and 64bit is 48 MB). The Non-Heap Code Cache is allocated during JVM startup and, once allocated, it cannot grow or shrink. Fortunately the Code Cache size could be changed with the <i>-XX:ReservedCodeCacheSize</i> setting. But increasing the Code Cache size will only delay its inevitable overflow. Therefore is more important to avoid the performance breaking interpreted-only mode. The <i>-XX:+UseCodeCacheFlushing</i> setting enables the compiler thread to cycle (optimize, throw away, optimize, throw away), that’s much better than disabled compilation. So if you see that Code Cache warning I would recommend to slightly increase the Code Cache size and to enable Code Cache Flushing. The <i>–XX:+PrintCompilation</i> setting give you more details (or watch the Code Cache behavior on JConsole). <p>I just want to leave you with three more tips for your own JVM GC tuning. There is a JVM setting <i>-XX:+PrintFlagsFinal</i> which will show you all JVM settings during the startup phase. Second tip is a suppression of programmatic caused Full GC STW by using the <i>System.gc()</i> and <i>Runtime.getRuntime().gc()</i> methods. The <i>-XX:+DisableExplicitGC</i> setting will ignore these method calls which are undermines the GC tuning efforts. Take a look for “Full GC (System)” entries on your GC log files. Third tip is to take a look at the <a href="http://www.spec.org">Standard Performance Evaluation Corporation</a> and how they configure the JVM for Weblogic in order to get best performance (move on the <a href="http://www.spec.org/osg/jEnterprise2010/results/jEnterprise2010.html">result page</a>, look for a Weblogic test on our platform and take a look on the JVM settings at the Notes/Tuning Information section).</p> Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com3tag:blogger.com,1999:blog-1817587040967009465.post-52730793093400945052012-08-28T10:55:00.001+02:002022-05-17T08:08:42.659+02:00SOA Suite Performance – Don’t fight against the machine - Part 1Performance optimization on SOA Suite applications is a challenge! After about one and a half years of performance tuning activities on a large SOA Suite project I’m fully confident to make such an assertion. Why is it so difficult to tune the performance, because the performance is depended on several system architecture layers. <br />
<br />
<a href="http://lh3.ggpht.com/-ihP8bgp3UbA/UDyGkCdKrGI/AAAAAAAAAOk/XQ1gdgRkV_U/s1600-h/SOA%252520Suite%252520Layers%25255B1%25255D.png"><img alt="SOA Suite Layers" border="0" height="427" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis-zEa_bqqHK1ltejYrJEWyV7MI_rlS3I59aXvntzZ8IcfY1OMzZ4H9XBwKfQip2z2Y92gwkBeWepF-Z9c5CaPpjgvn52zBV2vIuVaoxDOH19BqrHFLEhyphenhyphenlM_JdZVz4MQRmsDvHX0NEbIH/?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="SOA Suite Layers" width="250" /></a> <br />
On top of the stack JDeveloper developed applications/services running on the SCA Container. Design and configuration on SCA Composite and SCA Component level have a critical influence on the success of performance optimization activities. Below the SCA Application layer we have the FMW Common Infrastructure (e.g., JRF, OWSM, EM Fusion Control) together with the SOA Suite Service Engines (e.g. BPEL, Mediator) as SCA Runtime environment SOA Infra. There are many performance relevant tweaks you could do on the SOA Infra layer. The Oracle Weblogic Application Server is the foundation on which all Java EE-based Oracle FMW components are build. Classic techniques on JEE performance optimization are used together with the possible utilization of the Coherence Data Grid. JVM optimization is also well known but its performance essential to have the right GC strategy with the right parameterization. Below the JVM we will have the layer with the Operating System which could run on a Hypervisor. Both are highly critical on resource allocation and therefore important on performance tuning activities. As an Application Architect you have to trust the Infrastructure Experts doing their best on performance tuning because in most cases you are leaving your knowledge domain. <br />
<br />
Down below you have the machine hardware with network and storage. Here you will find your “physical” limitations. The machine is coming with a certain numbers of CPU/cores, clock speed and the size of the internal memory cache of the system CPU(s). You will have a certain speed and width of the system’s address and data buses. And you will be limited by the amount of memory, the width of its data path and the memory access time which causes the CPU(s) to wait for memory. And you will be highly depended on the speed of the I/O devices such as network and disk controllers. <br />
<br />
These hardware factors have the greatest influence on the application performance. For example, Oracle SOA Suite architectures will have CPU-intensive operations happening in a single thread for components like rule evaluation and XML processing. Therefore the CPU clock speed is an important factor to consider. There will come a time during your performance optimization activities when, despite all tuning activities on the upper architecture system layers, you have to add more powerful hardware or upgrade the existing hardware. If you miss the right time to scale up and to scale out, the application architecture will become out of balance on the non-functional system qualities by focusing too much on the performance aspect on the SCA application layer. And because you have the design freedom ugly compromise are make for reaching the right performance. Clearness and comprehensibility of the architecture, extensibility, reusability and maintainability are system qualities which will suffer as a result. System architects are also talking of increasing system entropy (disorder). Furthermore the relationship on costs of the performance tuning activities and the purchase of hardware is at a certain point of time no longer reasonable. <br />
<br />
When you start to reduce your SCA Composite modularization on performance reasons, when you realize that your BPEL processes are getting monolithic and you are doing <a href="http://suchier.blogspot.com/2011/09/oracle-soa-suite-bpelmania-bpel-vs.html">BPEL programming in small</a>, when you don’t mediate on inbound and outbound interfaces because of performance reasons you will have on indicator that it’s time to scale up and to scale out. <br />
<br />
<u>Note:</u> Don’t fight for last possible amount of performance on the SCA application layer. You should realize when the right time has come to throw in the towel. Don’t be naïve and believe that all performance problems could be solved on the layers above the machine. <br />
<br />
If you have online and batch processing you should also consider to have an own Weblogic Cluster running SOA Suite for online processing and an own Weblogic cluster for batch processing. This is an important consideration because the configuration on the layers will differ between an online and batch related configuration. That’s something we will examine on the next blog when we take a detailed look on the JVM. <br />
<br />
<br />
<br />
<br />
<br />
<br />Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com2tag:blogger.com,1999:blog-1817587040967009465.post-80380424233839512612011-09-06T10:52:00.001+02:002022-05-17T08:08:56.270+02:00Oracle SOA Suite: BPELmania (BPEL vs. Spring Beans vs. Mediator)<i>The current Oracle SOA Suite 11g PS4 (11.1.1.5) offers several SCA Component types for service implementation (BPEL, Human Task, Spring Context, Business Rule and Mediator). All these different SCA Component types raises the question what component to use in which context. Quite clear is the usage scenario of the Human Task and Business Rule Components. But the BPEL, Spring Context and Mediator Components have overlapping functionality. Too often an implementation based on BPEL Components is chosen instead of weighing against the other two available SCA implementation types. This fact is probably explicable form the history of the Oracle SOA Suite where version 10g only offered BPEL. Whereas Spring Context and Mediator Components are introduced starting with 11g and the SCA concept. </i><br />
<i> </i> <br />
<i>Let’s do a short introduction of the three SCA component types and weigh the pros and cons. </i><br />
<i> </i> <br />
<b>BPEL</b> <br />
BPEL (Business Process Execution Language) is an OASIS standardized orchestration and executable language for specifying actions within business processes. BPEL constructs and execute workflows by assembling discrete services into a complete process flow. Beside the standardized basic and structured activities to define BPEL processes, in addition Oracle also defines several extension (proprietary) activity types.<br />
<br />
BPEL describes processes on a true business process level (future wise covered by executable BPMN coming with the Oracle BPM Suite on top of the Oracle SOA Suite). And the graphical representation makes processes tangible for business users.<br />
<br />
In general I agree with the <a href="http://en.wikipedia.org/wiki/Business_Process_Execution_Language">Wikipedia description</a> that BPEL aims to enable “programming in the large”. But there is the potential danger that inexperienced SOA designer/developer use BPEL components for all kind of service implementation on the Oracle platform (especially the “Java Embedding” activity opens the door on ill-considered implementations). BPEL's control structures such as “if-then-else”, “while” and “repeat until” as well as its variable manipulation facilities together with the Oracle enhancements tends Oracle BPEL to become a “programming in the small” language.<br />
<br />
<b>Spring Beans</b> <br />
The Spring Framework is a popular application framework on the Java platform. It aims to reduce the complexity of the programming environment based on the four key concepts of focusing on POJO (Plain Old Java Objects), Dependency Injection (DI), AOP (Aspect-Oriented Programming) and the simplified API Abstraction.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy4bBZo-C2lIiMjRVHZAbbKIifR4aFXASt8e3r0_fTBsBE-SQLrMNMQRysKFyBJSB71HWTbq6TWCwQLMcqfZBn8xBeVVW7hLLANoBX5umo5xrAWD3t6XD1UEOZE_yDtSi4OyTeRD7sY1s3/s1600-h/image%25255B3%25255D.png"><img alt="image" border="0" height="236" src="http://lh5.ggpht.com/-J1B2qZ_PHn8/TmXaaFy75VI/AAAAAAAAAOI/u6cdrOCPYF8/image_thumb%25255B1%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="240" /></a> <br />
<br />
Normal Java Objects (POJO) is at the center of the Spring Framework. POJOs are cross-linked by Dependency Injection (bean dependencies on other objects are not hard-coded, instead object references described as bean properties on a XML context configuration file are injected by setter methods). POJOs will be supplemented in a non-intrusive way with cross-cutting aspects by using AOP (aspects like logging, monitoring, security, transactions). And finally POJOs communicate with other APIs via the simplified API abstraction (like JDBC, JMS, EJB, Quartz, etc.).<br />
<br />
The <a href="http://www.osoa.org/download/attachments/35/SCA_SpringComponentImplementationSpecification-V100.pdf?version=1">SCA Spring Component Implementation Specification</a> specifies how the Spring Framework can be used as a component implementation technology in SCA. Since <a href="http://www.oracle.com/technetwork/middleware/soasuite/soa-11gr1-ps2-new-features-097680.html">Oracle SOA Suite 11g Patch Set 2</a> it is possible to have Spring Beans as part of the <a href="http://www.springsource.org/about">Spring Framework</a> on the Oracle SCA Container as first-class citizen (use Spring Beans like any other SCA Component). Spring Beans makes it possible to run Java implemented services on the Oracle SCA Container.<br />
<br />
Compared with BPEL Components the intensive<b> </b>usage of Spring Beans entails<b> </b>risk the other way round. People with a strong JEE or Spring Framework development past will tend to use Spring Beans for all kind of implementations even for the “programming in large” concerns. Especially the possibility to use the matured and out-of-the-box available JCA Technology Adapter is often pushed into the background. Developers really don't have to keeping re-inventing the wheel.<br />
<br />
<b>Mediator</b> <br />
As the name suggests the Mediator Component is about intra-composite mediation between various SOA Suite Components. The Mediator brings Enterprise Service Bus (ESB) aspects inside of the SCA Composite. The main task is to route data and sequencing messages between consumers and producers. Defined routing rules could filter, transform and validate data. Additionally the Mediator Component could act as an “echo” service component. Which means that the Mediator is echoing directly back to the initial caller after transformation, validation or enrichment activities. Together with so-called Mediator Java Callout Handler which enables “pure” Java based message manipulation the Mediator starts to compete with BPEL and Spring Beans.<br />
<br />
<b>BPELmania – don’t forget the “evil” side of BPEL</b> <br />
It is somewhat similar with the famous Hammer-Nail quote from Abraham Maslow (“If you only have a hammer, you tend to see every problem as a nail.”). For some people BPEL is the hammer with the purpose to implement every service exclusively with BPEL (using BPEL as “glue”, not as programming language). The right approach is to weigh pros and cons of BPEL, Spring Beans and Mediator in a certain usage scenario. <br />
The BPEL main major advantages are the graphical business process visibility, the flexibility for quick process changes and the support for long running business processes.<br />
<br />
Business processes can run for several minutes, hours or days (or even longer). With pure Java it’s cumbersome to handle long running processes. It makes the application complex and complicated for the developers to maintain the process.<br />
<br />
BPEL also supports compensation in a relatively easy way. Compensation, or undoing non-transactional steps in the business process that have already completed successfully, is one of the most important concepts in business processes. The goal of compensation is to reverse the effects of previous activities that have been carried out as part of a business process that is being abandoned.<br />
<br />
Business processes may also have to react on certain events. Such events can be message events or alarm events. Message events are triggered by incoming messages through operation invocation on port types (onMessage Event Processing). Alarm events are time related and are triggered either after a certain duration or at a specific time (onAlarm Event Processing). Oracle BPEL provides good support for managing events in business processes.<br />
<br />
Another advantage of BPEL is the portability. BPEL can be executed on other process engines running on different vendor platforms. The prerequisite however is that the BPEL process is only using standardized basic and structured activities.<br />
<br />
List of BPEL advantages (on the Oracle SOA platform) <br />
<ul><li>Graphical business process visibility</li>
<li>Flexibility for quick process changes</li>
<li>Support for long running business processes</li>
<li>Business compensation handler (“UNDO”)</li>
<li>Oracle’s good integration of Human Workflow (Human Task Components)</li>
<li>Oracle’s good integration of the Business Rules Engine (Business Rule Components)</li>
<li>Support of events and EDN (Event Delivery Network)</li>
<li>Portability to other standard-based process engines (if obeying the BPEL standards)</li>
<li>Support of synchronous, asynchronous and one-way (asynchronous) process interaction with the caller</li>
</ul>It’s obvious that BPEL has been designed to address the requirements of defining business processes. But a BPEL process will cause definitely more load on the application server and the database, because of the BPEL process engine overhead causing a lot of transactions on the SOA/MDS database. It’s possible to minimize the additional load but it’s a complex endeavor. Developers have to deal with dehydration (storing the current status of the BPEL process into the database is known as dehydration), delivery service configuration for incoming messages, audit tracking configuration, the configuration of the completion persist policy, etc.<br />
<br />
Additionally Oracle BPEL could handle technical transaction but proper transactional behavior demands deep understanding of the platform behavior (transaction property configuration and dehydration causing activities which causes transaction commits).<br />
<br />
Dealing with BPEL variables will require knowledge of XPath and XSLT for transformations. XSLT transformations will cause slowing-down because of Oracle XSLT processor calls. But one of the major weaknesses is the memory consumption caused by XML BPEL variables kept in memory as DOM class (Document Object Model). A DOM class is an in-memory representation of an entire document and the complete infoset state for an XML document. In memory DOM-tree provide good flexibility for developers, but the cost of this flexibility is a potentially large memory footprint and significant processor requirements, as the entire representation of the document must be held in memory as objects for the duration of the document processing (acceptable for small documents , but memory and processor requirements can grow rapidly with document size).<br />
<br />
List of BPEL disadvantages (on the Oracle SOA platform) <br />
<ul><li>JDeveloper provides no BPEL debugging features </li>
<li>JDeveloper provides no BPEL refactoring support</li>
<li>BPEL process engine caused additional load (app server, DB)</li>
<li>Complex and non-transparent configuration for performance tuning</li>
<li>Complex and non-transparent configuration of technical transactions</li>
<li>Deep XPath and XSLT knowledge is needed (assign and transformation activities)</li>
<li>XSLT transformation performance overhead (overhead on Oracle XSLT processor calls)</li>
<li>Inapplicable for large XML document processing (because of memory and CPU consumption)</li>
<li>Risk of using BPEL for doing “programming in small”</li>
<li>Oracle extension (proprietary) activity types make processes non-portable</li>
<li>Compared with Spring Beans or Mediator Components, a single BPEL Components offer “only” one service operation (it’s in the nature of BPEL)</li>
</ul>Alternatively, in case of a straight forward sequenced process without any control flow, the usage of Spring Beans or Mediator should be considered to achieve higher performance and throughput.<br />
<br />
<b>Spring Beans for “programming in the small”</b> <br />
Spring Beans complement the Oracle SCA Components rather than competing on BPEL Components. In fact they are in a strong competition on SLSB EJBs (Stateless Session Bean). Spring Beans and EJBs implement self-contained business services invoked by BPEL. But Spring Beans operate inside of SCA Composites running on the SCA Container whereas EJBs are outside of the SCA Container running on the EJB Container.<br />
<br />
The Spring Framework leads to flexibility and modularization of the design because smaller (Spring Beans) components can be easily wired to more complex components (Spring Bean to Spring Bean wiring), following the principles of the SCA composite framework. Spring focuses on “wiring in the small” in traditional applications. On the Oracle SCA Container Spring Beans could be “wired in the small” and “wired in the large”.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhBFg5pX4n6kNxQu6gNxEctfDC5OCTjLw3-vOgvTLEw9qihA-o2LUMTLtWRx0C-wrtNpuFixlqawzmLwNK58sVdYhidW5YP2LZ9eIHVoxDjCaHBvwfmulEg9jmQOvE1BpPYz94NFeIxFS4/s1600-h/image%25255B8%25255D.png"><img alt="image" border="0" height="183" src="http://lh3.ggpht.com/-OrFal5OoBGU/TmXagzHu7BI/AAAAAAAAAOQ/GkQUm36n1Mg/image_thumb%25255B4%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="497" /></a> <br />
<br />
EJBs could be used through the SCA EJB Adapter (placed on the external references swim lane), but direct EJB to EJB wiring couldn’t happen on a SCA composite which blocks the architectural modularization concept. Additionally, EJBs could not leverage the Oracle SCA Adapter Framework (for example make use of the DB Adapter or File Adapter) which leads to additional development efforts.<br />
<br />
It is even possible to give Spring Bean implemented SCA Services an EJB interface (binding.ejb) in case that services have to interoperate with an EJB application landscape.<br />
<br />
One principal reason for the usage of Spring Beans instead of EJBs is SCA’s way to wrap Spring Beans with other SCA Components into one SCA Composite in order to have only one single deployment unit and artifact of versioning (the SCA Service Archive, SAR). This SAR can be versioned as one, deployed as one, tested as one and managed as one instead of worrying about individual pieces. Finally already before the SCA era started Spring Beans become very popular in the Java Community as an alternative and replacement of EJBs (perceived as too heavy-weighted and complex with a lot of unnecessary boilerplate overhead).<br />
<br />
An important advantage is the usage of Spring Beans in complex scenarios because Spring Beans could be easily debugged (not possible with BPEL or Mediator Components) and service mocking could happen in a declarative manner (on the context configuration file).<br />
<br />
Despite the completeness and maturity of the Oracle SOA platform, projects will run into a situation in which the Oracle SOA Suite cannot provide a solution. Spring Beans are working like a “Swiss army knife”. In other words, Spring Beans can provide the lever to code for patches in the Oracle SOA components. Spring Bean could help on certain scenarios like high performance requirements (on <PS5 make sure you have patch 12402061 or one of the following patches running) or non-working DB Adapter queries (like the range operator BETWEEN, multiple value operator IN on where conditions, dealing with XMLType columns or just very complex SQL commands).<br />
<br />
Spring Bean Advantages (on the Oracle SOA platform) <br />
<ul><li>Spring is SCA standardized </li>
<li>Easy debugging and testing (isolated testing and interface mocking)</li>
<li>Spring development is simple-n-short, on-point and easy to read (because of DI, AOP and especially because of the Simplified APIs)</li>
<li>High performance scenarios (“lean and mean”, no overhead like for example dehydration)</li>
<li>Enables easy Java logic reuse on custom-build and standard third-party libraries (packaged and deployed with the SCA Composite)</li>
<li>Flexibility and modularization by “wiring in small” and “wiring in large”</li>
<li>“Swiss army knife” of all missing platform features and necessary workarounds</li>
<li>Concept of “Pre-defined” and “global” Spring Beans (>=PS3) which provides out-of-the-box functionality and global spring context definitions</li>
<li>Compared with BPEL and Mediator, the Spring Bean Component is easy portable </li>
<li>Well integrated on the Oracle SCA environment (leverage SOA Suite build-in features)</li>
<li>Support of synchronous, asynchronous and one-way (asynchronous) Spring Bean interaction with the caller</li>
</ul>But because of the all-purpose aspects of Spring Beans there is a risk of non-consideration of BPEL components, Mediator components or already existing JCA Adapter. Using Spring Beans for “programming in large” and especially for long-running process coordination will be the wrong approach. Doing all kinds of “backend access layer” programming and disregard the existence of out-of-the-box JCA Adapter is a misunderstanding of the Oracle SOA platform offering. Developers need to resist the temptation of doing everything with Spring Bean components.<br />
<br />
Spring Bean disadvantages (on the Oracle SOA platform) <br />
<ul><li>No Audit Tracking information </li>
<li>Difficult to implement AOP aspects and Springs dynamic language support </li>
<li>Risk of using Spring Beans for doing “programming in large”</li>
<li>Risk of not using JCA Adapter for connectivity</li>
</ul><br />
<b>Mediator as “jack-of-all-trades”</b> <br />
The Mediator is a “fallen” ESB (former ESB on the 10g platform), now working as an intra-composite component. This light-weight Service Bus mainly competes with the OSB, the Oracle Service Bus (former AquaLogic Service Bus on the BEA platform). The Mediator could be used as a “composite proxy” behind the exposed service interfaces. In reverse, the Mediator could be used as an “external reference proxy” for any external service invoked by a composite. But virtualization of services is also a main task of the OSB. <a href="http://www.amazon.de/Oracle-Soa-Suite-Developers-Guide/dp/1849680183/ref=sr_1_1?s=books-intl-de&ie=UTF8&qid=1314775231&sr=1-1">Antony Reynolds and Matt Wright</a> describe three basic approaches on the usage of Mediator and OSB in inter-composite application communication. <br />
<ul><li>Centralized topology (go always via OSB)</li>
<li>Peer-to-Peer topology (go directly via the service infrastructure- called Oracle Fabric)</li>
<li>Hybrid topology (combine both upper approaches)</li>
</ul>It’s almost impossible to recommend only one approach. It always depends on the requirements in a given project. All approaches have pros and cons but the Peer-to-Peer topology has same key advantages. <br />
<ul><li>All invocations are optimized, resulting in significant improved performance</li>
<li>Transactions are propagated in composite-to-composite calling scenarios</li>
<li>Complete audit trails across the whole composite calling chain</li>
</ul>Finally the OSB is adding an additional layer of complexity in combination with additional communication overhead. OSB could be used for example handling service security aspects, service throttling and service result set caching (internal implemented by Coherence). But it certainly makes sense to use the OSB in an enterprise application (for example ERP systems) calling scenario. These are applications in their own right. Little sense makes the usage of the OSB in a composite-to-composite calling scenario where one composite is calling a “private” composite for service implementation (running on the same SCA Container). Private composite means an internal used composite implementing an internal re-used entity or utility service.<br />
<br />
Mediator is powerful and could be used on several scenarios were designer/developer primarily think of using BPEL or Spring Beans. First of all the Mediator could replace efficiently BPEL Components in a simple straight forward orchestration use case. If simple service invocations have to happen in sequential or parallel the Mediator might be an alternative. Especially in “low” level invocations on the JCA Adapters like the Database Adapter (for example to implement an Entity Service).<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlKi6K1-sm5AJIpHtKa_5Rj5RlE1JFJziZv_oX68hxFXKmxPd4lWQehxw9jPGuBVrWE2efOZ04VuQf4ma-0QnZ-Bd4RRh-kZtdiDIMYi8wfIq4IeF8iS_H9SKB9fG9O8mnKRAKqmxgYWh5/s1600-h/image%25255B12%25255D.png"><img alt="image" border="0" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga9vntZmxpWPBs9X5WQpJZ3bldNR1EXOq4iuH2kkaxSH-bCMs88WhtqS6gw7eJ93otG3pmH7X7ThpCnOPGJJl2jK0BApEd4a0CpTzSANVkcSAlHIyx9JymeXjZW6D0scQXp7INb4HWLlya/?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="516" /></a> <br />
<b></b> <br />
The Mediator could execute the calls in sequence or in parallel (for example Insert DML commands on the DB Adapter). Whilst implementing the mediation enrichment pattern, the reply from one target service can be forwarded to another target service without going back to the original caller (<a href="http://www.amazon.com/Oracle-Suite-Handbook-Osborne-ORACLE/dp/0071608974">Lucas Jellema</a> calls it “small-time enrichment”).<br />
<br />
Beside the “normal” XML payload validation, the Mediator could also do more complex Schematron validations (for doing cross XML document validation). The Mediator implements the feature of echo services. This means the Mediator is directly going back to the requester without the need to route to another target service. The echo feature of the Mediator provides the opportunity to implement utility services for complex transformation or validation. Even more interesting is the Java Callout Handler, which can act as a kind of Java backdoor capability. Java callouts enable you to use external Java classes to manipulate messages flowing through the Oracle Mediator. At this point the Mediator strongly overlaps with Spring Bean functionality. For example the Mediator Component could implement a complex Java based transformation or validation as echo service (complex validation implementation overlaps on the other side with the Business Rules Component).<br />
<br />
Finally the Mediator is absolutely necessary in a SCA Composite design where several exposed service operations are implemented by BPEL Components. A BPEL Component could only offer one service interface.<br />
<br />
Mediator advantages (on the Oracle SOA platform) <br />
<ul><li>Resequence messages capability</li>
<li>Support of EDN (Event Delivery Network)</li>
<li>Mediator Asynchronous Messaging (synchronous to asynchronous)</li>
<li>Mediator supports Domain Value Maps <br />
(DVM helps significantly when utilizing Canonical Data Models)</li>
<li>Mediator provides the VETRO capabilities intra-composite <br />
(VETRO stands for Validate, Enrich, Transform, Route, Operate)</li>
<li>Echo Service feature (independent service implementation)</li>
<li>Java Callout Handler (door-opener to the powerful Java world)</li>
</ul>The Oracle Mediator is an Oracle proprietary SCA Component Implementation Type. Portability of BPEL (without using Oracle extension activities) and Spring Beans to a new SOA platform could be reached easily. There is no SCA standard on Mediator Components therefore it would require large rework on a platform move.<br />
<br />
Sometimes it’s necessary to handle SOAP Faults on Mediator Java Callouts. Without patching the system it’s not possible to handle proper SOAP Faults (<=PS4). Designer and Developer should be also aware that the parallel execution type will cause a new transaction. This fact is (hidden) on the documentation but could cause long trouble-shooting sessions.<br />
<br />
Mediator disadvantages (on the Oracle SOA platform) <br />
<ul><li>Mediator is a highly Oracle proprietary component</li>
<li>Mediator SOAP Fault Handling on Java Callouts (only with patch possible)</li>
<li>Mediator parallel execution type initiate (in-transparent) a new transaction</li>
<li>Deep XPath and XSLT knowledge is needed (assign and transformation)</li>
<li>XSLT transformation performance overhead (overhead on Oracle XSLT processor calls)</li>
</ul><br />
<b>Summary</b> <br />
Use the Oracle SCA Components as originally conceived. BPEL is not the answer on all design/implementation scenarios. Ugly “back door” Java implementation through BPEL Java Embedded Activities should be buried in the past. Future Java based service development on the SCA Container is not a matter of SLSB (Stateless Session Bean) EJB development. These concerns are clearly pointing on the usage of Spring Beans. The Mediator component is a light-weight intra-composite ESB, but in selected use cases also a valid alternative on BPEL or Spring Bean development.<br />
<br />
On an architecture layer diagram the BPEL Component is placed on the Business Process Layer. A BPEL Component could call multiple Sub-BPEL processes on the Business Process Layer. BPEL processes shouldn’t implement business services, they should orchestrate them. New Business Services on the SCA Container should be implemented by Spring Beans or Mediator Components as Echo Service (for sure, Human Task and Business Rules Components are also excellent candidates to implement business services). Reuse of existing Business Services implemented by SLSB EJB is possible via EJB Adapter or <a href="http://suchier.blogspot.com/2011/04/oracle-sca-spring-bean-talks-to-ejb.html">direct calls from Spring Beans</a>. The Mediator Component is used for intra-composite and composite-to-composite (using the peer-to-peer topology) routing scenarios.<br />
<br />
<a href="http://lh5.ggpht.com/-5Z_mJ71XC4Y/TmXamybYiwI/AAAAAAAAAOc/pYzfjOqDQFc/s1600-h/image%25255B16%25255D.png"><img alt="image" border="0" height="390" src="http://lh6.ggpht.com/-JU9o8nfHeIE/TmXapdZ_m2I/AAAAAAAAAOg/xz-yPZR5HpY/image_thumb%25255B8%25255D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="498" /></a> <br />
<br />
The diagram doesn’t contain Human Task and Business Rules Components. Also the OSB is left out in order to reduce complexity. Layer bridging by skipping the Business Process Layer is a real-world scenario. <br />
<br />
The Oracle SOA Suite offers a rich construction kit on SCA Components and several ways to use these components. It’s the task of the architects, designer and developers to use these components in the right way.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com10tag:blogger.com,1999:blog-1817587040967009465.post-8203412540510247422011-07-11T00:52:00.001+02:002022-05-17T08:09:12.618+02:00Oracle SCA Composites Visualized By MS Visio<p>An Oracle SCA Composite is described through an associated configuration file called <i>composite.xml</i>. This file uses a standardized XML-based format called the <i>Service Component Definition Language (SCDL</i>, commonly pronounced “skiddle”) to describe the artifacts this SCA Composite contains and specify how they relate to one another. The <i>composite.xml</i> mainly includes the SCA Components, exposed and external referenced services implemented via adapter and the wires between these artifacts. <p>The <i>composite.xml</i> file is rendered in JDeveloper with the Visual SCA Composite Editor. This editor works for development and offers a “drag & drop” way of SCA programming. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzhojfSgW9WugN_s2ZpDEql46VyFtBQzkijAIPpexVjMQHd_2a2vEDT8J3NbUz_8LRhtOistHgDgw8YJI1VraJ5qDLZM615QInxxqdU7Mg1ZKo13FlY8HkqA2jjrni1dlgBhS11Fep3zRt/s1600-h/clip_image001%25255B5%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://lh5.ggpht.com/-KMPJdw3Qkb8/ThotDHnWmXI/AAAAAAAAAN4/MD-5cNHeSKU/clip_image001_thumb%25255B2%25255D.png?imgmax=800" width="502" height="339"></a> <p>Unfortunately Oracle offers no image export feature on this editor. This feature could be similarly to the “Create JPEG Image …” feature on the BPEL Editor. An image export would be very helpful for the creation of documentation. Additionally it would be helpful to discuss a SCA Composite structure without starting always JDeveloper (or even to have JDeveloper on the disk). Composite screenshots are often do not capture the whole composite and keep only a section of the composite. It would be desirable if SCA Composites are zoomable on Composite Editor. This feature could be similarly to the “Zoom” slider on the BPEL Editor. <p>For all these reasons, I developed a “SCA to Visio” application. This application takes the <i>composite.xml</i>, parses the content and creates a MS Visio diagram. This diagram reflects the SCA Composite. The application uses ActiveX or COM automation components natively on the Windows COM and Win32 libraries. A COM Automation server controls Microsoft Visio which has to be installed on the same machine. I tested the “SCA2Visio” application with a JRE6 version on a Win7 system with Microsoft Visio Premium 2010. <p>The generated Visio diagrams could be printed, re-layouted, stored in several graphical formats, enriched with additional information and could be zoomed in and out. It’s ideal for any documentation and architectural discussion. Additionally it’s a good way to show Composite-to-Composite overview diagrams. <p>This diagram is an SCA2Visio example of the last Calculator application used on my <a href="http://suchier.blogspot.com/2011/05/oracle-sca-spring-bean-with-own.html">Spring Bean blog entry</a>. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGEGYSSXKmVcfaOj4jWNMCZq3GGg9GzJrfR3GXUIIBKSWyjL4E16v86co_dIyujU5s4cFKFFrkAHWmvzLGTSZQSZ8L3L2aex_BKWp9eaRetJD6YQ_EwXBxzEV9243ML46amyZEw7OFRrv_/s1600-h/clip_image003%25255B5%25255D.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image003" border="0" alt="clip_image003" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgROwFSaJC8IIV_z9K8LcN3OXhKKGZV2fTUUtqzkP86Ouj_9kwRUb2szHfqjkYnhkePkO3bKlC05KtUWPWB6GEEH8lNo5LMhhuvBpw1hUSZSiEVRcmLc3aFBExtR6aKNzQJFCq4Gfj5lNCR/?imgmax=800" width="361" height="388"></a> <p>Download of SCA2Visio application is available <a href="http://dl.dropbox.com/u/32501249/Blog/SCA2VisioV1.0.zip">here</a> (Zip, 5.73 MB). Try it! Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0tag:blogger.com,1999:blog-1817587040967009465.post-41281313204759200752011-06-06T01:20:00.002+02:002022-05-17T08:09:25.267+02:00Oracle SCA Spring Bean Transactional BehaviorMy last <a href="http://suchier.blogspot.com/2011/05/oracle-sca-spring-bean-with-own.html">blog</a> was about Oracle SCA Spring Beans with own database access instead of using the provided JCA DB Adapter. It’s always a tradeoff to use the Oracle JCA Database Adapter or to implement own database access by the means of the Spring Framework. The DB Adapter in combination with the JDeveloper configuration wizard is easy to use and enable DML SQLs like quick data retrieval. Behind the DB Adapter runs the JPA persistence framework Oracle Toplink and the application could benefit from Toplink (<a href="http://download.oracle.com/docs/cd/B25221_05/web.1013/b13593/uowund002.htm">Unit of Work Concept</a>, <a href="http://download.oracle.com/docs/cd/B25221_05/web.1013/b13593/qryun015.htm#i1134735">declarative query result set caching</a>, etc.). On the other side complex SQL commands are difficult if not impossible to build with the DB Adapter. Some SQL commands are even not supported on the DB Adapter (for example set-operators). Therefore it’s very helpful to build the SQL command in a programmatic way without any adapter limitations on the Spring Bean. Additionally if a Spring Bean uses a DB Adapter the performance is suffering from the XML marshaling overhead. A direct database access inside of the Spring Bean is much more efficient. <br />
<br />
But in both ways it’s important to understand the transactional behavior inside of the Oracle SCA Container for Spring Beans. Transactional behavior could be influenced by declarative transaction management on the Spring Bean context configuration or in a programmatic way. For Spring Beans there is no property configuration available on the SCDL (like for example the <i>bpel.config.transaction</i> property for BPEL process transaction configuration). <br />
<br />
Spring Beans used on Oracle SCA Composites are always taking part in running transactions as default behavior. If there is no caller transaction running, the Spring Bean Component starts a new transaction. This behavior needs no additional configuration and would be the desired behavior in most use cases. <br />
<br />
If the Spring Bean should deviate from the default transactional behavior the Spring Beans needs some special configuration on the context configuration file. Therefore a <a href="http://static.springsource.org/spring/docs/1.2.x/reference/aop.html#d0e4561">transactional proxy</a> has to be defined on Spring Bean context. The bean definition should state the transaction manager that should be used and the transactional attributes for the service object (referenced by the target property). <br />
The following example is showing a transactional proxy configuration for the Calculator Service Bean. The example assumes existing audit tracking method(s) which should not take part in running transactions (PROPAGATION_REQUIRES_NEW). <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLXU4vI2U5JlCPn07bkreJ29CNFxfCo-f1TMBmggSA0stwNk_SlsRoy9E6wjz_LWk8_gTnBfCPfEr3eJ5thxKlZpNUmWZ1J0Lt1Ie9j9zKGkdfVBgWfbNWrHqTLRYpAPY4Y31bUZiS-4dp/s1600-h/clip_image002%25255B3%25255D.jpg"><img alt="clip_image002" border="0" height="111" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQVSGIR1o6UA1CgGE8cVWc58EGYZEoGCzKP8trceArSLO-3odQLkFSwa_qjh-Rj0sCHqfhHceHzuIMFw4XdVOtpvM_L5ip9kUonz4w3o1rsLuy0Bd_VQkdZMoQHhVTzfpfy1QWs9BhkWaK/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="244" /></a> <br />
<br />
The PROPAGATION_REQUIRES_NEW transactional attribute uses a completely independent transaction and will not affect outer transactions. Set the key attribute on “<i>*</i>” in order to set the transaction attribute for all methods. <br />
<br />
This is a list of valid transaction attributes supported by the Spring Framework: <br />
<ul><li>PROPAGATION_MANDATORY: Supports a current transaction; throw an exception if no current transaction exists.<br />
</li>
<li>PROPAGATION_NESTED: Executes within a nested transaction if a current transaction exists, behaves like PROPAGATION_REQUIRED else.<br />
</li>
<li>PROPAGATION_NEVER: Does not support a current transaction; throws an exception if a current transaction exists.<br />
</li>
<li>PROPAGATION_NOT_SUPPORTED: Does not support a current transaction; rather always executes non-transactionally.<br />
</li>
<li>PROPAGATION_REQUIRED: Supports a current transaction; creates a new one if none exists.<br />
</li>
<li>PROPAGATION_REQUIRES_NEW: Creates a new transaction, suspends the current transaction if one exists.<br />
</li>
<li>PROPAGATION_SUPPORTS: Supports a current transaction; executes non-transactionally if none exists.</li>
</ul>This approach could even manipulate the isolation level of transactions. Therefore you have to set on the Spring transaction manager bean the <i>allowCustomIsolationLevels</i> property flag to <i>true</i> (the default value is <i>false</i>). Afterwards you could specify the custom isolation level on the transactional attributes settings. For more details please take a look at the excellent developerWorks article <a href="http://www.ibm.com/developerworks/java/library/j-isolation/">“Specify custom isolation levels with the Spring Framework”</a>. <br />
<br />
Another alternative way to the declarative solution is the programmatic approach. A Spring Bean can get a reference to the running transaction, whenever the Spring Bean needs to have programmatic access to the transaction in order to do commit, rollback, suspend or resume a running transaction.<br />
<br />
The following listing shows an example on how a Spring Bean could get access of the running transaction. In this example the auditTracking operation is not part of the running global transaction.<br />
<br />
<table cellpadding="0" cellspacing="0"><tbody>
<tr> <td valign="top"><span style="background-color: #cccccc;"><tt>Transaction transaction = null;</tt><br />
<tt>TransactionManager txMg = null;</tt><br />
<tt></tt> </span><br />
<span style="background-color: #cccccc;"><tt>try {</tt><br />
<tt>ctx = new InitialContext();</tt><br />
<tt></tt><br />
<tt> // getting the transaction manager</tt><br />
<tt> txMg = (TransactionManager) </tt> </span><br />
<span style="background-color: #cccccc;"><tt> ctx.lookup("javax.transaction.TransactionManager");</tt><br />
<tt></tt><br />
<tt> // suspending the thread's transaction </tt><br />
<tt> transaction = txMg.suspend();</tt></span><br />
<span style="background-color: #cccccc;"><tt></tt><br />
<tt> // call audit tracking method </tt> </span><br />
<span style="background-color: #cccccc;"><tt> // this operation is not part of the global transaction</tt><br />
<tt> auditTracking(msg);</tt><br />
<tt>} catch (NamingException e) {</tt><br />
<tt></tt>…<br />
<tt>} catch (Exception e) {</tt><br />
…<br />
<tt>} finally {</tt><br />
<tt>try {</tt><br />
<tt> // resuming the transaction </tt><br />
<tt> txMg.resume(transaction);</tt><br />
<tt> } catch (…) { </tt> </span><br />
<span style="background-color: #cccccc;"><tt>… </tt> </span><br />
<tt><span style="background-color: #cccccc;">}</span></tt></td></tr>
<span style="background-color: #cccccc;"></span></tbody></table><u>Listing:</u> Programmatic access to the running transaction<br />
<br />
Note that in the example above, the auditTracking operation on the given example will not start an own transaction by default. This is a programmatic approach and the programmer has to take care of all kinds of transaction aspects. In my opinion the declarative approach is much more elegant because it lets the code free of any transactional requirements and centralize the configuration on the Spring Bean context. <br />
<br />
In a composite to composite calling scenario take care that <a href="http://download.oracle.com/docs/cd/E21764_01/integration.1111/e10226/soacompapp_mang.htm#SOAAG41005">Local Optimization</a> happens (take a look on the <a href="http://blogs.oracle.com/rammenon/entry/is_local_optimization_kicking">blog from Ramkumar Menon</a> on how to check if Local Optimization is kicking in the WS Binding) because otherwise the normal composite to composite transaction propagation is not supported. The <a href="http://download.oracle.com/docs/cd/E21764_01/integration.1111/e10224/sca_bindingcomps.htm#insertedID1">Oracle documentation</a> mentions that even WS-AT will not help in this scenario (chapter 35.1.1.1.2: “WS-AT transactions are not supported in composite-to-composite calls, even with the <i>oracle.webservices.local.optimization</i> property set to false.”). I’m not sure if this statement is in general true. <br />
<br />
Thanks to Clemens Utschig-Utschig who was pointing me on the declarative solution. Also thanks to Silviu Leahu who figured out the programmatic solution. <br />
<br />
That’s it. For more details take a look at the <a href="http://static.springsource.org/spring/docs/2.5.x/reference/jdbc.html">Spring JDBC documentation</a>.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0tag:blogger.com,1999:blog-1817587040967009465.post-71207779533955112442011-05-16T13:21:00.001+02:002011-06-16T10:44:10.271+02:00Oracle SCA Spring Bean With Own PersistenceMy last blogs are around the Oracle SCA Spring Bean basics illustrated with a calculator example. We already implemented the four basic forms of calculation by own Spring Bean implementations which are wired on the Calculator Bean (<a href="http://suchier.blogspot.com/2010/11/sca-spring-bean-basics.html">bottom-up blog</a>, <a href="http://suchier.blogspot.com/2011/03/oracle-sca-spring-bean-contract-first.html">top-down blog</a>). Additionally we called an EJB for the square and square root operation (<a href="http://suchier.blogspot.com/2011/04/oracle-sca-spring-bean-talks-to-ejb.html">blog</a>). <br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TdEHBrUbULI/AAAAAAAAANE/8rhJ280C7KQ/s1600-h/Composite3.png"><img alt="Composite" border="0" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzXvZ7Ctb1iUuC2cU96QMp-GRNCCXjELy-ObBVCeAQ35V0L3S8rFnnmd9LUysmjSiRvwF69vv65Xl9ct1apa8WKrOwGCbM9j7q3E8xOVSj3Z_eMFN7_aPEOhyEpw1kI20Hq8nE0dCyUSVY/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="Composite" width="240" /></a> <br />
<br />
But good calculators have the most familiar trigonometric functions sine, cosine, and tangent on them. So we extend your Calculator Service example with these new mathematical operations.<br />
<br />
But instead of using again the Math Java functions we utilize the Oracle Database for these functions. The implementation of mathematical function by using an Oracle Database is a kind of artificial, but I want to show the direct access of Spring Beans on the database.<br />
<br />
This is a practice-relevant topic because Oracle SOA applications sometimes have to ignore the DB Adapter because of complex query creation, special result set handling or just because of performance reasons. But the “normal” way of accessing a database should use the matured DB Adapter (also easy usable from a Spring Bean).<br />
<br />
Oracle SCA Spring Beans are running inside of the SCA Container on top of the WebLogic application server (we ignore IBM WebSphere on this example). The data source configuration with appropriate connection pooling happens on the WebLogic Application Server Console. Our Spring Bean should use the existing data source configuration instead of doing own data source configuration on the context configuration file.<br />
<br />
The Spring Framework offers an easy way to do a JNDI lookup. The <jee:jndi-lookup> can be used to retrieve and expose JNDI objects. In our case we reuse the existing SOA/MDS data source configuration (jdbc/SOALocalTxDataSource). Real world use cases will do a lookup on own data source or multi data source configurations. The data source will be injected on the Calculator Bean (setter DI). <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJoNYeHV6_kY5bxEr38uzjwnr1bA4L4Bpcrrf07-OfukRB9gxru2_kO5njpDqFIJTLtmAjwNMhkJvLe6rpsiIrWGW-Nt-Kg1vF1PpRRg5uu-W7hWquJTFsTXHjd8NZd66gRHgF-wotkiQz/s1600-h/clip_image0044.jpg"><img alt="clip_image004" border="0" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1e8ClO9AJ6vyHl00tjSWohxVZeUFsa2oAwub6d6DRYIhw8JThwicg8pzBnTn0jVrvh7Ep0-009xw7J9EoRKAyeY8pv6g9oBelDxQfDkXQBJQpYkCDg0-0tOy1Znd2pyabVhBYVsAs1eV/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="240" /></a> <br />
<br />
Inside of the bean implementation the easiest way to do JDBC calls is the usage of the JDBCTemplate (out-of-the-box implementation of the Template-Pattern). Without the abstraction of JdbcTemplate the usage of JDBC would be much more complex and error-prone. Therefore we create a JdbcTemplate instance on the data source setter method and passing the data source. <br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TdEHFFOz5lI/AAAAAAAAANU/EXWda37uINA/s1600-h/clip_image0064.jpg"><img alt="clip_image006" border="0" height="103" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTMkXPWfNUwPCN14WLdXWj70tceyxRLHVGCPENIIB3tE66zgMqKJuJ7IsSv_0BWoV5tUlUjSEVlEegP1pZJi_T5wC_usjdYEPiVm8KXfQNVXRWP35LxN4AFTfsVqOXQblUcn2uTO_w13lh/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image006" width="240" /></a> <br />
<br />
The JdbcTemplate offers several methods to execute SQL Statements. The methods execute(), query(), update() and batchUpdate() are available for all kind of DML commands. Our use case needs to do execute a select command therefore we use the query() method. If the query returns only one value from the database the queryForInt() or queryForLong() method could be used. Unfortunately Spring don’t offer a queryForDouble() method, so we have to use the more generic queryForObject() method which takes the expected return type as parameter. <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TdEHGzzNSkI/AAAAAAAAANc/t2B3ONXD2_s/s1600-h/clip_image0083.jpg"><img alt="clip_image008" border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg6wmI2tUYeH80-w9Wcn0Xhyphenhyphen2ADKt75hK0l6KYPefuNYgAs0ns-Zm-qbAWlcE5MZzrYliNHWkka7Z7B8FwQ9p2c4QrQKJPiPKL-SwWSF78BzbGxN-pC1wFEEayfqQYA1QIFLNMwq8D6UoQ/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image008" width="244" /></a> <br />
<br />
In case that the select returns several values the queryForMap() has to be used. The map collection assigns to each column name a value. Finally when we retrieve several rows from the database the queryForList() method has to be used. The list collection contains for each row a map collection. <br />
Finally test the new Calculator Service operations sine, cosine, and tangent (I’m using SOAPUI). <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsbyQfAcF-s0ZkF4NKqV6h5fsXxhTTgPGNJWdrszGAsiUEtJNkAGM8E2_Kt6_ramncXvi5R3uCKAs1SYw1Artds-0KJ0An9E6CK5RdERkyxuNrL7NaggXfjHfYhS1uYMPN2knHrbhW8Z0_/s1600-h/clip_image0103.jpg"><img alt="clip_image010" border="0" height="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5httRP4UMnvCH1tgPopdqXtAetWOOiz3OSwTNrG1NiqjPqLYTFCWDlKlVcIme1Y6ssQA-Jfo1UelhWfHaivAKhCC6SC3g4T-Y-VHceXOWzF9MefVbqUjRnSAnmeKdolMzlxtgxDG2kZiS/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image010" width="244" /></a> <br />
<br />
The source code is available as 7-zip <a href="http://dl.dropbox.com/u/32501249/Blog/Calculator04AccessDB.7z">here</a>.<br />
<br />
That’s it. We created the access on the database inside of a Spring Bean on the Oracle SCA Container. This blog only touches the Spring JDBC topic very briefly. For more details take a look at the <a href="http://static.springsource.org/spring/docs/2.5.x/reference/jdbc.html">Spring JDBC documentation</a>.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0tag:blogger.com,1999:blog-1817587040967009465.post-3477951314245145372011-04-10T03:44:00.003+02:002011-06-16T10:43:14.217+02:00Oracle SCA Spring Bean Talks To EJBMy last two blogs are setting the foundation of Oracle SCA Spring Bean development for the next steps on the Calculator Service example. First we build a “bottom-up” Calculator Service based on a given interface class in order to learn the Spring Bean basics (<a href="http://suchier.blogspot.com/2010/11/sca-spring-bean-basics.html">go to blog</a>). The second blog example was giving the Calculator Service a “top-down” interface and re-used the existing mathematical operations as given Spring Bean (<a href="http://suchier.blogspot.com/2011/03/oracle-sca-spring-bean-contract-first.html">go to blog</a>). <br />
<div style="text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrRlspii4ZQ9GakzF5dbOmrsB33hggDKIMkp5dxIN07nrupACWgHcRpVoS71yrgY6xzdlRN0dYB7JoYe-2hiStJWlFnrpOJNUUgLwEIF_9axcnZscR-QNK7grHHXyRodlf9FQmZpxO83wV/s1600-h/clip_image001%5B3%5D.png" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="clip_image001" border="0" height="161" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TaEIeO0vhJI/AAAAAAAAAL4/3wOXRlO9bjo/clip_image001_thumb.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="244" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Now we extend the Calculator Service example with an EJB access. This is a practice-relevant topic because Oracle SOA applications running on a SCA Container have to interact with existing EJBs. As the authors of the book “<a href="http://www.amazon.com/Understanding-SCA-Service-Component-Architecture/dp/0321515080/ref=sr_1_1?ie=UTF8&s=books&qid=1302398679&sr=8-1">Understanding SCA</a>” Jim Marino and Michael Rowley rightly point out that there are many enterprises which have mission-critical Java EE applications that will remain in production for years to come. The authors further describe SCA as schizophrenic in reference to EJBs. On the one hand, SCA offers a competing technology to EJB, but on the other, SCA extends EJB technology. <br />
<br />
In order to extend the Calculator Service we implement a Stateless Session Bean EJB (SLSB) which offers two mathematical operations which we reuse on our Calculator SCA Composite. The EJB offers a square operation and the inverse square root operation. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQMb9BtH9ixuHjpHVNAzgGN1-1JKnZWMSpqVfDNX2LN_zXKYQrVJB8BU-W_nEFtOz7fmqzTco-nq-sJSAwqpLGwTaU5IalR7YvIHKkN7jvZT-tnJpPNXvarQxbDTeMv7PHudc2ZGaDiJLn/s1600-h/clip_image003%5B3%5D.jpg"><img alt="clip_image003" border="0" height="130" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7db9eX33ZLTFjoBKT6fFrISdnE7bBoZyxk4utMBdtfACp4Zu6e7nMSiUCazALmvAVvEWlQqs5bzEV1FDbJUIb8-4vOmQhrn7a2kS0tiFNoroZDcdPy0apNrI8To4joxSfLsgg3VhS0mFF/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="244" /></a><br />
<br />
Access on existing EJBs could be implemented on several ways on the Oracle SOA Suite platform. An easy way of integration would be to annotate the existing EJB with JAX-WS annotations and offer the EJB methods as Web Service operations (assumed that the EJB is implemented on the 3.x EJB standard). On this integration scenario a WS Adapter would be placed on the “External References” swim lane of the SCA Composite. <br />
<br />
Another way of integration would be the usage of the EJB Service Adapter. This approach is working well if the EJB is based on the 3.x specification. EJB 2.x access has problems to interact with the EJB Service Adapter based on my experiences. Anyway, if a Spring Bean should talk to an EJB the EJB Service Adapter seems to be unnecessary overhead. The Spring Bean could act as EJB Client in an easy way. <br />
<br />
Spring makes it much easier to access EJBs. Additionally, using Spring Beans to access services provided by EJBs allows the implementation of those services to later transparently be switched between local EJB, remote EJB, or POJO (plain java object) variants, without the client code client code having to be changed. <br />
<br />
Spring is working with EJB proxy objects for accessing local or remote SLSBs. The configuration of the proxy is shown on the following Spring Bean context file. <br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TaEIfdC4I8I/AAAAAAAAAME/i5b-9B6apFA/s1600-h/clip_image005%5B3%5D.jpg"><img alt="clip_image005" border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQFPa8_Qr2JNGAqL5iYpe9tzpIi2ixhNVKUPPQUdQNMSpmdXtjO31bsTCK9YlYnWSOJ09qOO-NCjutBxgdpwN3xWuC9JR9P5g4oXMLs8m1Dx4RAqJ4mFhxzQ09lolpn6xJoj53ZxtBogUq/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="244" /></a><br />
<br />
The EJBCalculator bean definition creates a proxy for the EJB, which implements the business method interface. The EJB local home is cached on startup, so there’s only a single JNDI lookup. Each time the EJB is invoked, the proxy invokes the create() method on the local EJB and invokes the corresponding business method on the EJB. The ICalculatorServiceBean definition sets the ejbCalculator property to this proxy. <br />
<br />
Access on local SLSBs are realized with LocalStatelessSessionProxyFactoryBean proxies and access on remote SLSB are implemented with SimpleRemoteStatelessSessionProxyFactoryBean proxies (commented out on the given context snippet). Read also on the Spring Framework documentation the chapter about <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ejb.html">EJB Integration</a>. <br />
<br />
It’s important to take the matching JNDI binding name. The right jndiName setting on the Spring Bean context file could be taken from the JNDI Tree view of WebLogic. <br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TaEIgtlsP1I/AAAAAAAAAMM/T4C4D4wSD_U/s1600-h/clip_image007%5B3%5D.jpg"><img alt="clip_image007" border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgITCUrZri1HmrVdkBqwkYeYoGvBepqdk5Tkfz03nbLzAy-LTbgUJPD0qu88gZPTo2HPO_s2E5bKETmL4d28iXTws6o_qCK1egVgZNRcnAJL5P5HcpciiJIcAx7aIoj7HZJ-WcwFnfjd1iB/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image007" width="244" /></a><br />
<br />
If the JNDI Name is not matching the right EJB binding name you will not be able to deploy the SCA Composite. A Exception “NameNotFoundException” will stop your deployment. <br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TaEIhZoAfII/AAAAAAAAAMU/SmuuHimPCE0/s1600-h/clip_image009%5B3%5D.jpg"><img alt="clip_image009" border="0" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEBCuzNfHVRnAmJ9GgAuKIvcI1BmspnCkN-PwYsq4VqfwoguiURfHDe9J-dphlu8o-UooAd6ea3WAqz2ZiW4YB_7kMapcjAOppWOqxj7TX1jkbA750aXc2slkQTMm54kFME40tEsT3IF1m/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image009" width="244" /></a><br />
<br />
On the next step the new “square” and “squareRoot” operations have to be added on the Calculator WSDL. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjwVNywmvQARh0ynU9iq4hyAyxX9CIh-ON9Gua_hhsTJm0dv32J2SmPCG7XDvdvS4aU2TwHDYrCNai9G-UtlB8ShsN17pddcJDu-RlXXQDSowDZ76WTrShU5pjAOio10gX1MHFjUbiZU6O/s1600-h/clip_image010%5B3%5D.png"><img alt="clip_image010" border="0" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nOI-vai50YOxmnMVADzrJHAVl8WVVw2Av5JOspmAEy5CgA1qlKGx5Sj-m0QInXY8Y7nZVnLH3tGn4nr8crYjGYsbbvs74gYKCzwnShGlufZe4GC_nZ2KjG0VuSj2ZdrykR1VP6pm7sAr/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image010" width="244" /></a><br />
<br />
Put the EJBCalculator JAR on the SCA Composite lib folder (\SCA-INF\lib) and define the dependency (Project Properties -> Libraries and Classpath -> Add JAR/Directory). Rewire the WS Adapter with the Spring Bean CalculatorServiceComponent. This will cause a re-generation of the Calculator Service Interface classes. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYc-52L2ZSdFR0XHJeyElT0XqB4rULc6MyfWfEL9pCnPLPXCG8Fqy4ihapTZS1TMfJBm9lyt-Oupn8twPn0IMNvJ8t3UJ1JGALgelv8miX7AqDuyy7Xm9nXlhKw98kYEPiWh9F-zkrotlY/s1600-h/clip_image012%5B3%5D.jpg"><img alt="clip_image012" border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijTSb0IbQbmwaVXeckFUfntecpxD-Tsi5rfrmeuydMbQhhNCy-Fb61E3YFbZOtI3IwE2tAmHuQ8FF8cRST4cOlQNMEW1E-CnmBmR5MolmNsUYBw6QEI73nsGcLAKTeYvpC_hDaBVdfNMJX/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image012" width="244" /></a><br />
<br />
Add the setter method for the EJBCalculator business interface class on the CalculatorServiceImpl class. <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TaEIjq9WlhI/AAAAAAAAAMs/2MR48aKuq-Q/s1600-h/clip_image014%5B3%5D.jpg"><img alt="clip_image014" border="0" height="108" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZkq066xb29aeDtXhQoll1X0WEq0Eqo9Q5SZ4WTG9TM2yxGk4nXx4axzAZLA6a5hwZGWr0z9yQSHzekppMQ-UX-EqYZr9QDWz4ilkVr8Lp8S33dccUcqntasbIUyUyXAvGZdTxpvtlYiBV/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image014" width="244" /></a><br />
<br />
Last step is the implementation of the “square” and “squareRoot” methods which reuse the existing SLSB EJB by a fast local EJB call. <br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TaEIkGYNZ9I/AAAAAAAAAM0/17J11Mh0vyM/s1600-h/clip_image016%5B3%5D.jpg"><img alt="clip_image016" border="0" height="126" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrcy2NRuv77o0qRKXawVSUfVPqWBo9a_CSjIfFISu77Xqjce1c9QzRdxNvN27uSItT9YS2JZwRAxBRRgo7DVj4plQDAAnC8Oz-EXRVWXMSvgdRZdbPqcDANjzOiEZPGiSm4j8kI0Crm870/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image016" width="244" /></a><br />
<br />
Finally test the new Calculator Service operations (I’m using SOAPUI). <br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TaEIk8Y3-EI/AAAAAAAAAM8/s1j70Smqhys/s1600-h/clip_image018%5B3%5D.jpg"><img alt="clip_image018" border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVoD1p9D34T2CcFwPnISmhn2b72_LwVMVQNcLZtXGAfW-Gv79ZE6QCHnubLJ5s7Wdo-eP6AW5rS8GxauWdLlglujgxvHT2Tm5TE295uAyxMl5TYdZWfZwUr7IB7CAtOAqXYYrhmiqhhD4j/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image018" width="244" /></a><br />
<br />
The source code is available as 7-zip <a href="http://dl.dropbox.com/u/32501249/Blog/Calculator03AccessEJB.7z">here</a>.<br />
<br />
That’s it. We created the access on an SLSB EJB and reuse existing operations with a Spring Bean on the Oracle SCA Container.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com1tag:blogger.com,1999:blog-1817587040967009465.post-73204807245897389552011-03-11T00:47:00.002+01:002022-05-17T08:09:39.038+02:00Oracle SCA Spring Bean Contract-FirstMy <a href="http://suchier.blogspot.com/2010/11/sca-spring-bean-basics.html">last blog</a> was showing the Oracle SCA Spring Bean basics via a Calculator example application. The example application idea was taken from the <a href="http://tuscany.apache.org/getting-started-with-tuscany-using-the-command-line.html">Apache Tuscany “Getting Started” web page</a> and demonstrates how easy it is to implement the Calculator example on the SCA Container of the Oracle SOA Suite 11g. <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlbmw5ZRpI/AAAAAAAAAJ0/M-RaW3v5Km8/s1600-h/clip_image001%5B4%5D.png"><img alt="clip_image001" border="0" height="157" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFB1kDZCjujIbQFU_MrWUoG4fWF6MWFhHR1cZQ5aq_mCqCU6OWjvQ96_jX11S-FkiKcDF3noGHBeNUG_C_AXkJ0bxd_TQUVkyR5rConBWTdFOqyUiBhgeTv2J3pz6gdY0f-txkuiNjs4Zc/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image001" width="240" /></a><br />
<br />
The calculator example had a SCA Composite external Web Service interface bottom-up generated on the Calculator interface class. I don’t want to take part at the religious war on the usage of the top-down (also called contract-first) versus the bottom-up (contract-last) Web Service generation approach. I personally prefer the "contract first" approach, because of interoperability and the control on „data types“ (avoid „type inflation“). But I don‘t damn bottom-up Web Services. It always depends on the intended usage scenario. <br />
<br />
The following describes the top-down Web Service interface approach for Spring Beans used on the Oracle SOA Suite 11g in a step-by-step approach. I assume that you have installed the “Oracle SOA Composite Editor” and “Spring & Oracle WebLogic SCA” extension on Oracle JDeveloper. Furthermore I will not repeat the creation of the SCA Components for the AddService, SubtractService, MultiplyService and DivideService services from the last blog example. Keep the already developed CalculatorServiceComponent with the Calculator Components wiring. The CalculatorServiceBeanDef.xml should have no sca:service element and the CalculatorServiceComponent.componentType file has only reference elements. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ6cPoZC1mB7es0UouMQ1wjyv4xUOHiccJY9P6HHAFvyUz_wb1XCP9sjjFhk0raFz9eA6Kj96xmkEJJaoRiE6y4cxrZoeecjPOiDrjI6F7WJf9buMKL4e3Q70aKOXABAdMSm0TrtvG6oGb/s1600-h/clip_image002%5B4%5D.png"><img alt="clip_image002" border="0" height="147" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEhX-f08NAJiMimsLlFbfU3nliSAK5rvfRZ8N6s0CtM6bSB8RNCtTx9MpbYgTkN_hyZ_D70rdm9hIoytIu0ewyqpnetNgBSFtfEc-TXeKsC6DzMoq4juP05MORgS1XmohzUXKRC5J-jQle/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image002" width="240" /></a><br />
<br />
After setting the start position the first step is the creation the WSDL file. The WSDL file keeps the schema declaration for the WSDL messages and defines the Port Type operations. Only the devide operation has an additional fault message in order to provide a SOAP Fault on a division by zero exception. <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlbu9yR0LI/AAAAAAAAAKE/xm9JJARqSvM/s1600-h/clip_image004%5B4%5D.jpg"><img alt="clip_image004" border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6a0Y3usngL8enfc1u6VoVRS_IaRoqh7jdyXVAYamFnObqCZK07CE_F6y7GHK0lsVi59FGPR1bvYobfyfloyAv8YTmfD2upocrU8LpqY1UaxMNMyxiz9Pba1G9Ox7BRkdkypgfxYam-hw3/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="240" /></a><br />
<br />
Drag and drop a Web Service Adapter from the Component Palette on the Exposed Services swim lane of the SCA Composite canvas. A Web Service interface for the SCA Composite is generated and the Web Service wizard is asking for the name and WSDL URL. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYaue0HQZyj4ASv6n9tvplLrqncY54U9hQCkYg9_9_gpnvaqELn77Gkxra-aktlh0igpFnRP09weKYbD3aHy8kUd8if5DMeyrOirtL55ZUcX5Ejqg6OjPtcgKiqujPf4NRW91NhVoehwXv/s1600-h/clip_image005%5B4%5D.png"><img alt="clip_image005" border="0" height="178" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TXlbzH3NHQI/AAAAAAAAAKQ/GSUyEL0G-h4/clip_image005_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="240" /></a><br />
<br />
Name the Web Service Adapter CalculatorService and search for the new created Calculator WSDL file (Calculator.wsdl). Because we have only one Port Type the ICalculatorService Port Type is pre-selected. On this example we do not care about the Transaction Participation (default is NEVER). <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlb0bQjEnI/AAAAAAAAAKU/NjAyOfhgNZA/s1600-h/clip_image006%5B4%5D.png"><img alt="clip_image006" border="0" height="192" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlb16eVXxI/AAAAAAAAAKY/NZ_I73DP4OI/clip_image006_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image006" width="240" /></a><br />
<br />
Wire the WS Adapter with the Calculator Service Spring Bean. This will cause the generation of the necessary Java code. <br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TXlb3csW0YI/AAAAAAAAAKc/9i2Nw_aoInA/s1600-h/clip_image007%5B4%5D.png"><img alt="clip_image007" border="0" height="168" src="http://lh4.ggpht.com/_ItzgOsy1Ijs/TXlb4xbrX8I/AAAAAAAAAKg/oFwk-e4gTCY/clip_image007_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image007" width="240" /></a><br />
<br />
The interface ICalculatorService class is generated based on the Port Type ICalculatorService. An information popup window will inform you. <br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TXlb6IUmchI/AAAAAAAAAKk/tfPMtK5DnGo/s1600-h/clip_image008%5B4%5D.png"><img alt="clip_image008" border="0" height="55" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TXlb7hr5QoI/AAAAAAAAAKo/E-sxjifyqa0/clip_image008_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image008" width="240" /></a><br />
<br />
Additionally a warning popup window will inform you about necessary changes on the Spring Bean Context Definition file. <br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TXlb8kNp03I/AAAAAAAAAKs/Mv_3SSjGw20/s1600-h/clip_image009%5B4%5D.png"><img alt="clip_image009" border="0" height="134" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8yUetHtRLjb6anQPIB71omiP23zNcBCWuJXS-P-iw2h34gcC164y3VB9d88GOyjUa-4ncvseEAcDFM332Vo71Qj0f4Voyk5a0V9o9fkvQQ0jMIzRJEQm58D7YlZ_AyynoSG-CY5_0G1rU/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image009" width="240" /></a><br />
<br />
That’s the composite.xml view after the creation of a Web Service Adapter on the exposed services swim land and the wiring to the CalculatorService Spring Bean. <br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TXlb_WvF2MI/AAAAAAAAAK0/_vdSFaoOQIk/s1600-h/clip_image010%5B4%5D.png"><img alt="clip_image010" border="0" height="168" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcA3PBRBI/AAAAAAAAAK4/8gcVEC7Z84U/clip_image010_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image010" width="240" /></a><br />
<br />
Take a look at the Application Navigator view and the generated packages and classes. A new package named calculator.example.suchier was generated. That’s the WSDL targetNamespace (targetNamespace="http://suchier.example.calculator/") in the reverse order. The WSDL port type name ICalculatorService is the name giver of the Java Interface class. All WSDL Message definitions get equivalent Java classes. All generated classes are JAX-WS annotated. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPHhAU1phm6C4q4Y6wSJAaMuB-FZQb8cK_7gO9JreyRlWVC3CZZdCuMKFPMLO25DBNF7sbMWcxo-XpZPhTj-OjXtCXtkqy0BEeBmubU-ij1TYCPOlQXq3SG_0adB7eePEtOlGsuo4-zJuh/s1600-h/clip_image012%5B4%5D.jpg"><img alt="clip_image012" border="0" height="150" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcEIw8KSI/AAAAAAAAALA/MSNvNuuLyt8/clip_image012_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image012" width="240" /></a><br />
<br />
The WSDL SOAP Fault declaration DivideFault becomes a Java Exception class which extends the java.lang.Exception class. That’s the exception which has to be thrown on a division by zero exception. The Web Service client will receive a SOAP Fault response. <br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TXlcFfL4BnI/AAAAAAAAALE/EqVObd1ibMA/s1600-h/clip_image013%5B4%5D.png"><img alt="clip_image013" border="0" height="221" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcHOuYazI/AAAAAAAAALI/KN2SZQYPfuc/clip_image013_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image013" width="240" /></a><br />
<br />
The next step is the generation of the CalculatorServiceImpl class which implements the generated ICalculatorService interface class. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM31C-wcOo0ePpBCX3gJpUAkv6E9jFeFnCHu8XxccEQ4ZuDj1iUWM18yG6mxHHKuQbHjYEYopc1fGm7gh376eNbzqXz1IqW6brAq1w5vvs7p1xzB21TBkCzCoKPgzD-iFiYOAWM7nQkSv-/s1600-h/clip_image014%5B4%5D.png"><img alt="clip_image014" border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2dB2zrSabNnJ-N0P3rdY3XLTHEhtlXtj8bxN6c1C9ME6TSrjT3ILCKQwIxZZ_EjFxw4tuWUAEIAVT4BGIcElAJDfmYPMn3aIu584mHdwQ4qCnMH4Xv6wgMYlDebteL5rbX58sPYqjs3Yg/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image014" width="198" /></a><br />
<br />
Instead of rewriting the existing Calculator Service operations we reuse the existing Spring Bean on the calculator package. So we have to inject the pre-existing Calculator bean. Take a look at the necessary changes on the Spring Bean Context Definition file. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTx8WQ38xdxVj0D1-EMWsa4Ie0Kz8RlQHYHvBWu1RofHKFieV-ZMpeALHVdnH1qUzllImn2G-hhEYgu6XW7Vvzfxvu417cfQi8vAD261ZUdHG5NvaZ_idJ9mnbG-ZMAUjRH4LdPwIRZzp3/s1600-h/clip_image016%5B4%5D.jpg"><img alt="clip_image016" border="0" height="191" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcN06lwGI/AAAAAAAAALY/DDXqm9w1coI/clip_image016_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image016" width="240" /></a><br />
<br />
Afterwards we create calculatorService setter and the implementation operations. The divide operation has an additional implementation part for checking the divisor on zero (and throwing an DivideFault exception in case of a zero value on the divisor parameter). <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpraz4j9NVvZS3dYEkgnp8JYIbS5CHgxvtRevJlcf0VL_xDnG1tASjf2rTSpW5YGERUmcm0J3GWa480j73fsVp3ZoThFWdBf-eGc1yC9uT1oIFZcZgukQuA04daYtqXMARNFKsj4DVvFLb/s1600-h/clip_image018%5B4%5D.jpg"><img alt="clip_image018" border="0" height="200" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TXlcRLkXOVI/AAAAAAAAALg/_hAlWBE7U8A/clip_image018_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image018" width="240" /></a><br />
<br />
Last step is test the new Calculator service. On the divide operation we could check the “good day” scenario (where the divisor is different from zero). <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2zgG3bb3fhAKYLmNR8HE_B73Epyf9MX-TpeI7FHew9EEkMuIw1gvOJsPHmzWB0gFlIf8Mni5YT6gGc5eZHZfxaBsieALj8vu-vxfOA1tf5v4kIndnCXcF0fzkmx6W8KGbsPjZi7vAWwhu/s1600-h/clip_image020%5B4%5D.jpg"><img alt="clip_image020" border="0" height="83" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1str13Nzoi13a5_a_AjnaDxtMiSbWAl6cS_xMpniu3IFwmhdenCunciw5RGmaxwsiSE1L7r5Py5Rei5IINSNE0vSMJ-UvFOKc0fUxSExLQ-omfWAfFebHuTeuquBKY7nNKN7bd_TKcoxp/?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image020" width="240" /></a><br />
<br />
And we could check the “bad day” scenario (where the divisior is equal zero). <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcV2StD3I/AAAAAAAAALs/rt93LuZrdeQ/s1600-h/clip_image022%5B4%5D.jpg"><img alt="clip_image022" border="0" height="83" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TXlcXjweSfI/AAAAAAAAALw/PxAuQcaEKcA/clip_image022_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image022" width="240" /></a><br />
<br />
Unfortunately there seems to be a bug on the Spring Bean SOAP Fault implementation. The SOAP Fault is just setting the faultstring element. But the fault detail element is not on the SOAP Envelope (I expected the DivideErrorType faultInfo information on the detail element). <br />
<br />
The source code is available as 7-zip <a href="http://dl.dropbox.com/u/32501249/Blog/Calculator02ContractFirstApproach.7z">here</a>.<br />
That’s it. We create the first contract-first Web Service with Spring Beans on the Oracle SCA Container.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com2tag:blogger.com,1999:blog-1817587040967009465.post-83070751875408098472010-11-26T01:23:00.004+01:002022-05-17T08:09:49.365+02:00Oracle SCA Spring Bean Basics<a href="http://tuscany.apache.org/">Apache Tuscany</a> is an Open Source implementation of the <a href="http://www.osoa.org/display/Main/Service+Component+Architecture+Home">Service Component Architecture (SCA)</a> standard programmed in Java and C++. Tuscany was my first contact with the SCA technology. When I played around on Tuscany I remember a simple and straightforward POJO-based Calculator sample application. This application demonstrates the simplicity to implement a Java POJO service on the SCA Container and offer the service as SOAP/HTTP and REST Web Service. <br />
<br />
Since my first steps with an early beta version of the Oracle SOA Suite 11g I was missing this simplicity to just implement a Java POJO service on the SCA Container from Oracle. Since <a href="http://www.oracle.com/technetwork/middleware/soasuite/soa-11gr1-ps2-new-features-097680.html">Oracle SOA Suite 11g Patch Set 2</a> it is possible to have Spring Beans as part of the <a href="http://www.springsource.org/about">Spring Framework</a> on the Oracle SCA Container as first-class citizen. Therefore Oracle adds the possibility to have Java <a href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object">POJO</a> services in terms of Spring Beans. <br />
<br />
Let’s follow the simple Calculator example from the <a href="http://tuscany.apache.org/getting-started-with-tuscany-using-the-command-line.html">Apache Tuscany “Getting Started” web page</a> and see how to implement the Calculator application on the Oracle SCA Container. I have chosen this Calculator example because it’s separated on smaller function blocks (SCA Components) demonstrating the flexibility and modularization of SCA Services. Smaller components can be easily wired to more complex components. <br />
<br />
In case of the Calculator example, the application can be divided into five functional blocks: Add Service Component, Subtract Service Component, Multiply Service Component, Divide Service Component and a main block that takes a request and routes it to the right operation. This main block is called the Calculator Service Component. <br />
<br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO717R2xOtI/AAAAAAAAAB4/v0r1NRpY6Us/s1600-h/image%5B6%5D.png"><img alt="image" border="0" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaxG2L5vMEaQ-Em0exz3TvfFB87IcaMglOLOzbXBAx9GIC8qP0jYeQnTDh0dd4x4T5trkm-xcH90DSVKesS8aZts4Y7fjGQzzx02S9MVUlhp3SZCg91PKWI2n_2SBJN4L-CpOHQFVtnLbq/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="320" /></a><br />
<br />
The Calculator application is implemented with SCA Components which are placed on a SCA Composite. All the Components are implemented with Spring Beans connected (“wired”) with other Spring Beans. <br />
<br />
The following describes the Spring Bean creation in a step-by-step approach. I assume that you have installed the “Oracle SOA Composite Editor” and “Spring & Oracle WebLogic SCA” extension on Oracle JDeveloper. <br />
<br />
1. Create a JDeveloper Application with a meaningful name (e.g. OracleSCASamples)<br />
<img alt="clip_image003" border="0" height="241" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO71_WqG4zI/AAAAAAAAACE/i9C_PEF0fOs/clip_image003_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image003" width="320" /><br />
<br />
2. Name the project “Calculator” and add SOA as project technology <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4j9zzA7h93SQKrJfQKpLMLJLGEMgFrzA-h0UQWJxV19UOuiT48VrmLsZXDY30EuEIhMl7aU5dK8x-bh2K2D-2E_3jrhTP2rKqlK_kW9kydERmINONnhl6vfrXYC0hkAcj-ifsTKkbtoNV/s1600-h/clip_image004%5B4%5D.png"><img alt="clip_image004" border="0" height="181" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72B3F3_nI/AAAAAAAAACM/2_YoFYnnGmQ/clip_image004_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image004" width="240" /></a><br />
<br />
3. Take the “Empty Composite” as project template <br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO72DB-rF1I/AAAAAAAAACQ/LWylk7kmzVc/s1600-h/clip_image005%5B4%5D.png"><img alt="clip_image005" border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidUV8hU4y3otEa58bm99YQkDYBD8kLQLB0ZC-AknmvbkVECO1NtHKZZjidzaKwHZbYwcto6gVpX4FCgyHRmul1SjxHpabu9q_bqCm-FMEi4pehCjgP-XC8GZ-DLsPJs32wp8GlqhzjjLNp/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image005" width="240" /></a><br />
<br />
Afterwards you have an JDeveloper SOA project with an empty SCA Composite. On JDeveloper we have a one to one relationship between projects and composites.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHNK73DoAANx2Wum_dCWaCwy2YOD6irQlIZtCySPqxwr4jZSSIp28v1haWiFQlHjx1Q_Y5OYBrgdXrSvgMeXjhAV-7hQA4O-Y9V73yh38ZeqnbyE6LvQ3WvDSgiNU9WYr2syUeyr3d8z89/s1600-h/clip_image007%5B4%5D.jpg"><img alt="clip_image007" border="0" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKm7OrH2btptiNUHz8JH2W8MXfKWFiS8TvcgZE_GS0S7Wy-1K5C-XKOJAf1p8zsbwwAX6X5-IhnVxOujLZN6Rd92k-2RvaUqowEi6pI59535-GMsHEiHlWKmzTR2l6dNL7WZWB81vH1v2B/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image007" width="240" /></a><br />
<br />
Each Calculator operation on the Tuscany example is implemented as own SCA Component. So let’s create SCA Components for the AddService, SubtractService, MultiplyService and DivideService. The next steps are showing the creation of the AddService. The AddService Component will provide a service that adds two numbers together. The CalculatorService Component uses the AddService Component whenever it is asked to perform additions. <br />
<br />
Later we do the same implementation steps for the other needed Calculator services. <br />
<br />
4. Create a Java Class starting from the JDeveloper Technology Gallery<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho1YXbgnkZWVYcoa2DVBXumHIXcil4FkdG8JTFDT4oIqh1hOvMl9-Ai14qNeXtTlirD-VGSWXLuMa49jiWfEpoX1xtXFhc_nHTYIKBNKUykcO31w0hyphenhyphenJ3j88JtRfOWYz0Wj2k1lhyS1ohv/s1600-h/clip_image008%5B4%5D.png"><img alt="clip_image008" border="0" height="173" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72JE7o24I/AAAAAAAAACo/XOoJog6uDgI/clip_image008_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image008" width="240" /></a><br />
<br />
5. Name the class “AddServiceImpl” on the “calculator” package<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSLVKaZ0IKgrHuRN0OGS1WkCRb77Uy1wFg462r1_Ip-faatUb3Mw7RBIqucLTAydAbMDOslLGbfO-ogu_F85HMT2aPAHKl1GVygXMWGbo6b54XAQAdmnt_DuwXNqYUOHUilWYC0Z1dBN2A/s1600-h/clip_image009%5B4%5D.png"><img alt="clip_image009" border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZBuLLiD4ILeu4ML4M5QWzl-jduK6HcbCMpxUR2DAUp_rTZ6y6W-_RzlXrSzVriVtUQOqkC-d7J4Jt8K0FXrBEXJ0yNNCbzbtIvAQDON1TKEDkp3y8TvbiwxjDL4No8jQWz2YRGtRfBUMd/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image009" width="199" /></a><br />
<br />
6. Choose the “Calculator\src” folder as destination<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72MhDychI/AAAAAAAAAC0/wHoKVXbIYOs/s1600-h/clip_image010%5B4%5D.png"><img alt="clip_image010" border="0" height="155" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO72OMcPlhI/AAAAAAAAAC4/yQ9qgiLLXiY/clip_image010_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image010" width="240" /></a><br />
<br />
7. Develop the “add” operation of the AddServiceImpl class. As you see, we just implement the AddService as Plain Old Java Object (POJO).<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO72O4DYyQI/AAAAAAAAAC8/hctUQbz8rd8/s1600-h/clip_image011%5B4%5D.png"><img alt="clip_image011" border="0" height="160" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72QPy2WAI/AAAAAAAAADA/LeAD9k63qhQ/clip_image011_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image011" width="240" /></a> <br />
8. “Refactor” the Add Service Interface<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3z7InM-ai8VYcv5AGHgxUk4dEwzmBp3r0n84x0IqcYcEgdyTsDpDJsjLfhmwiNj48SjNLjoqZowb7LbZjEQE9pNYXOvzNSvuEucVWJjZtr-eLUcRxUPW1_DCMk8KluDikMJxQrkLFrV4E/s1600-h/clip_image013%5B4%5D.jpg"><img alt="clip_image013" border="0" height="184" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEeCAPKNxCyRAUwh4-n5t136O5epddZNzAHLSDhKNs6Yj2EtyTpQrJexQewRGEE0HmMNQKUWe_rfKnaE6QgWd7K_6bZYaaJx_9nvfCtAStXf25-B20w8hZHdvk4ya67N4VcTD2QDaiEolH/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image013" width="240" /></a><br />
<br />
9. Name the interface “IAddService” on the “calculator” package<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKDNftVyrphdA-rWSu4ppJJhSst2gi77595GEaEWENZcLYdXTe_5-K7aJrTiSFa2pK2ybeQygLS4E-Xpx27lUI1OVO0pDV-_7p2l7yc7cV8aTWTzqMRnyxSFARFjQUh2h6fzwAs8qj2h7u/s1600-h/clip_image014%5B4%5D.png"><img alt="clip_image014" border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPkkyo5SIwC4dHt-X2u4RtfzELJUjhs5-6s_6lU2i_oDtohyDZ_xI0sbFhsmEYp94760YnB_UuUjCuv32GVE2bMGWAcA6Wgvq602ELF4FFLwrqK3H8cPb6fPf-own2qd5iA_WkHKb39qgF/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image014" width="187" /></a><br />
<br />
Result: IAddService interface<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFbbkZXTRVSw7PTRAJC_tb_2eE8NFD0NuHvaPyTGP4_LC6CIaYeZXdFEgKAZ-d6WB6kbj3tc7LzlA8kU5pEQi-jCqe7bG5eiJW999liU8K5ejM02bcAS2tRlSu-9m3V9PFj1XDlVRcKnCI/s1600-h/clip_image015%5B4%5D.png"><img alt="clip_image015" border="0" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPUDlmZ0M2Dq7Ylqf5G9_-prvWpjJltXc_RVajCctnzMqutjE7gRlizCe_WZrCmzarTkzddqXRi8FSqUARox4mBUOHvYjVtpdjtPuEr0tRePjRmQ-D9eNvUS8NQ0LTc4_jDemlXsSPeITX/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image015" width="240" /></a><br />
<br />
<u>Note:</u> We also could first implement the interface and afterwards the implementation of this interface, but this way is a shortcut on this example. <br />
<br />
10. Create a Spring Bean Configuration starting from the JDeveloper Technology Gallery<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIsaImjAyzIaqcXf234Xzz5X-bdgE2aFnm4ix3yUZ2CjkKWnDp4_P1aFenr08jBUK-sInRyuMQo3l_bvxVZahIeOLPb51heqJuCkqOm8C6xNxvJvPYzxT8-sCpWB7vDqDgA7DOPhblj3qM/s1600-h/clip_image016%5B4%5D.png"><img alt="clip_image016" border="0" height="173" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3jmxblB0P6QnfhCf33hL1d34FeA_tkMWUebaJSv1dy6dEDYDgKk6dDB-RCR-3XZWUAgLdD0kEA6D-fzGT6te6r6BiZL64aHvavXQuCDeepxEPPiYuCYWd3vk4nuHq5sOFtTz12ykTR1J5/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image016" width="240" /></a><br />
<br />
11. Name the Spring Bean Definition file “AddServiceBeanDef.xml”<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs32wYNcpezlE9tmT5RxvMKWzYpjeWTachPtOQ2rm5rjNnjNltdMnnLXc_RNMikKKgtrynUvDYHC8Xx0EYSrnt8qZR_VcAw7-KBsaCFooPvSpy1In6ZyzUEu3MQ2tOUTsGTWLGJoLkYV0o/s1600-h/clip_image017%5B4%5D.png"><img alt="clip_image017" border="0" height="115" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjANG3C3O3sTbBHXU8x4gngPxEEtZI2OY90DxegKvYXByF-1RPZv3ALhS8lfVaeFiiS-5BB_FOy3OrR7rFjnrUohFrGtEEv8Bo6XyrUh_WFcewiWEhxHqrpcxR3RU_3pglS0P2OnJX8OzhF/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image017" width="240" /></a><br />
<br />
12. Add a “bean” element by selecting “bean (Spring 2.5 Core)” from the Component Palette (place the cursor behind the comment)<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGh79-MoWuvCqT8danIT7WRsW1LlK8-X0VrriFLIYVYUVlHoAKVQn-gb2F1o2lpOAYJybkV2ZHa6plmKs4c8tLRbG2vmihXQXsJgiK7i4HysqxZBEhXt-lU3xEKDMBREvCCmuqTQFMMnpN/s1600-h/clip_image019%5B4%5D.jpg"><img alt="clip_image019" border="0" height="63" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH1KO2dJnuo7yVtmbYgNr7g5aMkbmkSm3Pjc1kviuJmt1mpoGkCb3qsta98byJ9KATKanMglABJ9q91U2rn_gVR0Dan0WLDOJTyQ3Tl9CQ1Dgp4x00LVfDG9J5NwKf0WrkY30FXQ8wFRGG/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image019" width="240" /></a><br />
<br />
13. Add the name attribute “AddServiceBean” and class attribute “calculator.AddServiceImpl” on the bean element<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72e0PhwMI/AAAAAAAAAD0/gUBr3ZPDZqI/s1600-h/clip_image020%5B4%5D.png"><img alt="clip_image020" border="0" height="134" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb7FlVh8nf5ciQ0yksUGjCZtgpMI5M7s8lsUQJ4hs0worfI70tWY_relJstahS3fcxOlCcjtogZ8pTD9ubPK-UxC6Rc_zGL1FdpnxJaIkfY5pBVfB_eUrli5pX5bVZVhZrx2LA4LRzye_U/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image020" width="240" /></a><br />
<br />
14. Add a “Service” element by selecting “Service (WebLogic SCA)” from the Component Palette. On the upcoming pop-up window add “AddService” as name, “AddServiceBean” as target and “calculator.IAddService” as type. The target name has to match the bean name.<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72hfpjqCI/AAAAAAAAAD8/Il0qoGK6zVY/s1600-h/clip_image022%5B4%5D.jpg"><img alt="clip_image022" border="0" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgizbfZPpO1b1OFx21i3-jllARcZzMk7iRx0PpvdbS3OLADr1zwbiyyCFF2buW5dDCA2BNXoK39RsORJ-8xShbQYqdJWM8hVSMKW0_yNNsYzrq9l8juYWp8nVPjKBDPrC9tV_sEdprh1WOq/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image022" width="240" /></a><br />
<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO72juSp28I/AAAAAAAAAEE/bh4brWQziCI/s1600-h/clip_image023%5B4%5D.png"><img alt="clip_image023" border="0" height="137" src="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO72k5Luu6I/AAAAAAAAAEI/hZ1ryUodYuY/clip_image023_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image023" width="240" /></a><br />
<br />
<u>Note:</u> You may have to compile the Java classes. Take care that the SCA Service target attribute is matching the Bean name attribute. <br />
<br />
15. Drag and Drop the “Spring Context” from the Component Palette on the Composite Component section<br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72lxq_cZI/AAAAAAAAAEM/s8TuC2bASMs/s1600-h/clip_image025%5B4%5D.jpg"><img alt="clip_image025" border="0" height="77" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72nNsqOmI/AAAAAAAAAEQ/H6XuxOzCnhw/clip_image025_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image025" width="240" /></a><br />
<br />
16. Name the Component “AddServiceComponent” and select the “Use Existing Context” option and start the SOA Resource Brower with the magnifying glass icon<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBv5lZO7gIYib52P4pOhcLP4DcXb8GGf1A888WAfiRHwTjklxvsImmnTOKYLNnGmTn12okttmqiYpwoU6HN0bZr2ZSfu8SLTAzmmBFBjRNEb_j_FLr6axwR_DIUci34FGpujYQjevoA66j/s1600-h/clip_image026%5B4%5D.png"><img alt="clip_image026" border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi86DbiyAQmYcEpFji34tIPNcbb8iYQlKVcB3iRLko7HjNLUTRRGJsGrFED5sJqpKBmyAe06-IrPnMvcTo5IG6uYwACmaAx-e6jkPMrElmcmGxykhq-rOPc_WWx_dOPiOYdf_Zn5dXtAO1V/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image026" width="240" /></a><br />
<br />
17. Select “AddServiceBeanDef.xml” on the SOA Resource Browser (starts with the magnifying glass icon on step 16) <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDn9GbZY8cqs6UReE9J2hiRfMSpbLd8EJOtGUiIiCl2wI5zSvLm6FjCQtYLee6O8Efc46vfR2RMauZn9xfXLQOa3EWR-NT9ztRUhQFEV2WyZIVZHqBsWVWkWpCXjPtHlpsCMR6KbrkjSZ7/s1600-h/clip_image027%5B4%5D.png"><img alt="clip_image027" border="0" height="221" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72rheojoI/AAAAAAAAAEg/0nxVA7WargY/clip_image027_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image027" width="240" /></a><br />
<br />
18. Accept the “src/META-INF/AddServiceBeanDef.xml” Spring Bean Context path on the “Use Existing Context” field<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72sRvfGtI/AAAAAAAAAEk/hCN9ck9QLvI/s1600-h/clip_image028%5B4%5D.png"><img alt="clip_image028" border="0" height="178" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72uIlmcsI/AAAAAAAAAEo/YzUwmpAMpZM/clip_image028_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image028" width="240" /></a><br />
<br />
Afterwards the AddServiceComponent is placed on the SCA Composite<br />
<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72vIAINEI/AAAAAAAAAEs/MCkeG2WL1v8/s1600-h/clip_image029%5B4%5D.png"><img alt="clip_image029" border="0" height="92" src="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO72w55vK7I/AAAAAAAAAEw/17PqzIJykvg/clip_image029_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image029" width="240" /></a><br />
<br />
Additionally a <Spring Bean Component Name>.componentType file is created automatically on the SOA Content folder. This file keeps the exposed interface information (and the references on other services when the component is wired to other SCA Components).<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJLqYip0Z_h8jccURSO9o8VQ0lMhLlkYgm1_jzWfKaen_2QMbMUuU9jPuYyupMXAXqTRNCkEQGYPYVmK_q1xpNlsVRQ5PCMc5HSjzGXd-7qSk_G0ChyphenhyphenaMaWXQUj9H0sUOlgrc1NXGEor0q/s1600-h/clip_image030%5B4%5D.png"><img alt="clip_image030" border="0" height="105" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPM_RDtm759G1hQC1GBFPeHb0TYxsHrUhvPFZedyQjZhDH7lHfvRefgg8o5IdYzfvnQeuVrhVxDm6_td7acDT1jjps-cc0xxpL7kBmj_U6l3sOofaIaa9446rqtIAJHlZ93rVZUzFyFwxz/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image030" width="240" /></a><br />
19. Repeat step 4 to 19 for the SubtractService, MultiplyService and DivideService! <br />
<br />
20. Let’s take a look at the Calculator Service Component. This component will call the other arithmetic Service Components. Create a Java class “CalculatorServiceImpl” on the “calculator” Package<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO720etjAQI/AAAAAAAAAE8/ZZaeaSaMrME/s1600-h/clip_image031%5B4%5D.png"><img alt="clip_image031" border="0" height="240" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO7210icV7I/AAAAAAAAAFA/yWi_kdKCZpo/clip_image031_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image031" width="199" /></a><br />
<br />
21. Add private service variables (use the interface classes for the declaration), create the setter methods and create service methods for the basic arithmetic operations by using the existing arithmetic services.<br />
<a href="http://lh5.ggpht.com/_ItzgOsy1Ijs/TO7223STPII/AAAAAAAAAFE/euWnE1mpagI/s1600-h/clip_image032%5B4%5D.png"><img alt="clip_image032" border="0" height="194" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO724FDss5I/AAAAAAAAAFI/oMrUokYPBIQ/clip_image032_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image032" width="240" /></a><br />
<br />
<u>Note:</u> Like the shown add method you have to implement the subtract, multify and divide methods by using the right service. <br />
<br />
22. “Refactor” the Calculator Service Interface and name the interface “ICalculatorService”. Select the basic arithmetic operations as class members to extract.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRLnjlQJ0rP_Xab8T1SWO38TA0VipJukrxy6GZTAJWwkddTsS81ejGQ3XZ-fT19fZfu4ddJRf9hKGvb2S7RoZDyreb7t6ZMAnh1IDOo0mFaJHFTWzwTRAzj7_Mvg6sk6x8j1s-OkL5xAlM/s1600-h/clip_image033%5B4%5D.png"><img alt="clip_image033" border="0" height="240" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO726-gtQkI/AAAAAAAAAFQ/yvJqBZCJVic/clip_image033_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image033" width="187" /></a><br />
<br />
23. Create a Spring Bean Definition “CalculatorServiceBeanDef”<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1R8tRYAZDttQE9FoSpjd6CMNVpEWzOJeOFV368B3JBmrYhg52nfmba2wwMGyiwhmBmIYyxpuBaAKW-SWSDJsZwBoeT3plFj3iZzq7Ulj7tN1y7MvOczv3ahZFIc8-5Kh5gFFAqs8Q040U/s1600-h/clip_image034%5B4%5D.png"><img alt="clip_image034" border="0" height="115" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO729ET8bzI/AAAAAAAAAFY/_q1Dpn3mcLo/clip_image034_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image034" width="240" /></a> <br />
24. Set the bean name “CalculatorServiceBean” attribute and class “calculator.CalculatorServiceImpl” attribute<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO72_IZcCsI/AAAAAAAAAFc/8IQmug8dJG8/s1600-h/clip_image035%5B4%5D.png"><img alt="clip_image035" border="0" height="121" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO73DjAGkNI/AAAAAAAAAFg/xCMEGmobS6E/clip_image035_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image035" width="240" /></a><br />
<br />
25. Add the Calculator Spring Context on the Composite Component section<br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO73EzgernI/AAAAAAAAAFk/4Xy4MZJPEj8/s1600-h/clip_image036%5B4%5D.png"><img alt="clip_image036" border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRVAafXGRdBck1Do6gPJC32JkpCTBGJ74wmAzGZ76SwkD2EUcKcI2_NSa4eGN70nEmMTg-DyBXLZXRdeOY8ptgVYlaahXn-pSL5P8ZfZTlGeRys55NEotbX83KDdVJ1IYoRRAdvLkAahK3/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image036" width="240" /></a><br />
<br />
26. Next step is to “wire” the existing Spring Bean Components. Drag and Drop a wire from the CalculatorServiceComponent to the other Spring Bean Components.<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO73IN7UsII/AAAAAAAAAFs/8RFBrsWFiFA/s1600-h/clip_image038%5B4%5D.jpg"><img alt="clip_image038" border="0" height="186" src="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO73JdpUpKI/AAAAAAAAAFw/V5hNuAEVe-A/clip_image038_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image038" width="240" /></a><br />
<br />
Afterwards all the arithmetic SCA Components are wired to the CalculatorServiceComponent. This graphical wiring will add appropriate <sca:reference> elements on the Calculator Bean context definition file.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDzushPkR0JRckZEwzJVUcvKOyEHDPejZe-uvNIKtQePmlMf8PPeCiQsg6XE9tlANCevPy4-dsAObjvcnPY8OFJ0QR6gUZhVNTHVXNchCzDtJcbwi6f-wZBe4kRscnptLxGtW6zOAX_V-r/s1600-h/clip_image039%5B4%5D.png"><img alt="clip_image039" border="0" height="189" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_HZcTeGH-jydmDs0i1iopjaeVlZ-Wn1idSXasRCMPwLGMcQlRJNb0K66ZrxV-6x5U5lhoP5VYtYph9giiwg3wFYMZKEjq4fRYhsN-L7BECLkmHFzUv9R1MxO3DSVHczznC99e7p3UHnTG/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image039" width="240" /></a><br />
<br />
The new services references have to be injected on the Calculator Bean (“setter DI”). Therefore you have to add standard Spring property elements on the bean declaration within the Spring Bean context definition. These property elements causing a call on the setter operations on the CalculatorServiceImpl class. The bean property ref names have to match the right reference name.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigt-F1gT7bjXGuE5flTq0HqloZiPC4ivWin8tzGA7MZ8hDEgnfjAUJTkRFHKa7Q1iz3ebnOsLmsOkJCYHi2QOsXAJukkdY-R-F_QdMU5pfcxrkRMM2ABIHjv_mIMH740xciYYOLjjb1ifQ/s1600-h/clip_image040%5B4%5D.png"><img alt="clip_image040" border="0" height="188" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja7TYUpkotre0Z8TsXI8hHIiLAPy-G_b_7ZovxXOAYau-snQXh5f7e1H2enkROiPYae9XSHAseLjsxSJ5oEufcSgacPEwbRiuh5-zflqjFgyUFFFdKLx3Hdnj3GdVY17GHhRBLUOWZhlTj/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image040" width="240" /></a><br />
<br />
<u>Note:</u> When you missed the <sca:service> tags before you create the Spring Bean Components and you try to wire the beans you will see this error …<br />
<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73QZRywyI/AAAAAAAAAGE/xVpDf__nx0Y/s1600-h/clip_image041%5B4%5D.png"><img alt="clip_image041" border="0" height="191" src="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO73Tn1L_TI/AAAAAAAAAGI/ffHn-ptvUOA/clip_image041_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image041" width="240" /></a><br />
<br />
This error occurs because the automatic created <Spring Bean Component Name>.componentType files are missing the interface service information. So you have to add the missing service elements manually or you have to delete and re-create the SCA Components (don’t delete the Bean Definition File, the wizard is asking for it!). <br />
<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73UtEddmI/AAAAAAAAAGM/u5QFsslb_PA/s1600-h/clip_image042%5B4%5D.png"><img alt="clip_image042" border="0" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3zC4lr3Ia8em9Eko5_SjZElCwrXygCOuXDpvRDujEpKBr-upnd_mSWX5KlcrBdST09s0_5YN0yeW8zGHwB7u0p2vaze7Y6fm6pxL2nydGXUF6FxwneqycyEVke_vDFteUuPKrYATGCxJ1/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image042" width="240" /></a><br />
<br />
Another common error is the missing property declaration on the bean which should use other services (“missing setter DI”). This result in a nice NullPointerException during the first test (java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.fabric.common.FabricException: Invocation failed: java.lang.NullPointerException). <br />
<br />
27. Next step is to give the Calculator Service Component an exposed service interface. Therefore you have to give the Calculator service a callable interface declaration. You only have to declare an SCA service interface on the Calculator Service Bean definition.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxXA3h0gFHRu2mntlKVwZ0mROOTIBm4mI6xf5Q04ov8QdQO39cu02LBOZppJSH69KIKwz2ym2zsTSrLlll7z23cXM7A7dxtOTmVg5Mr4iCtzb6guo822sMixTU7LoLwUySlYXlddIvK4le/s1600-h/clip_image044%5B4%5D.jpg"><img alt="clip_image044" border="0" height="68" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLKoaIxq9A0CI8sQy4-k3XDT6NB4eqk9kJ0D4QL8zrpCvLSr9ly9ZB07_msK2mEHSE3L10uo2IXgvvStlMZ2PAz6xUTC0NuRLczotRLIchCe-0SVUEXYLLy1WRlkhPZDH-fy_pe_pgAC3J/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image044" width="240" /></a><br />
<br />
Afterwards you have to add the new service interface also on the CalculatorServiceComponent.componentType file. This declaration makes the Calculator Service Component connectable as public (callable from the SCA outside world) or private (callable from other SCA Components) service.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjubwszYOmuschX-k-9az83q9KBWKq26Ydw2-_2kKLLL6-3VICpbuYSuoLZObfaMXS7iLcPLFt3BocAAA8mEX65mgSX0wTJL_OUB8dJrj_cAJHwc3pacloQCePX83S9IAzVAFlolxmO6zHR/s1600-h/clip_image045%5B4%5D.png"><img alt="clip_image045" border="0" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWq6ZcQYnkWP6lldlk0k15jc2K2biZtC2oefv-q4G7iX_tixZxC4QWGyMdyVaqvPqr2PehXRWINS9_nRGNQ1dC-79MlkzgFeaatJAwLEcCvH1DNIjuiK2mYsDhIY0WKJN_q3k9eTHvLwMe/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image045" width="240" /></a><br />
<br />
<u>Note:</u> The service interface configuration gives the components the “green handle”. Only with this handle you are able to connect this component. <br />
<br />
28. Now the Calculator service can be exposed as public service. Drag and Drop a wire from the Calculator Service Component to the Exposed Service section.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDu2pdQLlCSjKAO3jboFa3YbbozIi2MqzVOmUNEdNiUJMOoqC7NMXFbzdUbbhvdNZQ3BnGUlUhyphenhyphencnZTixcJDJpeOzruMlOGojPezp8IhwDp-AlAUOsPE7GwsZf_KcJIEhmORGO2OjlienX/s1600-h/clip_image047%5B4%5D.jpg"><img alt="clip_image047" border="0" height="159" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73d6RoyrI/AAAAAAAAAGo/Nv1acGhOZWE/clip_image047_thumb%5B1%5D.jpg?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image047" width="240" /></a><br />
<br />
A pop-up window is asking you what kind of interface you want to create for the service. Because we want to create a Web Service interface and not an EJB interface we press the Web Service button. Btw. you could also have both interface in parallel – Web Service and EJB.<br />
<br />
<a href="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO73e4e5CKI/AAAAAAAAAGs/g0n4AHabDYY/s1600-h/clip_image048%5B4%5D.png"><img alt="clip_image048" border="0" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFsUDcNcC8ckUQWBsDcR_fid6j5zvVhtBsnWfIKxk6ZOqd90pSp-9PDwSFZdvWEpZvWglgw5nEecmdLwxT9WIzjgUmrNK-9L3SXpbzq5Iq5PNJqAxMf0mOIzbMl_IYBg06Z1TrXTxo3sey/?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image048" width="240" /></a><br />
<br />
The wizard is creating the necessary mapping between the Java classes and the XML representations. An ICalculatorService.wsdl file is created which offers the basic arithmetic operations of the Calculator Service Component. <br />
<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73g0JoS1I/AAAAAAAAAG0/t6w2M1LDNQw/s1600-h/clip_image049%5B4%5D.png"><img alt="clip_image049" border="0" height="132" src="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO73iapEa_I/AAAAAAAAAG4/l9gl8hPBmnk/clip_image049_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image049" width="240" /></a><br />
<br />
The Calculator Service is ready for deployment. Each component has a well-defined interface, using Java interfaces in the case of the calculator example. Notice that these are just plain Java services configured as Spring Beans with business logic and nothing else inside the Java classes (no extend on pre-specified classes, no implement on pre-specified interfaces, no pre-specified annotations, etc.).<br />
<br />
<a href="http://lh4.ggpht.com/_ItzgOsy1Ijs/TO73jU8QuKI/AAAAAAAAAG8/8TgV75zVwng/s1600-h/clip_image050%5B4%5D.png"><img alt="clip_image050" border="0" height="157" src="http://lh3.ggpht.com/_ItzgOsy1Ijs/TO73lL9MvgI/AAAAAAAAAHA/oyt2HednfeM/clip_image050_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image050" width="240" /></a><br />
<br />
This screenshot looks very similar to the diagram on the Tuscany guidelines.<br />
<br />
<a href="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73mdWeEuI/AAAAAAAAAHE/5o_NdKu9sMg/s1600-h/image%5B7%5D.png"><img alt="image" border="0" height="184" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73nR9yB1I/AAAAAAAAAHI/JUZ_DlrEIco/image_thumb%5B3%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="240" /></a><br />
<br />
29. A quick test could happen with the Test Web Service Client of the Oracle Enterprise Manager. But first you have to create the deployment unit (one JAR file) and deploy the SCA Composite on the SOA Server. My personal favorite Web Service Test Client is the Open Source <a href="http://www.soapui.org/">soapUI</a> tool. Therefore you have to copy the WSDL URL from the Test Web Service client. <br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbQfo4I6tntWnlP-Lz9gPfoLQn-3mh0DAqVc9xVJyV810y2dzLEeJ9z2bpwW9plysYLDUrID24bYa8kCBQrDwXCfke5zztYN1Avg6vVzvFdRB_iViVkS_nTn5z1r2IW_KF1vqEWYSXen_G/s1600-h/clip_image053%5B4%5D.png"><img alt="clip_image053" border="0" height="90" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73p0Ggx8I/AAAAAAAAAHQ/QgmAcRuwSQc/clip_image053_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image053" width="240" /></a><br />
<br />
Start soapUI and create a new soapUI project. Paste the WSDL on the new project.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT9cPevW16Evy_NJOjY80dn3N_jLv1FhOHbGj3BmbrDH77jPGzmNJDtwADojOVcxl6pl9XtEdfy5oPj7mjzXEaCFDC3EJpegnZEz5KtjOZOMksgl8-Gwh8TeH-IbP52pBJTneG5_zoEHQi/s1600-h/clip_image054%5B4%5D.png"><img alt="clip_image054" border="0" height="136" src="http://lh6.ggpht.com/_ItzgOsy1Ijs/TO73sGJv7qI/AAAAAAAAAHY/4x4-GzYTaiA/clip_image054_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="clip_image054" width="240" /></a><br />
<br />
Start your tests …<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDWEG2cYoHIV9EPjNQZZ03-ZQ1xEKTFXz9XHINMdMqzXw2OUYf1aIUqegkCjYhjAD-GhHtmMcCn9h0yiMnFNYT7OXh4RWSkkcoxCNtA__jzqf8EE4yqjSEaPn-rh1TzKkyY4V-06oxN671/s1600/soapUI.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="181" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDWEG2cYoHIV9EPjNQZZ03-ZQ1xEKTFXz9XHINMdMqzXw2OUYf1aIUqegkCjYhjAD-GhHtmMcCn9h0yiMnFNYT7OXh4RWSkkcoxCNtA__jzqf8EE4yqjSEaPn-rh1TzKkyY4V-06oxN671/s320/soapUI.png" width="320" /></a></div><div align="left" class="separator" style="clear: both; text-align: center;"><br />
</div>The source code is available as 7-zip <a href="http://dl.dropbox.com/u/32501249/Blog/Calculator01BottomUpApproach.7z">here</a>.<br />
<br />
That's it.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com2tag:blogger.com,1999:blog-1817587040967009465.post-9479765400983249052010-10-22T12:11:00.005+02:002022-05-17T08:09:59.033+02:00SCA Spring Bean ComponentsSince <a href="http://www.oracle.com/technetwork/middleware/soasuite/soa-11gr1-ps2-new-features-097680.html">Oracle SOA Suite 11g Patch Set 2</a>, the Oracle SOA Suite uses the <a href="http://www.springsource.org/about">Spring Framework</a> functionality provided by the WebLogic SCA (Service Component Architecture) of the Oracle WebLogic Server. The WebLogic Spring Container, based on the <a href="http://www.osoa.org/download/attachments/35/SCA_SpringComponentImplementationSpecification-V100.pdf">SCA Spring Component Implementation Specification</a>, can be used for deploying Spring Components wired with SCA semantics. Actually the Oracle SOA Suite supports the Spring Framework<a href="http://www.springsource.org/node/813"> version 2.5.6</a> which was released in November, 2008.<br />
<br />
Oracle marries SCA technology with the benefits of the Spring Framework. Objects created by the Spring Container are called Spring Beans. The Spring Container is configured by loading XML configuration files containing bean definitions which provide the information required to create the beans. Objects can be obtained by means of Dependency Lookup and Dependency Injection. Dependency Lookup (DL) is a pattern where a caller asks the container for an object with a specific name or of a specific type. Dependency Injection (DI) is a pattern where the container passes objects by name to other objects, via constructors, properties, or factory methods.<br />
<br />
Spring Bean development for the usage within an Oracle SCA Composite is easy and straightforward. Spring Beans will be created from new or existing Java classes which should become POJO services within the SCA Composite. The Spring Bean Component Editor is used to create a Spring Bean context definition. Based on a Spring Context, a SCA Spring Bean Component is created that transparently bridges the gap between Java and XML. Internally the Open Source <a href="http://www.eclipse.org/eclipselink/moxy.php">EclipseLink MOXy</a> JAXB implementation is used to map between Java classes and XML representations. Existing Spring Beans could be quickly reused on the Oracle SCA Container.<br />
<br />
The Spring Bean context definition configuration XML file keeps the Spring context definition and shields the service implementation. The context definition configuration XML file will allow for Dependency Lookup and Dependency Injection.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsxagDybAStWaWceR8kuH9Rveo_ZpShkEn672SVtvjB9iYlqbsv3mXWHSfmqFRkXISOt4QQjTeDcfPiKqmi50eS8rvRGNhD6ZuWE-Eoo4aeCfJ0Oz1wZc0pdO1O2A0VqY4ag9vo_c7F3ek/s1600/SCA+Spring+Bean+Configuration.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsxagDybAStWaWceR8kuH9Rveo_ZpShkEn672SVtvjB9iYlqbsv3mXWHSfmqFRkXISOt4QQjTeDcfPiKqmi50eS8rvRGNhD6ZuWE-Eoo4aeCfJ0Oz1wZc0pdO1O2A0VqY4ag9vo_c7F3ek/s320/SCA+Spring+Bean+Configuration.png" width="320" /></a></div><br />
<br />
Spring Beans complete the Oracle SOA platform. Enabling of Java POJOs as SCA Components was definitely a missing feature. The Spring Framework adds the power of Dependency Injection (DI), Aspect Oriented Programming (AOP) and a lot of simplified API abstraction to the Oracle SOA developers.Alexander Suchierhttp://www.blogger.com/profile/07792005839080627159noreply@blogger.com0