com.gentics.api.portalnode.connector
Class PortalConnectorFactory

java.lang.Object
  extended by com.gentics.api.portalnode.connector.PortalConnectorFactory

public final class PortalConnectorFactory
extends Object

PortalConnectorFactory can be used to create instances for datasources, RuleTrees and Resolvables.

Author:
herbert

Method Summary
static Datasource createDatasource(Map handleprops)
          Creates a new datasource handle with the specified properties as well as a new Datasource (with default properties).
static Datasource createDatasource(Map handleprops, Map dsprops)
          Creates a new Datasource connection with the specified properties which should point to a Content Repository of Gentics Content.Node.
static Expression createExpression(String rule)
          Parse the given expression string into an Expression.
static MultichannellingDatasource createMultichannellingDatasource(Map<String,String> handleProps, Map<String,String> dsProps)
          Create a new instance of a multichannelling datasource
static RuleTree createRuleTree(String rule)
          Deprecated. deprecated, replaced by createExpression(String)
static WritableMultichannellingDatasource createWritableMultichannellingDatasource(Map<String,String> handleProps, Map<String,String> dsProps)
          Create a new writeable multichannelling datasource instance
static WriteableDatasource createWriteableDatasource(Map handleProperties)
          Creates a new datasource handle with the specified properties as well as a new writeable datasource (with default properties).
static WriteableDatasource createWriteableDatasource(Map handleProperties, Map datasourceProperties)
          Creates a new datasource handle with the specified properties as well as a new writeable datasource with the specified properties.
static void destroy()
          Destroy the portal connector factory, close all database connections, remove the scheduler (created background threads).
protected static void destroyDatasourceFactories()
          Destroy all created datasource factories, close all handles (closing database connections)
static Changeable getChangeableContentObject(String contentId, WriteableDatasource datasource)
          Returns a changeable content object with the given content id.
static Resolvable getContentObject(String contentId, Datasource datasource)
          Returns a content object with the given content id.
static void prefillAttributes(Datasource ds, Collection<Resolvable> objects, List<String> prefillAttributes)
          Prefill the given attributes for objects which were fetched from the given datasource
protected static void startScheduler()
          Start the scheduler
protected static void stopScheduler()
          Stop the scheduler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDatasource

public static Datasource createDatasource(Map handleprops)
Creates a new datasource handle with the specified properties as well as a new Datasource (with default properties).

Parameters:
handleprops - Handle properties used when initializing SQL handle.
Returns:
a new initialized Datasource
See Also:
Datasource, createDatasource(Map, Map)

createDatasource

public static Datasource createDatasource(Map handleprops,
                                          Map dsprops)
Creates a new Datasource connection with the specified properties which should point to a Content Repository of Gentics Content.Node. For every different datasource (different handleproperties) a datasource handle will be created and reused with the given pooling settings.
Note: the returned instance of Datasource is NOT thread-safe.
      Handle Property - Parameters:
      type - Type of the datasource. (jndi or jdbc)
      For JNDI:
      name - The name of the defined JNDI datasource.
      
      For JDBC:
      driverClass = The name of the JDBC class to be used (e.g. com.mysql.jdbc.Driver)
      url = The URL which describes the JDBC datasource. (e.g. jdbc:mysql://playground.office:3306/testdb?user=root)
      
      Optional JDBC Pool Parameters:
      maxActive = Controls the maximum number of objects that can be borrowed from the pool at one time.
      maxIdle = Controls the maximum number of objects that can sit idle in the pool at any time.
      
      for more options and more detailed documentation for JDBC Pool options
      take a look at the API documentation of
      GenericObjectPool
 

Parameters:
handleprops - Handle properties used when initializing SQL handle.
dsprops - Datasource properties, may be an empty map.
Returns:
a new and initialized Datasource or null if one of the parameters where null or the sanity check failed. Datasource may be unusable (DatasourceNotAvailableException) if invalid properties where given.

createMultichannellingDatasource

public static MultichannellingDatasource createMultichannellingDatasource(Map<String,String> handleProps,
                                                                          Map<String,String> dsProps)
Create a new instance of a multichannelling datasource

Parameters:
handleProps - handle properties
dsProps - datasource properties
Returns:
instance of the multichannelling datasource or null

getContentObject

public static Resolvable getContentObject(String contentId,
                                          Datasource datasource)
                                   throws DatasourceNotAvailableException
Returns a content object with the given content id.

Parameters:
contentId - The content id of the object which should be returned. ([objecttype].[object id] e.g. 10002.123)
datasource - Datasource used to load the content object.
Returns:
the content object corresponding to the given content id. This method returns null if datasource is null or contentid is null or it doesn't exist or the syntax of the contentid is wrong.
Throws:
DatasourceNotAvailableException

createExpression

public static Expression createExpression(String rule)
                                   throws ParserException
Parse the given expression string into an Expression. You should reuse parsed Expressions whereever possible as well as reuse DatasourceFilters which are created from those expressions.

Parameters:
rule - The Rule string to be parsed as Expression.
Returns:
the parsed Expression.
Throws:
ParserException
See Also:
Datasource.createDatasourceFilter(Expression)

createRuleTree

public static RuleTree createRuleTree(String rule)
                               throws ParserException
Deprecated. deprecated, replaced by createExpression(String)

Creates a new RuleTree with the given rule string. Take care that you reuse parsed RuleTree's wherever possible by replacing the resolver. Parsing strings to RuleTrees is cpu expensive.

Parameters:
rule - The rule string which is used to initialize the RuleTree
Returns:
a new and initialized RuleTree to match the given rule string.
Throws:
ParserException - when rule has invalid syntax or is null.
See Also:
RuleTree

createWriteableDatasource

public static WriteableDatasource createWriteableDatasource(Map handleProperties)
Creates a new datasource handle with the specified properties as well as a new writeable datasource (with default properties).

Parameters:
handleProperties - Handle properties used when initializing SQL handle.
Returns:
The WriteableDatasource which might be used to read/write content objects.

createWriteableDatasource

public static WriteableDatasource createWriteableDatasource(Map handleProperties,
                                                            Map datasourceProperties)
Creates a new datasource handle with the specified properties as well as a new writeable datasource with the specified properties.

Parameters:
handleProperties - Handle properties used when initializing SQL handle.
datasourceProperties - Datasource properties, may be an empty map.
Returns:
The WriteableDatasource which might be used to read/write content objects or null if the sanity check failed

createWritableMultichannellingDatasource

public static WritableMultichannellingDatasource createWritableMultichannellingDatasource(Map<String,String> handleProps,
                                                                                          Map<String,String> dsProps)
Create a new writeable multichannelling datasource instance

Parameters:
handleProps - handle properties
dsProps - datasource properties
Returns:
instance of the datasource or null

getChangeableContentObject

public static Changeable getChangeableContentObject(String contentId,
                                                    WriteableDatasource datasource)
                                             throws DatasourceNotAvailableException
Returns a changeable content object with the given content id.

Parameters:
contentId - The content id of the object which should be returned. ([objecttype].[object id] e.g. 10002.123)
datasource - Writeable Datasource used to load the content object.
Returns:
the content object corresponding to the given content id.
Throws:
DatasourceNotAvailableException

prefillAttributes

public static void prefillAttributes(Datasource ds,
                                     Collection<Resolvable> objects,
                                     List<String> prefillAttributes)
                              throws NodeException
Prefill the given attributes for objects which were fetched from the given datasource

Parameters:
ds - datasource
objects - collection of objects fetched from the datasource
prefillAttributes - list of attributes to be prefilled
Throws:
NodeException

startScheduler

protected static void startScheduler()
Start the scheduler


stopScheduler

protected static void stopScheduler()
Stop the scheduler. This method should be called before the factory is taken out of service


destroyDatasourceFactories

protected static void destroyDatasourceFactories()
Destroy all created datasource factories, close all handles (closing database connections)


destroy

public static void destroy()
Destroy the portal connector factory, close all database connections, remove the scheduler (created background threads). This method must be called to take the PortalConnectorFactory out of service



Copyright © 2013 Gentics Software GmbH. All Rights Reserved.