© 2002 BEA Systems, Inc.


com.bea.p13n.rules.advislets
Class RulesAdvisletImpl

java.lang.Object
  |
  +--com.bea.p13n.advisor.AbstractAdvislet
        |
        +--com.bea.p13n.rules.advislets.RulesAdvisletImpl

public class RulesAdvisletImpl
extends AbstractAdvislet

This class is the implementation class for a generic Advislet that handles rules based advice. It is designed to be extended by Advislets that wish to make use of the rules engine and provides a number of methods that can be overridden to change some of the default behaviour.

Required inputs to the Advislet are:

The output objects from rule evaluation are placed in a List in the Advice with the RESULTS key.


Field Summary
static java.lang.String IGNORE_RULE_NAME
          The key name for the optional ignore rule name parameter.
static java.lang.String IGNORE_RULESET_NOT_FOUND
          The key name for the optional ignore rule name parameter.
static java.lang.String RULESET_NAME
          The key name for the optional rule set name parameter.
 
Fields inherited from class com.bea.p13n.advisor.AbstractAdvislet
advisletMetadata, advisor, parametersMap
 
Constructor Summary
RulesAdvisletImpl(Advisor advisor, Metadata metadata)
          Construct an instance of this object and bind it to its Advisor and Metadata instances.
 
Method Summary
protected  void addResults(Advice advice, java.util.Iterator iterator)
          Adds the contents of a given iterator to a given advice.
 Advice getAdvice(AdviceRequest request)
          Executes an AdviceRequest and returns the Advice object.s
protected  java.lang.Object[] getInputObjects(Advice advice, AdviceRequest request)
          Returns the input objects for a given advice and advice request.
protected  ObjectFilter getObjectFilter(Advice advice, AdviceRequest request)
          Returns the object filter for a given advice and advice request.
 java.lang.Object[] getRequiredAttributes()
           
protected  java.lang.String getRuleNameToFire(Advice advice, AdviceRequest request)
          Returns the name of the rule that must be fired for a given advice and advice request.
protected  java.lang.String getRuleSetName(Advice advice, AdviceRequest request)
          Returns the rule set name for the given advice and advice request.
protected  RulesManager getRulesManager(Advice advice, AdviceRequest request)
          Returns a RulesManager instance for a given advice and advice request.
 boolean initialize(java.util.Map parameters, java.lang.Object parameterDocument)
          Initialize this instance from its XML configuration environment.
protected  void sendRuleEvent(AdviceRequest request, Advice advice)
          Generates a rule event for tracking listeners.
protected  AdviceRequest setupRequest(Advice advice, AdviceRequest request)
          Sets up a given advice request.
 
Methods inherited from class com.bea.p13n.advisor.AbstractAdvislet
getAdvisor, getMetadata, toString, validateAdviceRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RULESET_NAME

public static final java.lang.String RULESET_NAME
The key name for the optional rule set name parameter.

IGNORE_RULE_NAME

public static final java.lang.String IGNORE_RULE_NAME
The key name for the optional ignore rule name parameter.

IGNORE_RULESET_NOT_FOUND

public static final java.lang.String IGNORE_RULESET_NOT_FOUND
The key name for the optional ignore rule name parameter.
Constructor Detail

RulesAdvisletImpl

public RulesAdvisletImpl(Advisor advisor,
                         Metadata metadata)
Construct an instance of this object and bind it to its Advisor and Metadata instances.

Parameters:
advisor - The Advisor instance.
metadata - The Metadata instance.
Method Detail

initialize

public boolean initialize(java.util.Map parameters,
                          java.lang.Object parameterDocument)
                   throws AdvisorException
Initialize this instance from its XML configuration environment.

Parameters:
paramters - the configuration paramters
parameterDocument - the XML Document node for the configuration environment
Returns:
true if required initialization parameters were present.
Overrides:
initialize in class AbstractAdvislet

getAdvice

public Advice getAdvice(AdviceRequest request)
                 throws java.lang.IllegalArgumentException,
                        AdvisorException
Executes an AdviceRequest and returns the Advice object.s

Parameters:
request - the AdviceRequest containing the paramters for the request
Returns:
the Advice instance with the result of the Advisor.getAdvice call.
Overrides:
getAdvice in class AbstractAdvislet

getInputObjects

protected java.lang.Object[] getInputObjects(Advice advice,
                                             AdviceRequest request)
Returns the input objects for a given advice and advice request.

Parameters:
advice - The target advice.
request - The target request.
Returns:
The input objects.

setupRequest

protected AdviceRequest setupRequest(Advice advice,
                                     AdviceRequest request)
                              throws AdvisorException
Sets up a given advice request.

Parameters:
advice - The current advice.
request - The current advice request.
Returns:
The initialized advice request.
Throws:
AdvisorException - On general Advisor exception.

getRuleSetName

protected java.lang.String getRuleSetName(Advice advice,
                                          AdviceRequest request)
                                   throws AdvisorException
Returns the rule set name for the given advice and advice request.

Parameters:
advice - The current advice.
request - The current advice request.
Returns:
The rule set name.
Throws:
AdvisorException - On general Advisor exception.

getRuleNameToFire

protected java.lang.String getRuleNameToFire(Advice advice,
                                             AdviceRequest request)
                                      throws AdvisorException
Returns the name of the rule that must be fired for a given advice and advice request.

Parameters:
advice - The current advice.
request - The current advice request.
Returns:
The rule name.
Throws:
AdvisorException - On general Advisor exception.

getObjectFilter

protected ObjectFilter getObjectFilter(Advice advice,
                                       AdviceRequest request)
                                throws AdvisorException
Returns the object filter for a given advice and advice request.

Parameters:
advice - The current advice.
request - The current advice request.
Returns:
The object filter.
Throws:
AdvisorException - On general Advisor exception.

addResults

protected void addResults(Advice advice,
                          java.util.Iterator iterator)
                   throws AdvisorException
Adds the contents of a given iterator to a given advice.

Parameters:
advice - The target advice.
iterator - The source iterator.
Throws:
AdvisorException - On general Advisor exception.

getRequiredAttributes

public java.lang.Object[] getRequiredAttributes()

Overrides:
getRequiredAttributes in class AbstractAdvislet

getRulesManager

protected RulesManager getRulesManager(Advice advice,
                                       AdviceRequest request)
                                throws AdvisorException
Returns a RulesManager instance for a given advice and advice request.

Parameters:
advice - The current advice.
request - The current advice request.
Throws:
AdvisorException - On general Advisor exception.

sendRuleEvent

protected void sendRuleEvent(AdviceRequest request,
                             Advice advice)
Generates a rule event for tracking listeners.

Parameters:
request - The current advice request.
advice - The current advice.

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved