com.sap.portal.httpconnectivity.transformationservice
Class AbstractTransformerHolder

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

public abstract class AbstractTransformerHolder
extends java.lang.Object
implements com.sapportals.portal.prt.service.IService

Abstractization of transformers holder that implemented as a service. Class provide methods to load transformers defined in the par. It assumes that there is a file ../<par path>/xml/Transformers.xml that defines the transformers. It also assumes that the XSL transformers are located in folder ../<par path>/xml/XSLLibrary/Transformers.
Folder view:

...
  -<par name>
    - xml
     | Transformers.xml
     - XSLLibrary
       - Transformers
         Transformer1.xsl
         Transformer2.xsl
 ...  
 
Transformers are initialized automaticlly when service is initilezed. Loading process is:
1. Release all this provider transformers (to prevent re-setting of transformers).
2. Getting the list of ITransformerInformation objects according to the Transformers.xml file.
3. Setting the transformers to the transformation service.


Field Summary
protected  com.sapportals.portal.prt.service.IServiceContext m_serviceContext
          The service context
static com.sap.tc.logging.Category TRNS_HLDR_CATEGORY
           
static com.sap.tc.logging.Location TRNS_HLDR_LOCATION
           
protected static java.lang.String TRNS_HLDR_LOG_SUBLOC
           
 
Constructor Summary
AbstractTransformerHolder()
           
 
Method Summary
abstract  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.
protected  java.lang.String getSAXClassName(java.lang.String tClassName)
          Get the full class name of a SAX handler.
abstract  EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
          Method that is used to get the SAX handlers.
protected  java.lang.String getTransformersResourcePath()
          Gets the Transformer.xml file path.
protected  java.lang.String getXSLTransformerPath(java.lang.String tXSLPath)
          Get the file location of XSL files according to the string defined in Transformers.xml.
 void init(com.sapportals.portal.prt.service.IServiceContext serviceContext)
          Initialize the service.
protected  java.util.List loadTransformers()
          Create a list of transformers information (ITransformerInsformation instances) from the Transformers.xml supplied by the holder implementation.
protected abstract  void releaseAllTransformers()
          Release all the transformers of the holder
protected  void setTransformers(java.util.List transformers)
          Sets list of transformers to 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 java.lang.String TRNS_HLDR_LOG_SUBLOC

m_serviceContext

protected com.sapportals.portal.prt.service.IServiceContext m_serviceContext
The service context

TRNS_HLDR_LOCATION

public static com.sap.tc.logging.Location TRNS_HLDR_LOCATION

TRNS_HLDR_CATEGORY

public static com.sap.tc.logging.Category TRNS_HLDR_CATEGORY
Constructor Detail

AbstractTransformerHolder

public AbstractTransformerHolder()
Method Detail

init

public void init(com.sapportals.portal.prt.service.IServiceContext serviceContext)
Initialize the service. Activate the process of loading the service transformers
Specified by:
init in interface com.sapportals.portal.prt.service.IService
Parameters:
serviceContext - the service context from the PRT

loadTransformers

protected java.util.List loadTransformers()
                                   throws TransformationServiceException
Create a list of transformers information (ITransformerInsformation instances) from the Transformers.xml supplied by the holder implementation. The transformers.xml file should be in .../root/portalapps/<par name>/xml/Transformers.xml. If you want to change the location, overwrite the getTransformersResourcePath() method.
Returns:
list of ITransformerInformation objects that are created from the Transformers.xml file
Throws:
TransformationServiceException - when unable to read any transformer

setTransformers

protected void setTransformers(java.util.List transformers)
                        throws TransformationServiceException
Sets list of transformers to the transformation service.
Parameters:
transformers - list of transformers to set. List must hold ITransformerInformation instaces.
Throws:
TransformationServiceException - when cannot set a transformer

getTransformersResourcePath

protected java.lang.String getTransformersResourcePath()
Gets the Transformer.xml file path. Overwrite this method to provide customized path
Returns:
full path to the transformers XML file

getSAXClassName

protected java.lang.String getSAXClassName(java.lang.String tClassName)
Get the full class name of a SAX handler. Overwrite this method to add you prefix.
Parameters:
tClassName - the name of the class as it was written in the transformers.xml.
Returns:
the full class name

getXSLTransformerPath

protected java.lang.String getXSLTransformerPath(java.lang.String tXSLPath)
Get the file location of XSL files according to the string defined in Transformers.xml. Assuming that the XSLs are in folder: ../<par path>/xml/XSLLibrary/Transformers and that parameter tXSLPath is just the name of the file. Overwrite this method to provide your base XSLs folder. Method is called for each transformer before setting it to the transformation service.
Parameters:
tXSLPath - the path as it was entered in the transformers.xml file
Returns:
full path to the XSL file

createTransformerInformation

public abstract 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
Create new instance of ITransformerInformation. Used mainly when setting new transformers.
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 abstract void releaseAllTransformers()
Release all the transformers of the holder

getSAXHandler

public abstract EPSAXDefaultHandler getSAXHandler(ITransformerInformation tInfo)
                                           throws TransformationServiceException
Method that is used to get the SAX handlers. This method must be overwritten in providers that provides SAX handlers.
Parameters:
tInfo - the transformer information
Returns:
the generated sax handler
Throws:
TransformationServiceException - when cannot instancite SAX handler