@Service @ContractsProvided(value={WebContainerImpl.class,WebContainer.class}) public class WebContainerImpl extends Object implements WebContainer
Constructor and Description |
---|
WebContainerImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addContext(Context context,
String contextRoot)
Registers the given Context with all VirtualServer
at the given context root.
|
void |
addVirtualServer(VirtualServer virtualServer)
Adds the given VirtualServer to this
WebContainer.
|
void |
addWebListener(WebListener webListener)
Adds the given WebListener to this
WebContainer.
|
Context |
createContext(File docRoot)
Creates a Context and configures it with the given
docroot and classloader.
|
Context |
createContext(File docRoot,
ClassLoader classLoader)
Creates a Context and configures it with the given
docroot and classloader.
|
Context |
createContext(File docRoot,
String contextRoot,
ClassLoader classLoader)
Creates a Context, configures it with the given
docroot and classloader, and registers it with all
VirtualServer.
|
VirtualServer |
createVirtualServer(String id,
File docRoot)
Creates a VirtualServer with the given id and docroot, and
maps it to all WebListener instances.
|
VirtualServer |
createVirtualServer(String id,
File docRoot,
WebListener... webListeners)
Creates a VirtualServer with the given id and docroot, and
maps it to the given WebListener instances.
|
<T extends WebListener> |
createWebListener(String id,
Class<T> c)
Creates a WebListener from the given class type and
assigns the given id to it.
|
List<Sniffer> |
getSniffers()
Returns the list of sniffers associated with this embedded container
|
VirtualServer |
getVirtualServer(String id)
Finds the VirtualServer with the given id.
|
Collection<VirtualServer> |
getVirtualServers()
Gets the collection of VirtualServer instances registered
with this WebContainer.
|
WebListener |
getWebListener(String id)
Finds the WebListener with the given id.
|
Collection<WebListener> |
getWebListeners()
Gets the collection of WebListener instances registered
with this WebContainer.
|
void |
removeContext(Context context)
Stops the given Context and removes it from all
VirtualServer.
|
void |
removeVirtualServer(VirtualServer virtualServer)
Stops the given virtualServer and removes it from this
WebContainer.
|
void |
removeWebListener(WebListener webListener)
Stops the given webListener and removes it from this
WebContainer.
|
void |
setConfiguration(WebContainerConfig config)
Sets the embedded configuration for this embedded instance.
|
void |
setLogLevel(Level level)
Sets log level
|
public void setConfiguration(WebContainerConfig config)
WebContainer
setConfiguration
in interface WebContainer
config
- the embedded instance configurationpublic List<Sniffer> getSniffers()
public Context createContext(File docRoot)
The classloader of the class on which this method is called will be used.
In order to access the new Context or any of its resources, the Context must be registered with a VirtualServer that has been started.
createContext
in interface WebContainer
docRoot
- the docroot of the ContextVirtualServer.addContext(org.glassfish.embeddable.web.Context, java.lang.String)
public Context createContext(File docRoot, ClassLoader classLoader)
The given classloader will be set as the thread's context classloader whenever the new Context or any of its resources are asked to process a request. If a null classloader is passed, the classloader of the class on which this method is called will be used.
In order to access the new Context or any of its resources, the Context must be registered with a VirtualServer that has been started.
createContext
in interface WebContainer
docRoot
- the docroot of the ContextclassLoader
- the classloader of the ContextVirtualServer.addContext(org.glassfish.embeddable.web.Context, java.lang.String)
public Context createContext(File docRoot, String contextRoot, ClassLoader classLoader)
The given classloader will be set as the thread's context classloader whenever the new Context or any of its resources are asked to process a request. If a null classloader is passed, the classloader of the class on which this method is called will be used.
createContext
in interface WebContainer
docRoot
- the docroot of the ContextcontextRoot
- the contextroot at which to registerclassLoader
- the classloader of the Contextpublic void addContext(Context context, String contextRoot) throws ConfigException, GlassFishException
If VirtualServer has already been started, the given context will be started as well.
addContext
in interface WebContainer
context
- the Context to registercontextRoot
- the context root at which to registerConfigException
- if a Context already exists
at the given context root on VirtualServerGlassFishException
- if the given context fails
to be startedpublic void removeContext(Context context) throws ConfigException, GlassFishException
removeContext
in interface WebContainer
context
- the Context to be stopped and removedGlassFishException
- if an error occurs during the stopping
or removal of the given contextConfigException
public <T extends WebListener> T createWebListener(String id, Class<T> c) throws InstantiationException, IllegalAccessException
createWebListener
in interface WebContainer
id
- the id of the new WebListenerc
- the class from which to instantiate the
WebListenerIllegalAccessException
- if the given Class or
its nullary constructor is not accessible.InstantiationException
- if the given Class
represents an abstract class, an interface, an array class,
a primitive type, or void; or if the class has no nullary
constructor; or if the instantiation fails for some other reason.ExceptionInInitializerError
- if the initialization
failsSecurityException
- if a security manager, s, is
present and any of the following conditions is met:
s.checkMemberAccess(this, Member.PUBLIC)
denies
creation of new instances of the given Class
s.checkPackageAccess()
denies access to the package
of this class
public void addWebListener(WebListener webListener) throws ConfigException, GlassFishException
If this WebContainer has already been started, the given webListener will be started as well.
addWebListener
in interface WebContainer
webListener
- the WebListener to addConfigException
- if a WebListener with the
same id has already been registered with this
WebContainerGlassFishException
- if the given webListener fails
to be startedpublic WebListener getWebListener(String id)
getWebListener
in interface WebContainer
id
- the id of the WebListener to findpublic Collection<WebListener> getWebListeners()
getWebListeners
in interface WebContainer
public void removeWebListener(WebListener webListener) throws GlassFishException
removeWebListener
in interface WebContainer
webListener
- the WebListener to be stopped
and removedGlassFishException
- if an error occurs during the stopping
or removal of the given webListenerpublic VirtualServer createVirtualServer(String id, File docRoot, WebListener... webListeners)
createVirtualServer
in interface WebContainer
id
- the id of the VirtualServerdocRoot
- the docroot of the VirtualServerwebListeners
- the list of WebListener instances from
which the VirtualServer will receive requestspublic VirtualServer createVirtualServer(String id, File docRoot)
createVirtualServer
in interface WebContainer
id
- the id of the VirtualServerdocRoot
- the docroot of the VirtualServerpublic void addVirtualServer(VirtualServer virtualServer) throws ConfigException, GlassFishException
If this WebContainer has already been started, the given virtualServer will be started as well.
addVirtualServer
in interface WebContainer
virtualServer
- the VirtualServer to addConfigException
- if a VirtualServer with the
same id has already been registered with this
WebContainerGlassFishException
- if the given virtualServer fails
to be startedpublic VirtualServer getVirtualServer(String id)
getVirtualServer
in interface WebContainer
id
- the id of the VirtualServer to findpublic Collection<VirtualServer> getVirtualServers()
getVirtualServers
in interface WebContainer
public void removeVirtualServer(VirtualServer virtualServer) throws GlassFishException
removeVirtualServer
in interface WebContainer
virtualServer
- the VirtualServer to be stopped
and removedGlassFishException
- if an error occurs during the stopping
or removal of the given virtualServerpublic void setLogLevel(Level level)
setLogLevel
in interface WebContainer
level
- Copyright © 2021. All rights reserved.