BEA Systems, Inc.

com.beasys.commerce.axiom.reasoning.rules.service
Class RulesServiceBean

java.lang.Object
  |
  +--com.beasys.commerce.axiom.reasoning.rules.service.RulesServiceBean

public class RulesServiceBean
extends java.lang.Object
implements javax.ejb.SessionBean

Implements a rules service bean

See Also:
Serialized Form

Field Summary
static long CONTEXT_POOL_ACCESS_LIMIT
          The context pool access limit
static java.lang.String CONTEXT_POOL_MAX_SIZE
          The context wrapper pool max size limit
static int CONTEXT_WRAPPER_CACHE_CAPACITY
          The capacity of the context wrapper cache
protected  long contextExpirationAge
          The context expiration age
protected  int contextExpirationPolicy
          The context expiration policy
protected  long contextExpirationUseCount
          The context expiration use count
protected  com.beasys.commerce.axiom.reasoning.rules.service.RulesServiceBean.Stack contextWrapperCache
          A cache of context wrappers
protected  java.util.HashMap contextWrapperPool
          The context wrappers used for application of rules
protected  long contextWrapperPoolAccessCount
          The context wrapper pool access count
protected  int contextWrapperPoolMaxSize
          The context wrapper pool max size limit
static java.lang.String EXCEPTION_MSG_DELIMITER
          The exception message delimiter
protected  boolean initialized
          A flag indicating whether or not the instance has been initialized
static java.lang.String MIME_TYPE_HANDLERS_MAP
          The name of the mime type handlers map environment property
static java.lang.String MIME_TYPE_MAP_DELIMITER
          The delimiter used to separate mime type keys from values
static java.lang.String MIME_TYPE_PAIR_DELIMITER
          The delimiter used to separate mime type map entries
static java.lang.String MIME_TYPES_MAP
          The name of the mime types map environment property
static float POOL_REDUCTION_FACTOR
          The size reduction factor used during context wrapper pool maintenance
protected static int RELOAD_RULESETS_NEVER
          The code for the "never" rule set reload policy
static java.lang.String RELOAD_RULESETS_NEVER_STRING
          The code string for the "never" rule set reload policy
protected static int RELOAD_RULESETS_PERIODICALLY
          The code for the "periodically" rule set reload policy
static java.lang.String RELOAD_RULESETS_PERIODICALLY_STRING
          The code string for the "periodically" rule set reload policy
protected static int RELOAD_RULESETS_WHEN_MODIFIED
          The code for the "when modified" rule set reload policy
static java.lang.String RELOAD_RULESETS_WHEN_MODIFIED_STRING
          The code string for the "when modified" rule set reload policy
static java.lang.String ROOT_CONTEXT_NAME
          The name of the root jndi context
static java.lang.String RULE_SET_DATA_HOME_NAME
          The name of the rule set data bean home environment property
static java.lang.String RULE_SET_RELOAD_INTERVAL
          The name of the rule set reload interval environment property
static java.lang.String RULE_SET_RELOAD_POLICY
          The name of the rule set reload policy environment property
static java.lang.String RULE_SHEET_DIRECTORY
          The name of the rule sheet deployment directory environment property
protected  ServiceProviderManager serviceProviderManager
          The service provider manager
protected  javax.ejb.SessionContext sessionContext
          The ejb session context.
static java.lang.String VENDOR_INDEPENDENT_MIME_TYPE
          The name of the vendor independent mime type environment property
 
Constructor Summary
RulesServiceBean()
          Constructor
 
Method Summary
 java.util.Set applyRules(java.lang.String rulesetURI, java.util.Set inputObjects, java.util.Set outputObjectsTypeFilter, java.util.Set outputObjectsCreatorFilter)
          Applies a named set of rules to the set of objects provided by the caller in order to produce a resultant set of objects.
 void ejbActivate()
          Activates
 void ejbCreate()
          Creates
 void ejbPassivate()
          Passivates
 void ejbRemove()
          Removes TODO: 1.
protected  long getContextExpirationAge(int rulesetReloadPolicy, long rulesetReloadInterval)
          Gets the context expiration age which corresponds to a rule set reload policy and ruleset reload interval
protected  int getContextExpirationPolicy(int rulesetReloadPolicy)
          Gets the context expiration policy which corresponds to a rule set reload policy
protected  long getContextExpirationUseCount(int rulesetReloadPolicy)
          Gets the context expiration use count which corresponds to a rule set reload policy
protected  ContextWrapper getContextWrapper(java.lang.String rulesetURI)
          Gets a context wrapper
protected  java.util.Map getMimeTypeHandlersMap(java.lang.String mimeTypeHandlersMapString)
          Gets the mime type handlers map from a mime type handlers map string
protected  java.util.Map getMimeTypesMap(java.lang.String mimeTypesMapString)
          Gets the mime types map from a mime types map string
protected  int getReloadPolicyCode(java.lang.String rulesetReloadPolicyString)
          Gets the numeric code for the ruleset reload policy
protected  long getRulesetExpirationAge(int rulesetReloadPolicy, long rulesetReloadInterval)
          Gets the ruleset expiration age which corresponds to a rule set reload policy and ruleset reload interval
protected  int getRulesetExpirationPolicy(int rulesetReloadPolicy)
          Gets the rule set expiration policy which corresponds to a rule set reload policy
protected  ContextWrapper getWrapperForContext(com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context context)
          Gets a wrapper for the given context
protected  void performPoolMaintenance()
          Performs pool maintenance
protected  boolean poolMaintenanceNeeded()
          Determines if pool maintenance is needed
 void setSessionContext(javax.ejb.SessionContext sessionContext)
          Sets the session context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_POOL_ACCESS_LIMIT

public static final long CONTEXT_POOL_ACCESS_LIMIT
The context pool access limit

CONTEXT_POOL_MAX_SIZE

public static final java.lang.String CONTEXT_POOL_MAX_SIZE
The context wrapper pool max size limit

CONTEXT_WRAPPER_CACHE_CAPACITY

public static final int CONTEXT_WRAPPER_CACHE_CAPACITY
The capacity of the context wrapper cache

EXCEPTION_MSG_DELIMITER

public static final java.lang.String EXCEPTION_MSG_DELIMITER
The exception message delimiter

MIME_TYPE_HANDLERS_MAP

public static final java.lang.String MIME_TYPE_HANDLERS_MAP
The name of the mime type handlers map environment property

MIME_TYPES_MAP

public static final java.lang.String MIME_TYPES_MAP
The name of the mime types map environment property

MIME_TYPE_MAP_DELIMITER

public static final java.lang.String MIME_TYPE_MAP_DELIMITER
The delimiter used to separate mime type keys from values

MIME_TYPE_PAIR_DELIMITER

public static final java.lang.String MIME_TYPE_PAIR_DELIMITER
The delimiter used to separate mime type map entries

POOL_REDUCTION_FACTOR

public static final float POOL_REDUCTION_FACTOR
The size reduction factor used during context wrapper pool maintenance

RELOAD_RULESETS_NEVER_STRING

public static final java.lang.String RELOAD_RULESETS_NEVER_STRING
The code string for the "never" rule set reload policy

RELOAD_RULESETS_PERIODICALLY_STRING

public static final java.lang.String RELOAD_RULESETS_PERIODICALLY_STRING
The code string for the "periodically" rule set reload policy

RELOAD_RULESETS_WHEN_MODIFIED_STRING

public static final java.lang.String RELOAD_RULESETS_WHEN_MODIFIED_STRING
The code string for the "when modified" rule set reload policy

ROOT_CONTEXT_NAME

public static final java.lang.String ROOT_CONTEXT_NAME
The name of the root jndi context

RULE_SET_DATA_HOME_NAME

public static final java.lang.String RULE_SET_DATA_HOME_NAME
The name of the rule set data bean home environment property

RULE_SET_RELOAD_INTERVAL

public static final java.lang.String RULE_SET_RELOAD_INTERVAL
The name of the rule set reload interval environment property

RULE_SET_RELOAD_POLICY

public static final java.lang.String RULE_SET_RELOAD_POLICY
The name of the rule set reload policy environment property

RULE_SHEET_DIRECTORY

public static final java.lang.String RULE_SHEET_DIRECTORY
The name of the rule sheet deployment directory environment property

VENDOR_INDEPENDENT_MIME_TYPE

public static final java.lang.String VENDOR_INDEPENDENT_MIME_TYPE
The name of the vendor independent mime type environment property

RELOAD_RULESETS_NEVER

protected static final int RELOAD_RULESETS_NEVER
The code for the "never" rule set reload policy

RELOAD_RULESETS_PERIODICALLY

protected static final int RELOAD_RULESETS_PERIODICALLY
The code for the "periodically" rule set reload policy

RELOAD_RULESETS_WHEN_MODIFIED

protected static final int RELOAD_RULESETS_WHEN_MODIFIED
The code for the "when modified" rule set reload policy

contextExpirationAge

protected long contextExpirationAge
The context expiration age

contextExpirationPolicy

protected int contextExpirationPolicy
The context expiration policy

contextExpirationUseCount

protected long contextExpirationUseCount
The context expiration use count

contextWrapperCache

protected com.beasys.commerce.axiom.reasoning.rules.service.RulesServiceBean.Stack contextWrapperCache
A cache of context wrappers

contextWrapperPool

protected java.util.HashMap contextWrapperPool
The context wrappers used for application of rules

contextWrapperPoolAccessCount

protected long contextWrapperPoolAccessCount
The context wrapper pool access count

contextWrapperPoolMaxSize

protected int contextWrapperPoolMaxSize
The context wrapper pool max size limit

initialized

protected boolean initialized
A flag indicating whether or not the instance has been initialized

serviceProviderManager

protected ServiceProviderManager serviceProviderManager
The service provider manager

sessionContext

protected javax.ejb.SessionContext sessionContext
The ejb session context.
Constructor Detail

RulesServiceBean

public RulesServiceBean()
Constructor
Method Detail

applyRules

public java.util.Set applyRules(java.lang.String rulesetURI,
                                java.util.Set inputObjects,
                                java.util.Set outputObjectsTypeFilter,
                                java.util.Set outputObjectsCreatorFilter)
                         throws java.lang.IllegalArgumentException,
                                RulesServiceException
Applies a named set of rules to the set of objects provided by the caller in order to produce a resultant set of objects.
Parameters:
rulesetURI - The uri of the rule set which contains the set of rules that is to be applied.
inputObjects - The set of objects to which the rules are to be applied
outputObjectsTypeFilter - A set of class objects used to perform type-based selection of the return objects.
outputObjectsCreatorFilter - A set of output object creator name strings to be used to perform creator-name selection of the return objects after type-based filtering has been performed.
Returns:
A filtered set of objects which resulted from the application of the rules.
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length, or if inputObjects is null or if outputObjectsTypeFilter is null
RulesServiceException - thrown on an error in the rules service

ejbActivate

public void ejbActivate()
Activates
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Creates
Throws:
javax.ejb.CreateException - Thrown if unable to create the ejb

ejbPassivate

public void ejbPassivate()
Passivates
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Removes TODO: 1. Add handler for exceptions
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext sessionContext)
Sets the session context.
Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
sessionContext - The session context

getContextExpirationAge

protected long getContextExpirationAge(int rulesetReloadPolicy,
                                       long rulesetReloadInterval)
                                throws java.lang.IllegalArgumentException
Gets the context expiration age which corresponds to a rule set reload policy and ruleset reload interval
Parameters:
rulesetReloadPolicy - The ruleset reload policy
rulesetReloadInterval - The ruleset reload interval
Returns:
The expiration age
Throws:
IllegalArgumentExpiration - Thrown if rulesetReloadPolicy is invalid, or if reload interval is negative

getContextExpirationPolicy

protected int getContextExpirationPolicy(int rulesetReloadPolicy)
                                  throws java.lang.IllegalArgumentException,
                                         RulesServiceException
Gets the context expiration policy which corresponds to a rule set reload policy
Parameters:
rulesetReloadPolicy - The ruleset reload policy
Returns:
The expiration policy
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetReloadPolicy is negative
RulesServiceException - Thrown if unable to determine the expiration policy

getContextExpirationUseCount

protected long getContextExpirationUseCount(int rulesetReloadPolicy)
                                     throws java.lang.IllegalArgumentException,
                                            RulesServiceException
Gets the context expiration use count which corresponds to a rule set reload policy
Parameters:
rulesetReloadPolicy - The ruleset reload policy
Returns:
The expiration use count
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetReloadPolicy is negative
RulesServiceException - Thrown if unable to determine the expiration policy

getContextWrapper

protected ContextWrapper getContextWrapper(java.lang.String rulesetURI)
                                    throws java.lang.IllegalArgumentException,
                                           RulesServiceException
Gets a context wrapper
Parameters:
rulesetURI - The uri of the rule set for which the context wrapper should be gotten
Returns:
The context wrapper
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length
RulesServiceException - Thrown if unable to get context wrapper

getMimeTypeHandlersMap

protected java.util.Map getMimeTypeHandlersMap(java.lang.String mimeTypeHandlersMapString)
                                        throws java.lang.IllegalArgumentException,
                                               RulesServiceException
Gets the mime type handlers map from a mime type handlers map string
Parameters:
mimeTypeHandlersMapString - The string which contains the mime type handlers map
Returns:
The mime type handlers map
Throws:
java.lang.IllegalArgumentException - Thrown if mimeTypeHandlersMapString is null or or zero-length
RulesServiceException - Thrown if unable to get the map from the string

getMimeTypesMap

protected java.util.Map getMimeTypesMap(java.lang.String mimeTypesMapString)
                                 throws java.lang.IllegalArgumentException,
                                        RulesServiceException
Gets the mime types map from a mime types map string
Parameters:
mimeTypesMapString - The string which contains the mime types map
Returns:
The mime types map
Throws:
java.lang.IllegalArgumentException - Thrown if mimeTypesMapString is null or or zero-length
RulesServiceException - Thrown if unable to get the map from the string

getRulesetExpirationAge

protected long getRulesetExpirationAge(int rulesetReloadPolicy,
                                       long rulesetReloadInterval)
                                throws java.lang.IllegalArgumentException
Gets the ruleset expiration age which corresponds to a rule set reload policy and ruleset reload interval
Parameters:
rulesetReloadPolicy - The ruleset reload policy
rulesetReloadInterval - The ruleset reload interval
Returns:
The expiration age
Throws:
IllegalArgumentExpiration - Thrown if rulesetReloadPolicy is invalid, or if reload interval is negative

getRulesetExpirationPolicy

protected int getRulesetExpirationPolicy(int rulesetReloadPolicy)
                                  throws java.lang.IllegalArgumentException,
                                         RulesServiceException
Gets the rule set expiration policy which corresponds to a rule set reload policy
Parameters:
rulesetReloadPolicy - The ruleset reload policy
Returns:
The expiration policy
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetReloadPolicy is negative
RulesServiceException - Thrown if unable to determine the expiration policy

getReloadPolicyCode

protected int getReloadPolicyCode(java.lang.String rulesetReloadPolicyString)
                           throws java.lang.IllegalArgumentException,
                                  RulesServiceException
Gets the numeric code for the ruleset reload policy
Parameters:
rulesetReloadPolicyString - The string version of the code
Returns:
The numeric code for the reload policy
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetReloadPolicyString is null or zero-length
RulesServiceException - Thrown if unable to determine a numeric code

getWrapperForContext

protected ContextWrapper getWrapperForContext(com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context context)
                                       throws java.lang.IllegalArgumentException
Gets a wrapper for the given context
Parameters:
context - The context to be wrapped
Returns:
A wrapper for the context
Throws:
java.lang.IllegalArgumentException - Thrown if context is null

performPoolMaintenance

protected void performPoolMaintenance()
Performs pool maintenance

poolMaintenanceNeeded

protected boolean poolMaintenanceNeeded()
Determines if pool maintenance is needed
Returns:
True if maintenance is needed, false otherwise

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved