org.apache.turbine.services.intake
Class TurbineIntakeService

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitable
        |
        +--org.apache.turbine.services.BaseService
              |
              +--org.apache.turbine.services.TurbineBaseService
                    |
                    +--org.apache.turbine.services.intake.TurbineIntakeService
All Implemented Interfaces:
Initable, IntakeService, Service

public class TurbineIntakeService
extends TurbineBaseService
implements IntakeService

This service provides access to input processing objects based on an XML specification.

Version:
$Id: TurbineIntakeService.java,v 1.4 2002/02/15 17:58:28 jmcnally Exp $
Author:
John McNally

Inner Class Summary
private  class TurbineIntakeService.PoolBuffer
          An inner class for group specific pools.
 
Field Summary
private  AppData appData
          The top element of the object tree
private static int GETTER
           
private  java.util.Map getterMap
          The cache of property getters.
private  java.util.Map groupKeyMap
          The cache of group keys.
private  java.util.Map groupNameMap
          The cache of group names.
private  java.lang.String[] groupNames
          Array of group names.
private  OMTool omTool
          Keep a OMTool to be able to retrieve objects
private  java.util.HashMap poolRepository
          The pool repository, one pool for each class.
private static int SETTER
           
private  java.util.Map setterMap
          The cache of property setters.
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.intake.IntakeService
DEFAULT_POOL_CAPACITY, SERVICE_NAME, XML_PATH
 
Fields inherited from interface org.apache.turbine.services.Service
SERVICE_NAME
 
Constructor Summary
TurbineIntakeService()
          Constructor.
 
Method Summary
 void clearPool()
          Clears all instances from the pool.
 void clearPool(java.lang.String name)
          Clears instances of a group from the pool.
 int getCapacity(java.lang.String name)
          Gets the capacity of the pool for a named group.
 java.lang.reflect.Method getFieldGetter(java.lang.String className, java.lang.String propName)
          Gets the Method that can be used to get a property value.
 java.lang.reflect.Method getFieldSetter(java.lang.String className, java.lang.String propName)
          Gets the Method that can be used to set a property.
 Group getGroup(java.lang.String groupName)
          Gets an instance of a named group either from the pool or by calling the Factory Service if the pool is empty.
 java.lang.String getGroupKey(java.lang.String groupName)
          Gets the key (usually a short identifier) for a group.
 java.lang.String getGroupName(java.lang.String groupKey)
          Gets the group name given its key.
 java.lang.String[] getGroupNames()
          Names of all the defined groups.
 int getSize(java.lang.String name)
          Gets the current size of the pool for a group.
 void init(javax.servlet.ServletConfig config)
          Called the first time the Service is used.
private  java.lang.Object pollInstance(java.lang.String groupName)
          Polls and recycles an object of the named group from the pool.
 boolean releaseGroup(Group instance)
          Puts a Group back to the pool.
 void setCapacity(java.lang.String name, int capacity)
          Sets the capacity of the pool for a group.
private  void writeAppData(java.lang.String xmlPath, java.lang.String appDataPath, java.io.File serialAppData)
          This method writes the appData file into Objects and stores the information into this classes appData property
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker
 

Field Detail

groupNames

private java.lang.String[] groupNames
Array of group names.

groupNameMap

private java.util.Map groupNameMap
The cache of group names.

groupKeyMap

private java.util.Map groupKeyMap
The cache of group keys.

getterMap

private java.util.Map getterMap
The cache of property getters.

setterMap

private java.util.Map setterMap
The cache of property setters.

omTool

private OMTool omTool
Keep a OMTool to be able to retrieve objects

appData

private AppData appData
The top element of the object tree

poolRepository

private java.util.HashMap poolRepository
The pool repository, one pool for each class.

GETTER

private static final int GETTER

SETTER

private static final int SETTER
Constructor Detail

TurbineIntakeService

public TurbineIntakeService()
Constructor.
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws InitializationException
Called the first time the Service is used.
Overrides:
init in class TurbineBaseService
Parameters:
config - A ServletConfig.

writeAppData

private void writeAppData(java.lang.String xmlPath,
                          java.lang.String appDataPath,
                          java.io.File serialAppData)
                   throws java.lang.Exception
This method writes the appData file into Objects and stores the information into this classes appData property

getGroup

public Group getGroup(java.lang.String groupName)
               throws TurbineException
Gets an instance of a named group either from the pool or by calling the Factory Service if the pool is empty.
Specified by:
getGroup in interface IntakeService
Parameters:
groupName - the name of the group.
Returns:
a Group instance.
Throws:
TurbineException - if recycling fails.

releaseGroup

public boolean releaseGroup(Group instance)
Puts a Group back to the pool.
Specified by:
releaseGroup in interface IntakeService
Parameters:
instance - the object instance to recycle.
Returns:
true if the instance was accepted.

getCapacity

public int getCapacity(java.lang.String name)
Gets the capacity of the pool for a named group.
Specified by:
getCapacity in interface IntakeService
Parameters:
name - the name of the class.

setCapacity

public void setCapacity(java.lang.String name,
                        int capacity)
Sets the capacity of the pool for a group. Note that the pool will be cleared after the change.
Specified by:
setCapacity in interface IntakeService
Parameters:
name - the name of the group.
capacity - the new capacity.

getSize

public int getSize(java.lang.String name)
Gets the current size of the pool for a group.
Specified by:
getSize in interface IntakeService
Parameters:
name - the name of the group.

clearPool

public void clearPool(java.lang.String name)
Clears instances of a group from the pool.
Specified by:
clearPool in interface IntakeService
Parameters:
name - the name of the group.

clearPool

public void clearPool()
Clears all instances from the pool.
Specified by:
clearPool in interface IntakeService

pollInstance

private java.lang.Object pollInstance(java.lang.String groupName)
                               throws TurbineException
Polls and recycles an object of the named group from the pool.
Parameters:
groupName - the name of the group.
Returns:
the object or null.
Throws:
TurbineException - if recycling fails.

getGroupNames

public java.lang.String[] getGroupNames()
Names of all the defined groups.
Specified by:
getGroupNames in interface IntakeService
Returns:
array of names.

getGroupKey

public java.lang.String getGroupKey(java.lang.String groupName)
Gets the key (usually a short identifier) for a group.
Specified by:
getGroupKey in interface IntakeService
Parameters:
groupName - the name of the group.
Returns:
the the key.

getGroupName

public java.lang.String getGroupName(java.lang.String groupKey)
Gets the group name given its key.
Specified by:
getGroupName in interface IntakeService
Parameters:
the - the key.
Returns:
groupName the name of the group.

getFieldSetter

public java.lang.reflect.Method getFieldSetter(java.lang.String className,
                                               java.lang.String propName)
Gets the Method that can be used to set a property.
Specified by:
getFieldSetter in interface IntakeService
Parameters:
className - the name of the object.
propName - the name of the property.
Returns:
the setter.

getFieldGetter

public java.lang.reflect.Method getFieldGetter(java.lang.String className,
                                               java.lang.String propName)
Gets the Method that can be used to get a property value.
Specified by:
getFieldGetter in interface IntakeService
Parameters:
className - the name of the object.
propName - the name of the property.
Returns:
the getter.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.