Class Jetty6xEmbeddedLocalContainer
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.container.spi.AbstractContainer
-
- org.codehaus.cargo.container.spi.AbstractLocalContainer
-
- org.codehaus.cargo.container.spi.AbstractEmbeddedLocalContainer
-
- org.codehaus.cargo.container.jetty.internal.AbstractJettyEmbeddedLocalContainer
-
- org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer
-
- All Implemented Interfaces:
Container
,EmbeddedLocalContainer
,RunnableContainer
,LocalContainer
,Loggable
- Direct Known Subclasses:
Jetty7xEmbeddedLocalContainer
public class Jetty6xEmbeddedLocalContainer extends AbstractJettyEmbeddedLocalContainer
A Jetty 6.x instance running embedded.
-
-
Field Summary
Fields Modifier and Type Field Description protected Method
addHandlerMethod
The method to call to add a handler for a webapp.protected Object
contextHandlers
The ContextHandlerCollection into which deployed webapps are added.protected Object
defaultRealm
A default security realm.protected Class
handlerClass
The org.mortbay.jetty.handler.Handler class.protected Object
handlers
The org.mortbay.jetty.handler.HandlerCollection instance.static String
ID
Unique container id.protected Method
removeHandlerMethod
The method to call to undeploy a handler for a webapp.-
Fields inherited from class org.codehaus.cargo.container.jetty.internal.AbstractJettyEmbeddedLocalContainer
server
-
-
Constructor Summary
Constructors Constructor Description Jetty6xEmbeddedLocalContainer(LocalConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDeployables()
Add the cargo deployables and the Cargo Ping Check.void
addHandler(Object handler)
Deploy the handler representing the webapp to jetty.protected void
addJettyHandlers()
Add Jetty handlers.protected void
configureJettyConnectors()
Configure Jetty connectors.Object
createHandler(String contextPath, String war)
Create a WebAppContext for the webapp given as a string.Object
createHandler(Deployable deployable)
Create a WebAppContext for the Deployable.protected void
createServerObject()
Create a Jetty Server Object.protected void
doStart()
Implementation ofRunnableContainer.start()
that all containers extending this class must implement.String
getId()
String
getName()
void
removeHandler(Object handler)
Undeploy the handler representing the webapp.void
setDefaultRealm(Object webapp)
If a default realm is available, set it on the given webapp.protected void
setSecurityRealm()
Defines a security realm and adds defined users to it.protected void
startJetty()
Starts the Jetty server.-
Methods inherited from class org.codehaus.cargo.container.jetty.internal.AbstractJettyEmbeddedLocalContainer
doStop, getCapability, getServer, getVersion, waitForCompletion
-
Methods inherited from class org.codehaus.cargo.container.spi.AbstractEmbeddedLocalContainer
getClassLoader, getType, setClassLoader, startInternal, stopInternal
-
Methods inherited from class org.codehaus.cargo.container.spi.AbstractLocalContainer
executePostStartTasks, forceStopInternal, getConfiguration, getFileHandler, getOutput, getState, getTimeout, isAppend, restart, setAppend, setConfiguration, setFileHandler, setOutput, setState, setTimeout, start, stop, verify, waitForPortShutdown, waitForStarting
-
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.cargo.container.LocalContainer
getConfiguration, getFileHandler, setConfiguration, setFileHandler
-
Methods inherited from interface org.codehaus.cargo.container.internal.RunnableContainer
getOutput, getTimeout, isAppend, restart, setAppend, setOutput, setTimeout, start, stop
-
-
-
-
Field Detail
-
ID
public static final String ID
Unique container id.- See Also:
- Constant Field Values
-
defaultRealm
protected Object defaultRealm
A default security realm. If ServletPropertySet.USERS has been specified, then we create a default realm containing those users and then force that realm to be associated with every webapp (see TODO comment on setSecurityRealm())
-
contextHandlers
protected Object contextHandlers
The ContextHandlerCollection into which deployed webapps are added.
-
handlerClass
protected Class handlerClass
The org.mortbay.jetty.handler.Handler class.
-
handlers
protected Object handlers
The org.mortbay.jetty.handler.HandlerCollection instance.
-
addHandlerMethod
protected Method addHandlerMethod
The method to call to add a handler for a webapp.
-
removeHandlerMethod
protected Method removeHandlerMethod
The method to call to undeploy a handler for a webapp.
-
-
Constructor Detail
-
Jetty6xEmbeddedLocalContainer
public Jetty6xEmbeddedLocalContainer(LocalConfiguration configuration)
-
-
Method Detail
-
getId
public String getId()
- Returns:
- the short name of the container. Note: this is not a unique id. It is simply the name in a computer-usable format.
-
getName
public String getName()
- Returns:
- the human readable name of the Container (ex: "Resin 3.x", "JBoss 3.0.8", etc).
-
setDefaultRealm
public void setDefaultRealm(Object webapp) throws Exception
If a default realm is available, set it on the given webapp.- Parameters:
webapp
- the webapp to set the realm on- Throws:
Exception
- on invokation error
-
doStart
protected void doStart() throws Exception
Implementation ofRunnableContainer.start()
that all containers extending this class must implement.- Specified by:
doStart
in classAbstractEmbeddedLocalContainer
- Throws:
Exception
- if any error is raised during the container start
-
configureJettyConnectors
protected void configureJettyConnectors() throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
Configure Jetty connectors.- Throws:
ClassNotFoundException
- thrown if the connectors could not be configuredInstantiationException
- thrown if the connectors could not be configuredIllegalAccessException
- thrown if the connectors could not be configuredInvocationTargetException
- thrown if the connectors could not be configuredNoSuchMethodException
- thrown if the connectors could not be configured
-
addJettyHandlers
protected void addJettyHandlers() throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
Add Jetty handlers.- Throws:
ClassNotFoundException
- thrown if the handlers could not be addedInstantiationException
- thrown if the handlers could not be addedIllegalAccessException
- thrown if the handlers could not be addedInvocationTargetException
- thrown if the handlers could not be addedNoSuchMethodException
- thrown if the handlers could not be added
-
addDeployables
protected void addDeployables() throws Exception
Add the cargo deployables and the Cargo Ping Check.- Throws:
Exception
- thrown if the deployables could not be added
-
createHandler
public Object createHandler(Deployable deployable) throws Exception
Create a WebAppContext for the Deployable. NB also force the defaultRealm to be set on it if one is present.- Parameters:
deployable
- the cargo webapp to deploy- Returns:
- a jetty webapp
- Throws:
Exception
- on invokation exception
-
createHandler
public Object createHandler(String contextPath, String war) throws Exception
Create a WebAppContext for the webapp given as a string. NB Also force the defaultRealm to be set if one is present.- Parameters:
contextPath
- the context path for the webappwar
- the webapp- Returns:
- a jetty webapp
- Throws:
Exception
- on invokation exception
-
addHandler
public void addHandler(Object handler) throws Exception
Deploy the handler representing the webapp to jetty. If jetty is already started, then start the handler.- Parameters:
handler
- the handler representing the webapp- Throws:
Exception
- on invocation exception
-
removeHandler
public void removeHandler(Object handler) throws Exception
Undeploy the handler representing the webapp.- Parameters:
handler
- the handler representing the webapp- Throws:
Exception
- on invocation exception
-
setSecurityRealm
protected void setSecurityRealm() throws Exception
Defines a security realm and adds defined users to it. If a user has specified the standard ServletPropertySet.USERS property, then we try and turn these into an in-memory default realm, and then set that realm on all of the webapps. TODO: this is not ideal. We need a way to specify N named realms to the server so that individual webapps can find their appropriate realms by name.- Throws:
Exception
- in case of error
-
createServerObject
protected void createServerObject() throws Exception
Create a Jetty Server Object.- Overrides:
createServerObject
in classAbstractJettyEmbeddedLocalContainer
- Throws:
Exception
- in case of error
-
startJetty
protected void startJetty()
Starts the Jetty server.
-
-