com.sapportals.wcm.rendering.collection

Class ComponentFactory

java.lang.Object
  extended bycom.sapportals.wcm.rendering.collection.ComponentFactory
All Implemented Interfaces:
IFactoryInfoProvider

public final class ComponentFactory
extends Object
implements IFactoryInfoProvider

Since:
EP5 SP6 and EP6 SP1 The ComponentFactory is a singleton factory, that allows other classes to retrieve instances of IComponents. When the factory is called for the first time or when it receives a ConfigEvent , it reads out information from the config framework. This information allows a mapping of a descriptive name ("alias") to a java-class. This allows a usage of the descriptive name throughout the configuration of the other parts of the rendering framework. If a mapping points to a not-existing or non-loadable class or if the class found does not implement the needed interface, an error message is written in the log.files, stating the name of the alias and the mapped java-class.

Nested Class Summary
 
Nested classes inherited from class com.sapportals.wcm.rendering.base.IFactoryInfoProvider
IFactoryInfoProvider.MappingInformation
 
Field Summary
static String COMPONENT_PAGER
          key to retrieve a pager class instance from the factory using the factory's getComponent method and stating this constant as alias-parameter
static String COMPONENT_PATH
          key to retrieve a path class instance (a.k.a.
static String COMPONENT_SORT_HEADER
          key to retrieve a sort header class instance from the factory using the factory's getComponent method and stating this constant as alias-parameter
static String DATA_KEY_PAGER_DATA
          key to use when transferring data to an IComponent instance using its setData method.
static String DATA_KEY_PARENT
          key to use when transferring data to an IComponent instance using its setData method.
static String DATA_KEY_RESOURCE_LIST
          key to use when transferring data to an IComponent instance using its setData method.
static String DATA_KEY_SEARCH_SESSION
          key to use when transferring data to an IComponent instance using its setData method.
static String DATA_KEY_SORT_DATA
          key to use when transferring data to an IComponent instance using its setData method.
static String LINE_BREAK
          constant used to separate debugging information
 
Method Summary
 boolean checkComponentAlias(String alias)
          Checks is a component with the given alias exists
 void configEvent(ConfigEvent parm1)
          is called by the configuration, if configuration for the factory was changed.
 String createLinkID(IComponent component, ArrayList values)
          creates a unique ID that also holds the given IComponent's alias and all the entries of the given ArrayList.
 String createStaticLinkID(IComponent component, ArrayList values, String id)
          creates a unique ID that also holds the given IComponent's alias and all the entries of the given ArrayList.
 IComponentEvent decodeEvent(ICollectionRenderer renderer, IProxy proxy, Event event, Map values)
          creates a new IComponent from the component's alias found inside the given event and let's it fire the returned IComponentEvent or null.
 IComponent getComponent(IProxy proxy, IResource res, IFlavor impFlavor, String alias)
           
 IComponent getComponent(String alias, IProxy proxy)
          returns a new instance of an IComponent that is defined for the given alias or null, if no component is defined for the given alias.
 IComponent getComponent(String alias, IProxy proxy, ICollectionRenderer renderer)
          returns a new instance of an IComponent that is defined for the given alias or null, if no component is defined for the given alias.
 IComponent getComponent(String alias, IProxy proxy, ICollectionRenderer renderer, IResource res, IFlavor flavor)
           
 IComponent getComponent(String alias, IProxy proxy, IFlavor flavor)
           
 String getConfigListenerId()
          Gets the configListenerId attribute of the UICommandFactory object
 String getFactoryName()
           
static ComponentFactory getInstance()
          Gets the instance attribute of the ComponentFactory class.
 long getLastReloadTime()
           
 List getMappings(Locale locale)
           
 List getPresentConfiguration(IResourceContext context)
          returns a list of setting information of the groupcommands.
 String getPresentConfiguration(IResourceContext context, String style, boolean showJavaClassNames)
          returns a string representation of the structure of all defined groupcommands with their children.
 Status getStatus()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_BREAK

public static final String LINE_BREAK
constant used to separate debugging information


COMPONENT_PAGER

public static final String COMPONENT_PAGER
key to retrieve a pager class instance from the factory using the factory's getComponent method and stating this constant as alias-parameter

See Also:
Constant Field Values

COMPONENT_PATH

public static final String COMPONENT_PATH
key to retrieve a path class instance (a.k.a. "breadcrumb") from the factory using the factory's getComponent method and stating this constant as alias-parameter

See Also:
Constant Field Values

COMPONENT_SORT_HEADER

public static final String COMPONENT_SORT_HEADER
key to retrieve a sort header class instance from the factory using the factory's getComponent method and stating this constant as alias-parameter

See Also:
Constant Field Values

DATA_KEY_SORT_DATA

public static final String DATA_KEY_SORT_DATA
key to use when transferring data to an IComponent instance using its setData method. It is used as the key for a Map entry that must be of class SortDefinition.

See Also:
Constant Field Values

DATA_KEY_PAGER_DATA

public static final String DATA_KEY_PAGER_DATA
key to use when transferring data to an IComponent instance using its setData method. It is used as the key for a Map entry that must be of class PagerData.

See Also:
Constant Field Values

DATA_KEY_RESOURCE_LIST

public static final String DATA_KEY_RESOURCE_LIST
key to use when transferring data to an IComponent instance using its setData method. It is used as the key for a Map entry that must be of class IResourceList.

See Also:
Constant Field Values

DATA_KEY_SEARCH_SESSION

public static final String DATA_KEY_SEARCH_SESSION
key to use when transferring data to an IComponent instance using its setData method. It is used as the key for a Map entry that must be of class ISearchSession.

See Also:
Constant Field Values

DATA_KEY_PARENT

public static final String DATA_KEY_PARENT
key to use when transferring data to an IComponent instance using its setData method. It is used as the key for a Map entry that must be of class ICollection.

See Also:
Constant Field Values
Method Detail

getInstance

public static ComponentFactory getInstance()
Gets the instance attribute of the ComponentFactory class.

Returns:
the only available instance of this factory in the VM.

getComponent

public IComponent getComponent(String alias,
                               IProxy proxy,
                               ICollectionRenderer renderer)
returns a new instance of an IComponent that is defined for the given alias or null, if no component is defined for the given alias. The components attributes alias, flavor, proxy, renderer, resource, startUri will be set with the values obtained from the given parameters.


getComponent

public IComponent getComponent(IProxy proxy,
                               IResource res,
                               IFlavor impFlavor,
                               String alias)

getComponent

public IComponent getComponent(String alias,
                               IProxy proxy,
                               ICollectionRenderer renderer,
                               IResource res,
                               IFlavor flavor)

checkComponentAlias

public boolean checkComponentAlias(String alias)
Checks is a component with the given alias exists

Parameters:
alias -
Returns:

getComponent

public IComponent getComponent(String alias,
                               IProxy proxy)
returns a new instance of an IComponent that is defined for the given alias or null, if no component is defined for the given alias. The components attributes alias, proxy, resource, startUri will be set with the values obtained from the given parameters.


getComponent

public IComponent getComponent(String alias,
                               IProxy proxy,
                               IFlavor flavor)

decodeEvent

public IComponentEvent decodeEvent(ICollectionRenderer renderer,
                                   IProxy proxy,
                                   Event event,
                                   Map values)
                            throws WcmException
creates a new IComponent from the component's alias found inside the given event and let's it fire the returned IComponentEvent or null. If the id of the Htmlb-Component that fired the Event was not created using the factory's createLinkID or createStaticLinkID, this method might throw an WcmException or simply return null. Otherwise, a new Component instance is created, its attributes alias, proxy, renderer are set with the parameters given and its decodeEvent method is called, using again the given parameters. The created instance of the IComponent will not be reused by the factory in later calls.

Throws:
WcmException

createLinkID

public String createLinkID(IComponent component,
                           ArrayList values)
                    throws WcmException
creates a unique ID that also holds the given IComponent's alias and all the entries of the given ArrayList. It also adds a String obtained from IDCounter.currentID(). Therefore, the ID created by this method cannot be reproduced at a later time. If you need to access the htmlb-Component inside your IComponent after an http-request-cycle, use the factory's createStaticLinkID method. None of the given parameters must be null.

Throws:
WcmException - if the creation of the linkID failed. This exception might wrap a WdfException.

createStaticLinkID

public String createStaticLinkID(IComponent component,
                                 ArrayList values,
                                 String id)
                          throws WcmException
creates a unique ID that also holds the given IComponent's alias and all the entries of the given ArrayList. It also adds the id-parameter given. Therefore, the ID created by this method can be reproduced at a later time. Note that if you create two htmlb-Components within the same IComponent and the same ArrayList and id, there will be a NonUniqueIDException thrown when rendering the html-page. None of the given parameters must be null.

Throws:
WcmException - if the creation of the linkID failed. This exception might wrap a WdfException.

getConfigListenerId

public String getConfigListenerId()
Gets the configListenerId attribute of the UICommandFactory object

Returns:
The configListenerId value

configEvent

public void configEvent(ConfigEvent parm1)
is called by the configuration, if configuration for the factory was changed. If the event is of type ConfigEvent.CONFIGURABLE_LOADED or ConfigEvent.CONFIGMANAGER_TERMINATED , the factory deletes all its entries and reloads the configuration, creating all commands anew.

Parameters:
parm1 - the event raised by the configuration

getPresentConfiguration

public String getPresentConfiguration(IResourceContext context,
                                      String style,
                                      boolean showJavaClassNames)
returns a string representation of the structure of all defined groupcommands with their children.

Parameters:
context - the current context of the user, sets e.g. the language of the labels for the commands
style - currently not used
showJavaClassNames - flag to show (true) or hide (false) java class names in the returned string
Returns:
a String with line breaks and indentions to show the structure of all configured commands

getPresentConfiguration

public List getPresentConfiguration(IResourceContext context)
returns a list of setting information of the groupcommands. GroupCommands are free to add information to this list. When using this list a type check should be done before casting to String to avoid ClassCastException s.

Parameters:
context - Description of the param
Returns:
a list containing information provided by the factory's groupcommands.

getFactoryName

public String getFactoryName()
Specified by:
getFactoryName in interface IFactoryInfoProvider
Returns:
a human-readable name of the factory, must not be null

getMappings

public List getMappings(Locale locale)
Specified by:
getMappings in interface IFactoryInfoProvider
Parameters:
locale - defines the language to use, if the factory offers translated information, must not be null
Returns:
a list that must only contain IFactoryInfoProvider.MappingInformation, must not be null

getStatus

public Status getStatus()
Specified by:
getStatus in interface IFactoryInfoProvider
Returns:
the aggregated status of the factory. If, e.g., there have been errors creating a class defined in the config, the factory should return Status.ERROR

getLastReloadTime

public long getLastReloadTime()
Specified by:
getLastReloadTime in interface IFactoryInfoProvider
Returns:
the time of the last reload of the config by this factory. Expects a format such as returned by System.currentTimeMillis(). An implementing class might also return -1 to indicate, that no information is available.


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.