com.sap.portal.httpconnectivity.transformationservice

Class AbstractTransformerHolder

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

public abstract class AbstractTransformerHolder
extends Object
implements IService

An abstract class for creating a transformer holder. Provides methods to load transformers defined in the PAR file.
<par path>/xml/Transformers.xml defines the transformers. The XSL transformers must be located in the folder <par path>/xml/XSLLibrary/Transformers.
The following shows the required folder structure:

...
  -<par name>
    - xml
     | Transformers.xml
     - XSLLibrary
       - Transformers
         Transformer1.xsl
         Transformer2.xsl
 ...  
 

Transformers are initialized automatically when the service is initialized. The loading process is:
  1. Release all provider transformers.
  2. Get the list of ITransformerInformation objects from the Transformers.xml file.
  3. Register the transformers with the transformation service.


Field Summary
protected  IServiceContext m_serviceContext
          A constant that defines the service context.
static com.sap.tc.logging.Category TRNS_HLDR_CATEGORY
          A constant that defines the log category.
static com.sap.tc.logging.Location TRNS_HLDR_LOCATION
          A constant that defines the log location.
protected static String TRNS_HLDR_LOG_SUBLOC
          A constant that defines the sublocation.
 
Constructor Summary
AbstractTransformerHolder()
           
 
Method Summary
abstract  ITransformerInformation createTransformerInformation(String componentName, String transformerName, Float transformerVersion, TransformerType transformerType, String fromUri, String toUri, String description)
          Creates a new instance of ITransformerInformation.
protected  String getSAXClassName(String tClassName)
          Gets the full class name of a SAX handler.
abstract  EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
          Gets the SAX handlers.
protected  String getTransformersResourcePath()
          Gets the path for the Transformer.xml file.
protected  String getXSLTransformerPath(String tXSLPath)
          Gets the location of the XSL files as defined in Transformers.xml.
 void init(IServiceContext serviceContext)
          Loads the service transformers.
protected  List loadTransformers()
          Creates a list of transformers from Transformers.xml.
protected abstract  void releaseAllTransformers()
          Releases all the transformers from the holder.
protected  void setTransformers(List transformers)
          Registers the list of transformers with the transformation service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sapportals.portal.prt.service.IService
afterInit, configure, destroy, getContext, getKey, release
 

Field Detail

TRNS_HLDR_LOG_SUBLOC

protected static final String TRNS_HLDR_LOG_SUBLOC
A constant that defines the sublocation.

See Also:
Constant Field Values

m_serviceContext

protected IServiceContext m_serviceContext
A constant that defines the service context.


TRNS_HLDR_LOCATION

public static com.sap.tc.logging.Location TRNS_HLDR_LOCATION
A constant that defines the log location.


TRNS_HLDR_CATEGORY

public static com.sap.tc.logging.Category TRNS_HLDR_CATEGORY
A constant that defines the log category.

Constructor Detail

AbstractTransformerHolder

public AbstractTransformerHolder()
Method Detail

init

public void init(IServiceContext serviceContext)
Loads the service transformers.

Specified by:
init in interface IService
Parameters:
serviceContext - the service context from the PRT
See Also:
IServiceContext

loadTransformers

protected List loadTransformers()
                         throws TransformationServiceException
Creates a list of transformers from Transformers.xml. The Transformers.xml file must be in /root/portalapps/<par name>/xml/Transformers.xml.
To change the location for the Transformers.xml file, overwrite the #getTransformersResourcePath() method.

Returns:
the list of transformers
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

setTransformers

protected void setTransformers(List transformers)
                        throws TransformationServiceException
Registers the list of transformers with the transformation service. The list of transformers must contain ITransformerInformation instances.

Parameters:
transformers - the list of transformers
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

getTransformersResourcePath

protected String getTransformersResourcePath()
Gets the path for the Transformer.xml file. Assumes the Transformer.xml file is in /root/portalapps/<par name>/xml/Transformers.xml.
Overwrite this method to change the path for the Transformer.xml file.

Returns:
the path of the transformers XML file

getSAXClassName

protected String getSAXClassName(String tClassName)
Gets the full class name of a SAX handler. Overwrite this method to return the name of the SAX handler class inherited from EPSAXDefaultHandler.

Parameters:
tClassName - the name of the class in the Transformers.xml file
Returns:
the full class name

getXSLTransformerPath

protected String getXSLTransformerPath(String tXSLPath)
Gets the location of the XSL files as defined in Transformers.xml. Assumes that the XSL files are in the folder: <par path>/xml/XSLLibrary/Transformers.
This method is called for each transformer before registering it with the transformation service.
Overwrite this method to change the base XSL folder.

Parameters:
tXSLPath - the path as defined in the Transformers.xml file
Returns:
the path of the XSL file

createTransformerInformation

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

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 abstract void releaseAllTransformers()
Releases all the transformers from the holder.
Note: It is strongly recommended not to use this method.


getSAXHandler

public abstract EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
                                           throws TransformationServiceException
Gets the SAX handlers. This method must be overwritten for providers that supply SAX handlers.

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
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