Class TurbineAssemblerBrokerService
- java.lang.Object
-
- org.apache.turbine.services.BaseInitable
-
- org.apache.turbine.services.BaseService
-
- org.apache.turbine.services.TurbineBaseService
-
- org.apache.turbine.services.assemblerbroker.TurbineAssemblerBrokerService
-
- All Implemented Interfaces:
AssemblerBrokerService
,Initable
,Service
public class TurbineAssemblerBrokerService extends TurbineBaseService implements AssemblerBrokerService
TurbineAssemblerBrokerService allows assemblers (like screens, actions and layouts) to be loaded from one or more AssemblerFactory classes. AssemblerFactory classes are registered with this broker by adding them to the TurbineResources.properties file.- Version:
- $Id$
- Author:
- Leon Messerschmidt, Henning P. Schmiedehausen
-
-
Field Summary
-
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, serviceBroker
-
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
-
Fields inherited from interface org.apache.turbine.services.assemblerbroker.AssemblerBrokerService
SERVICE_NAME
-
Fields inherited from interface org.apache.turbine.services.Service
SERVICE_NAME
-
-
Constructor Summary
Constructors Constructor Description TurbineAssemblerBrokerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Assembler>
TgetAssembler(Class<T> type, String name)
Attempt to retrieve an Assembler of a given type with a name.<T extends Assembler>
Loader<T>getLoader(Class<T> type)
Get a Loader for the given assembler typevoid
init()
Initializes the AssemblerBroker and loads the AssemblerFactory classes registered in TurbineResources.Properties.<T extends Assembler>
voidregisterFactory(AssemblerFactory<T> factory)
Register a new AssemblerFactory-
Methods inherited from class org.apache.turbine.services.TurbineBaseService
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, toString, wait, wait, wait
-
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
-
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
-
-
-
-
Constructor Detail
-
TurbineAssemblerBrokerService
public TurbineAssemblerBrokerService()
-
-
Method Detail
-
init
public void init() throws InitializationException
Initializes the AssemblerBroker and loads the AssemblerFactory classes registered in TurbineResources.Properties.- Specified by:
init
in interfaceInitable
- Overrides:
init
in classTurbineBaseService
- Throws:
InitializationException
- if problems occur while registering the factories
-
registerFactory
public <T extends Assembler> void registerFactory(AssemblerFactory<T> factory)
Register a new AssemblerFactory- Specified by:
registerFactory
in interfaceAssemblerBrokerService
- Type Parameters:
T
- the type of the assembler- Parameters:
factory
- factory to register
-
getAssembler
public <T extends Assembler> T getAssembler(Class<T> type, String name) throws TurbineException
Attempt to retrieve an Assembler of a given type with a name. Cycle through all the registered AssemblerFactory classes of type and return the first non-null assembly found. If an assembly was not found return null.- Specified by:
getAssembler
in interfaceAssemblerBrokerService
- Type Parameters:
T
- the type of the assembler- Parameters:
type
- type of Assemblername
- name of the requested Assembler- Returns:
- an Assembler or null
- Throws:
TurbineException
- if the assembler could not be loaded
-
getLoader
public <T extends Assembler> Loader<T> getLoader(Class<T> type)
Get a Loader for the given assembler type- Specified by:
getLoader
in interfaceAssemblerBrokerService
- Type Parameters:
T
- the type of the assembler- Parameters:
type
- The Type of the Assembler- Returns:
- A Loader instance for the requested type
-
-