© 2005 BEA Systems, Inc.

com.bea.p13n.advisor
Class AbstractAdvislet

java.lang.Object
  extended bycom.bea.p13n.advisor.AbstractAdvislet
All Implemented Interfaces:
AdviceConstants, AdviceRequestConstants, Advislet, AdvisletChainElement
Direct Known Subclasses:
CatalogQueryAdvisletImpl, ContentQueryAdvisletImpl, RulesAdvisletImpl

public abstract class AbstractAdvislet
extends Object
implements Advislet, AdviceRequestConstants, AdviceConstants

An abstract class which provides some default method implementations for classes wishing to implement the Advislet interface.


Field Summary
protected  Metadata advisletMetadata
          The metadata for the Advislet
protected  Advisor advisor
          The Advisor associated with this Advislet instance.
protected  Map parametersMap
          The parameters Map for the Advislet
 
Fields inherited from interface com.bea.p13n.advisor.AdviceRequestConstants
CATALOG_QUERY_WRAPPER, CONTENT_APPEND_QUERY_STRING, CONTENT_MANAGER, CONTENT_MANAGER_HOME, CONTENT_QUERY_CONTEXT_PARAMS, CONTENT_QUERY_MAX_ITEMS, CONTENT_QUERY_NODE, CONTENT_QUERY_SORT_BY, CONTENT_QUERY_STRING, CONTENT_SEARCH_PATHS, DATE, HTTP_REQUEST, HTTP_SESSION, NOW, RULES_FILTER_CLASS, RULES_FILTER_CLASS_NAME, RULES_INPUT_OBJECTS, RULES_RULENAME_TO_FIRE, RULES_RULESET_NAME, SHOPPING_CART, TIME, TIME_INSTANT, USER
 
Fields inherited from interface com.bea.p13n.advisor.AdviceConstants
RESULTS
 
Constructor Summary
AbstractAdvislet(Advisor advisor, Metadata advisletMetadata)
          Constructs a new AbstractAdvislet associated with the Advisor supplied.
 
Method Summary
 Advice getAdvice(AdviceRequest request)
          Makes recommendations based on the AdviceRequest passed in.
protected  Advisor getAdvisor()
          Gets the Advisor associated with this Advislet.
 Metadata getMetadata()
          Returns the metadata for the Advislet.
 Object[] getRequiredAttributes()
          Returns an array of required attributes for the advislet.
 boolean initialize(Map parameters, Object parameterDocument)
          Initializes this with the given parameters and a parameterDocument.
 String toString()
          Returns a String representation of this.
 void validateAdviceRequest(AdviceRequest request)
          Allows for custom AdviceRequest validation logic in addition to the required attribute checking performed by the Advisor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

advisletMetadata

protected Metadata advisletMetadata
The metadata for the Advislet


advisor

protected Advisor advisor
The Advisor associated with this Advislet instance.


parametersMap

protected Map parametersMap
The parameters Map for the Advislet

Constructor Detail

AbstractAdvislet

public AbstractAdvislet(Advisor advisor,
                        Metadata advisletMetadata)
Constructs a new AbstractAdvislet associated with the Advisor supplied.

Method Detail

getAdvice

public Advice getAdvice(AdviceRequest request)
                 throws IllegalArgumentException,
                        AdvisorException
Description copied from interface: Advislet
Makes recommendations based on the AdviceRequest passed in.

Specified by:
getAdvice in interface Advislet
Parameters:
request - The advice request for which to make a recommendation.
Returns:
The advice which contain the recommendations based on the type of request made.
Throws:
AdvisorException - thrown on an error when processing the request.
IllegalArgumentException - thrown if the adviceRequest parameter is null or if it is an unsupported type.

getAdvisor

protected Advisor getAdvisor()
Gets the Advisor associated with this Advislet.

Returns:
The Advisor set as the parent.

getMetadata

public Metadata getMetadata()
Returns the metadata for the Advislet.

Specified by:
getMetadata in interface AdvisletChainElement
Returns:
the metadata for the Advislet.

getRequiredAttributes

public Object[] getRequiredAttributes()
Description copied from interface: Advislet
Returns an array of required attributes for the advislet. The array contains pairs of items: even items are attribute names while odd items are the Class for the item. This information is used by the Advisor to ensure Advislets are not invoked with invalid parameters. Overide the validateAdviceRequest method to perform additional processing above and beyond attribute type checking.

Specified by:
getRequiredAttributes in interface Advislet
Returns:
an array that contains the attributes required by the Advislet.

initialize

public boolean initialize(Map parameters,
                          Object parameterDocument)
                   throws AdvisorException
Initializes this with the given parameters and a parameterDocument.

Specified by:
initialize in interface AdvisletChainElement
Parameters:
parameters - A map containing key-value pairs.
parameterDocument - An Object representing a parameter document.
Returns:
returns true if this operation is successful, otherwise returns false.
Throws:
AdvisorException - If an error occurs during initialization process.

toString

public String toString()
Returns a String representation of this.

Returns:
a String representation of this.

validateAdviceRequest

public void validateAdviceRequest(AdviceRequest request)
                           throws IllegalArgumentException
Description copied from interface: Advislet
Allows for custom AdviceRequest validation logic in addition to the required attribute checking performed by the Advisor.

Specified by:
validateAdviceRequest in interface Advislet
Parameters:
request - the request to validate.
Throws:
IllegalArgumentException - thrown if the adviceRequest parameter is null or if it is an unsupported type.

© 2005 BEA Systems, Inc.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved