Class TurbineServletService
- java.lang.Object
-
- org.apache.turbine.services.BaseInitable
-
- org.apache.turbine.services.BaseService
-
- org.apache.turbine.services.TurbineBaseService
-
- org.apache.turbine.services.servlet.TurbineServletService
-
- All Implemented Interfaces:
Initable,Service,ServletService
public class TurbineServletService extends TurbineBaseService implements ServletService
This class provides a context service when the application is run in a ServletContainer. It is mainly a wrapper around the ServletContext API.
This class requires Servlet API 2.1 or better.
- Version:
- $Id$
- Author:
- Kevin A. Burton, Raphaƫl Luta, Jeff Brekke, Santiago Gala, Jason van Zyl, Jon S. Stevens
-
-
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.Service
SERVICE_NAME
-
Fields inherited from interface org.apache.turbine.services.servlet.ServletService
SERVICE_NAME
-
-
Constructor Summary
Constructors Constructor Description TurbineServletService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringexpandRelative(String path)Expands a string that points to a relative path or path list, leaving it as an absolute path based on the servlet context.StringgetContextPath()Returns the context path for this Turbine application.StringgetRealPath(String uri)Returns the complete filesystem path for a given URIURLgetResource(String uri)Returns an URL object for a given URI string.InputStreamgetResourceAsStream(String uri)Same as getResource except that it returns an InputStreamStringgetServerName()Returns the server name that this Turbine application is running on.StringgetServerPort()Returns the port that this Turbine application is running through on the server.StringgetServerScheme()Returns the server scheme for this Turbine application.ServletConfiggetServletConfig()Returns the servlet config used by this Turbine web application.ServletContextgetServletContext()Returns the servlet context used by this Turbine web application.voidinit()Load all configured components and initialize them.-
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
-
TurbineServletService
public TurbineServletService()
-
-
Method Detail
-
init
public void init()
Load all configured components and initialize them. This is a zero parameter variant which queries the Turbine Servlet for its config.- Specified by:
initin interfaceInitable- Overrides:
initin classTurbineBaseService
-
getResource
public URL getResource(String uri)
Returns an URL object for a given URI string. This URI is considered relative to the context.- Specified by:
getResourcein interfaceServletService- Parameters:
uri- the URI to resolve as an URL- Returns:
- an URL object or null is the uri is malformed or can't be resolved
- See Also:
ServletContext.getResource(java.lang.String)
-
getResourceAsStream
public InputStream getResourceAsStream(String uri)
Same as getResource except that it returns an InputStream- Specified by:
getResourceAsStreamin interfaceServletService- Parameters:
uri- the URI to resolve- Returns:
- an InputStream on the URI content or null
- See Also:
ServletContext.getResourceAsStream(java.lang.String)
-
getRealPath
public String getRealPath(String uri)
Returns the complete filesystem path for a given URI- Specified by:
getRealPathin interfaceServletService- Parameters:
uri- the URI to resolve- Returns:
- the full system path of this URI
- See Also:
ServletContext.getRealPath(java.lang.String)
-
getServletConfig
public ServletConfig getServletConfig()
Returns the servlet config used by this Turbine web application.- Specified by:
getServletConfigin interfaceServletService- Returns:
- turbine servlet config
-
getServletContext
public ServletContext getServletContext()
Returns the servlet context used by this Turbine web application.- Specified by:
getServletContextin interfaceServletService- Returns:
- turbine servlet context
-
getServerScheme
public String getServerScheme()
Returns the server scheme for this Turbine application. This will either be http or https.- Specified by:
getServerSchemein interfaceServletService- Returns:
- String
-
getServerName
public String getServerName()
Returns the server name that this Turbine application is running on.- Specified by:
getServerNamein interfaceServletService- Returns:
- String
-
getServerPort
public String getServerPort()
Returns the port that this Turbine application is running through on the server.- Specified by:
getServerPortin interfaceServletService- Returns:
- String
-
getContextPath
public String getContextPath()
Returns the context path for this Turbine application.- Specified by:
getContextPathin interfaceServletService- Returns:
- String
-
expandRelative
public String expandRelative(String path)
Expands a string that points to a relative path or path list, leaving it as an absolute path based on the servlet context. It will return null if the text is empty or the config object is null.- Parameters:
path- The String containing a path or path list.- Returns:
- A String with the expanded path or path list.
-
-