public final class PortalConnectorFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
PortalConnectorFactory.JobListener
Interface for JobListeners
|
Modifier and Type | Method and Description |
---|---|
static <T extends Datasource> |
createDatasource(java.lang.Class<T> clazz,
java.lang.String id)
Create a datasource instance of the given class with given id
|
static Datasource |
createDatasource(java.util.Map handleprops)
Creates a new datasource handle with the specified properties as well as
a new Datasource (with default properties).
|
static Datasource |
createDatasource(java.util.Map handleprops,
java.util.Map dsprops)
Creates a new Datasource connection with the specified properties which
should point to a Content Repository of Gentics Content.Node.
|
static Datasource |
createDatasource(java.lang.String id)
Create a datasource instance for the datasource with given id
|
static Expression |
createExpression(java.lang.String rule)
Parse the given expression string into an Expression.
|
static MultichannellingDatasource |
createMultichannellingDatasource(java.util.Map<java.lang.String,java.lang.String> handleProps,
java.util.Map<java.lang.String,java.lang.String> dsProps)
Create a new instance of a multichannelling datasource
|
static RuleTree |
createRuleTree(java.lang.String rule)
Deprecated.
deprecated, replaced by
createExpression(String) |
static WritableMultichannellingDatasource |
createWritableMultichannellingDatasource(java.util.Map<java.lang.String,java.lang.String> handleProps,
java.util.Map<java.lang.String,java.lang.String> dsProps)
Create a new writeable multichannelling datasource instance
|
static WriteableDatasource |
createWriteableDatasource(java.util.Map handleProperties)
Creates a new datasource handle with the specified properties as well as
a new writeable datasource (with default properties).
|
static WriteableDatasource |
createWriteableDatasource(java.util.Map handleProperties,
java.util.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 java.util.List<java.lang.String> |
getAvailableDatasources()
Get the list of all available datasource ids
|
static java.util.List<java.lang.String> |
getAvailableDatasources(java.lang.Class<? extends Datasource> datasourceClass)
Get the available datasources as list of ids
|
static Changeable |
getChangeableContentObject(java.lang.String contentId,
WriteableDatasource datasource)
Returns a changeable content object with the given content id.
|
static Resolvable |
getContentObject(java.lang.String contentId,
Datasource datasource)
Returns a content object with the given content id.
|
static void |
handleJobRun(java.lang.Class<? extends java.lang.Runnable> clazz,
java.lang.String name,
java.lang.Throwable e)
Let registered job listeners handle a job run
|
static boolean |
isAutoRepair()
Check whether the auto-repair functionality is switched on or off by
configuration.
|
static boolean |
isAutoRepair2()
Check whether the auto-repair2 functionality is switched on or off by
configuration.
|
static void |
pauseScheduler()
Pause the scheduler for background jobs
|
static void |
prefillAttributes(Datasource ds,
java.util.Collection<Resolvable> objects,
java.util.List<java.lang.String> prefillAttributes)
Prefill the given attributes for objects which were fetched from the given datasource
|
static void |
registerDatasource(java.lang.String id,
DatasourceType type,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.util.List<java.lang.String> handles)
Register a datasource at the factory.
|
static void |
registerDatasource(java.lang.String id,
DatasourceType type,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.util.List<java.lang.String> handleIds,
boolean allowOverwrite)
Register a datasource at the factory.
|
static void |
registerHandle(java.lang.String id,
HandleType type,
java.util.Map<java.lang.String,java.lang.String> parameters)
Register a datasource handle at the factory.
|
static void |
registerHandle(java.lang.String id,
HandleType type,
java.util.Map<java.lang.String,java.lang.String> parameters,
boolean allowOverwrite)
Register a datasource handle at the factory.
|
static java.util.UUID |
registerJobListener(PortalConnectorFactory.JobListener listener)
Register a job listener
|
static void |
resumeScheduler()
Resume the scheduler for background jobs
|
static void |
setAutoRepair(boolean flag)
Set the autorepair flag
|
static void |
setAutoRepair2(boolean flag)
Set the autorepair2 flag
|
protected static void |
startScheduler()
Start the scheduler
|
protected static void |
stopScheduler()
Stop the scheduler.
|
static void |
unregisterJobListener(java.util.UUID uuid)
Unregister a job listener
|
static void |
unregisterUnusedHandles()
Unregister (and close) currently unused handles
|
public static Datasource createDatasource(java.util.Map handleprops)
handleprops
- Handle properties used when initializing SQL handle.Datasource
,
createDatasource(Map, Map)
public static Datasource createDatasource(java.util.Map handleprops, java.util.Map dsprops)
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:mariadb://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
handleprops
- Handle properties used when initializing SQL handle.dsprops
- Datasource properties, may be an empty map.public static MultichannellingDatasource createMultichannellingDatasource(java.util.Map<java.lang.String,java.lang.String> handleProps, java.util.Map<java.lang.String,java.lang.String> dsProps)
handleProps
- handle propertiesdsProps
- datasource propertiespublic static Resolvable getContentObject(java.lang.String contentId, Datasource datasource) throws DatasourceNotAvailableException
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.DatasourceNotAvailableException
- when the datasource is not availablepublic static Expression createExpression(java.lang.String rule) throws ParserException
rule
- The Rule string to be parsed as Expression.ParserException
- when creating the expression failsDatasource.createDatasourceFilter(Expression)
public static RuleTree createRuleTree(java.lang.String rule) throws ParserException
createExpression(String)
rule
- The rule string which is used to initialize the RuleTreeParserException
- when rule has invalid syntax or is null.RuleTree
public static WriteableDatasource createWriteableDatasource(java.util.Map handleProperties)
handleProperties
- Handle properties used when initializing SQL
handle.public static WriteableDatasource createWriteableDatasource(java.util.Map handleProperties, java.util.Map datasourceProperties)
handleProperties
- Handle properties used when initializing SQL
handle.datasourceProperties
- Datasource properties, may be an empty map.public static WritableMultichannellingDatasource createWritableMultichannellingDatasource(java.util.Map<java.lang.String,java.lang.String> handleProps, java.util.Map<java.lang.String,java.lang.String> dsProps)
handleProps
- handle propertiesdsProps
- datasource propertiespublic static Changeable getChangeableContentObject(java.lang.String contentId, WriteableDatasource datasource) throws DatasourceNotAvailableException
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.DatasourceNotAvailableException
- when the datasource is not availablepublic static void prefillAttributes(Datasource ds, java.util.Collection<Resolvable> objects, java.util.List<java.lang.String> prefillAttributes) throws NodeException
ds
- datasourceobjects
- collection of objects fetched from the datasourceprefillAttributes
- list of attributes to be prefilledNodeException
- when prefilling failsprotected static void startScheduler()
protected static void stopScheduler()
protected static void destroyDatasourceFactories()
public static void destroy()
public static void registerHandle(java.lang.String id, HandleType type, java.util.Map<java.lang.String,java.lang.String> parameters) throws DuplicateIdException, NodeException
id
- id of the datasource handletype
- handle typeparameters
- handle parametersDuplicateIdException
- if a handle with that id was already registeredNodeException
- if the parameters are invalidpublic static void registerHandle(java.lang.String id, HandleType type, java.util.Map<java.lang.String,java.lang.String> parameters, boolean allowOverwrite) throws DuplicateIdException, NodeException
id
- id of the datasource handletype
- handle typeparameters
- handle parametersallowOverwrite
- true if overwriting existing handles should be allowedDuplicateIdException
- if a handle with that id was already registered and allowOverwrite was falseNodeException
- if the parameters are invalidpublic static void unregisterUnusedHandles()
public static void registerDatasource(java.lang.String id, DatasourceType type, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.List<java.lang.String> handles) throws DuplicateIdException, NodeException
id
- datasource idtype
- datasource typeparameters
- datasource parametershandles
- list of datasource handle idsDuplicateIdException
- if a datasource with that id was already registeredNodeException
- when registering failspublic static void registerDatasource(java.lang.String id, DatasourceType type, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.List<java.lang.String> handleIds, boolean allowOverwrite) throws DuplicateIdException, NodeException
id
- datasource idtype
- datasource typeparameters
- datasource parametershandleIds
- list of datasource handle idsallowOverwrite
- true if overwriting existing datasources should be allowed, false if notDuplicateIdException
- if a datasource with that id was already registered and allowOverwrite was falseNodeException
- when registering failspublic static boolean isAutoRepair()
public static void setAutoRepair(boolean flag)
flag
- true to enable auto repairpublic static boolean isAutoRepair2()
public static void setAutoRepair2(boolean flag)
flag
- true to enable auto repair 2public static java.util.List<java.lang.String> getAvailableDatasources()
public static java.util.List<java.lang.String> getAvailableDatasources(java.lang.Class<? extends Datasource> datasourceClass)
datasourceClass
- datasource class. If null, all available datasources will be returnedpublic static Datasource createDatasource(java.lang.String id) throws NodeException
id
- datasource idNodeException
- if no datasource with given id was registeredpublic static <T extends Datasource> T createDatasource(java.lang.Class<T> clazz, java.lang.String id) throws NodeException
T
- Datasource implementation classclazz
- datasource classid
- datasource idNodeException
- if no datasource with given id was registered or if the datasource does not implement the given classpublic static void handleJobRun(java.lang.Class<? extends java.lang.Runnable> clazz, java.lang.String name, java.lang.Throwable e)
clazz
- class of the jobname
- name of the jobe
- exception (if the job had an error)public static java.util.UUID registerJobListener(PortalConnectorFactory.JobListener listener)
listener
- job listenerpublic static void unregisterJobListener(java.util.UUID uuid)
uuid
- UUID of the registrypublic static void pauseScheduler()
public static void resumeScheduler()
Copyright © 2022 Gentics Software. All Rights Reserved.