Home > Apache Tuscany Docs 2.x > Index > Development Guides > SCA Java Runtime Overview |
Apache Tuscany Docs 2.x > Index > Development Guides > SCA Java Runtime Overview | Tuscany Home | User List | Dev List | Issue Tracker |
Apache Tuscany Docs 2.x
SCA Java Runtime Overview
Software OrganizationSource Code LocationsIf you take a Tuscany SCA Java source distribution or look in the Tuscany subversion repository (http://svn.apache.org/repos/asf/tuscany/java/sca/) you'll see the code layed out as follows: BUILDING CHANGES LICENSE NOTICE README RELEASE_NOTES distribution - the code that defines and build Tuscany distributions features - Maven projects that collect together Tuscany modules maven archetypes - Maven archetypes for creating Tuscany project templates maven-tuscany-plugin - ??? modules - the source code for the runtime and the SCA extensions samples - project samples testing itest - project integration tests compliance-tests - OASIS compliance tests pom.xml There is some related source code that's worth mentioning up front. Firstly the project Maven build relies on a set of Maven plugins that have been written specifically for Tuscany. They can also be found in the Tuscany subversion repository (http://svn.apache.org/repos/asf/tuscany/maven-plugins/trunk/) and are as follows:
maven-bundle-plugin - Creates Tuscany OSGi bundles based on the Tuscany modules and their dependencies
also generates eclipse PDE projects for Tuscany modules
maven-eclipse-compiler - Compiles using the Eclipse compiler and performs OSGi validation
maven-java2wsdl-plugin - TBD
maven-osgi-junit - Runs Junit tests in an OSGi environment
maven-tuscany-plugin - TBD
maven-wsdl2java-plugin - TBD
Secondly there are a set of tests that the OASIS SCA specifications define called otests. These test the Tuscany SCA runtime for compliance with the specifications. The tests themselves are stored in the OASIS subversion system (http://tools.oasis-open.org/version-control/browse/). Tuscany has a set of modules that retrieve these tests automatically and configure the Tuscany environment to run them (http://svn.apache.org/repos/asf/tuscany/otest/) as follows: README build.xml - Ant utility script pom.xml sca-assembly - Generated automatically by svn externals when you check this directory out sca-java-caa - Generated automatically by svn externals when you check this directory out sca-java-ci - Generated automatically by svn externals when you check this directory out sca-policy - Generated automatically by svn externals when you check this directory out tuscany-java-caa-test-runner - Java Common Annotations and APIs test runner tuscany-java-ci-test-runner - Java Component Implementation test runner tuscany-policy-test-runner - Policy test runner tuscany-test-runner - Assembly test runner SCA Java ModulesAll of the functional code in Tuscany Java SCA can be found under the modules directory. There are a lot of sub-directories here but they basically fall into one of two categories, core function or extensions. We are using the term extension here in the sense that the SCA Assembly specification talks about and extension model You always have to have the core functions but most of the extensions are optional (we say most here because without some of the basic extensions the runtime won't do anything) Finding extension modules is easy. Modules that start with the following words are extensions.
binding
databinding
implementation
interface
policy
As you can see SCA extensions relate to the extensible parts of the SCA composite file. For example, if you want to use <binding.jms/> in you SCA composite files then you need to include the Tuscany modules for this extension in you installation. In this case that would mean the modules binding-jms and binding-jms-runtime. All of the other modules in the modules directory are core modules and are generally required to be present in you Tuscany runtime installation. The use of the word "generally" here sounds a bit vague. This is because the Tuscany runtime itself is based on an extensibility mechanism which means that many parts of the runtime (as well as the SCA extensions) are pluggable. In this way, for example, different hosting environments can be supported. Well talk about runtime extensibility further down this article but for the time being consider all core modules to be mandatory. Runtime Building BlocksAs you may have realized the Tuscany SCA Java runtime is just a Java program that, once started listens for incoming messages (via SCA component services) and, sometimes responds with outgoing messages (via SCA component references).
The runtime then provides the context within which SCA composite applications run. If we crack open the Tuscany Runtime box we see the following structure.
We'll take a high level look at these different blocks in turn starting with Core. Tuscany CoreThe Tuscany core is made up of several modules that provide basic runtime and extensibility support to the extensions that provide the real SCA functions. If you look in the modules directory of a Tuscany distribtuion (2.0-M4 at the time of writing - this list may change in subsequent releases) the modules that make up the Tuscany core are as follows: assembly - The in-memory model of an OASIS SCA composite application (sometimes called an assembly) assembly-xml - The Tuscany processors that translate to and from XML and the in-memory model assembly-xsd - The schema used to validate the contents of various SCA files, e.g. the composite file builder - Process the in-memory model to build a complete SCA application representation common-java - General Java utilities common-xml - General XML utilities contribution - Read and process SCA contributions core - The core Tuscany SCA Java runtime functions core-databinding - The core databinding functions core-spi - The Java interfaces that extension developers use to create and register extensions databinding - Builds on the core databinding functions to provide features common to all databindings??? deployment - Loads the runtime and orchestrates the loading of SCA contributions extensibility - Reads META-INF/services files and manages Tuscany extensibility extensibility-equinox - Manages Tuscany extensibility in an OSGi environment host-http - Base interfaces for providing integration with a servlet container interface-java - Java interface model and instrospection interface-java-jaxws - Process JAX-WS annotations from a Java interface interface-wsdl - WSDL interface model launcher - Command line Tuscany runtime launcher monitor - Collects errors as they occur in the Tuscany runtime node-api - API for accessing an embedded Tuscany node (A node loads/runs contributions) node-impl - The JSE implementation for the node API node-impl-osgi - The OSGi implementation for the node API ???? node-launcher - The JSE based command line launcher for a Tuscany node node-launcher-equinox - The OSGi based command line launcher for a Tuscany node sca-api - The OASIS defined SCA API sca-client-impl - The Tuscany implementation of the OASIS defined SCA client xsd - The in-memory model of an XSD file, along with the processors to read it We have already said that there are a set of extensions that, while in theory they are are optional, are in practice required to do anything useful. These are are follows: binding-sca-runtime - The implementation for the local version of binding.sca binding-sca-axis2-runtime - The implementation for the remote version of binding.sca based on web services binding-ws - The in-memory model for binding.ws binding-ws-axis2 - TBD - should be called runtime binding-ws-axis2-policy - TBD binding-ws-wsdlgen - TBD databinding-axiom - The databinding for Axiom databinding-jaxb - The databinding for JAXB databinding-jaxb-axiom - TBD endpoint-tribes - The distributed endpoint registry based on tribes host-jetty - Allows Jetty to be started automatically to support HTTP based bindings host-webapp - Allows Tuscany to be embedded in a WAR implementation-java - The in-memory model for implementation.java implementation-java-runtime - The runtime artifacts for implementation.java The rest of the modules are optional and can be omitted. In practice the easiest way to get started is to keep all of the modules. By default this is what you get when you install the binding distribution. In the future you're free to remove the extensions you don't use to reduce the size of the installation. The Tuscany project may even make releases in the future that package sets of extensions targeted at particular types of application. Tuscany SCA APIThe Tuscany SCA API is used by SCA applications to access various information from the runtime. It's not mandatory to use the API but it can be useful in some circumstances. launcher Tuscany API node-api Tuscany API node-launcher Tuscany API node-launcher-equinox Tuscany API sca-api OASIS API sca-client-impl OASIS API Tuscany SPIThe Tuscany SPI is generally used for building extensions. Extensions come in two flavours SCA extensions, like implementation and binding types, and Tuscany runtime extensions, like builders and binders. Both of these types of extension are discussed a little later in this article. The modules and module packages that describe the Tuscany SPI are as follows: assembly org.apache.tuscany.sca.assembly org.apache.tuscany.sca.definitions org.apache.tuscany.sca.interfacedef org.apache.tuscany.sca.policy assembly-xsd sca-core-1.1.xsd sca-policy-1.1.xsd contribution org.apache.tuscany.sca.contribution org.apache.tuscany.sca.contribution.java org.apache.tuscany.sca.contribution.namespace org.apache.tuscany.sca.contribution.processor org.apache.tuscany.sca.contribution.resolver org.apache.tuscany.sca.contribution.scanner core org.apache.tuscany.sca.core.assembly org.apache.tuscany.sca.core.context org.apache.tuscany.sca.core.factory org.apache.tuscany.sca.core.invocation org.apache.tuscany.sca.core.scope core-databinding org.apache.tuscany.sca.core.databinding.processor core-spi (why not extension SPI?) org.apache.tuscany.sca.context org.apache.tuscany.sca.invocation org.apache.tuscany.sca.provider org.apache.tuscany.sca.runtime org.apache.tuscany.sca.work databinding org.apache.tuscany.sca.databinding org.apache.tuscany.sca.databinding.annotation org.apache.tuscany.sca.databinding.javabeans org.apache.tuscany.sca.databinding.util org.apache.tuscany.sca.databinding.xml deployment org.apache.tuscany.sca.deployment extensibility org.apache.tuscany.sca.core org.apache.tuscany.sca.extensibility monitor org.apache.tuscany.sca.monitor xsd org.apache.tuscany.sca.xsd More detail on extension points and SPIs can be found here Tuscany Runtime Extensibility and ExtensionsAs we've already mentioned the Tuscany core doesn't do much on it's own apart from providing basic features and support the plugging in of extensions which do the real work. Extensions come in two forms. Extension types defined by the OASIS SCA specifications and those that are particular to Tuscany. In the first category are the extension types defined by the OASIS Assembly specification:
The Tuscany runtime defines it's own extension types which exploit the core runtimes extensibility features
The Tuscany extensibility framework is based on two simple ideas. Firstly that the Tuscany runtime provides extension points into which extension functions can be plugged. Secondly that the the Java META-INF/services mechanism provides a way for extension developers to register new extension functions with these extension points. The Tuscany extensibility framework exposes quite a few extension points, for example,(o.a.t.s = org.apache.tuscany) org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint org.apache.tuscany.sca.assembly.builder.BindingBuilder org.apache.tuscany.sca.assembly.builder.CompositeBuilder org.apache.tuscany.sca.assembly.builder.ContractBuilder org.apache.tuscany.sca.assembly.builder.ImplementationBuilder org.apache.tuscany.sca.core.FactoryExtensionPoint org.apache.tuscany.sca.assembly.AssemblyFactory org.apache.tuscany.sca.assembly.SCABindingFactory org.apache.tuscany.sca.binding.atom.AtomBindingFactory org.apache.tuscany.sca.binding.comet.CometBindingFactory org.apache.tuscany.sca.binding.corba.CorbaBindingFactory org.apache.tuscany.sca.binding.ejb.EJBBindingFactory org.apache.tuscany.sca.binding.http.HTTPBindingFactory org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory org.apache.tuscany.sca.binding.rest.RESTBindingFactory org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory org.apache.tuscany.sca.binding.rmi.RMIBindingFactory org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory org.apache.tuscany.sca.contribution.ContributionFactory org.apache.tuscany.sca.contribution.java.JavaImportExportFactory org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory org.apache.tuscany.sca.definitions.DefinitionsFactory org.apache.tuscany.sca.implementation.bpel.BPELFactory org.apache.tuscany.sca.implementation.java.JavaImplementationFactory org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory org.apache.tuscany.sca.implementation.web.WebImplementationFactory org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory org.apache.tuscany.sca.invocation.MessageFactory org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory org.apache.tuscany.sca.policy.PolicyFactory org.apache.tuscany.sca.context.ContextFactoryExtensionPoint org.apache.tuscany.sca.context.ComponentContextFactory org.apache.tuscany.sca.context.PropertyValueFactory org.apache.tuscany.sca.context.RequestContextFactory org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint org.apache.tuscany.sca.contribution.processor.ValidationSchema org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint org.apache.tuscany.sca.contribution.resolver.ModelResolver org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint org.apache.tuscany.sca.core.ModuleActivator org.apache.tuscany.sca.databinding.DataBindingExtensionPoint org.apache.tuscany.sca.databinding.DataBinding org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint org.apache.tuscany.sca.databinding.TransformerExtensionPoint org.apache.tuscany.sca.databinding.PullTransformer org.apache.tuscany.sca.databinding.PushTransformer org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint org.apache.tuscany.sca.definitions.xml.Definitions org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint org.apache.tuscany.sca.host.http.ServletHostExtensionPoint org.apache.tuscany.sca.host.http.ServletHost org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint org.apache.tuscany.sca.provider.BindingProviderFactory org.apache.tuscany.sca.provider.ImplementationProviderFactory org.apache.tuscany.sca.provider.PolicyProviderFactory org.apache.tuscany.sca.provider.WireFormatProviderFactory org.apache.tuscany.sca.provider.OperationSelectorProviderFactory org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint org.apache.tuscany.sca.runtime.DomainRegistryFactory org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint org.apache.tuscany.sca.runtime.RuntimeWireProcessor org.apache.tuscany.sca.core.UtilityExtensionPoint org.apache.tuscany.sca.databinding.Mediator org.apache.tuscany.sca.databinding.SimpleTypeMapper org.apache.tuscany.sca.core.scope.ScopeRegistry org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper org.apache.tuscany.sca.deployment.Deployer org.apache.tuscany.sca.interfacedef.FaultExceptionMapper org.apache.tuscany.sca.interfacedef.InterfaceContractMapper org.apache.tuscany.sca.monitor.MonitorFactory org.apache.tuscany.sca.runtime.CompositeActivator org.apache.tuscany.sca.runtime.EndpointReferenceBinder org.apache.tuscany.sca.runtime.EndpointSerializer org.apache.tuscany.sca.runtime.RuntimeProperties org.apache.tuscany.sca.work.WorkScheduler org.apache.tuscany.sca.node.NodeFactory org.apache.tuscany.sca.xsd.XSDFactory Extension points are usually used in groups. You have to populate the right extension points when implementing say an implementation or a binding extensions. The best way to get a grip on how this works is to look at existing extensions and see what they do. As an example, if you look at how the implementation.java extension registers an extension to read the <implemenation.java/> element from a composite file and turn it into an in-memory Java model you will see the following file: modules/implementation-java/src/main/resources/META-INF/services/o.a.t.s.contribution.processor.StAXArtifactProcessor Which contains a single line as follows: org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#implementation.java,model=org.apache.tuscany.sca.implementation.java.JavaImplementation This tells the Tuscany runtime to register and extension in the StAXArtifactProcessorExtensionPoint with the follwing properties:
The full set of extension points required to represent the implementation.java extension is spread across the implemenation-java and implementation-java-runtime modules as follows: implementation-java
implementation-java-runtime
All of these extension point entries come together at runtime to allow Tuscany to process implementation.java elements that appear in composite files. Most extension are packaged in a least two modules. For example the implementation.java extension is provided in the following modules: modules/implementation-java - the implementation.java model classes and XML processor modules/implementation-java-runtime - the runtime artifacts such as the runtime providers You will currently see extension that don't match this pattern. Often this is because the extension has been moved into 2.x from 1.x but has not been tidied up yet. More detail on extension points and SPIs can be found here Runtime hosting and containers, OSGi, JSE, Webapps etc.The Tuscany runtime will work in the JSE environment and when deployed to an OSGi runtime like Felix or Equinox. Since 1.x we have been through an exercise of refactoring all of the runtime modules into OSGi bundles and providing consistent OSGi manifest files. See (http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/OSGi+Enablement+for+Tuscany+Runtime) for more details on how we OSGi-igfied the Tuscany runtime. A launcher is provided to each environment. For JSE use the following class from modules/node-launcher: org.apache.tuscany.sca.node.launcher.NodeLauncher For in OSGi in the Equinoz framework use the following class from modules/node-launcher-equinox: org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher In both cases you use the launcher to create a node instance as follows: Node node = launcher.createNode(new Contribution("contrib1", "./contrib1.jar"), new Contribution("contrib2", "./contrib2.jar")); node.start(); When you use the JSE launcher the runtime starts and creates a classpath to load the Tuscany runtime. It uses the following algorithm (coded in the NodeLauncherUtil.runtimeClassloader method) to create the classpath:
When you use the OSGI launcher the algorithm is similar but of course this time the Tuscany bundles are loaded into the OSGi framework. The node launcher starts up the Equinox framework and then goes looking for bundles to load using the following algorithm:
There is no single classpath that gives access to the Tuscany runtime. TODO what features of the OSGi integration do we need to cover in this overview? You can of course use the launchers from the command line in various guises. TBD TODO - what other ways are we actually going to support for starting the runtime? SCA Domain and NodesThe design for the 2.x SCA domain is based on a registry that is accessible from all nodes that are running composites in the domain. There is also the intention to add a management mechanism to allow for central control of the nodes. This is not in place yet.
It is out intention to bring the Domain Manager function over from the 1.x code base to provide a central place for adding contributions and assigning them to nodes. This time though it won't be mandatory to run a Domain Manager to have nodes run a distributed SCA application. If you are happy to configure nodes directly and start them individually you are able to do that. The domain manager will just be one of a number of applications that can sit on top of and exploit the distributed registry. The registry holds information that is common across the domain including:
The following diagram shows an example of domain data populating the registry and two nodes, in separate JVMs, running separate composites from the SCA application
With no domain manager each node is started with a set of contributions. A node reads the contributions and processes deployed composites ready to run. As part of this processing domain level information, such as deployed endpoints and available policies, is published to the registry for other nodes to find. When domain level information is required by a node, for example, when a component reference targets a service running on a different node in the domain, the information can be obtained by looking in the registry. If a domain manager is present it can pre-process all available contributions and pre-populate the registry as required. This is however not mandatory. Runtime LifecycleCreateRuntime creation is contrilled by the environment in which the runtime is being started. For example, if you are running Tuscany from the runtime then using the node launcher will start the runtime. Alternatively if you are deploying Tuscany embedded in a web app then the runtime will not be started until the WAR file is deployed. See the previous hosting section for more details. ReadWhen a node is started and configured with the location of a contribution, for example, Node node = launcher.createNode(new Contribution("contrib1", "./contrib1.jar"), new Contribution("contrib2", "./contrib2.jar")); the node will look at each contribution and identify all of the aritifacts that it holds. Artifacts can be anything from XML, XSD, WSDL and Java .class files to the SCA .composite files. Once the node knows what artifacts are available in all of its input contributions it will read the composite files. It does this using the extension processors that are provided with each extension. The output of reading the composite file is an in-memory model of the SCA application. This model is used to configured the runtime in later phases. ResolveThe in-memory model that results from the read phase will contain a lot of unresolved references. For example, for a component that uses
<implementation.java class="my.package.MyClassImpl"/>
The model knows the name of the class file that will be used to implement the component but it doesn't actually have a reference to that real Java class. These references are resolved in the resolve phase. Again the extension processors are used and this time their resolve method looks through the available contributions, using the import/export relationships, to locate referenced artifacts. BuildOnce we get to this stage we have an in-memory model that faithfully matches what was present in the .composite files that are deployed to the node. We now need to build the model to prepare it read for creating the runtime artifacts. There are a number of things that we need to do an primarily the process involves applying the SCA rules to calculate a complete model of the application based on the input composite files. The input composite files don't necessarily contain all of the right details in the right places, for example, imagine a Java component implementation as follows: @Service(MyClass.class) class MyClassImpl implements MyClass { @Reference protected MyOtherClass myOtherClassReference; public String doSomething(String input){ return myOtherClassReference.doSomething(input); } } We can define an SCA component as follows: <component name="MyComponent"> <implementation.java class="my.package.MyClassImpl"/> </component> We haven't said that this component defines any services or references but based on the component type implied by the MyClassImpl class we know that it really as a service called "MyClass" and a reference called "myOtherClassReference". The build processThe build process applies these kinds of rules and enhances the in-memory model with all of the implied information. The following diagram shows the basic process and the steps that form the process.
The steps are as follows:
The endpoints and endpoint references provide the runtime connection between the component implementations and the bindings protocols used when communicating with other components. The hold all of the message handling chains in the runtime. Endpoints and Endpoint ReferencesThe following diagram shows how enpoints and enpoint references relate to the model of the more recognizable component references and services.
And endpoint maps to a service binding and an endpoint reference maps to a reference target (or a configured reference binding if one is present instead of a target).You will note that endpoints and endpoint references are used to represent callbacks too. An service that specifies a callback gives rise to one or more callback endpoint references. These sit behind the callback proxy at runtime. An endpoint reference that specifies a callback gives rise to a callback endpoint. This endpoint receives callback messages. Looking in more detail you can see that both endpoints and endpoint references hold the interceptor chains that proces references side (endpoint reference) and service side (endpoint) messages. At the end of the interceptor chain endpoint information is placed into the protocol message. The following diagram shows how the web service binding uses endpoint information in forward and callback messages.
The twist here is that while a forward Tuscany message has a from field that points to the source endpoint reference when this gets turned into a SOAP envelope the from field represents the callback endpoint if there is one. Building endpoints and endpoint referencesThe following diagram shows how endpoints and endpoint references are created and used at a very high level.
ActivateAt the activate stage the various extension providers are created as required. StartDuring start the "start" operation is called on all active providers in order to perform any extension specific start processing. Message ProcessingReference side operation and binding chains
Service side operation and binding chains
StopDuring stop the "stop" operation is called on all started providers in order to perform any extension specific stop processing. DeactivateDuring the deactivate stage the various parts of the runtime model are picked apart to allow for successful garbage collection. InterfacesMapping interfaces to the runtime model
Reference side runtime interface driven databinding processing
Service side runtime interface driven databinding processing
Children
Show Children
|
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2010, The Apache Software Foundation, Licensed under ASL 2.0. |