com.sap.portal.httpconnectivity.transformationservice
Class TransformersProvider

java.lang.Object
  |
  +--com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
        |
        +--com.sap.portal.httpconnectivity.transformationservice.TransformersProvider
All Implemented Interfaces:
com.sapportals.portal.prt.service.IService

public class TransformersProvider
extends AbstractTransformerHolder

Service that implements a simple transformers provider for the transformation service.
Content developer that would like to provide his own persistent transformers should supply par file that declares this class as it's class name property in the portalapp.xml (see example).
Providers that would like to supply SAX handlers must extend this class and overwrite method getSAXHandler(). Providers that would like to provide ResourceBundle that will be used in their transformers must extend this class ans overwrite getResourceBundle() method. The new derived class must be located in the core part of the service. In both last cases the class name property must point to the new implemented derived class.
The provider must also register the provider in the portal runtime registry by adding the name of the par to the portalapp.xml.
Example of provider where the par name is com.sap.portal.SimpleTransformerProvider:
1. portalapp.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <application>
   <registry>
       <entry path="runtime/transformers/com.sap.portal.SimpleTransformerProvider" 
           name="TransformersProvider"
           type="service"/> 
   </registry>
   <application-config>
      <property name="ServicesReference" value="com.sap.portal.htmlb,com.sap.portal.transformationservice"/>
       <property name="releasable" value="false"/>     
       <property name="startup" value="true"/>
   </application-config>
  <components/>
   <services>
       <service name="TransformersProvider">
           <service-config>
               <property name="className" value="com.sap.portal.httpconnectivity.transformationservice.TransformersProvider"/>
               <property name="classNameFactory" value=""/>
               <property name="classNameManager" value=""/>
               <property name="SecurityZone" value="com.sap.portal/no_safety" />
           </service-config>
       </service>
   </services>
</application>
 

2. Transformers.xml:
<?xml version="1.0" encoding="utf-8"?>
<transformation-resources>
   <transformers type="XSL"><!-- Holder of XSL transformers -->
       <transformer>       <!-- Represet single transforemr -->
           <property name="Name"       value="SIMPLE_TRANSFORMER"/> <!-- Name of the transformer-->
           <property name="Description"    value="Transform from my scheme to XHTMLB"/>         
           <property name="FromURI"    value="MY_SCHEME"/>           <!-- Source scheme URI -->
           <property name="ToURI"      value="XHTMLB"/>        <!-- result scheme URI -->
           <property name="SourceName" value="MY_SCHEME_TO_XHTMLB.xsl"/><!-- XSL file name -->
               <!-- Transformer version, allows you to add new versions of transformers without the need to 
                   change the code that use these transformers -->
           <property name="Version"    value="1.0"/>                                       
       </transformer> 
          <!-- You can add more transformers here -->
   </transformers> 
</transformation-resources> 
 

Version:
$Revision$

Field Summary
static java.lang.String KEY
          Key of the service.
static java.lang.String PROVIDER_RESOURCE_BUNDLE_NAME
          Default name for the resource bundle name
 
Fields inherited from class com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
m_serviceContext, TRNS_HLDR_CATEGORY, TRNS_HLDR_LOCATION, TRNS_HLDR_LOG_SUBLOC
 
Constructor Summary
TransformersProvider()
           
 
Method Summary
 void afterInit()
           
 void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)
          configure the service
 ITransformerInformation createTransformerInformation(java.lang.String componentName, java.lang.String transformerName, java.lang.Float transformerVersion, TransformerType transformerType, java.lang.String fromUri, java.lang.String toUri, java.lang.String description)
          Create new instance of ITransformerInformation.
 void destroy()
          This method is called by the portal runtime when the service is destroyed.
 com.sapportals.portal.prt.service.IServiceContext getContext()
          Get the context of the provider service
 java.lang.String getKey()
          This method should return a string that is unique to this service amongst all other services deployed in the portal runtime.
 java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
          Get the resource bundle assosiated with the provider according to a locale.
 EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
          Method that is used to get the SAX handlers.
 void release()
          This method is called by the portal runtime when the service is released.
protected  void releaseAllTransformers()
          Release all the transformers of the holder
 
Methods inherited from class com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
getSAXClassName, getTransformersResourcePath, getXSLTransformerPath, init, loadTransformers, setTransformers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVIDER_RESOURCE_BUNDLE_NAME

public static java.lang.String PROVIDER_RESOURCE_BUNDLE_NAME
Default name for the resource bundle name

KEY

public static final java.lang.String KEY
Key of the service. Do not try to change the key on your provider.
Constructor Detail

TransformersProvider

public TransformersProvider()
Method Detail

configure

public final void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)
configure the service
Parameters:
configuration -  

destroy

public final void destroy()
This method is called by the portal runtime when the service is destroyed.

release

public final void release()
This method is called by the portal runtime when the service is released.

getContext

public final com.sapportals.portal.prt.service.IServiceContext getContext()
Get the context of the provider service
Returns:
the context of the service, which was previously set by the portal runtime

getKey

public final java.lang.String getKey()
This method should return a string that is unique to this service amongst all other services deployed in the portal runtime.
Returns:
a unique key of the service

afterInit

public final void afterInit()

createTransformerInformation

public ITransformerInformation createTransformerInformation(java.lang.String componentName,
                                                            java.lang.String transformerName,
                                                            java.lang.Float transformerVersion,
                                                            TransformerType transformerType,
                                                            java.lang.String fromUri,
                                                            java.lang.String toUri,
                                                            java.lang.String description)
                                                     throws TransformationServiceException
Description copied from class: AbstractTransformerHolder
Create new instance of ITransformerInformation. Used mainly when setting new transformers.
Overrides:
createTransformerInformation in class AbstractTransformerHolder
Following copied from class: com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
Parameters:
componentName - the component name
transformerName - the transformer name
transformerVersion - the version of the transformer
transformerType - type of transformer
fromUri - source scheme
toUri - result scheme
description - transformer description
Returns:
transformer information instance
Throws:
TransformationServiceException - when input data is missing
See Also:
by the defining it's properties

releaseAllTransformers

protected void releaseAllTransformers()
Description copied from class: AbstractTransformerHolder
Release all the transformers of the holder
Overrides:
releaseAllTransformers in class AbstractTransformerHolder

getSAXHandler

public EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
                                  throws TransformationServiceException
Description copied from class: AbstractTransformerHolder
Method that is used to get the SAX handlers. This method must be overwritten in providers that provides SAX handlers.
Overrides:
getSAXHandler in class AbstractTransformerHolder
Following copied from class: com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
Parameters:
tInfo - the transformer information
Returns:
the generated sax handler
Throws:
TransformationServiceException - when cannot instancite SAX handler

getResourceBundle

public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
Get the resource bundle assosiated with the provider according to a locale. This method will be called each time before execution of the transformer.
Parameters:
locale - the locale of current call to the provider
Returns:
the resource bundle if it exists, or null if doesn't