Class DefinitionsServiceImpl
- java.lang.Object
-
- org.apache.unomi.services.impl.definitions.DefinitionsServiceImpl
-
- All Implemented Interfaces:
EventListener
,DefinitionsService
,org.osgi.framework.BundleListener
,org.osgi.framework.SynchronousBundleListener
public class DefinitionsServiceImpl extends Object implements DefinitionsService, org.osgi.framework.SynchronousBundleListener
-
-
Constructor Summary
Constructors Constructor Description DefinitionsServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
bundleChanged(org.osgi.framework.BundleEvent event)
Condition
extractConditionBySystemTag(Condition rootCondition, String systemTag)
Retrieves a condition matching the specified system tag identifier from the specified root condition.Condition
extractConditionByTag(Condition rootCondition, String tag)
Deprecated.As of version 1.2.0-incubating, useextractConditionBySystemTag(Condition, String)
insteadSet<Condition>
extractConditionsByType(Condition rootCondition, String typeId)
Retrieves all conditions of the specified type from the specified root condition.ActionType
getActionType(String id)
Retrieves the action type associated with the specified identifier.Set<ActionType>
getActionTypeBySystemTag(String tag)
Retrieves the set of action types with the specified system tag.Set<ActionType>
getActionTypeByTag(String tag)
Retrieves the set of action types with the specified tag.Collection<ActionType>
getAllActionTypes()
Retrieves all known action types.Collection<ConditionType>
getAllConditionTypes()
Retrieves all condition types.Collection<ValueType>
getAllValueTypes()
Retrieves all known value types.ConditionBuilder
getConditionBuilder()
Retrieves a new instance of a ConditionBuilder to help to build conditions.ConditionType
getConditionType(String id)
Retrieves the condition type associated with the specified identifier.Set<ConditionType>
getConditionTypesBySystemTag(String tag)
Retrieves the set of condition types with the specified system tag.Set<ConditionType>
getConditionTypesByTag(String tag)
Retrieves the set of condition types with the specified tag.PropertyMergeStrategyType
getPropertyMergeStrategyType(String id)
Retrieves the property merge strategy type associated with the specified identifier.Map<Long,List<PluginType>>
getTypesByPlugin()
Retrieves a Map of plugin identifier to a list of plugin types defined by that particular plugin.ValueType
getValueType(String id)
Retrieves the value type associated with the specified identifier.Set<ValueType>
getValueTypeByTag(String tag)
Retrieves the set of value types with the specified tag.void
postConstruct()
void
preDestroy()
void
refresh()
Forces a refresh of the definitions from the persistence service.void
reloadTypes(boolean refresh)
void
removeActionType(String id)
Remove the action typevoid
removeConditionType(String id)
Remove the condition typeboolean
resolveConditionType(Condition rootCondition)
Resolves (if possible) theConditionType
s for the specified condition and its sub-conditions (if any) from the type identifiers existing on the specified condition TODO: remove from API and move to a different class?void
setActionType(ActionType actionType)
Stores the action typevoid
setBundleContext(org.osgi.framework.BundleContext bundleContext)
void
setConditionType(ConditionType conditionType)
Stores the condition typevoid
setDefinitionsRefreshInterval(long definitionsRefreshInterval)
void
setPersistenceService(PersistenceService persistenceService)
void
setSchedulerService(SchedulerService schedulerService)
-
-
-
Method Detail
-
setBundleContext
public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
-
setPersistenceService
public void setPersistenceService(PersistenceService persistenceService)
-
setSchedulerService
public void setSchedulerService(SchedulerService schedulerService)
-
setDefinitionsRefreshInterval
public void setDefinitionsRefreshInterval(long definitionsRefreshInterval)
-
postConstruct
public void postConstruct()
-
reloadTypes
public void reloadTypes(boolean refresh)
-
preDestroy
public void preDestroy()
-
getTypesByPlugin
public Map<Long,List<PluginType>> getTypesByPlugin()
Description copied from interface:DefinitionsService
Retrieves a Map of plugin identifier to a list of plugin types defined by that particular plugin.- Specified by:
getTypesByPlugin
in interfaceDefinitionsService
- Returns:
- a Map of plugin identifier to a list of plugin types defined by that particular plugin
-
getAllConditionTypes
public Collection<ConditionType> getAllConditionTypes()
Description copied from interface:DefinitionsService
Retrieves all condition types.- Specified by:
getAllConditionTypes
in interfaceDefinitionsService
- Returns:
- a Collection of all collection types
-
getConditionTypesByTag
public Set<ConditionType> getConditionTypesByTag(String tag)
Description copied from interface:DefinitionsService
Retrieves the set of condition types with the specified tag.- Specified by:
getConditionTypesByTag
in interfaceDefinitionsService
- Parameters:
tag
- the tag marking the condition types we want to retrieve- Returns:
- the set of condition types with the specified tag (and its sub-tags, if specified)
-
getConditionTypesBySystemTag
public Set<ConditionType> getConditionTypesBySystemTag(String tag)
Description copied from interface:DefinitionsService
Retrieves the set of condition types with the specified system tag.- Specified by:
getConditionTypesBySystemTag
in interfaceDefinitionsService
- Parameters:
tag
- the system tag marking the condition types we want to retrieve- Returns:
- the set of condition types with the specified tag (and its sub-tags, if specified)
-
getConditionType
public ConditionType getConditionType(String id)
Description copied from interface:DefinitionsService
Retrieves the condition type associated with the specified identifier.- Specified by:
getConditionType
in interfaceDefinitionsService
- Parameters:
id
- the identifier of the condition type to retrieve- Returns:
- the condition type associated with the specified identifier or
null
if no such condition type exists
-
removeConditionType
public void removeConditionType(String id)
Description copied from interface:DefinitionsService
Remove the condition type- Specified by:
removeConditionType
in interfaceDefinitionsService
- Parameters:
id
- the condition type to remove
-
setConditionType
public void setConditionType(ConditionType conditionType)
Description copied from interface:DefinitionsService
Stores the condition type- Specified by:
setConditionType
in interfaceDefinitionsService
- Parameters:
conditionType
- the condition type to store
-
getAllActionTypes
public Collection<ActionType> getAllActionTypes()
Description copied from interface:DefinitionsService
Retrieves all known action types.- Specified by:
getAllActionTypes
in interfaceDefinitionsService
- Returns:
- all known action types
-
getActionTypeByTag
public Set<ActionType> getActionTypeByTag(String tag)
Description copied from interface:DefinitionsService
Retrieves the set of action types with the specified tag.- Specified by:
getActionTypeByTag
in interfaceDefinitionsService
- Parameters:
tag
- the tag marking the action types we want to retrieve- Returns:
- the set of action types with the specified tag
-
getActionTypeBySystemTag
public Set<ActionType> getActionTypeBySystemTag(String tag)
Description copied from interface:DefinitionsService
Retrieves the set of action types with the specified system tag.- Specified by:
getActionTypeBySystemTag
in interfaceDefinitionsService
- Parameters:
tag
- the system tag marking the action types we want to retrieve- Returns:
- the set of action types with the specified tag
-
getActionType
public ActionType getActionType(String id)
Description copied from interface:DefinitionsService
Retrieves the action type associated with the specified identifier.- Specified by:
getActionType
in interfaceDefinitionsService
- Parameters:
id
- the identifier of the action type to retrieve- Returns:
- the action type associated with the specified identifier or
null
if no such action type exists
-
removeActionType
public void removeActionType(String id)
Description copied from interface:DefinitionsService
Remove the action type- Specified by:
removeActionType
in interfaceDefinitionsService
- Parameters:
id
- the action type to remove
-
setActionType
public void setActionType(ActionType actionType)
Description copied from interface:DefinitionsService
Stores the action type- Specified by:
setActionType
in interfaceDefinitionsService
- Parameters:
actionType
- the action type to store
-
getAllValueTypes
public Collection<ValueType> getAllValueTypes()
Description copied from interface:DefinitionsService
Retrieves all known value types.- Specified by:
getAllValueTypes
in interfaceDefinitionsService
- Returns:
- all known value types
-
getValueTypeByTag
public Set<ValueType> getValueTypeByTag(String tag)
Description copied from interface:DefinitionsService
Retrieves the set of value types with the specified tag.- Specified by:
getValueTypeByTag
in interfaceDefinitionsService
- Parameters:
tag
- the tag marking the value types we want to retrieve- Returns:
- the set of value types with the specified tag
-
getValueType
public ValueType getValueType(String id)
Description copied from interface:DefinitionsService
Retrieves the value type associated with the specified identifier.- Specified by:
getValueType
in interfaceDefinitionsService
- Parameters:
id
- the identifier of the value type to retrieve- Returns:
- the value type associated with the specified identifier or
null
if no such value type exists
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)
- Specified by:
bundleChanged
in interfaceorg.osgi.framework.BundleListener
-
getPropertyMergeStrategyType
public PropertyMergeStrategyType getPropertyMergeStrategyType(String id)
Description copied from interface:DefinitionsService
Retrieves the property merge strategy type associated with the specified identifier.- Specified by:
getPropertyMergeStrategyType
in interfaceDefinitionsService
- Parameters:
id
- the identifier of the property merge strategy type to retrieve- Returns:
- the property merge strategy type associated with the specified identifier or
null
if no such property merge strategy type exists
-
extractConditionsByType
public Set<Condition> extractConditionsByType(Condition rootCondition, String typeId)
Description copied from interface:DefinitionsService
Retrieves all conditions of the specified type from the specified root condition. TODO: remove?- Specified by:
extractConditionsByType
in interfaceDefinitionsService
- Parameters:
rootCondition
- the condition from which we want to extract all conditions with the specified typetypeId
- the identifier of the condition type we want conditions to extract to match- Returns:
- a set of conditions contained in the specified root condition and matching the specified condition type or an empty set if no such condition exists
-
extractConditionByTag
@Deprecated public Condition extractConditionByTag(Condition rootCondition, String tag)
Deprecated.As of version 1.2.0-incubating, useextractConditionBySystemTag(Condition, String)
insteadDescription copied from interface:DefinitionsService
Retrieves a condition matching the specified tag identifier from the specified root condition. TODO: remove from API and move to a different class? TODO: purpose and behavior not clear- Specified by:
extractConditionByTag
in interfaceDefinitionsService
- Parameters:
rootCondition
- the root condition where to start the extraction by classtag
- the tag to use to extract the condition- Returns:
- Condition the condition that has been found matching the tag, or null if none matched
-
extractConditionBySystemTag
public Condition extractConditionBySystemTag(Condition rootCondition, String systemTag)
Description copied from interface:DefinitionsService
Retrieves a condition matching the specified system tag identifier from the specified root condition.- Specified by:
extractConditionBySystemTag
in interfaceDefinitionsService
- Parameters:
rootCondition
- the root condition where to start the extraction by classsystemTag
- the tag to use to extract the condition- Returns:
- Condition the condition that has been found matching the tag, or null if none matched
-
resolveConditionType
public boolean resolveConditionType(Condition rootCondition)
Description copied from interface:DefinitionsService
Resolves (if possible) theConditionType
s for the specified condition and its sub-conditions (if any) from the type identifiers existing on the specified condition TODO: remove from API and move to a different class?- Specified by:
resolveConditionType
in interfaceDefinitionsService
- Parameters:
rootCondition
- the condition for which we want to resolve the condition types from the existing condition type identifiers- Returns:
true
-
refresh
public void refresh()
Description copied from interface:DefinitionsService
Forces a refresh of the definitions from the persistence service. Warning: this may seriously impact performance so it is recommended to use this in specific cases such as for example in integration tests.- Specified by:
refresh
in interfaceDefinitionsService
-
getConditionBuilder
public ConditionBuilder getConditionBuilder()
Description copied from interface:DefinitionsService
Retrieves a new instance of a ConditionBuilder to help to build conditions.- Specified by:
getConditionBuilder
in interfaceDefinitionsService
- Returns:
- a new instance of a ConditionBuilder
-
-