|
Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.p13n.rules.model.RuleModelInfoSvc
public class RuleModelInfoSvc
A singelton service to provide information to help with rules models.
The available ClauseModelInfo and RuleTypeInfo set can externally
configured. The RuleModelInfoSvc singelton
will
configure
itself by finding all the
META-INF/rules-model-info.xml resources available to its ClassLoader. Each
file resource will be parsed according to the XML schema for the
http://www.bea.com/servers/p13n/xsd/rule-model-info namespace. This
structure looks like:
<?xml version="1.0" encoding="ASCII"?>
<rule-model-info
xmlns="http://www.bea.com/servers/p13n/xsd/rule-model-info">
<clause-model-info>
<clause-type>clauseType1</clause-type>
<clause-type>clauseType2</clause-type>
<usage>condition|action</usage>
<clause-model-class>ClauseModel implementation class name</clause-model-class>
<recognizer>ClauseModelRecognizer implementation class name</recognizer>
[<recognizer-priority>100</recognizer-priority>]
</clause-model-info>
<rule-type-info [allow-multiple-actions="true|false"]>
<rule-type>ruleType1</rule-type>
<rule-type>ruleType2</rule-type>
[<recognizer>RuleTypeRecognizer implementation class name</recognizer>]
[<recognizer-priority>100</recognizer-priority>]
<clause-type>*</clause-type>
<clause-type>available clauseType1</clause-type>
<excluded-clause-type>available clauseType2</excluded-clause-type>
</rule-type-info>
</rule-model-info>
Each <clause-model-info> configures an
ClauseModelInfo
mapped to each contained
<clause-type>. <usage> must be either condition
(to signify a condition clause), action
(for an action
clause), or either
(if it's available as either action or condition
usage). <clause-model-class> is the fully qualified class name of
the ClauseModel subclass that should be used. <recognizer> is the
fully qualified class name of the ClauseModelRecognizer that should be used
to recognize the <clause-type>. <recognizer-priority> is the
priority of the recognizer as a positive integer (0 or greater), which
controls the order in which recognizers execute. A higher numbers means it
runs earlier and can recognize a clause before other recognizers.
Each <rule-type-info> configures an
RuleTypeInfo
mapped to each contained
<rule-type>. The optional allow-multiple-actions
attribute specifies whether the rule can have multiple actions; it defaults
to true. <recognizer> is the fully qualified class name of
the RuleTypeRecognizer that should be used to recognize the
<rule-type>. <recognizer-priority> is the
priority of the recognizer as a positive integer (0 or greater), which
controls the order in which recognizers execute. A higher numbers means it
runs earlier and can recognize a clause before other recognizers.
Each <clause-type> specified is an available clause
type for the rule-type; each should have a corresponding
<clause-model-info> entry in one of the META-INF/rule-model-info.xml
resources. *
can be used to signify that any clause type is
available for this rule type. <excluded-clause-type> will exclude a
clause type from this rule-type; similarly, *
will exclude all
clause types not specified listed in a <clause-type> element.
Mulitple registrations of the same <clause-type> or <rule-type> are non-deterministic. Additionally, a ClauseModelRecognizer or RuleTypeRecognizer that recognizes outside of its <clause-model> or <rule-type-info> are non-deterministic.
Note: turning on debug for this class (via a com.bea.p13n.util.debug.Debug style debug.properties) will show the load sequencing, including any errors in the META-INF/rule-model-info.xml files.
Nested Class Summary | |
---|---|
static class |
RuleModelInfoSvc.ClauseModelInfo
Base information about clause models. |
static class |
RuleModelInfoSvc.RuleTypeInfo
Information about rule-types. |
Field Summary | |
---|---|
static int |
DEF_RECOGNIZER_PRIORITY
|
Method Summary | |
---|---|
void |
addClauseModelInfo(RuleModelInfoSvc.ClauseModelInfo info)
Add a clause model configuration to this instance. |
void |
addRuleTypeInfo(RuleModelInfoSvc.RuleTypeInfo info)
Add a rule type configuration to this instance. |
boolean |
allowsMultipleActions(String ruleType)
Tell if the specified rule type allows multiple actions. |
boolean |
areEquivalentTypeAliases(String type1,
String type2)
Tell if 2 typeAliases are equivalent. |
static ClauseModel |
createClauseModel(String clauseType,
Class<? extends ClauseModel> clauseClass,
org.apache.xmlbeans.XmlObject clause)
Helper method to construct an initialized ClauseModel. |
ClauseModel |
createNewClauseModel(String clauseType)
Get a new, uninitialized clause model for the specified clause type. |
static RuleModelInfoSvc |
get()
Get the singleton instance of this. |
String[] |
getActionClauseTypes(String ruleType)
Get the supported condition clause types for the specified rule type. |
String[] |
getAvailableClauseTypes(String ruleType)
Get the supported clause types for the specified rule type. |
ClauseModel |
getClauseModel(String clauseType,
org.apache.xmlbeans.XmlObject clause)
Get a clause model instance initialized against the specified clause structure. |
ClauseModel |
getClauseModel(org.apache.xmlbeans.XmlObject clause)
Get a clause model instance initialized against the specified clause structure. |
Map<String,RuleModelInfoSvc.ClauseModelInfo> |
getClauseModelInfos()
Get the map of clauseType to ClauseModelInfo objects. |
String |
getClauseType(org.apache.xmlbeans.XmlObject clause)
Get the clause type for the specified clause structure. |
String[] |
getConditionClauseTypes(String ruleType)
Get the supported condition clause types for the specified rule type. |
RuleModel |
getRuleModel(String ruleType)
Create a new, empty RuleModel of the specified ruleType. |
String |
getRuleType(RuleModel rule)
Get the String for the specified rule. |
Map<String,RuleModelInfoSvc.RuleTypeInfo> |
getRuleTypeInfos()
Get the map of ruleType to RuleTypeInfo objects. |
Map<String,String> |
getTypeAliasMap()
Get the map of type-alias short-name to fully-qualified java class name for type-aliases. |
boolean |
isActionClause(String clauseType)
Determine if a clause type is available as an action. |
boolean |
isConditionClause(String clauseType)
Determine if a clause type is available as a condition. |
boolean |
isKnownClauseType(String clauseType)
Tell if the specified clause type is registered. |
static void |
loadConfiguration(RuleModelInfoSvc svc,
URL file,
ClassLoader cl)
Load the configuration in the specified file conforming to the http://www.bea.com/servers/p13n/xsd/rule-model-info schema. |
static void |
loadDefaultConfiguration(RuleModelInfoSvc svc)
Load the default ClauseModelInfo and RuleTypeInfo configuration into the specified service instance. |
static void |
loadDefaultConfiguration(RuleModelInfoSvc svc,
ClassLoader cl)
Load the default ClauseModelInfo and RuleTypeInfo configuration into the specified service instance. |
boolean |
removeClauseModelInfo(String clauseType)
Remove a clause model configuration to this instance. |
boolean |
removeRuleTypeInfo(String ruleType)
Remove a rule type configuration to this instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEF_RECOGNIZER_PRIORITY
Method Detail |
---|
public static RuleModelInfoSvc get()
loadDefaultConfiguration(RuleModelInfoSvc)
public static void loadDefaultConfiguration(RuleModelInfoSvc svc) throws IOException
IOException
- on error loading default rule model info
configuration.public static void loadDefaultConfiguration(RuleModelInfoSvc svc, ClassLoader cl) throws IOException
svc
- the instance to load.cl
- the ClassLoader to load from.
IOException
- on error loading default rule model info
configuration.loadConfiguration(RuleModelInfoSvc, URL, ClassLoader)
public static void loadConfiguration(RuleModelInfoSvc svc, URL file, ClassLoader cl)
svc
- the instance to loadfile
- the URL to the configuration file.cl
- the ClassLoader to use to load objects.public static ClauseModel createClauseModel(String clauseType, Class<? extends ClauseModel> clauseClass, org.apache.xmlbeans.XmlObject clause) throws IllegalArgumentException
clause
- the xml structure of the clause or null for a new, empty
instance.
IllegalArgumentException
- if clause can't be instantied or
isn't the correct structure for the clause class.public Map<String,String> getTypeAliasMap()
public boolean areEquivalentTypeAliases(String type1, String type2)
public Map<String,RuleModelInfoSvc.ClauseModelInfo> getClauseModelInfos()
public void addClauseModelInfo(RuleModelInfoSvc.ClauseModelInfo info)
public boolean removeClauseModelInfo(String clauseType)
public Map<String,RuleModelInfoSvc.RuleTypeInfo> getRuleTypeInfos()
public void addRuleTypeInfo(RuleModelInfoSvc.RuleTypeInfo info)
public boolean removeRuleTypeInfo(String ruleType)
public String getRuleType(RuleModel rule)
public boolean allowsMultipleActions(String ruleType)
public RuleModel getRuleModel(String ruleType)
public boolean isKnownClauseType(String clauseType)
public String getClauseType(org.apache.xmlbeans.XmlObject clause)
public boolean isConditionClause(String clauseType)
public boolean isActionClause(String clauseType)
public ClauseModel getClauseModel(String clauseType, org.apache.xmlbeans.XmlObject clause)
public ClauseModel getClauseModel(org.apache.xmlbeans.XmlObject clause)
public ClauseModel createNewClauseModel(String clauseType)
public String[] getAvailableClauseTypes(String ruleType)
public String[] getConditionClauseTypes(String ruleType)
public String[] getActionClauseTypes(String ruleType)
|
Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |