|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
simple.http.load.LoaderEngine
public class LoaderEngine
The LoaderEngine
is used to load Service
implementations into the system so that they can be executed by
a ProtocolHandler
. The LoaderEngine
is
a LoaderManager
and thus can be exported to a remote
process where it can be managed/administered.
This will retrieve linked Service
objects based on
the simple.util.Resolver
object. So the later the
link is made the higher its priority. Each of the methods of the
LoaderManager
are governed by access control. This
is so that Service
objects cannot access the methods
of the LoaderEngine
and change the configuration.
The permission required for access to the LoaderEngine
is the LoaderPermission
. There are three actions that
can be granted using this permission. First is "load" permission
which grants permission for the load
methods and the
unload
method. The second is "link" this grants the
permission to use the link
and unlink
methods. The final action token is "update" which grants permission
for the update
and remove
methods.
Monitoring activity within the LoaderEngine
can be
done by registering a Loader
. This enables the
loader to recieve updates on the configuration of the loader
engine as it changes. This needs LoaderPermission
with the "update" action.
Service
,
Resolver
,
Serialized FormField Summary | |
---|---|
protected Context |
context
This is the context this loader engine operates from. |
protected simple.http.load.Processor |
delegate
This is used to update any Loader objects. |
protected simple.http.load.Profile |
profile
This contains the configuration of the loader engine. |
protected simple.http.load.Registry |
registry
This contains the loaded Service 's. |
protected Resolver |
resolver
The Resolver for the linked classes. |
Fields inherited from class java.rmi.server.RemoteObject |
---|
ref |
Constructor Summary | |
---|---|
|
LoaderEngine()
Constructor for the LoaderEngine that uses the
class loader of the current instance to load the services. |
|
LoaderEngine(Context context)
Constructor for the LoaderEngine that uses the
class loader of the current instance to load the services. |
protected |
LoaderEngine(Context context,
java.io.File path)
Constructor for the LoaderEngine takes a file
classpath. |
|
LoaderEngine(Context context,
java.net.URL codebase)
Constructor for the LoaderEngine that uses the
class loader of the current instance to load the services. |
|
LoaderEngine(Context context,
java.net.URL[] codebase)
Constructor for the LoaderEngine takes a URL
classpath. |
Method Summary | |
---|---|
void |
link(java.lang.String pattern,
java.lang.String name)
This is used to link a Service to a wild card
pattern. |
void |
link(java.lang.String pattern,
java.lang.String name,
int pos)
This is used to link a Service to a wild card
pattern. |
void |
load(java.lang.String name,
java.lang.String className)
This loads the class into the system. |
void |
load(java.lang.String name,
java.lang.String className,
java.lang.Object data)
This loads the class into the system. |
void |
load(java.lang.String name,
java.lang.String className,
java.lang.Object[] data)
This loads the class into the system. |
Resource |
lookup(java.lang.String name)
This will look for and retrieve the requested resource. |
void |
remove(java.lang.String name)
This is used to terminate updates on a Loader
object which has previously registered for updates. |
Resource |
resolve(java.lang.String target)
This will look for and retrieve the requested resource. |
void |
unlink(Match match)
This is used to unlink a loaded Service that
was linked to the specified match. |
void |
unlink(java.lang.String pattern)
This is used to unlink a loaded Service that
was linked to the specified pattern. |
void |
unload(java.lang.String name)
When an instance has been loaded by the load
method this can be used to purge it from the system and
subsequently remove all links to it. |
void |
update(java.lang.String name,
Loader loader)
This is used to insert a Loader object which
is used to recieve updates on the configuration. |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
---|
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
---|
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
---|
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Resolver resolver
Resolver
for the linked classes.
protected simple.http.load.Processor delegate
Loader
objects.
protected Context context
protected simple.http.load.Registry registry
Service
's.
protected simple.http.load.Profile profile
Constructor Detail |
---|
public LoaderEngine() throws java.io.IOException
LoaderEngine
that uses the
class loader of the current instance to load the services.
The semantics will be similar to Class.forName
.
This will use an empty array of URL
objects
so that this instances loader is always used to retrieve
the byte codes for referenced Service
objects.
java.io.IOException
- this is thrown if the is an I/O
problem with the RMI runtime or generating the classpathpublic LoaderEngine(Context context) throws java.io.IOException
LoaderEngine
that uses the
class loader of the current instance to load the services.
The semantics will be similar to Class.forName
.
This will use an array of URL
objects, which
contains only the current working directory as the codebase
to load the referenced Service
objects.
context
- used to acquire the codebase and to provide
Service
objects with a view of the file system
java.io.IOException
- this is thrown if the is an I/O
problem with the RMI runtime or generating the classpathprotected LoaderEngine(Context context, java.io.File path) throws java.io.IOException
LoaderEngine
takes a file
classpath. This will load the code with the semantics of
the Class.forName
before trying to load the
code from the specified classpath. To keep consistant the
LoaderEngine(Context, URL)
should be used to
specify a single codebase source instead of this.
This will use an array of URL
objects, which
contains only the specified local directory as a codebase
to load the referenced Service
objects.
context
- used to provide a view of the file systempath
- this is the file classpath that all the code
for the Service
implementations is loaded
java.io.IOException
- this is thrown if the is an I/O
problem with the RMI runtime or generating the classpathpublic LoaderEngine(Context context, java.net.URL codebase) throws java.io.IOException
LoaderEngine
that uses the
class loader of the current instance to load the services.
The semantics will be similar to Class.forName
.
When a ProtocolHandler
wants to create an
instance it only needs to provide the codebase and context.
This will use an array of URL
objects, which
contains only the specified codebase URL as the codebase
to load the referenced Service
objects.
context
- used to provide a view of the file systemcodebase
- this is the URL classpath that all the code
for the Resource
implementations is loaded
java.io.IOException
- this is thrown if the is an I/O
problem with the RMI runtime or generating the classpathpublic LoaderEngine(Context context, java.net.URL[] codebase) throws java.io.IOException
LoaderEngine
takes a URL
classpath. This URL classpath is where the implementation
objects are loaded from. If the suggested URL classpath is
not well formed then a MalformedURLException
is thrown. This will load the code with the semantics of
the Class.forName
before trying to load the
code from a URL. When a ProtocolHandler
wants
to create an instance it only need create a list of URL
locations, which can be used to act as the classpath.
This will create a URLClassLoader
using the
given set of URL
objects. The loading of the
Resource
objects will follow the semantics of
the URLClassLoader(URL[])
instance.
context
- used to provide a view of the file systemcodebase
- this is the URL classpath that all the code
for the Resource
implementations is loaded
java.io.IOException
- this is thrown if the is an I/O
problem with the RMI runtime or generating the classpathMethod Detail |
---|
public void update(java.lang.String name, Loader loader)
Loader
object which
is used to recieve updates on the configuration. The loader
can be a remote object which enables the local instance to
to communicate its state to a remote administration utility.
Once registered the Loader
will recieve an
immedidate update of the managers layout.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"update" token. This ensures that any Loader
instances from an untrusted codebase cannot register.
update
in interface LoaderManager
loader
- this is the Loader
object that
will recieve updates on state changes
java.lang.SecurityException
- if the caller does not have
the permission to register the Loader
public void remove(java.lang.String name)
Loader
object which has previously registered for updates. If the
Loader
wishes to resume updates it must
register again using the update
method.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"update" token. This ensures that any Loader
instances from an untrusted codebase cannot remove objects
that have registered.
remove
in interface LoaderManager
name
- this is the name of the Loader
that is terminating updates
java.lang.SecurityException
- if the caller does not have
the permission to register the Loader
public void load(java.lang.String name, java.lang.String className) throws LoadingException
Resource
implementation identified by the class name. If the class
can not be loaded ClassNotFoundException
is
thrown. The fully qualified package name must be given.
Once the Service
class has been loaded it is
used to create an instance. This instance can then have
links established to it. The link is created using the
unique name of the instance specified and a wild pattern.
load
in interface LoaderManager
name
- this is the unique name given to the instanceclassName
- the fully qualified service class name
LoadingException
- thrown if the class cannot be
located or loadedpublic void load(java.lang.String name, java.lang.String className, java.lang.Object data) throws LoadingException
Resource
implementation identified by the class name. If the class
can not be loaded ClassNotFoundException
is
thrown. The fully qualified package name must be given.
Once the Service
class has been loaded it is
used to create an instance. This instance can then have
links established to it. The link is created using the
unique name of the instance specified and a wild pattern.
load
in interface LoaderManager
name
- this is the unique name given to the instanceclassName
- the fully qualified service class namedata
- this is a parameter used for initialization
LoadingException
- thrown if the class cannot be
located or loadedpublic void load(java.lang.String name, java.lang.String className, java.lang.Object[] data) throws LoadingException
Resource
implementation identified by the class name. If the class
can not be loaded ClassNotFoundException
is
thrown. The fully qualified package name must be given.
Once the Service
class has been loaded it is
used to create an instance. This instance can then have
links established to it. The link is created using the
unique name of the instance specified and a wild pattern.
This method also allows an object to be issued to the new
service instance for configuration purposes.
load
in interface LoaderManager
name
- this is the unique name given to the instanceclassName
- the fully qualified service class namedata
- the configuration objects used by the service
LoadingException
- thrown if the class cannot be
located or loadedpublic void unload(java.lang.String name)
load
method this can be used to purge it from the system and
subsequently remove all links to it. If the class name
specified does not correspond to a Service
that had be previously loaded this will return quietly.
The fully qualified package name must be given.
unload
in interface LoaderManager
name
- this is the name of the service objectpublic void link(java.lang.String pattern, java.lang.String name)
Service
to a wild card
pattern. The Service
can be linked using the
patterns '*' and '?'. This will enable the resource to be
isolated using a string that matches the suggested pattern.
Patterns can take the form of a string with wild characters
embedded in it, for instance "*.html". Also if the class
name does not belong to a previously loaded
Service
this should return quietly.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"link" action. This ensures that any Service
instances loaded from an untrusted codebase cannot change
the configuration settings.
link
in interface LoaderManager
pattern
- this is a wild string used for matchingname
- this is the Service
that will be
identified by the pattern
java.lang.SecurityException
- if the caller does not have
the permission to link the patternpublic void link(java.lang.String pattern, java.lang.String name, int pos)
Service
to a wild card
pattern. The Service
can be linked using the
patterns '*' and '?'. This will enable the resource to be
isolated using a string that matches the suggested pattern.
Patterns can take the form of a string with wild characters
embedded in it, for instance "*.html". Also if the class
name does not belong to a previously loaded
Service
this should return quietly.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"link" action. This ensures that any Service
instances loaded from an untrusted codebase cannot change
the configuration settings.
link
in interface LoaderManager
pattern
- this is a wild string used for matchingname
- this is the Service
that will be
identified by the patternpos
- the position within the list of patterns to add
the new match
java.lang.SecurityException
- if the caller does not have
the permission to link the patternpublic void unlink(java.lang.String pattern)
Service
that
was linked to the specified pattern. If that pattern was
not used to match a Service
then this returns
quietly.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"link" action. This ensures that any Service
instances loaded from an untrusted codebase cannot change
the configuration settings.
unlink
in interface LoaderManager
pattern
- this is a wild string used for matching
java.lang.SecurityException
- if the caller does not havepublic void unlink(Match match)
Service
that
was linked to the specified match. If that pattern was
not used to match a Service
then this returns
quietly.
This throws a SecurityException
if the caller
does not have the LoaderPermission
with the
"link" action. This ensures that any Service
instances loaded from an untrusted codebase cannot change
the configuration settings.
unlink
in interface LoaderManager
match
- this is the pattern match to remove from this
java.lang.SecurityException
- if the caller does not havepublic Resource lookup(java.lang.String name)
Resource
implementation that will handle the target.
If the named service does not corrospond to a previously loaded service then this will return a resource object that will report the appropriate HTTP status and description.
name
- this is than name of the service to retrieve
public Resource resolve(java.lang.String target)
Resource
implementation that will handle the target.
The path will be matched with a pattern that was linked to a
Resource
object. This uses Resolver
to match the target with the Resource
. This will
thus match on priority of last entry. So if a resource can
match two or more patterns then the last entered pattern
is the one that resolves the Resource
.
This will attempt to resolve the path given without striping the query of parameters. If the link does not accomodate for paths with querys or parameters the resolver will skip past the match. Some default * link should be made so that if all links fail there is some fallback resource.
resolve
in interface ResourceEngine
target
- the URI style path that represents the target
Resource
Resource
object to
handle the desired target
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |