|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
jrunx.kernel.ServiceAdapter
|
+--jrunx.scheduler.ThreadPoolService
|
+--jrun.servlet.network.NetworkService
The base class for developing network services. Network services are modules that, running within a server, make a particular application protocol such as FTP or DHCP available across a network. Services can typically interact with multiple clients concurrently, handling requests through one or more endpoints. The clients can be end-users using applications or applets, or other services.
This class takes care of most of the management for Tcp sockets. if other types of sockets are needed, a subclass can certianly override the necessary methods.
| Field Summary | |
static java.lang.String |
BYTES_IN
|
static java.lang.String |
BYTES_OUT
|
static java.lang.String |
HANDLED_MS
|
static java.lang.String |
HANDLED_RQ
|
protected int |
metricsElapsedIndex
|
protected int |
metricsIndexIn
|
protected int |
metricsIndexOut
|
protected int |
metricsServicedIndex
|
protected javax.net.ServerSocketFactory |
serverSocketFactory
|
protected java.net.ServerSocket |
ss
|
| Fields inherited from class jrunx.scheduler.ThreadPoolService |
metrics, threadPool |
| 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 |
| Fields inherited from interface jrunx.scheduler.RunnableFactory |
BUSY, EXCEPTION, SHUTDOWN |
| Constructor Summary | |
NetworkService()
|
|
| Method Summary | |
protected java.net.Socket |
accept()
Subclasses can override this to change the socket class or implement a different concurrency policy. |
protected void |
bindToSocket()
Create and bind a protocol specific socket. |
Metrics |
createMetrics()
|
int |
getAvailablePort(int startPort,
int portCount)
Gets first unused port |
int |
getBacklog()
Gets the server socket backlog |
java.lang.String |
getBindAddress()
Gets the bind address for the service |
int |
getInputMetricIndex()
|
java.lang.String |
getInterface()
Gets the accepted interface pattern |
Metrics |
getMetrics()
|
abstract java.lang.String |
getMetricsPrefix()
Gets the prefix to be used for metrics, such as "jcp" or "web". |
int |
getOutputMetricIndex()
|
int |
getPort()
Gets the port that this service will bind to |
RunnableFactory |
getRunnableFactory()
|
int |
getServicedMetricIndex()
|
abstract java.lang.String |
getServiceName()
Gets the service name, such as JRun Web Server. |
java.lang.String |
getSocketFactoryName()
Gets the socket factory class for this endpoint. |
int |
getTimeout()
Gets the socket read timeout |
protected int |
getTimeoutMs()
|
void |
init()
Not every service needs to init, implement it out of convenience. |
void |
setBacklog(int backlog)
Sets the server socket backlog. |
void |
setBindAddress(java.lang.String addr)
Sets the bind address for the service. |
void |
setInterface(java.lang.String iface)
Sets the accepted interface pattern. |
void |
setPort(int port)
Sets the port that this service will bind to |
void |
setSocketFactoryName(java.lang.String className)
Sets the socket factory class for this endpoint. |
void |
setTimeout(int seconds)
Sets the socket read timeout |
void |
start()
Every service other than mere data collections should start |
void |
stop()
Every service other than mere data collections should stop |
void |
updateRequestMetrics()
Updates the end of the request. |
| Methods inherited from class jrunx.scheduler.ThreadPoolService |
getActiveHandlerThreads, getMaxHandlerThreads, getMinHandlerThreads, getThreadWaitTimeout, setActiveHandlerThreads, setMaxHandlerThreads, setMinHandlerThreads, setThreadWaitTimeout |
| Methods inherited from interface jrunx.scheduler.ThreadPoolServiceMBean |
getActiveHandlerThreads, getMaxHandlerThreads, getMinHandlerThreads, getThreadWaitTimeout, setActiveHandlerThreads, setMaxHandlerThreads, setMinHandlerThreads, setThreadWaitTimeout |
| 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 |
destroy, getStatus, updateStatus |
| Methods inherited from interface jrunx.scheduler.RunnableFactory |
createRunnable, destroyRunnable, invokeRunnable, swapRunnable |
| Field Detail |
public static final java.lang.String BYTES_IN
public static final java.lang.String BYTES_OUT
public static final java.lang.String HANDLED_RQ
public static final java.lang.String HANDLED_MS
protected int metricsIndexIn
protected int metricsIndexOut
protected int metricsServicedIndex
protected int metricsElapsedIndex
protected javax.net.ServerSocketFactory serverSocketFactory
protected java.net.ServerSocket ss
| Constructor Detail |
public NetworkService()
| Method Detail |
public void init()
throws java.lang.Exception
ServiceAdapterinit in interface Serviceinit in class ThreadPoolServicepublic void setBindAddress(java.lang.String addr)
NetworkServiceMBeansetBindAddress in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanaddr - The bind addresspublic java.lang.String getBindAddress()
NetworkServiceMBeangetBindAddress in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanpublic void setPort(int port)
NetworkServiceMBeansetPort in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanport - The port numberpublic int getPort()
NetworkServiceMBeangetPort in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBean
public int getAvailablePort(int startPort,
int portCount)
getAvailablePort in interface NetworkServiceMBeanstartPort - The port number to start scanportCount - The number of ports to check for availabilitypublic void setBacklog(int backlog)
NetworkServiceMBeansetBacklog in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanbacklog - The backlogpublic int getBacklog()
NetworkServiceMBeangetBacklog in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanpublic void setInterface(java.lang.String iface)
NetworkServiceMBeansetInterface in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeaniface - The interfacepublic java.lang.String getInterface()
NetworkServiceMBeangetInterface in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanpublic void setSocketFactoryName(java.lang.String className)
NetworkServiceMBeansetSocketFactoryName in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanclassName - The server socket factory class namepublic java.lang.String getSocketFactoryName()
NetworkServiceMBeangetSocketFactoryName in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanpublic void setTimeout(int seconds)
NetworkServiceMBeansetTimeout in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanseconds - The read timeout in secondspublic int getTimeout()
NetworkServiceMBeangetTimeout in interface NetworkServiceMBeanjrun.servlet.network.NetworkServiceMBeanprotected int getTimeoutMs()
public void start()
throws java.lang.Exception
ServiceAdapterstart in interface Servicestart in class ThreadPoolServicepublic RunnableFactory getRunnableFactory()
getRunnableFactory in class ThreadPoolServicepublic Metrics createMetrics()
createMetrics in class ThreadPoolService
public void stop()
throws java.lang.Exception
ServiceAdapterstop in interface Servicestop in class ServiceAdapterpublic abstract java.lang.String getMetricsPrefix()
getMetricsPrefix in class ThreadPoolServicepublic abstract java.lang.String getServiceName()
protected void bindToSocket()
throws java.io.IOException
java.io.IOException - in case of address binding errorsConfigException - if the configuration information is problematic
protected java.net.Socket accept()
throws java.io.IOException,
java.lang.InterruptedException
public Metrics getMetrics()
getMetrics in class ThreadPoolServicepublic int getOutputMetricIndex()
public int getInputMetricIndex()
public int getServicedMetricIndex()
public final void updateRequestMetrics()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||