|
Oracle Fusion Middleware Java API Reference for Oracle Business Rules 11g Release 1 (11.1.1.6.2) E10663-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.rules.sdk2.dictionary.DictionaryObject
oracle.rules.sdk2.dictionary.DictionaryComponent
oracle.rules.sdk2.dictionary.DictionaryName
oracle.rules.sdk2.dictionary.RuleDictionary
public class RuleDictionary
The RuleDictionary class is used to access and modify a rule dictionary in memory. A rule dictionary contains a data model, rule sets, and links to other rule dictionaries.
RuleDictionary does not provide any concurrency properties. Multiple threads may access a single RuleDictionary instance, but each thread must use its own handle.
A transaction consists of all changes made to DictionaryObjects in between invocations of RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
. Transactions can be undone and redone using the UndoableEdit
instance returned from a call to update.
A handle can be created using the RuleDictionary.createHandle()
method. An application would have a single RuleDictionary instance which was newly created or read from a persistent store. This is then shared among shared among different readers or writers by providing each with a RuleDictionary handle created from calling RuleDictionary.createHandle()
. Note that both the instance and handles use the same RuleDictionary class. The changes in a transaction are stored in the local RuleDictionary handle and then moved to the shared RuleDictionary instance when RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
is called. Note:When multiple threads are modifying their handle, an SDKException
will be thrown if update is called and another handle has called update since the current handle's last call to update.
It also means that an update may fail with a ConcurrentUpdateException
if two updates happen nearly simultaneously. In either case, the transaction should be rolled back using RuleDictionary.rollback()
.
If concurrent editing is desired, it is recommended that applications implement their own concurrent editing semantics on top of the provided primitives. Take note that allowing truly concurrent editing is very difficult because users can make incompatible changes to a dictionary. In many cases, allowing exclusive access to only one writer at a time is easier to implement and easier to manage in practice.
Note that a thread that only reads from it's handle must periodically call RuleDictionary.rollback()
or RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
in order to see the latest contents of the main dictionary(even though it has made no changes).
A transaction only covers updates to the main RuleDictionary instance. It does not cover saving the dictionary to a persistent store. In particular, do not save more than one in-memory rule dictionary to the same persistent store. The second save will overwrite the first.
Rule dictionaries can link to other rule dictionaries. These links allow a large dictionary to be partitioned into several smaller dictionaries. This affords reuse of a shared data model, or partitioning sensitive rules into a dictionary with stricter access control. For more information see DictionaryLink
.
The RuleDictionary is a container for the dictionary objects it contains, e.g., the RuleDictionary.getRuleSet(String)
method returns a RuleSet
object, and then RuleSet.getRuleByName(String)
is a factory that returns a Rule
object, and so forth.
DictionaryComponentTable implements List methods like remove. When a DictionaryObject is removed, subsequent attempts to access properties of the dictionary object will result in a RuntimeException.
The following examples show how to use the RuleDictionary.
RuleDictionary dic = RuleDictionary.createDictionary("MyDic");
The example assumes that multiple handles may be updating the Dictionary concurrently. Because the concurrency control is optimistic and does not use locks, the RuleDictionary users must be prepared to retry their updates. Below is a naive example of doing this, using a while(true) loop.
RuleDictionary.UndoableEdit undo = null; List warnings = new ArrayList(); while (true) { RuleSet rs = dic.createEmptyRuleSet("newRuleSet"); rs.setDescription("my favorite rules"); try { undo = dic.update(warnings); } catch (ConcurrentUpdateException e) { dic.rollback(); continue; } catch (SDKException e) { dic.rollback(); continue; } break; }
Readers should begin with an update, commit, or rollback to ensure they see the latest dictionary updates.
UndoableEdit undo = dic.update(warnings); // even if we haven't modified the dictionary, update returns unresolved prior warnings... RuleSet rs = dic.getRuleSet("newRuleSet"); assert rs != null;
undo.undo();
dic.rollback(); // another way to sync up with the latest in-memory dictionary content RuleSet rs = dic.getRuleSet("newRuleSet"); assert rs == null;
Nested Class Summary |
---|
Nested classes/interfaces inherited from class oracle.rules.sdk2.dictionary.DictionaryComponent |
---|
DictionaryComponent.Diff, DictionaryComponent.DiffType |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary |
---|
Method Summary | |
---|---|
java.lang.Object |
addDictionaryChangeListener(DictionaryChangeListener listener) Add a DictionaryChangeListener to receive notifications of dictionary changes via DictionaryChangeEvent s. |
void |
copyTo(RuleDictionary from) copy to this dictionary |
static RuleDictionary |
createDictionary(java.lang.String name, DictionaryFinder finder) Create a new rule dictionary. |
DictionaryLink |
createDictionaryLink(java.lang.String pkg, java.lang.String name) Create a DictionaryLink and add it into the rule dictionary. |
RuleSet |
createEmptyRuleSet(java.lang.String name) Create and return an empty RuleSet with the given name. |
RuleDictionary |
createHandle() Get a handle to access the dictionary. |
java.lang.String |
dataModelRL() Generate the RL for the data model in this dictionary and in linked dictionaries. |
void |
diff(RuleDictionary that, java.lang.Object versionInfo) Compute the difference between this dictionary and that one, identified by versionInfo. |
java.lang.String |
formatNumber(java.lang.Number n) |
java.lang.String |
getAliasByID(DOID id) Get alias of DictionaryComponent by its ID. |
static RuleDictionary |
getBuiltinDictionary() get builtin rule dictionary |
CombinedDataModel |
getCombinedDataModel() Get accessor for data model components in the combined dictionary DO NOT CACHE the result of this method across RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>) calls. |
DataModel |
getDataModel() Get the datamodel from this dictionary. |
DictionaryProperty<DataModel> |
getDataModelProperty() Get DataModel Property. |
java.util.List<RuleDictionary> |
getDictionaries() get this dictionary and all linked dictionaries. |
RuleDictionary |
getDictionary(java.lang.String alias) Get Dictionary from all linked dictionaries by alias |
java.lang.String |
getDictionaryDescription() Get description of the dictionary. |
DictionaryFinder |
getDictionaryFinder() get the finder for linked dictionaries |
DictionaryLink |
getDictionaryLink(java.lang.String alias) Get the dictionary link by alias. |
DictionaryLink |
getDictionaryLink(java.lang.String pkg, java.lang.String name) Get the dictionary link by fully qualified name. |
java.util.List<java.lang.String> |
getDictionaryLinkAliases() Get a List of DictionaryLink Aliases that are currently stored in in the RuleDictionary (in-memory copy). |
DictionaryLinkTable |
getDictionaryLinkTable() Get the dictionary link table |
TableProperty<DictionaryLink> |
getDictionaryLinkTableProperty() Get DictionaryLinkTable Property. |
java.lang.String |
getFullyQualifiedNameByID(DOID id) Get fully qualified name of DictionaryComponent by its ID. |
java.lang.String |
getLifeCycle() Get the dictionary life cycle |
java.lang.String |
getLifeCycleDescription() Get the dictionary life cycle description |
java.util.List<RuleDictionary> |
getLinkedDictionaries() get all linked dictionaries (recursively) but not this one. |
java.util.Locale |
getLocale() get the locale that was set for this dictionary. |
java.lang.String |
getNameByID(DOID id) Get name of DictionaryComponent by its ID. |
java.text.NumberFormat |
getNumberFormat() Get the NumberFormat for this RuleDictionary instance. |
DictionaryObject |
getObjectByID(DOID id) Get dictionary object by its ID. |
java.lang.String |
getResourceBundle() Get the name of the user resource bundle for TranslatedProperty s. |
java.util.ResourceBundle.Control |
getResourceBundleControl() Get the user resource bundle control for TranslatedProperty s. |
java.util.ResourceBundle[] |
getResourceBundles() get resource bundles to translate TranslatedProperty s first is system, second is user bundle. |
RuleSet |
getRuleSet(java.lang.String alias) Get the ruleset by alias from this dictionary |
java.util.List<java.lang.String> |
getRuleSetAliases(boolean combined) Get a List of RuleSet Aliases that are currently stored in in the RuleDictionary (in-memory copy). |
java.lang.String[] |
getRuleSetOptions() Get rulesets in dictionary (and linked dictionaries) as an option list |
java.util.List<RuleSet> |
getRuleSets(java.lang.String alias) Get the rulesets by alias from this dictionary and linked dictionaries. |
RuleSetTable |
getRuleSetTable() Get the ruleset table. |
TableProperty<RuleSet> |
getRuleSetTableProperty() Get RuleSetTable Property. |
java.lang.String |
getServiceConfiguration() |
java.lang.String |
getServiceName() get name of decision service exposing this dictionary's decision functions |
java.lang.String |
getServiceNamespace() |
java.lang.String[][] |
getSynopsis() Get a synopsis of the dictionary contents. |
java.util.ResourceBundle |
getTypeNameBundle() Deprecated. use getResourceBundles()[0] |
java.util.List<SDKWarning> |
getWarnings(boolean includeDescendants) get Warnings associated with this dictionary object or its descendants. |
boolean |
isCustomizationMode() Is customization mode turned on? |
boolean |
isTransactionInProgress() |
boolean |
isValid() is the dictionary valid? |
java.lang.Number |
parseNumber(java.lang.String value) Parse a number. |
boolean |
processDecisionTrace(DecisionTrace trace) |
static boolean |
processDecisionTrace(DecisionTrace trace, RuleDictionary dict) |
static RuleDictionary |
readDictionary(java.io.Reader reader, DictionaryFinder finder) Read a RuleDictionary from a Reader. |
java.lang.Object |
removeDictionaryChangeListener(DictionaryChangeListener listener) Remove DictionaryChangeListener . |
DictionaryLink |
removeDictionaryLink(java.lang.String alias) Remove dictionary link by name. |
boolean |
removeDiff(java.lang.Object versionInfo) Remove all the Diff information associated with versionInfo. |
RuleSet |
removeRuleSet(java.lang.String name) Remove ruleset by name. |
void |
rollback() rollback the current update transaction. |
java.lang.String |
ruleSetRL(java.lang.String alias) Generate the RL for the given rule set in this dictionary and in linked dictionaries. |
void |
setCustomizationMode(boolean flag) Set customization mode. |
void |
setDictionaryDescription(java.lang.String desc) Set description to the dictionary. |
void |
setDictionaryFinder(DictionaryFinder finder) set the finder for linked dictionaries |
void |
setLifeCycle(java.lang.String lifecycle) Set the dictionary life cycle |
void |
setLifeCycleDescription(java.lang.String description) Set the dictionary life cycle description |
void |
setLocale(java.util.Locale locale) set the locale. |
void |
setResourceBundle(java.lang.String name) Set the name of the user resource bundle for TranslatedProperty s. |
void |
setResourceBundleControl(java.util.ResourceBundle.Control control) Set the user resource bundle control for TranslatedProperty s. |
void |
setServiceConfiguration(java.lang.String sc) |
void |
setServiceName(java.lang.String sn) |
void |
setServiceNamespace(java.lang.String sn) |
UndoableEdit |
update(java.util.List<SDKWarning> exceptions) Update the RuleDictionary. |
void |
validate(java.util.List<SDKException> errors, java.util.List<SDKWarning> warnings) Validate and append errors and warnings. |
void |
writeDictionary(java.io.Writer writer) Write a RuleDictionary to a Writer. |
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryName |
---|
getFullyQualifiedName, getPackage, getPackageProperty, isFullyQualifiedName, setPackage |
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryComponent |
---|
clear, containsKey, containsValue, entrySet, get, getAlias, getAlias, getAliasProperty, getAllReferences, getCustom, getDependents, getDescription, getDescriptionProperty, getDiff, getDiffProperties, getDiffs, getFullyQualifiedAlias, getIndex, getIndex, getName, getNameProperty, getNext, getObjectPath, getOptions, getPrevious, getProperties, getProperty, getSelected, hasDiff, init, isAliasDistinct, isEmpty, isNameDistinct, keySet, put, putAll, remove, setAlias, setCustom, setDescription, setName, size, validate, values |
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryObject |
---|
equals, exists, getAEReferences, getContainedIDs, getContainedIDs, getDictionary, getID, getIndent, getLevel, getObjectType, getParentByClass, getParentComponent, getParentComponentTable, getParentObject, getReferences, getRuleSet, getState, hashCode, isModified, validate |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Method Detail |
---|
public boolean isCustomizationMode()
public void setCustomizationMode(boolean flag)
RuleDictionary.isCustomizationMode()
.public DictionaryFinder getDictionaryFinder()
public void setDictionaryFinder(DictionaryFinder finder)
public java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
public java.lang.Number parseNumber(java.lang.String value)
value
- to parsepublic java.lang.String formatNumber(java.lang.Number n)
public java.text.NumberFormat getNumberFormat()
if (dictionary.getNumberFormat() instanceof DecimalFormat) { DecimalFormat df = (DecimalFormat)dictionary.getNumberFormat(); DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); dfs.setDecimalSeparator(','); df.setDecimalFormatSymbols(dfs); }
The number format will change when the dictionary locale is changed. Changes to decimal format symbols will be overwritten when the locale is changed.
public DictionaryObject getObjectByID(DOID id)
If ID is global (starts with "G"), then linked dictionaries are searched as well. If ID is builtin (starts with "B"), then only the builtin dictionary is searched.
id
- the ID of the DictionaryObjectpublic java.lang.String getAliasByID(DOID id)
id
- Stringpublic java.lang.String getNameByID(DOID id)
id
- Stringpublic java.lang.String getFullyQualifiedNameByID(DOID id)
id
- Stringpublic static RuleDictionary readDictionary(java.io.Reader reader, DictionaryFinder finder) throws SDKException, java.io.IOException
The content of the Reader should have been produced by a prior call to RuleDictionary.writeDictionary(java.io.Writer)
. Warning: The returned RuleDictionary has not been updated or validated, and therefore some information may be missing or incorrect. Most users should immediately invoke RuleDictionary.update(List)
on the returned RuleDictionary
.
The Reader parameter should be configured to read the UTF-8 character set. For example, if the dictionary is being read from a file, a common construction would look like:
Reader reader = new BufferedReader( new InputStreamReader( new FileInputStream( new File(DICT_LOCATION)), "UTF-8"));
This method does not close the Reader instance passed to it. It is the responsibility of the caller to close the Reader (typically in a finally block) to prevent a resource leak.
reader
- containing a rule dictionary documentfinder
- to find linked dictionariesSDKException
- if the dictionary can't be deserializedjava.io.IOException
- if can't read from Readerpublic static RuleDictionary createDictionary(java.lang.String name, DictionaryFinder finder) throws SDKException
name
- dictionary namefinder
- finder for linked dictionariesSDKException
public void writeDictionary(java.io.Writer writer) throws SDKException, java.io.IOException
Warning: Rule dictionaries containing validation warnings can be written, just as Java source files with compilation errors can be saved. It is the responsibility of user to ensure a dictionary is valid before it is deployed in an application.
The Writer parameter should be configured to write the UTF-8 character set.
For example, if the dictionary was to be written to the same file it was read from, a common construction would look like:
StringWriter swriter = new StringWriter(); rd.writeDictionary(swriter); Writer writer = null; try { writer = new OutputStreamWriter(new FileOutputStream(new File(fileName)),"UTF-8"); writer.write(swriter.toString()); } finally { if (writer != null) try { writer.close(); } catch (IOException e) {} }
Here we first write the dictionary to a StringWriter to ensure no SDKExceptions are thrown; If instead we first opened the File for writing and an SDKException was thrown, the file would have already been truncated on most platforms. With the above code, this will only happen if an IOException is thrown in the the call to write. If this method is to be used in production code, it is recommended that the user first makes a backup copy of the file before attempting to write to it in order to prevent losing the file if an IOException occurs.
This method does not close the Writer instance passed to it. It is the responsibility of the caller to close the Writer (typically in a finally block) to prevent a resource leak.
writer
- write the dictionary hereSDKException
- if the dictionary can't be serializedjava.io.IOException
- if can't write to writerpublic RuleDictionary createHandle() throws SDKException
SDKException
- if the dictionary is invalidRuleDictionary.clone()
public java.lang.String getDictionaryDescription()
public void setDictionaryDescription(java.lang.String desc)
desc
- description of the dictionary.public boolean isTransactionInProgress()
public UndoableEdit update(java.util.List<SDKWarning> exceptions) throws SDKException, ConcurrentUpdateException
exceptions
- a List of exceptions to append to.SDKException
- if invalid and exceptions is null.ConcurrentUpdateException
- if this dictionary version was updated by another thread.public void validate(java.util.List<SDKException> errors, java.util.List<SDKWarning> warnings)
DictionaryComponent
validate
in class DictionaryComponent
errors
- a List of error exceptions to append to.warnings
- a List of warning exceptions to append to.DictionaryObject.validate(List,List,int,int)
public java.util.List<RuleDictionary> getDictionaries()
public RuleDictionary getDictionary(java.lang.String alias)
alias
- of dictionarypublic java.util.List<RuleDictionary> getLinkedDictionaries()
public DictionaryProperty<DataModel> getDataModelProperty()
public DataModel getDataModel()
getDataModel
in class DictionaryObject
public CombinedDataModel getCombinedDataModel()
RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
calls.getCombinedDataModel
in class DictionaryObject
public RuleSet createEmptyRuleSet(java.lang.String name)
name
- of ruleset to createpublic java.util.List<java.lang.String> getRuleSetAliases(boolean combined)
The list is ordered by Java String comparison.
combined
- whether to get rule set names from linked dictionariespublic RuleSet getRuleSet(java.lang.String alias)
alias
- ruleset aliaspublic java.util.List<RuleSet> getRuleSets(java.lang.String alias)
alias
- ruleset aliaspublic TableProperty<RuleSet> getRuleSetTableProperty()
public RuleSetTable getRuleSetTable()
public RuleSet removeRuleSet(java.lang.String name)
name
- ruleset to removepublic DictionaryLink createDictionaryLink(java.lang.String pkg, java.lang.String name)
pkg
- package of the linked dictionaryname
- name of the linked dictionarypublic DictionaryLink getDictionaryLink(java.lang.String pkg, java.lang.String name)
name
- namepublic DictionaryLink getDictionaryLink(java.lang.String alias)
alias
- dictionary link aliaspublic TableProperty<DictionaryLink> getDictionaryLinkTableProperty()
public DictionaryLinkTable getDictionaryLinkTable()
public DictionaryLink removeDictionaryLink(java.lang.String alias)
alias
- of linked dictionary to removepublic boolean isValid()
public java.util.List<java.lang.String> getDictionaryLinkAliases()
public java.lang.String dataModelRL() throws SDKException
RuleSession
.SDKException
public java.lang.String ruleSetRL(java.lang.String alias) throws SDKException
RuleSession
.alias
- alias of the ruleSet for which to generate codeSDKException
public java.lang.Object addDictionaryChangeListener(DictionaryChangeListener listener)
DictionaryChangeListener
to receive notifications of dictionary changes via DictionaryChangeEvent
s.listener
- a DictionaryChangeListener
public java.lang.Object removeDictionaryChangeListener(DictionaryChangeListener listener)
DictionaryChangeListener
.listener
- a DictionaryChangeListener
RuleDictionary.addDictionaryChangeListener(oracle.rules.sdk2.dictionary.DictionaryChangeListener)
public void rollback()
public static RuleDictionary getBuiltinDictionary()
public java.lang.String getLifeCycle()
public void setLifeCycle(java.lang.String lifecycle)
lifecycle
- the life cyclepublic java.lang.String getLifeCycleDescription()
public void setLifeCycleDescription(java.lang.String description)
description
- the life cycle descriptionpublic void copyTo(RuleDictionary from)
from
- dictionary to copy from
@Deprecated
public java.util.ResourceBundle getTypeNameBundle()
getResourceBundles()[0]
public java.util.ResourceBundle[] getResourceBundles()
TranslatedProperty
s first is system, second is user bundle.public java.lang.String getResourceBundle()
TranslatedProperty
s. This is the first argument to ResourceBundle.getBundle(String,Locale)
public void setResourceBundle(java.lang.String name)
TranslatedProperty
s. This is the first argument to ResourceBundle.getBundle(String,Locale)
public java.util.ResourceBundle.Control getResourceBundleControl()
TranslatedProperty
s. This is the third argument to ResourceBundle.getBundle(String,Locale,ResourceBundle.Control)
public void setResourceBundleControl(java.util.ResourceBundle.Control control)
TranslatedProperty
s. This is the third argument to ResourceBundle.getBundle(String,Locale,ResourceBundle.Control)
control
- must be serializablepublic java.util.List<SDKWarning> getWarnings(boolean includeDescendants)
DictionaryObject
RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
are returned.getWarnings
in class DictionaryObject
includeDescendants
- whether to include warnings bound to this object's descendants.public java.lang.String[] getRuleSetOptions()
public java.lang.String getServiceName()
public void setServiceName(java.lang.String sn)
public java.lang.String getServiceNamespace()
public void setServiceNamespace(java.lang.String sn)
public java.lang.String getServiceConfiguration()
public void setServiceConfiguration(java.lang.String sc)
public boolean processDecisionTrace(DecisionTrace trace)
public static boolean processDecisionTrace(DecisionTrace trace, RuleDictionary dict)
public void diff(RuleDictionary that, java.lang.Object versionInfo)
RuleDictionary.update(java.util.List<oracle.rules.sdk2.exception.SDKWarning>)
d, until RuleDictionary.removeDiff(Object)
is called.that
- RuleDictionaryversionInfo
-DictionaryComponent.Diff
, DictionaryProperty
, SettableProperty
, TableProperty
public boolean removeDiff(java.lang.Object versionInfo)
versionInfo
-RuleDictionary.diff(RuleDictionary, Object)
public java.lang.String[][] getSynopsis()
|
Oracle Fusion Middleware Java API Reference for Oracle Business Rules 11g Release 1 (11.1.1.6.2) E10663-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |