2016/05/28 - Apache Tuscany has been retired.

For more information, please explore the Attic.

 
 Apache Tuscany > Home > SCA Overview > SCA Java > Java SCA Documentation Menu > SCA Java Extension Development Guide > Mike Edwards Ramble through Adding a New Implementation Type > Adding the Spring Implementation Type User List | Dev List | Issue Tracker  

(3rd May 2007) This pages and the pages hung off it describe the creation of the module which supports the Spring Component Type that I am working on for a demo. This might be useful to anyone looking to build their own Component Type implementation.

Sequence

Order Work Item
Comment
0
implementation-spring module created

org.apache.tuscany.implementation.spring package
 
1 Created ModuleActivator file
Points at the SpringModuleActivator class
2 Create SpringModuleActivator class Core of the Spring implementation module
3
Create SpringArtifactProcessor class
Reads the implementation.spring xml in the composite file
- one required attribute = location, which specifies the location of the Spring application context
Creates the implementationSpring instance
Initiates resolution of the componentType of the Spring application context by calling SpringXMLComponentTypeLoader
4
Create SpringXMLComponentTypeLoader class
Reads the Spring application context and introspects the Beans referenced from it to determine the component type of the Spring implementation (ie Services, References, Properties)
     
     
     
     
     

ModuleActivator file

Placed into the resources/META-INF/services directory:

# Implementation class for the ExtensionActivator
org.apache.tuscany.implementation.script.ScriptModuleActivator

SpringModuleActivator class 

Constructor

Creates resources used by other parts of the Module implementation:

  • AssemblyFactory
  • JavaInterfaceFactory
  • PolicyFactory

start()

Takes an ExtensionPointRegistry as input parameter, which provides access to configuration of the core.

  • Creates a SpringArtifactProcessor and adds to the registry StAXArtifactProcessors
  • Creates a SpringImplementationProviderFactory and adds to the registry ProviderFactories

Creates a series of artifacts that are required by the SpringArtifactProcessor and SpringImplementationProviderFactory:

  • ExtensibleJavaInterfaceIntrospector (used to introspect Spring Beans)
  • JavaPropertyValueObjectFactory

stop()

Removes the SpringArtifactProcessor from the registry StAXArtifactProcessors 

getExtensionPoints() 

Returns a very simple DefaultJavaClassIntrospectorExtensionPoint. 

SpringArtifactProcessor class 

Handles the <implementation.spring..../> element used in composite files.

Constructor

Takes a series of classes used  in loading & resolution:

  • AssemblyFactory
  • JavaInterfaceFactory
  • JavaInterfaceIntrospector
  • PolicyFactory 
  • JavaPropertyValueObjectFactor

read()

Reads the <implementation.spring.../> element from the composite.

Gets the location attribute - throws an exception if the attribute is missing. 

Creates a SpringImplementation instance, sets its location field and returns it. 

resolve() 

Given the SpringImplementation instance and a ModelResolver, gets the ComponentType for the implementation.

Does this by invoking  SpringXMLComponentTypeLoader.load() - will follow up by reading a side file if this does not fully resolve the component type.

getArtifactType() 

Returns the fully qualified name of the implementation.spring element (includes the SCA namespace...)  

 SpringXMLComponentTypeLoader class

  1.  

Resolution of the ComponentType of Spring application context

ComponentType of the Spring application-context is performed by reading the application-context.xml file and by introspecting the Java beans which it references. This is done by the SpringXMLComponentTypeLoader class.

website stats