Download presentation
Presentation is loading. Please wait.
Published byAugustus Baldwin Modified over 9 years ago
1
Tuscany 2.x Extensibility and SPIs Raymond Feng
2
Tuscany Extensibility http://cwiki.apache.org/confluence/display/TUSCANYxDO Cx2x/Tuscany+2.x+Extensibility+and+SPIs#extensions http://cwiki.apache.org/confluence/display/TUSCANYxDO Cx2x/Tuscany+2.x+Extensibility+and+SPIs#extensions
3
Tuscany Core and Extensions
4
How is Extensibility achieved? Inspired by Eclipse ExtensionPoint/Extension pattern Use Jar service provider configuration files with extended syntax –http://java.sun.com/j2se/1.4.2/docs/guide/jar/j ar.html#Service Provider –META-INF/services/
5
ExtensionPoint Registry
6
META-INF/services META- INF/services/ org.apache.tuscany.sca.contribution. processor.StAXArtifactProcessor –org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.o asis- open.org/ns/opencsa/sca/200903#composite,model=org.apache.tuscany.sca.ass embly.Composite
7
An example
8
Service Discovery Two types of service discovery mechanisms –Classloader –OSGi bundles Sort by ranking attribute (to override default implementations) –A: ;ranking=100 (A is picked) –B: ;ranking=50 Discover by a filter
9
OSGi-friendly Service Discovery Bundle.getResource() An implementation of ExtensionPointRegistry that uses OSGi service registry
10
Service Attributes Similar with OSGi header syntax – ;attr1=value1,attr2=value2 –Both, and ; can be used to separate attributes –| can be used to declare multiple providers on one line – | ;attr1=value1
11
Service Constructors The Tuscany runtime introspects the constrcutors of an implementation class by the following order for extension points – (ExtensionPointRegistry registry) – (ExtensionPointRegistry registry, Map attributes) – () The extension point controls how to instantiate an extension implementation class
12
LifeCycle of Extensions The implementation class of an extension point or extension can optionally implement the LifeCycleListener –start() –stop()
13
Extension Points org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint org.apache.tuscany.sca.core.UtilityExtensionPoint org.apache.tuscany.sca.core.FactoryExtensionPoint org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint org.apache.tuscany.sca.context.ContextFactoryExtensionPoint org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint org.apache.tuscany.sca.databinding.DataBindingExtensionPoint org.apache.tuscany.sca.databinding.TransformerExtensionPoint org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint org.apache.tuscany.sca.host.http.ServletHostExtensionPoint org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint
14
ModuleActivator ModuleActivator is now a special type of LifeCycleListener –void start() –void stop() In 2.x, the implementation class of a ModuleActivator receives ExtensionPointRegistry via constructors instead of start/stop methods Almost all of the 1.x module activators are now converted into regular extension
15
Utility Extension Point A collection of utility functions Replace static singletons with a registry managed utilities Utilities without a META-INF/services configuration –org.apache.tuscany.sca.common.xml.stax.StA XHelper (concrete class)
16
Tuscany SPIs http://cwiki.apache.org/confluence/display/TUSCANYxD OCx2x/Tuscany+2.x+Extensibility+and+SPIs http://cwiki.apache.org/confluence/display/TUSCANYxD OCx2x/Tuscany+2.x+Extensibility+and+SPIs
17
Tuscany SPI packages Listed by OSGi Export-Package header The categories –model interfaces (assembly, implementation- java) –base implementation classes –extension point and extension interfaces (extensibility, core-spi, contribution) –common utilities (common-xml, common-java) –node apis and base implementations
18
Models tuscany-assembly –org.apache.tuscany.sca.assembly –org.apache.tuscany.sca.assembly.builder –org.apache.tuscany.sca.assembly.impl –org.apache.tuscany.sca.definitions –org.apache.tuscany.sca.definitions.util –org.apache.tuscany.sca.interfacedef –org.apache.tuscany.sca.interfacedef.impl –org.apache.tuscany.sca.interfacedef.util –org.apache.tuscany.sca.policy –org.apache.tuscany.sca.policy.impl –org.apache.tuscany.sca.policy.util
19
Interface-java and interface-wsdl Interface-java –org.apache.tuscany.sca.interfacedef.java.impl –org.apache.tuscany.sca.interfacedef.java.introspect –org.apache.tuscany.sca.interfacedef.java Interface-wsdl –org.apache.tuscany.sca.interfacedef.wsdl Xsd –org.apache.tuscany.sca.xsd –org.apache.tuscany.sca.xsd.xml
20
Contribution and deployment Contribution –org.apache.tuscany.sca.contribution.scanner –org.apache.tuscany.sca.contribution.resolver –org.apache.tuscany.sca.contribution.processor –org.apache.tuscany.sca.contribution –org.apache.tuscany.sca.contribution.namespace –org.apache.tuscany.sca.contribution.java Deployment –org.apache.tuscany.sca.deployment –org.apache.tuscany.sca.deployment.impl
21
Extensibility and core-spi Extensibility –org.apache.tuscany.sca.core –org.apache.tuscany.sca.extensibility Core-spi –org.apache.tuscany.sca.context –org.apache.tuscany.sca.invocation –org.apache.tuscany.sca.management –org.apache.tuscany.sca.provider –org.apache.tuscany.sca.runtime –org.apache.tuscany.sca.work Monitor –org.apache.tuscany.sca.monitor
22
Databinding –org.apache.tuscany.sca.databinding –org.apache.tuscany.sca.databinding.xml –org.apache.tuscany.sca.databinding.impl –org.apache.tuscany.sca.databinding.util –org.apache.tuscany.sca.databinding.annotation –org.apache.tuscany.sca.databinding.javabeans
23
Node-api and launcher Node-api –org.apache.tuscany.sca.node –org.apache.tuscany.sca.node.configuration Node-impl –org.apache.tuscany.sca.node.impl
24
Common utilities Common-java –org.apache.tuscany.sca.common.java.classloader –org.apache.tuscany.sca.common.java.collection –org.apache.tuscany.sca.common.java.io –org.apache.tuscany.sca.common.java.reflection Common-xml –org.apache.tuscany.sca.common.xml –org.apache.tuscany.sca.common.xml.dom –org.apache.tuscany.sca.common.xml.sax –org.apache.tuscany.sca.common.xml.stax –org.apache.tuscany.sca.common.xml.stax.reader –org.apache.tuscany.sca.common.xml.xpath
25
A scheme for internal package dependencies Semi-SPIs for internal module dependencies –Export-Package: a.b;version=2.0.0;internal=true;mandatory:=int ernal –Import-Package: a.b;version=2.0.0;internal=true
26
Changed SPIs Monitor is now mostly request-scoped New Builder SPIs for extensions (implementation, binding and policy) Context –CompositeContext (maybe should be named as NodeContext) –ProcessorContext –BuilderContext
27
Changed SPIs (2) ???ProviderFactory.create???Provider() now takes RuntimeEndpoint for service binding and RuntimeEndpointReference for reference binding RuntimeWire is removed. RuntimeEndpoint and RuntimeEndpointReference own the invocation chains.
28
References
29
Useful Links http://cwiki.apache.org/confluence/display/ TUSCANYxDOCx2x/Tuscany+2.x+Extensi bility+and+SPIshttp://cwiki.apache.org/confluence/display/ TUSCANYxDOCx2x/Tuscany+2.x+Extensi bility+and+SPIs http://www.manning.com/laws/ (Chapter 13 and Chapter 14)http://www.manning.com/laws/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.