Package net.officefloor.servlet.supply
Class ServletSupplierSource
- java.lang.Object
-
- net.officefloor.compile.spi.supplier.source.impl.AbstractSupplierSource
-
- net.officefloor.servlet.supply.ServletSupplierSource
-
- All Implemented Interfaces:
SupplierSource
public class ServletSupplierSource extends AbstractSupplierSource
SupplierSource
to provideServlet
functionality.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.compile.spi.supplier.source.impl.AbstractSupplierSource
AbstractSupplierSource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_CHAIN_SERVLETS
Property
name to chain theServletManager
in to serviceHttpRequest
instances viaFilter
/Servlet
mappings.
-
Constructor Summary
Constructors Constructor Description ServletSupplierSource(TomcatServletManager servletContainer, InjectionRegistry injectionRegistry)
Instantiate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServletServicer
forceStartServletContainer(AvailableType[] availableTypes)
Force starts theServlet
container.static ServletManager
getServletManager()
Obtains theServletManager
.protected void
loadSpecification(AbstractSupplierSource.SpecificationContext context)
Loads theSupplierSourceSpecification
.static void
registerForInjection(java.lang.String className)
Registers theClass
for injection.static void
sendError(java.lang.Throwable failure, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Sends an error.void
supply(SupplierSourceContext context)
Supplies the necessaryManagedObjectSource
instances.void
terminate()
Terminates the supply contract.-
Methods inherited from class net.officefloor.compile.spi.supplier.source.impl.AbstractSupplierSource
getSpecification
-
-
-
-
Field Detail
-
PROPERTY_CHAIN_SERVLETS
public static final java.lang.String PROPERTY_CHAIN_SERVLETS
Property
name to chain theServletManager
in to serviceHttpRequest
instances viaFilter
/Servlet
mappings.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServletSupplierSource
public ServletSupplierSource(TomcatServletManager servletContainer, InjectionRegistry injectionRegistry)
Instantiate.- Parameters:
servletContainer
-TomcatServletManager
.injectionRegistry
-InjectionRegistry
.
-
-
Method Detail
-
getServletManager
public static ServletManager getServletManager()
Obtains theServletManager
.- Returns:
ServletManager
.
-
sendError
public static void sendError(java.lang.Throwable failure, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
Sends an error.
The
Throwable
will (in most cases) be reported back toOfficeFloor
for appropriateException
response. If not possible, an appropriateException
message is also provided.- Parameters:
failure
- Failure.request
-HttpServletRequest
.response
-HttpServletResponse
.- Throws:
java.io.IOException
- If fails to send error.
-
registerForInjection
public static void registerForInjection(java.lang.String className) throws java.lang.Exception
Registers theClass
for injection.- Parameters:
className
-Class
name.- Throws:
java.lang.Exception
- If fails to register for injection.
-
forceStartServletContainer
public static ServletServicer forceStartServletContainer(AvailableType[] availableTypes) throws java.lang.Exception
Force starts theServlet
container.- Parameters:
availableTypes
-AvailableType
instances.- Returns:
ServletServicer
to theServlet
container.- Throws:
java.lang.Exception
- If fails to startServlet
container.
-
loadSpecification
protected void loadSpecification(AbstractSupplierSource.SpecificationContext context)
Description copied from class:AbstractSupplierSource
Loads theSupplierSourceSpecification
.- Specified by:
loadSpecification
in classAbstractSupplierSource
- Parameters:
context
-AbstractSupplierSource.SpecificationContext
.
-
supply
public void supply(SupplierSourceContext context) throws java.lang.Exception
Description copied from interface:SupplierSource
Supplies the necessaryManagedObjectSource
instances.- Parameters:
context
-SupplierSourceContext
.- Throws:
java.lang.Exception
- If fails to provide supply ofManagedObjectSource
instances.
-
terminate
public void terminate()
Description copied from interface:SupplierSource
Terminates the supply contract.
This should release all resources required by the supplier.
-
-