|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.services.StandardManager
wt.rule.impl.StandardRuleService
The standard implementation of the RuleService
interface.
Use the newStandardRuleService
static factory method(s),
not the StandardRuleService
constructor, to construct instances
of this class. Instances must be constructed using the static factory(s),
in order to ensure proper initialization of the instance.
Supported API: false
Extendable: false
Nested Class Summary | |
private static class |
StandardRuleService.CompareByName
A comparator that can be used to determine if two rules have the same name. |
Field Summary | |
private RuleApplierFactory |
_applierFactory
|
private Map |
_managedCaches
|
private RuleMergerFactory |
_mergerFactory
|
private Map |
_postStoreWork
|
private RuleSelectorFactory |
_selectorFactory
|
private RuleValidatorFactory |
_validatorFactory
|
private static boolean |
AUTO_INIT
|
private static String |
CLASSNAME
|
private StandardRuleService.CompareByName |
NAME_COMPARATOR
|
private static String |
RESOURCE
|
private static String |
RULE_RESOURCE
|
Fields inherited from class wt.services.StandardManager |
|
Fields inherited from interface wt.services.Manager |
MANAGER_SERVICE, STARTUP_AUTOMATIC, STARTUP_MANUAL, STATUS_EMERGENCY_SHUTDOWN, STATUS_EMERGENCY_SHUTTING_DOWN, STATUS_SHUTDOWN, STATUS_SHUTDOWN_ERRORS, STATUS_SHUTDOWN_FAILURE, STATUS_SHUTTING_DOWN, STATUS_STARTED, STATUS_STARTED_ERRORS, STATUS_STARTING_UP, STATUS_STARTUP_FAILURE |
Constructor Summary | |
StandardRuleService()
|
Method Summary | |
void |
addCache(RuleCache cache,
RuleType ruleType)
Add a CacheManager to the list of caches managed
by this service for the specified RuleType . |
void |
addPostStoreTask(Persistable object,
com.objectspace.jgl.UnaryFunction task)
Add a task to be executed when a POST_STORE event is
received for the specified object. |
Object |
applyRule(Object object,
Rule rule)
Apply rule to the object . |
Object |
applyRule(Object object,
Rule rule,
WTContainerRef container)
Apply rule to the object . |
Rule |
disableRule(Rule rule)
Disable the specified Rule . |
Rule |
enableRule(Rule rule)
Enable the specified Rule . |
QueryResult |
findRules(Class objType,
RuleType ruleType,
boolean enabled)
Find all TypeBasedRule s in the Classic
container that are of type ruleType and whose object
type attribute equals objType . |
QueryResult |
findRules(Class objType,
RuleType ruleType,
WTContainerRef container,
boolean enabled)
Find all TypeBasedRule s in the specified container
that are of type ruleType and whose object type attribute
equals objType . |
private RuleApplierFactory |
getApplierFactory()
Get the RuleApplierFactory used by this
service to obtain RuleApplier s. |
String |
getConceptualClassname()
Deprecated. |
private RuleMergerFactory |
getMergerFactory()
Get the RuleMergerFactory used by this
service to obtain RuleMerger s. |
Rule |
getRule(Object object,
RuleType ruleType)
Select an appropriate rule from the Classic container
based on the object and ruleType supplied
as arguments. |
Rule |
getRule(Object object,
RuleType ruleType,
WTContainerRef container)
Select an appropriate rule from the specified container based on the object and ruleType supplied as arguments. |
private RuleSelectorFactory |
getSelectorFactory()
Get the RuleSelectorFactory used by this
service to obtain RuleSelector s. |
private RuleValidatorFactory |
getValidatorFactory()
Get the RuleValidatorFactory used by this
service to obtain RuleValidator s. |
Rule |
mergeRules(Rule[] rules,
RuleType ruleType)
Merge the provided rules into a composite rule. |
static StandardRuleService |
newStandardRuleService()
Default factory for the class. |
void |
notifyPostDelete(Rule target)
Notify the cache that a wt.fc.PersistenceManagerEvent.POST_DELETE
event for a Rule has occured. |
void |
notifyPostStore(Rule target)
Notify the cache that a wt.fc.PersistenceManagerEvent.POST_STORE
event for a Rule has occured. |
void |
notifyUpdate(Rule target)
Notify the cache that a wt.fc.PersistenceManagerEvent.UPDATE
event for a Rule has occured. |
protected void |
performStartupProcess()
Add listeners for the following events: wt.fc.PersistenceManagerEvent.PRE_STORE
wt.fc.PersistenceManagerEvent.POST_STORE
wt.fc.PersistenceManagerEvent.POST_DELETE
wt.fc.PersistenceManagerEvent.UPDATE
wt.fc.PersistenceManagerEvent.PRE_MODIFY
|
private void |
validateRule(Rule rule)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String CLASSNAME
private static final String RULE_RESOURCE
private final RuleSelectorFactory _selectorFactory
private final RuleApplierFactory _applierFactory
private final RuleMergerFactory _mergerFactory
private final RuleValidatorFactory _validatorFactory
private final Map _postStoreWork
private final Map _managedCaches
private final StandardRuleService.CompareByName NAME_COMPARATOR
private static final boolean AUTO_INIT
Constructor Detail |
public StandardRuleService()
Method Detail |
public String getConceptualClassname()
getConceptualClassname
in interface NetFactor
getConceptualClassname
in class StandardManager
public static StandardRuleService newStandardRuleService() throws WTException
WTException
public Rule getRule(Object object, RuleType ruleType) throws WTException
Classic
container
based on the object
and ruleType
supplied
as arguments.
The object
argument may be a type identifier or
a normal object. A type identifier is one of the following:
Class
TypeIdentifier
String
specifying the name of the type
getRule
in interface RuleService
object
- the object that the rule should be applicable to (cannot be null
)ruleType
- the type of rule to select (cannot be null
)
WTException
public Rule getRule(Object object, RuleType ruleType, WTContainerRef container) throws WTException
object
and ruleType
supplied as arguments.
The object
argument may be a type identifier or
a normal object. A type identifier is one of the following:
Class
TypeIdentifier
String
specifying the name of the type
getRule
in interface RuleService
object
- the object that the rule should be applicable to (cannot be null
)ruleType
- the type of rule to select (cannot be null
)container
-
WTException
public Object applyRule(Object object, Rule rule, WTContainerRef container) throws WTException, WTPropertyVetoException
rule
to the object
. Return the resulting
object. The result object might be the same object or a different
one depending on the semantics of the rule. The specified container
is used to lookup resource objects that are required while applying
the rule.
If the rule
is null
then nothing is done
and the original object
is returned.
NOTE: This interface does not support operations that require
returning multiple objects.
Supported API: false
applyRule
in interface RuleService
object
- the object that the rule should be applied to (cannot be null
)rule
- the rule to be appliedcontainer
- the container to use for resource object lookups
WTException
WTPropertyVetoException
public Object applyRule(Object object, Rule rule) throws WTException, WTPropertyVetoException
rule
to the object
. Return the resulting
object. The result object might be the same object or a different
one depending on the semantics of the rule. The Classic
container is used to lookup resource objects that are required while
applying the rule.
If the rule
is null
then nothing is done
and the original object
is returned.
NOTE: This interface does not support operations that require
returning multiple objects.
Supported API: false
applyRule
in interface RuleService
object
- the object that the rule should be applied to (cannot be null
)rule
- the rule to be applied
WTException
WTPropertyVetoException
public QueryResult findRules(Class objType, RuleType ruleType, boolean enabled) throws WTException
TypeBasedRule
s in the Classic
container that are of type ruleType
and whose object
type attribute equals objType
.
If enabled
is true then only return those rules that
are enabled. If enabled
is false
then all
matching rules are returned.
Supported API: false
findRules
in interface RuleService
objType
- the object type that the returned rules should referenceruleType
- the type of rule that should be returnedenabled
- whether only enabled rules should be returned
WTException
public QueryResult findRules(Class objType, RuleType ruleType, WTContainerRef container, boolean enabled) throws WTException
TypeBasedRule
s in the specified container
that are of type ruleType
and whose object type attribute
equals objType
.
If enabled
is true then only return those rules that
are enabled. If enabled
is false
then all
matching rules are returned.
Supported API: false
findRules
in interface RuleService
objType
- the object type that the returned rules should referenceruleType
- the type of rule that should be returnedcontainer
- the container to start searching inenabled
- whether only enabled rules should be returned
WTException
public Rule disableRule(Rule rule) throws WTException
Rule
.
disableRule
in interface RuleService
rule
- the rule to disable
WTException
public Rule enableRule(Rule rule) throws WTException
Rule
.
enableRule
in interface RuleService
rule
- the rule to enable
WTException
public Rule mergeRules(Rule[] rules, RuleType ruleType) throws WTException, WTPropertyVetoException
mergeRules
in interface RuleService
rules
- the rules to be mergedruleType
- the ruleType of the rules to be merged
WTException
WTPropertyVetoException
public void addPostStoreTask(Persistable object, com.objectspace.jgl.UnaryFunction task)
POST_STORE
event is
received for the specified object.
The task is a UnaryFunction
that takes
one argument. When a POST_STORE
event is received for
the specified object, the function is called with that object as its
sole argument.
The functions are held in a weak map, so if the object is garbage
collected before it is persisted, the task will be removed.
Supported API: false
addPostStoreTask
in interface RuleServiceSvr
object
- task
- public void addCache(RuleCache cache, RuleType ruleType)
CacheManager
to the list of caches managed
by this service for the specified RuleType
.
These caches will be notified when the following events occur for a rule with the specified rule type:
wt.fc.PersistenceManagerEvent.POST_STORE
wt.fc.PersistenceManagerEvent.POST_DELETE
wt.fc.PersistenceManagerEvent.UPDATE
addCache
in interface RuleServiceSvr
cache
- ruleType
- public void notifyPostStore(Rule target)
wt.fc.PersistenceManagerEvent.POST_STORE
event for a Rule
has occured.
notifyPostStore
in interface RuleCache
target
- public void notifyPostDelete(Rule target)
wt.fc.PersistenceManagerEvent.POST_DELETE
event for a Rule
has occured.
notifyPostDelete
in interface RuleCache
target
- public void notifyUpdate(Rule target)
wt.fc.PersistenceManagerEvent.UPDATE
event for a Rule
has occured.
notifyUpdate
in interface RuleCache
target
- protected void performStartupProcess() throws ManagerException
wt.fc.PersistenceManagerEvent.PRE_STORE
wt.fc.PersistenceManagerEvent.POST_STORE
wt.fc.PersistenceManagerEvent.POST_DELETE
wt.fc.PersistenceManagerEvent.UPDATE
wt.fc.PersistenceManagerEvent.PRE_MODIFY
PRE_STORE
The StandardRuleService listens for
PersistenceManagerEvent.PRE_STORE
events. If AUTO_INIT
is true, then in response to this event, it applies the appropriate
INIT
rule to the target object in order to supply default values for
the object. The auto-initialization only occurs for the following types
of objects:
WTAnalysisActivity
WTChangeActivity2
WTChangeInvestigation
WTChangeIssue
WTChangeOrder2
WTChangeProposal
WTChangeRequest2
WTDocument
EPMDocument
WTPart
WTProductConfiguration
WTProductInstance2
ManagedBaseline
DiscreteActionItem
POST_STORE
The StandardRuleService listens for
PersistenceManagerEvent.POST_STORE
events. When it receives
a POST_STORE
event it checks to see if there are any tasks to
be performed on the object. If there is, it performs those tasks (see
wt.rule.RuleService#addPostStoreTask
for more details). If it
detects that a Rule
has been created, it calls
notifyPostStore
on all the RuleCache
s it manages
that have registed for the RuleType
of the that was created.
POST_DELETE
The StandardRuleService listens for
PersistenceManagerEvent.POST_DELETE
events. If it detects
that a Rule
has been deleted, it calls notifyPostDelete
on all the RuleCache
s it manages that have registed for the
RuleType
of the rule that was deleted.
PRE_MODIFY
The StandardRuleService listens for
PersistenceManagerEvent.PRE_MODIFY
events. If it detects that a rule
is being modified then a validator is obtained and used to validate the rule. If
the rule is not valid then the modification is rejected.
UPDATE
The StandardRuleService listens for
PersistenceManagerEvent.UPDATE
events. If it detects
that a Rule
has been updated, it calls notifyUpdate
on all the RuleCache
s it manages that have registed for
the RuleType
of the rule that has been updated.
performStartupProcess
in class StandardManager
ManagerException
private void validateRule(Rule rule) throws WTException
WTException
private RuleSelectorFactory getSelectorFactory()
RuleSelectorFactory
used by this
service to obtain RuleSelector
s.
private RuleApplierFactory getApplierFactory()
RuleApplierFactory
used by this
service to obtain RuleApplier
s.
private RuleMergerFactory getMergerFactory()
RuleMergerFactory
used by this
service to obtain RuleMerger
s.
private RuleValidatorFactory getValidatorFactory()
RuleValidatorFactory
used by this
service to obtain RuleValidator
s.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |