com.sap.portal.httpconnectivity.transformationservice

Class TransformersProvider

java.lang.Object
  extended by com.sap.portal.httpconnectivity.transformationservice.AbstractTransformerHolder
      extended by com.sap.portal.httpconnectivity.transformationservice.TransformersProvider
All Implemented Interfaces:
IService

public class TransformersProvider
extends AbstractTransformerHolder

A class that implements a simple transformer provider for the transformation service.
Content developers providing their own persistent transformers must supply a PAR file that declares TransformersProvider as its class name property in portalapp.xml (see the example below).
Providers supplying SAX handlers must extend this class and overwrite the method com.sap.portal.httpconnectivity.transformationservice.ITransformerInformation.getSAXHandler.
Providers supplying a resource bundle must extend this class and overwrite the method Locale.getResourceBundle.
For SAX handlers and resource bundles, the class name property must point to the new derived class. The provider must also register in the portal runtime registry by adding the name of the PAR to portalapp.xml.
The following is an example of a 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> 
 


Field Summary
static String KEY
          The service key.
static String PROVIDER_RESOURCE_BUNDLE_NAME
          A constant that defines the default name for the resource bundle.
 
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()
          If the service is defined as a startup service, this method is called during server startup after all other services have been initialized (that is, after the init methods of all other services have been called).
 void configure(IServiceConfiguration configuration)
          Configures the service.
 ITransformerInformation createTransformerInformation(String componentName, String transformerName, Float transformerVersion, TransformerType transformerType, String fromUri, String toUri, String description)
          Creates a new instance of ITransformerInformation.
 void destroy()
          Destroys the service.
 IServiceContext getContext()
          Gets the context of the provider service set by the Portal Runtime (PRT).
 String getKey()
          Gets a unique key.
 ResourceBundle getResourceBundle(Locale locale)
          Gets the resource bundle for the provider according to the specified locale.
 EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
          Gets the SAX handlers.
 void release()
          Releases the service.
protected  void releaseAllTransformers()
          Releases all the transformers from 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 String PROVIDER_RESOURCE_BUNDLE_NAME
A constant that defines the default name for the resource bundle.


KEY

public static final String KEY
The service key. Do not change the key for your provider.

See Also:
Constant Field Values
Constructor Detail

TransformersProvider

public TransformersProvider()
Method Detail

configure

public final void configure(IServiceConfiguration configuration)
Configures the service. This method is called by the Portal Runtime (PRT).

Parameters:
configuration - a configuration key and value
See Also:
IService

destroy

public final void destroy()
Destroys the service. This method is called by the Portal Runtime (PRT).

See Also:
IService

release

public final void release()
Releases the service. This method is called by the Portal Runtime (PRT).

See Also:
IService

getContext

public final IServiceContext getContext()
Gets the context of the provider service set by the Portal Runtime (PRT).

Returns:
the context of the service
See Also:
IService

getKey

public final String getKey()
Gets a unique key. This method is called by the Portal Runtime (PRT).

Returns:
the unique key for the service
See Also:
IService

afterInit

public final void afterInit()
Description copied from interface: IService
If the service is defined as a startup service, this method is called during server startup after all other services have been initialized (that is, after the init methods of all other services have been called). If the service is not defined as a startup service, or is deployed after server startup, this method is executed immediately after the init method. NOTE: If the service is called during server startup, from within the init method of another service, the init and afterInit methods will be executed together, even if the service is defined as a startup service.


createTransformerInformation

public ITransformerInformation createTransformerInformation(String componentName,
                                                            String transformerName,
                                                            Float transformerVersion,
                                                            TransformerType transformerType,
                                                            String fromUri,
                                                            String toUri,
                                                            String description)
                                                     throws TransformationServiceException
Description copied from class: AbstractTransformerHolder
Creates a new instance of ITransformerInformation. This method is used mainly when registering new transformers.

Specified by:
createTransformerInformation in class AbstractTransformerHolder
Parameters:
componentName - the component name
transformerName - the transformer name
transformerVersion - the transformer version
transformerType - the transformer type
fromUri - the source scheme
toUri - the result scheme
description - the transformer description
Returns:
the transformer information instance
Throws:
TransformationServiceException - if the source data is corrupt, if it cannot write to the result, if one of the transformers doesn't exist or if an error occurs during the transformation

releaseAllTransformers

protected void releaseAllTransformers()
Description copied from class: AbstractTransformerHolder
Releases all the transformers from the holder.
Note: It is strongly recommended not to use this method.

Specified by:
releaseAllTransformers in class AbstractTransformerHolder

getSAXHandler

public EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
                                  throws TransformationServiceException
Description copied from class: AbstractTransformerHolder
Gets the SAX handlers. This method must be overwritten for providers that supply SAX handlers.

Specified by:
getSAXHandler in class AbstractTransformerHolder
Parameters:
tInfo - transformer information
Returns:
the generated SAX handler
Throws:
TransformationServiceException - if the source data is corrupt, if it cannot write to the result, if one of the transformers doesn't exist or if an error occurs during the transformation

getResourceBundle

public ResourceBundle getResourceBundle(Locale locale)
Gets the resource bundle for the provider according to the specified locale. This method is called before executing a transformer. Returns null if the resource bundle doesn't exist.

Parameters:
locale - the locale of the current call to the provider
Returns:
the resource bundle
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] EP-ADMIN [sap.com] tc/ep/admin/api/extd api EP-PIN


Copyright 2011 SAP AG Complete Copyright Notice