BEA Systems, Inc.

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

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

public class ServiceProviderManager
extends java.lang.Object

Implements a rules service provider manager

Version:
1.0
Author:
BEA Systems, Inc.

Field Summary
static java.lang.String DIRECTORY_RELATIVE_URI_LEADING_STRING
          The leading character(s) of a ruleset-directory-relative uri
static java.lang.String FILE_PROTOCOL
          The protocol string for file uri's
static java.lang.String HOST_DELIMITER
          The delimiter string used after the host in a uri
protected  javax.naming.Context jndiContext
          The jndi context to use for lookups
protected  java.util.Map mimeTypeHandlersMap
          The map of mime types to mime type handlers
protected  java.util.Map mimeTypesMap
          The map of uri extensions to mime types
static java.lang.String PROTOCOL_DELIMITER
          The delimiter string used after the protocol in a uri
protected  java.util.Map rulesetBuilders
          A map of cached ruleset builders
protected  java.lang.String rulesetDataHomeName
          The ruleset data bean home name
protected  long rulesetExpirationAge
          The ruleset expiration age
protected  int rulesetExpirationPolicy
          The ruleset expiration policy
protected  java.util.Map rulesetExpirers
          The ruleset expirers
protected  java.lang.String rulesheetDirectory
          The rule sheet deployment directory
protected  java.util.Map serviceProviders
          The registered service providers
static char URI_EXTENSION_DELIMITER
          The character used to delimit a uri extension
protected  java.lang.String vendorIndependentMimeType
          The vendor independent mime type
static java.lang.String XML_EXTENSION
          The file extension for xml files
 
Constructor Summary
ServiceProviderManager(int rulesetExpirationPolicy, long rulesetExpirationAge, java.lang.String rulesheetDirectory, java.util.Map mimeTypesMap, java.util.Map mimeTypeHandlersMap, java.lang.String vendorIndependentMimeType, javax.naming.Context jndiContext, java.lang.String rulesetDataHomeName)
          Constructor
 
Method Summary
 com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context createContext(java.lang.String rulesetURI)
          Creates a context for the given rule set uri
protected  java.lang.String createFullyQualifiedURIForURI(java.lang.String rulesetURI)
          Creates a fully-qualified rule set uri which corresponds to a rule set uri
protected  void createRulesetForNative(java.lang.String rulesetURI, com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider serviceProvider)
          Creates a ruleset for native language rules
protected  void createRulesetForXML(java.lang.String rulesetURI, com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider serviceProvider)
          Creates a ruleset for a set of rules expressed as xml
protected  java.lang.String getMimeTypeForURI(java.lang.String rulesetURI)
          Gets the mime type for a ruleset uri
protected  com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider getServiceProviderForMimeType(java.lang.String mimeType)
          Gets the service provider which can service a given mime type
protected  void loadServiceProvider(java.lang.String serviceProviderName)
          Loads a service provider and adds it to the map of service providers
protected  void performRulesetMaintenance()
          Performs ruleset maintenance TODO: 1.
protected  boolean rulesetMaintenanceNeeded()
          Determines whether or not ruleset maintenance is required
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_RELATIVE_URI_LEADING_STRING

public static final java.lang.String DIRECTORY_RELATIVE_URI_LEADING_STRING
The leading character(s) of a ruleset-directory-relative uri

FILE_PROTOCOL

public static final java.lang.String FILE_PROTOCOL
The protocol string for file uri's

HOST_DELIMITER

public static final java.lang.String HOST_DELIMITER
The delimiter string used after the host in a uri

PROTOCOL_DELIMITER

public static final java.lang.String PROTOCOL_DELIMITER
The delimiter string used after the protocol in a uri

URI_EXTENSION_DELIMITER

public static final char URI_EXTENSION_DELIMITER
The character used to delimit a uri extension

XML_EXTENSION

public static final java.lang.String XML_EXTENSION
The file extension for xml files

jndiContext

protected javax.naming.Context jndiContext
The jndi context to use for lookups

mimeTypesMap

protected java.util.Map mimeTypesMap
The map of uri extensions to mime types

mimeTypeHandlersMap

protected java.util.Map mimeTypeHandlersMap
The map of mime types to mime type handlers

rulesetBuilders

protected java.util.Map rulesetBuilders
A map of cached ruleset builders

rulesetDataHomeName

protected java.lang.String rulesetDataHomeName
The ruleset data bean home name

rulesetExpirationAge

protected long rulesetExpirationAge
The ruleset expiration age

rulesetExpirationPolicy

protected int rulesetExpirationPolicy
The ruleset expiration policy

rulesetExpirers

protected java.util.Map rulesetExpirers
The ruleset expirers

rulesheetDirectory

protected java.lang.String rulesheetDirectory
The rule sheet deployment directory

serviceProviders

protected java.util.Map serviceProviders
The registered service providers

vendorIndependentMimeType

protected java.lang.String vendorIndependentMimeType
The vendor independent mime type
Constructor Detail

ServiceProviderManager

public ServiceProviderManager(int rulesetExpirationPolicy,
                              long rulesetExpirationAge,
                              java.lang.String rulesheetDirectory,
                              java.util.Map mimeTypesMap,
                              java.util.Map mimeTypeHandlersMap,
                              java.lang.String vendorIndependentMimeType,
                              javax.naming.Context jndiContext,
                              java.lang.String rulesetDataHomeName)
                       throws java.lang.IllegalArgumentException,
                              RulesServiceException
Constructor
Parameters:
rulesetExpirationPolicy - The rule set expiration policy
rulesetExpirationAge - The age in milliseconds at which rulesets should be expired. Ignored if rulesetExpirationPolicy is not EXPIRE_RULE_SET_AT_AGE
rulesheetDirectory - The rulesheet deployment directory
mimeTypesMap - The map of uri extensions to mime types
mimeTypeHandlersMap - The map of mime types to mime type handlers
vendorIndependentMimeType - The vendor independent, xml-based mime type
jndiContext - The jndi context to use for lookups
Throws:
java.lang.IllegalArgumentException - Thrown if: 1. rulesetExpirationPolicy is invalid 2. rulesetExpirationPolicy is EXPIRE_RULE_SET_AT_AGE and rulesetExpirationAge is negative 3. mimeTypesMap is null 4. mimeTypeHandlersMap is null 5. vendorIndependentMimeType is null or zero-length 6. jndiContext is null 7. rulesetDataHomeName is null or zero-length
RulesServiceException -  
Method Detail

createContext

public com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context createContext(java.lang.String rulesetURI)
                                                                                throws RulesServiceException
Creates a context for the given rule set uri
Parameters:
rulesetURI - The rule set uri for which a context is to be created
Returns:
The new context
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null
RulesServiceException - Thrown if unable to create the context TODO: 1. Improve no-service-provider-found code

loadServiceProvider

protected void loadServiceProvider(java.lang.String serviceProviderName)
                            throws RulesServiceException
Loads a service provider and adds it to the map of service providers
Parameters:
serviceProviderName - The name of the service provider class
Throws:
java.lang.IllegalArgumentException - Thrown if serviceProviderName is null or zero-length
RulesServiceException -  

createRulesetForNative

protected void createRulesetForNative(java.lang.String rulesetURI,
                                      com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider serviceProvider)
                               throws java.lang.IllegalArgumentException,
                                      RulesServiceException
Creates a ruleset for native language rules
Parameters:
rulesetURI - The uri of the native rule set
serviceProvider - The serviceProvider that will create the ruleset
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length, or if serviceProvider is null
RulesServiceException - Thrown if unable to create the ruleset

createRulesetForXML

protected void createRulesetForXML(java.lang.String rulesetURI,
                                   com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider serviceProvider)
                            throws java.lang.IllegalArgumentException,
                                   RulesServiceException
Creates a ruleset for a set of rules expressed as xml
Parameters:
rulesetURI - The uri of the rule set for which the ruleset should be created.
serviceProvider - The service provider that will create the ruleset
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length, or if serviceProvider is null
RulesServiceException - Thrown if unable to create the ruleset

createFullyQualifiedURIForURI

protected java.lang.String createFullyQualifiedURIForURI(java.lang.String rulesetURI)
                                                  throws java.lang.IllegalArgumentException,
                                                         RulesServiceException
Creates a fully-qualified rule set uri which corresponds to a rule set uri
Parameters:
rulesetURI - The rule set uri
Returns:
The url for the rule set uri
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length
RulesServiceException - Thrown if unable to create the uri

getMimeTypeForURI

protected java.lang.String getMimeTypeForURI(java.lang.String rulesetURI)
                                      throws java.lang.IllegalArgumentException,
                                             RulesServiceException
Gets the mime type for a ruleset uri
Parameters:
rulesetURI - The uri for which the mime type should be obtained
Returns:
The mime type
Throws:
java.lang.IllegalArgumentException - Thrown if rulesetURI is null or zero-length
RulesServiceException - Thrown if unable to determine mime type

getServiceProviderForMimeType

protected com.beasys.commerce.axiom.reasoning.rules.serviceProvider.ServiceProvider getServiceProviderForMimeType(java.lang.String mimeType)
                                                                                                           throws java.lang.IllegalArgumentException,
                                                                                                                  RulesServiceException
Gets the service provider which can service a given mime type
Parameters:
mimeType - The mime type to be serviced
Returns:
The service provider or null if no service provider is found
Throws:
java.lang.IllegalArgumentException - Thrown if mimeType is null or zero-length
RulesServiceException - Thrown if unable to determine a service provider

performRulesetMaintenance

protected void performRulesetMaintenance()
Performs ruleset maintenance TODO: 1. Add actual implementation. Right now this is just a stub

rulesetMaintenanceNeeded

protected boolean rulesetMaintenanceNeeded()
Determines whether or not ruleset maintenance is required
Returns:
True if maintenance is required, false otherwise TODO: 1. Add actual implementation. Right now this is just a stub

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved