jrun.servlet
Class ServletEngineService

jrunx.kernel.ServiceAdapter
  |
  +--jrunx.kernel.ServicePartition
        |
        +--jrunx.kernel.ConfigurableServicePartition
              |
              +--jrun.servlet.ServletEngineService
All Implemented Interfaces:
ConfigurableServicePartitionMBean, javax.naming.Referenceable, java.io.Serializable, Service, ServiceMBean, ServicePartitionMBean, ServletEngine, ServletEngineServiceMBean

public final class ServletEngineService
extends ConfigurableServicePartition
implements ServletEngine

The servlet engine. This class serves as a service partition to all of the servlet services, and also serves as the main dispatcher for servlet requests.

Author:
Karl Moss
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_MAP_HOST
           
 
Fields inherited from class jrunx.kernel.ServicePartition
sortedServices
 
Fields inherited from class jrunx.kernel.ServiceAdapter
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER
 
Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
ServletEngineService()
           
 
Method Summary
 void addService(ServiceMBean service, javax.management.ObjectName serviceName)
          Add a ServiceMBean to the partitioned Services using the specified ObjectName for the Service.
 void destroy()
          Every service is eventually destroyed.
 void dispatch(ServletConnection connection)
          this is the main servlet engine entry point, for every request going to every webapp.
protected  java.util.Set findMappingsByHost(java.lang.String host)
           
protected  WebApplication findMatchingPrefix(java.util.Set maps, java.lang.String uri)
           
 WebApplication findWebApplication(java.lang.String uri)
          called by JRunServletContext.getContext() to locate other webapps within the same logical host.
protected  WebApplication findWebApplication(java.lang.String host, int port, java.lang.String uri)
           
 java.lang.String getDefaultLocale()
          Gets the current default locale for the VM
 java.util.Set getExpandedMappings()
          Return all the mappings for each of the web-apps we know about.
 java.lang.String getMimeType(java.lang.String name)
          Gets the mime type for the given resource name
 java.lang.String getMimeTypesPath()
          Gets the path of the mime.types file, or null if none.
 ReplicationIdService getReplicationIdService()
          Get the ReplicationIdService
 long getServletCheckInterval()
          Gets the servlet check interval
 ServletEngine getServletEngine()
          Returns a direct reference to the servlet engine
 ServletUsers getServletUsers()
          Get a direct reference to the ServletUsers for the servlet engine
 SessionReplicationService getSessionReplicationService()
           
 void init()
          Not every service needs to init, implement it out of convenience.
protected  void processMimeTypes(java.io.InputStream in)
          Read and process the mime.types file.
 void removeService(ServiceMBean service)
          Override removeService so we can remove webapps from the list of mappings
 void setDefaultLocale(java.lang.String locale)
          Sets the new default locale for the entire VM
 void setMimeMapping(MimeMapping mapping)
          Sets (adds) a new MimeMapping for the servlet engine
 void setMimeTypesPath(java.lang.String path)
          Sets the path of the mime.types file.
 void setServletCheckInterval(long ms)
          The number of milliseconds between checking for a change in a servlet class file.
 void setVirtualHostMapping(VirtualHostMapping mapping)
          Sets (adds) a new VirtualHostMapping for the servlet engine
 void setWebAppMapping(WebAppMapping mapping)
          Sets (adds) a new WebAppMapping for the servlet engine.
 void start()
          Every service other than mere data collections should start
 void stop()
          Every service other than mere data collections should stop
 
Methods inherited from class jrunx.kernel.ConfigurableServicePartition
destroyServices, initServices, loadAndInit, loadChildren, setChildElements, startServices, stopServices
 
Methods inherited from class jrunx.kernel.ServicePartition
addService, getServices, invokeChain, iterator, removeService
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.kernel.ConfigurableServicePartitionMBean
setChildElements
 
Methods inherited from interface jrunx.kernel.ServicePartitionMBean
addService, iterator, removeService
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
getStatus, updateStatus
 

Field Detail

DEFAULT_MAP_HOST

public static final java.lang.String DEFAULT_MAP_HOST
Constructor Detail

ServletEngineService

public ServletEngineService()
Method Detail

getServletEngine

public ServletEngine getServletEngine()
Description copied from interface: ServletEngineServiceMBean
Returns a direct reference to the servlet engine
Specified by:
getServletEngine in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Returns:
The servlet engine

setServletCheckInterval

public void setServletCheckInterval(long ms)
Description copied from interface: ServletEngineServiceMBean
The number of milliseconds between checking for a change in a servlet class file. Automatic reloading of modified servlet classes relies on this setting. A setting of -1 will result in disabling servlet reloading
Specified by:
setServletCheckInterval in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
interval - Number of ms before checking for a new servlet class

getServletCheckInterval

public long getServletCheckInterval()
Description copied from interface: ServletEngineServiceMBean
Gets the servlet check interval
Specified by:
getServletCheckInterval in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Returns:
The number of ms before checking for a new servlet class

init

public void init()
          throws java.lang.Exception
Description copied from class: ServiceAdapter
Not every service needs to init, implement it out of convenience.
Specified by:
init in interface Service
Overrides:
init in class ConfigurableServicePartition

start

public void start()
           throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should start
Specified by:
start in interface Service
Overrides:
start in class ConfigurableServicePartition

stop

public void stop()
          throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should stop
Specified by:
stop in interface Service
Overrides:
stop in class ConfigurableServicePartition

destroy

public void destroy()
             throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service is eventually destroyed. Convenience implementation.
Specified by:
destroy in interface Service
Overrides:
destroy in class ConfigurableServicePartition

addService

public void addService(ServiceMBean service,
                       javax.management.ObjectName serviceName)
                throws java.lang.Exception
Description copied from interface: ServicePartitionMBean
Add a ServiceMBean to the partitioned Services using the specified ObjectName for the Service.
Specified by:
addService in interface ServicePartitionMBean
Overrides:
addService in class ServicePartition

getServletUsers

public ServletUsers getServletUsers()
Description copied from interface: ServletEngine
Get a direct reference to the ServletUsers for the servlet engine
Specified by:
getServletUsers in interface ServletEngine

getReplicationIdService

public ReplicationIdService getReplicationIdService()
Description copied from interface: ServletEngine
Get the ReplicationIdService
Specified by:
getReplicationIdService in interface ServletEngine

getSessionReplicationService

public SessionReplicationService getSessionReplicationService()
Specified by:
getSessionReplicationService in interface ServletEngine

setVirtualHostMapping

public void setVirtualHostMapping(VirtualHostMapping mapping)
Description copied from interface: ServletEngineServiceMBean
Sets (adds) a new VirtualHostMapping for the servlet engine
Specified by:
setVirtualHostMapping in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
mapping - The new mapping to add

setWebAppMapping

public void setWebAppMapping(WebAppMapping mapping)
                      throws java.lang.Exception
Description copied from interface: ServletEngine
Sets (adds) a new WebAppMapping for the servlet engine. If the WebAppMapping target is null or empty, the mapping will be removed.
Specified by:
setWebAppMapping in interface ServletEngine
Following copied from interface: jrun.servlet.ServletEngine
Parameters:
mapping - The new mapping to add

removeService

public void removeService(ServiceMBean service)
                   throws java.lang.Exception
Override removeService so we can remove webapps from the list of mappings
Specified by:
removeService in interface ServicePartitionMBean
Overrides:
removeService in class ServicePartition

dispatch

public final void dispatch(ServletConnection connection)
this is the main servlet engine entry point, for every request going to every webapp. Once a fresh request is decoded, we come here to dispatch to it.
Specified by:
dispatch in interface ServletEngine
Following copied from interface: jrun.servlet.ServletEngine
Parameters:
request - The HttpServletRequest
response - The HttpServletResponse

getExpandedMappings

public java.util.Set getExpandedMappings()
Description copied from interface: ServletEngine
Return all the mappings for each of the web-apps we know about.
Specified by:
getExpandedMappings in interface ServletEngine

findWebApplication

public WebApplication findWebApplication(java.lang.String uri)
called by JRunServletContext.getContext() to locate other webapps within the same logical host. [ed] fixme - are different hosts separated out by this?
Specified by:
findWebApplication in interface ServletEngine
Following copied from interface: jrun.servlet.ServletEngine
Parameters:
uri - The request uri

findWebApplication

protected WebApplication findWebApplication(java.lang.String host,
                                            int port,
                                            java.lang.String uri)

findMappingsByHost

protected java.util.Set findMappingsByHost(java.lang.String host)

findMatchingPrefix

protected WebApplication findMatchingPrefix(java.util.Set maps,
                                            java.lang.String uri)

setDefaultLocale

public void setDefaultLocale(java.lang.String locale)
Description copied from interface: ServletEngineServiceMBean
Sets the new default locale for the entire VM
Specified by:
setDefaultLocale in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
locale - The new locale

getDefaultLocale

public java.lang.String getDefaultLocale()
Description copied from interface: ServletEngineServiceMBean
Gets the current default locale for the VM
Specified by:
getDefaultLocale in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Returns:
The current default locale

setMimeMapping

public void setMimeMapping(MimeMapping mapping)
Description copied from interface: ServletEngineServiceMBean
Sets (adds) a new MimeMapping for the servlet engine
Specified by:
setMimeMapping in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
mapping - The new MIME mapping to add

getMimeType

public java.lang.String getMimeType(java.lang.String name)
Description copied from interface: ServletEngineServiceMBean
Gets the mime type for the given resource name
Specified by:
getMimeType in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
name - The resource name
Returns:
The mime type, or null if not found

setMimeTypesPath

public void setMimeTypesPath(java.lang.String path)
                      throws java.lang.Exception
Description copied from interface: ServletEngineServiceMBean
Sets the path of the mime.types file. This file contains MIME type mappings in the Apache format: type extension1 extension2 extension3 The path is relative to the jrun root directory, such as /lib/mime.types.
Specified by:
setMimeTypesPath in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Parameters:
path - The relative path of the mime.types file.

processMimeTypes

protected void processMimeTypes(java.io.InputStream in)
                         throws java.lang.Exception
Read and process the mime.types file. The caller is responsible for closing the input stream

getMimeTypesPath

public java.lang.String getMimeTypesPath()
Description copied from interface: ServletEngineServiceMBean
Gets the path of the mime.types file, or null if none.
Specified by:
getMimeTypesPath in interface ServletEngineServiceMBean
Following copied from interface: jrun.servlet.ServletEngineServiceMBean
Returns:
The relative path of the mime.types file


Copyright � 2002 Macromedia Corporation. All Rights Reserved.