jetty_readme
Jetty Component
Introduction
Jetty component provides the functionality of starting a Jetty Server with and without default configurations of listeners, webapplications and servlets. It also provides the feature of dynamically configuring a running Jetty HttpServer with additional listeners, webapplications and servers.
It provides instantiable extensions to the www components, which must also be on the classpath of this component's deployment.
This component has been built against Jetty 4.2.24. It compiles against later versions, but
How to build
First build SmartFrog framework by running ant dist in core/smartfrog
-
Build the ant tasks by running ant in core/extras/ant
-
Build Jetty by running ant in core/components/jetty
-
Step 3 creates one jar file in core/components/jetty/dist/lib. Copy this jar file and the jar files for jetty source from core/components/jetty/lib to core/smartfrog/dist/lib. Other option for adding the jetty jar files is to update class path for the SmartFrog daemon so that jetty classes are available at run time.
Component Description
The Jetty package has different components for jetty server, jetty server with admin privileges, listeners, webapplications, servletcontexts, handlers and servlets.
These are all declared in
org/smartfrog/services/jetty/components.sf
HttpServerAdmin
Administration component
Attribute Name | Description | Optional/Mandatory |
---|---|---|
httpserverHost | Host on which the Jetty server configured with admin privileges runs | Mandatory |
listenerPort | Port on which the jetty server listens | Mandatory |
contextPath | Context Path for the Jetty server | Optional |
CoreJettyServer
Attribute Name | Description | Optional/Mandatory |
---|---|---|
jettyhome | Jetty home path.This is essentially the base directory for operations; | Mandatory |
serverHost | Host on which the Jetty server runs | Mandatory |
enableLogging | Boolean to keep logging on or off | Mandatory |
logPattern | pattern for log files | Mandatory, but a default is declared |
logDir | Directory for log files. If a relative directory path is supplied, it is resolved relative to jettyhome. | Default is declared as log/ |
HttpServer
This component extends CoreJettyServer with extra declarations. It requires a compete
JettyListener
Declare a listener for incoming requests
Attribute Name | Description | Optional/Mandatory |
---|---|---|
listenerPort | Port on which the listener listens | Mandatory |
serverHost | Host on which the listener runs | Optional. Omit it bind to all network cards on the host |
server | Jetty server to which the listener is attached | Mandatory |
Be aware that setting the serverHost value to "localhost" will bind the server to the loopback address, if there is an entry in the hosttable mapping that name to 127.0.0.1.
JettyWebApplication
Declares a web application
Attribute Name | Description | Optional/Mandatory |
---|---|---|
contextPath | Context Path for the web application | Mandatory |
warFile | Path of the web application | Mandatory |
resourceId | Resource id for the web application | Optional |
server | Jetty server to which this web application is attached | Mandatory |
JettyServletContext
Attribute Name | Description | Optional/Mandatory |
---|---|---|
contextPath | Context Path for the servlet context | Mandatory |
resourceBase | Resourcebase for the servlet context | Mandatory |
server | Jetty server to which this servlet context is attached | Mandatory |
classPath | Classpath for the servlet context | Optional |
Run-time properties
Attribute Name | Description |
---|---|
ipaddr | IP Address of the context (currently determined from the network card/address that the SmartFrog daemon is listening on) |
absolutePath | Base path of this context |
JettyHandler
This component is used by different handlers like Dump, Forward, HTAccess etc. for getting added to the ServletContexts. Each handler has specific attributes for its implementation.
Usage
The Jetty component can be used for starting different instances of Jetty Server on the same system with and without admin privileges by configuring the attributes defined for each component. A property named jetty.home needs to be set for jetty location on the server before deploying this component.
In a simplest usage the HttpServer component is extended to start a server, by default it is started on port 8080 on the specified host and attached with specified server. For starting another instance of Jetty server, it can be configured for some other port also by configuring the listeners component. Each server instance is added to the ProcessCompond as it is started. This is useful for the dynamic binding feature explained below.
Please go through core/components/jetty/ src/org/smartfrog/services/jetty/example1/2/3.sf for sample usage.
Dynamic binding of listeners, webapplications and servlets to an already running Jetty server can be by giving a reference to a Jetty server to which it should be attached to the components derived from JettyListener , JettyWebApplication and JettyServletContext components. Since all the running Jetty servers have reference in ProcessCompound, the reference to the mentioned server is taken from ProcessCompound and the listeners, webapplications and servletcontexts are added to it.
Please go through core/components/jetty/src/org/smartfrog/services/jetty/dynamicexample.sf for sample usage.