Apache Tuscany 2.x Extensibility and SPIs  Raymond Feng [email_address]
Tuscany Extensibility http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Tuscany+2.x+Extensibility+and+SPIs#extensi...
Tuscany Core and Extensions
How is Extensibility achieved? <ul><li>Inspired by Eclipse ExtensionPoint/Extension pattern </li></ul><ul><li>Use Jar serv...
ExtensionPoint Registry
META-INF/services <ul><li>META-INF/services/ org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor </li></ul...
An example
Service Discovery <ul><li>Two types of service discovery mechanisms </li></ul><ul><ul><li>Classloader </li></ul></ul><ul><...
OSGi-friendly Service Discovery <ul><li>Bundle.getResource() </li></ul><ul><li>An implementation of ExtensionPointRegistry...
Service Attributes <ul><li>Similar with OSGi header syntax  </li></ul><ul><ul><li><ClassName>;attr1=value1,attr2=value2 </...
Service Constructors <ul><li>The Tuscany runtime introspects the constrcutors of an implementation class by the following ...
LifeCycle of Extensions  <ul><li>The implementation class of an extension point or extension can optionally implement the ...
Extension Points <ul><li>org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint </li></ul><ul><li>org.apache.tuscany.sc...
ModuleActivator <ul><li>ModuleActivator is now a special type of  LifeCycleListener </li></ul><ul><ul><li>void start() </l...
Utility Extension Point <ul><li>A collection of utility functions </li></ul><ul><li>Replace static singletons with a regis...
Tuscany SPIs http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Tuscany+2.x+Extensibility+and+SPIs
Tuscany SPI packages <ul><li>Listed by OSGi Export-Package header </li></ul><ul><li>The categories </li></ul><ul><ul><li>m...
Models <ul><li>tuscany-assembly </li></ul><ul><ul><li>org.apache.tuscany.sca.assembly  </li></ul></ul><ul><ul><li>org.apac...
Interface-java and interface-wsdl <ul><li>Interface-java </li></ul><ul><ul><li>org.apache.tuscany.sca.interfacedef.java.im...
Contribution and deployment <ul><li>Contribution </li></ul><ul><ul><li>org.apache.tuscany.sca.contribution.scanner  </li><...
Extensibility and core-spi  <ul><li>Extensibility </li></ul><ul><ul><li>org.apache.tuscany.sca.core  </li></ul></ul><ul><u...
Databinding <ul><li>Databinding </li></ul><ul><ul><li>org.apache.tuscany.sca.databinding  </li></ul></ul><ul><ul><li>org.a...
Node-api and launcher <ul><li>Node-api </li></ul><ul><ul><li>org.apache.tuscany.sca.node  </li></ul></ul><ul><ul><li>org.a...
Common utilities <ul><li>Common-java </li></ul><ul><ul><li>org.apache.tuscany.sca.common.java.classloader  </li></ul></ul>...
A scheme for internal package dependencies <ul><li>Semi-SPIs for internal module dependencies </li></ul><ul><ul><li>Export...
Changed SPIs <ul><li>Monitor is now mostly request-scoped </li></ul><ul><li>New Builder SPIs for extensions (implementatio...
Changed SPIs (2) <ul><li>???ProviderFactory.create???Provider() now takes RuntimeEndpoint for service binding and RuntimeE...
References
Useful Links <ul><li>http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Tuscany+2.x+Extensibility+and+SPIs </li></u...
Upcoming SlideShare
Loading in …5
×

Apache Tuscany 2.x Extensibility And SPIs

1,476 views

Published on

Apache Tuscany 2.x Extensibility And SPIs

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,476
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
40
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Apache Tuscany 2.x Extensibility And SPIs

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

×