JSPservletPkg
Class JSPhandler

JSPservletPkg.JSPhandler

public class JSPhandler

It loads classes through ClassEntry with JSPloader and registers them. JES2 activator. Based on Sun SnoopActivator.java

Copyright (c) 2000-2001

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; version 2
 of the License.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 

Version:
1, 0
Author:
Alexis Grandemange
See Also:
JSPhandler.ClassEntry, JSPloader

Inner Class Summary
(package private)  class JSPhandler.ClassEntry
          Class invoked by JSPhandler for a given jar name.
(package private)  class JSPhandler.Log
          Class wraping trace use.
(package private)  class JSPhandler.Scanner
          Implements a scanner thread.
 
Field Summary
(package private)  java.lang.String adminPasswd
          Password for admin page authentication (ServletLog, DisklessLog, ServletStat, DisklessStat, ServletUpdate).
(package private)  java.lang.String adminUser
          User for admin page authentication (ServletLog, DisklessLog, ServletStat, DisklessStat, ServletUpdate).
(package private)  java.lang.String[] aErrorPage
          Area of error handling pages
(package private)  java.lang.String allPermissionPolicy
          describes an default policy file and set sandbox for archive execution.
(package private)  JSPservletPkg.BasicSchemeHandler basic
          Handle on BasicSchemeHandler.
(package private)  java.lang.String basicPasswd
          password for basic page authentication
(package private)  java.lang.String basicUser
          user for basic page authentication
(package private)  boolean bDisklessClt
          If true, diskless and send messages to a diskless server.
(package private)  boolean bMulticast
          If true, multicast - use of port and mcg variable.
(package private)  JSPservletPkg.BundleContext bundleContext
          Context of the bundle (parameter of start method)
(package private)  java.lang.String cachePath
          path were jars are locally stored - initialized by constructor.
(package private)  java.lang.String CALDAPpasswd
          Password to use to connect to LDAP for CA certificate.
(package private)  java.lang.String CALDAPuser
          Principal to use to connect to LDAP for CA certificate.
(package private)  java.lang.String CAURL
          URL to access CA certificate in LDAP.
(package private)  java.util.HashMap classEntries
          ClassEntry HashMap.
(package private)  java.util.Properties configProp
          Configuration Properties - initialized by constructor.
(package private)  java.lang.String contextPath
          Used to identify a particular JSPservlet bundle.
(package private)  java.lang.String CRLLDAPpasswd
          Password to use to connect to LDAP for CRL.
(package private)  java.lang.String CRLLDAPuser
          Principal to use to connect to LDAP for CRL.
(package private)  int CRLperiod
          Certificate Revocation List Scan Period in seconds.
(package private)  java.lang.String CRLURL
          URL to access Certificate Revocation List in LDAP.
(package private)  java.lang.String defaultPolicy
          describes a policy for archive without policy.
(package private)  java.lang.String DISKLESSLOG_ALIAS
          DisklessLog alias
(package private)  DisklessLog dl
          Handle on DisklessLog servlet.
(package private) static int EP_NOTFOUND
          servlet or resource not found
(package private) static int EP_OTHER
          other errors
(package private) static int EP_REVOKED
          archive certificate revoked
(package private) static int EP_SIZE
          error page array size
(package private) static int EP_UNAUTHORIZED
          servlet attempted an unauthorized access
(package private)  int expiration
          resources expiration time in seconds - initialized by constructor.
(package private)  JSPservletPkg.HttpService http
          Handle on HttpService.
(package private)  JSPservletPkg.ServiceReference httpauthref
          Initialized in start from com.sun.jes.service.http.auth.basic.BasicSchemeHandler
(package private)  JSPservletPkg.ServiceReference httpref
          Initialized in start from org.osgi.service.http.HttpService
(package private)  java.lang.String ID
          PageBox unique identifier
(package private)  ICPhandler ih
          Diskless and ICP support.
(package private)  java.lang.String keystore
          keystore location.
(package private)  java.lang.String keystorePassword
          keystore password.
(package private)  JSPhandler.Log log
          Handle on Log object.
(package private)  java.lang.String logfile
          Path of log file.
(package private)  java.lang.String mcg
          Multicast group form xxx.xxx.xxx.xxx or listening address (ptp).
(package private)  int port
          Multicast port.
(package private)  java.lang.String[] remAddrs
          Server addresses.
(package private)  java.lang.String remoteLocFile
          remote locations properties file name - initialized by constructor.
(package private)  java.util.Properties remoteLocProp
          remote locations Properties - initialized by constructor.
(package private)  int[] remPorts
          Server ports.
(package private)  JSPhandler.Scanner scanner
          Scanner object
(package private) static int SCANPERIOD
          Scanner wake-up
(package private)  java.lang.ClassLoader servletClassLoader
          ClassLoader used to create JSPhandler.
(package private)  java.lang.String SERVLETLOG_ALIAS
          ServletLog alias
(package private)  java.lang.String SERVLETSTAT_ALIAS
          ServletStat alias
(package private)  java.lang.String SERVLETUPDATE_ALIAS
          ServletUpdate alias
(package private)  ServletLog sl
          Handle on ServletLog servlet.
(package private)  ServletStat ss
          Handle on ServletStat servlet.
(package private)  ServletUpdate su
          Handle on ServletUpdate servlet.
(package private)  boolean toStat
          record statistics or not
(package private)  boolean toTrace
          Initial tracing mode.
(package private)  boolean useBundleSpace
          If true, uses bundle space provided by BundleContext.
 
Constructor Summary
JSPhandler()
           
 
Method Summary
 void delete(java.lang.String jarName)
          Invoked by ServletUpdate.
(package private)  java.lang.String disklessRemotePropInit(java.io.InputStream is)
          Invoked by ICPhandler.
protected  void finalize()
          to avoid loitering
(package private)  java.io.File getFile(java.lang.String path)
          Get a File using path parameter and checks it exists or can be created.
(package private)  java.lang.String getInitParameter(java.lang.String parameter)
          Parameters retrieval from a property file.
private  void httpRegister()
          Method invoked from start and serviceChanged
private  void httpUnregister()
          Method invoked from stop and serviceChanged
 void initialize()
          Initializes parameters from property file in archive.
private  void initializeParameters()
          Restores InitParameters from JSPservlet.properties in this jar file.
(package private)  boolean memoryUpdate(java.lang.String jarName, java.lang.String remoteLocation)
          Invoked by update.
 void serviceChanged(JSPservletPkg.ServiceEvent event)
          ServiceListener's serviceChanged method.
 void start(JSPservletPkg.BundleContext bc)
          BundleActivator method invoked at bundle start.
 void stop(JSPservletPkg.BundleContext bc)
          BundleActivator method invoked at bundle stop.
 boolean update(java.lang.String jarName, java.lang.String remoteLocation)
          Invoked by ServletUpdate.
 

Field Detail

cachePath

java.lang.String cachePath
path were jars are locally stored - initialized by constructor.
See Also:
JSPhandler.ClassEntry, JSPloader

classEntries

java.util.HashMap classEntries
ClassEntry HashMap. key: jar name value: ClassEntry

remoteLocFile

java.lang.String remoteLocFile
remote locations properties file name - initialized by constructor.
See Also:
JSPhandler.ClassEntry

logfile

java.lang.String logfile
Path of log file.

toTrace

boolean toTrace
Initial tracing mode.

log

JSPhandler.Log log
Handle on Log object.

remoteLocProp

java.util.Properties remoteLocProp
remote locations Properties - initialized by constructor.
See Also:
update(String jarName, String remoteLocation), JSPhandler.ClassEntry

servletClassLoader

java.lang.ClassLoader servletClassLoader
ClassLoader used to create JSPhandler.

defaultPolicy

java.lang.String defaultPolicy
describes a policy for archive without policy.

allPermissionPolicy

java.lang.String allPermissionPolicy
describes an default policy file and set sandbox for archive execution.

keystore

java.lang.String keystore
keystore location. Also states if policy should be downloaded.

keystorePassword

java.lang.String keystorePassword
keystore password.

expiration

int expiration
resources expiration time in seconds - initialized by constructor.

CRLURL

java.lang.String CRLURL
URL to access Certificate Revocation List in LDAP. Initialized by constructor.

CRLLDAPuser

java.lang.String CRLLDAPuser
Principal to use to connect to LDAP for CRL. Initialized by constructor.

CRLLDAPpasswd

java.lang.String CRLLDAPpasswd
Password to use to connect to LDAP for CRL. Initialized by constructor.

CRLperiod

int CRLperiod
Certificate Revocation List Scan Period in seconds. Initialized by constructor.

CAURL

java.lang.String CAURL
URL to access CA certificate in LDAP. Initialized by constructor.

CALDAPuser

java.lang.String CALDAPuser
Principal to use to connect to LDAP for CA certificate. Initialized by constructor.

CALDAPpasswd

java.lang.String CALDAPpasswd
Password to use to connect to LDAP for CA certificate. Initialized by constructor.

basicUser

java.lang.String basicUser
user for basic page authentication

basicPasswd

java.lang.String basicPasswd
password for basic page authentication

adminUser

java.lang.String adminUser
User for admin page authentication (ServletLog, DisklessLog, ServletStat, DisklessStat, ServletUpdate).

adminPasswd

java.lang.String adminPasswd
Password for admin page authentication (ServletLog, DisklessLog, ServletStat, DisklessStat, ServletUpdate).

toStat

boolean toStat
record statistics or not

EP_OTHER

static final int EP_OTHER
other errors

EP_NOTFOUND

static final int EP_NOTFOUND
servlet or resource not found

EP_UNAUTHORIZED

static final int EP_UNAUTHORIZED
servlet attempted an unauthorized access

EP_REVOKED

static final int EP_REVOKED
archive certificate revoked

EP_SIZE

static final int EP_SIZE
error page array size

SCANPERIOD

static final int SCANPERIOD
Scanner wake-up

scanner

JSPhandler.Scanner scanner
Scanner object

aErrorPage

java.lang.String[] aErrorPage
Area of error handling pages

ID

java.lang.String ID
PageBox unique identifier

configProp

java.util.Properties configProp
Configuration Properties - initialized by constructor. Replaces web.xml that doesn't exist on embedded servers.

useBundleSpace

boolean useBundleSpace
If true, uses bundle space provided by BundleContext.

bDisklessClt

boolean bDisklessClt
If true, diskless and send messages to a diskless server. If false, acts as a diskless server. Default false: writes on local file system.

bMulticast

boolean bMulticast
If true, multicast - use of port and mcg variable. If false, point to point - port contains the listening port. mcg contains the listening address (interface). remAddrs is an array of remote server addresses (if bDisklessClt == true). remPorts is an array of remote server ports (if bDisklessClt == true).

remAddrs

java.lang.String[] remAddrs
Server addresses.

remPorts

int[] remPorts
Server ports.

mcg

java.lang.String mcg
Multicast group form xxx.xxx.xxx.xxx or listening address (ptp).

port

int port
Multicast port.

ih

ICPhandler ih
Diskless and ICP support.

sl

ServletLog sl
Handle on ServletLog servlet.

dl

DisklessLog dl
Handle on DisklessLog servlet.

ss

ServletStat ss
Handle on ServletStat servlet.

su

ServletUpdate su
Handle on ServletUpdate servlet.

http

JSPservletPkg.HttpService http
Handle on HttpService. Created in start method. Used to register/unregister servlets.

basic

JSPservletPkg.BasicSchemeHandler basic
Handle on BasicSchemeHandler. Created in start method. Used in HttpContext to prompt the user for credentials.

httpref

JSPservletPkg.ServiceReference httpref
Initialized in start from org.osgi.service.http.HttpService

httpauthref

JSPservletPkg.ServiceReference httpauthref
Initialized in start from com.sun.jes.service.http.auth.basic.BasicSchemeHandler

SERVLETUPDATE_ALIAS

final java.lang.String SERVLETUPDATE_ALIAS
ServletUpdate alias

SERVLETLOG_ALIAS

final java.lang.String SERVLETLOG_ALIAS
ServletLog alias

DISKLESSLOG_ALIAS

final java.lang.String DISKLESSLOG_ALIAS
DisklessLog alias

SERVLETSTAT_ALIAS

final java.lang.String SERVLETSTAT_ALIAS
ServletStat alias

contextPath

java.lang.String contextPath
Used to identify a particular JSPservlet bundle.

bundleContext

JSPservletPkg.BundleContext bundleContext
Context of the bundle (parameter of start method)
Constructor Detail

JSPhandler

public JSPhandler()
Method Detail

getFile

java.io.File getFile(java.lang.String path)
Get a File using path parameter and checks it exists or can be created.
Parameters:
path - path to File.

initializeParameters

private void initializeParameters()
Restores InitParameters from JSPservlet.properties in this jar file.

getInitParameter

java.lang.String getInitParameter(java.lang.String parameter)
Parameters retrieval from a property file.

initialize

public void initialize()
Initializes parameters from property file in archive.

delete

public final void delete(java.lang.String jarName)
Invoked by ServletUpdate.
Parameters:
jarName - name of the jar.

memoryUpdate

final boolean memoryUpdate(java.lang.String jarName,
                           java.lang.String remoteLocation)
                    throws JSPloaderException
Invoked by update. Search ClassEntry with jarName. Creates it if not found.
Parameters:
jarName - name of the jar.
remoteLocation - URL where to download the jar.
Returns:
boolean true if jarName found or false otherwise.
Throws:
JSPloaderException - in ClassEntry.getProperty.
See Also:
JSPhandler.ClassEntry.update(String remoteLocation)

update

public final boolean update(java.lang.String jarName,
                            java.lang.String remoteLocation)
                     throws JSPloaderException
Invoked by ServletUpdate.
  1. Remove local cache
  2. If remote location was set by ServletUpdate, updates and persists remote properties.

Parameters:
jarName - name of the jar.
remoteLocation - URL where to download the jar.
Returns:
boolean true if jarName found or false otherwise.
Throws:
JSPloaderException - when persisting modified properties.
See Also:
memoryUpdate(String jarName, String remoteLocation)

finalize

protected void finalize()
to avoid loitering

disklessRemotePropInit

java.lang.String disklessRemotePropInit(java.io.InputStream is)
Invoked by ICPhandler. Initialize remoteLocProp from ICP_OP_ARCHIVE_STATUS
Parameters:
is - remote property stream.

start

public void start(JSPservletPkg.BundleContext bc)
           throws JSPservletPkg.BundleException
BundleActivator method invoked at bundle start.
Parameters:
bc - context of the bundle.
Throws:
JSPservletPkg.BundleException - propagated from framework invocation.

serviceChanged

public void serviceChanged(JSPservletPkg.ServiceEvent event)
ServiceListener's serviceChanged method. Note start has subscribed to events from org.osgi.service.http.HttpService and com.sun.jes.service.http.auth.basic.BasicSchemeHandler.
Parameters:
event - notification of a service change.

httpRegister

private void httpRegister()
Method invoked from start and serviceChanged

httpUnregister

private void httpUnregister()
Method invoked from stop and serviceChanged

stop

public void stop(JSPservletPkg.BundleContext bc)
          throws JSPservletPkg.BundleException
BundleActivator method invoked at bundle stop. It invokes scanner.toEnd to stop scanner thread. It can take up to SCANPERIOD to end.
Parameters:
bc - context of the bundle.
Throws:
JSPservletPkg.BundleException - propagated from framework invocation.