org.gloin.resource
Class ResourceServiceImpl
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--org.gloin.resource.ResourceServiceImpl
- All Implemented Interfaces:
- java.rmi.Remote, RemoteResourceService, ResourceService, java.io.Serializable
- public class ResourceServiceImpl
- extends java.rmi.server.UnicastRemoteObject
- implements RemoteResourceService
Provides an implementation of the ResourceService
interface. This resource service implementation takes care of
registering itself with Jini lookup services. Stores resources into
an abstract byte store and provides remote access to that byte
store. Supports the following following functionality:
Provides a way for clients of registering services to access
resources stored in the resource service. To implement this
functionality, the resource service registers a service of type
ResourceAccess
in ambient Jini Lookup Services. JRAP
url clients can find this service using the standard template
defined for JRAP urls. The registered ResourceAccess
provides read access to registered byte streams.
Optionally enables Jini services which need to use this resource
service (e.g. to support their codebase annotations) to remotely
send byte streams to be stored by this resource service. This
resource service will read bytes sent in a remote input stream and
register those bytes under a name supplied by the registering
service.
To provide this write access, the resource service can choose to
register itself with an attribute of type,
ResourceServiceEntry
. This associated attribute must
contain a remote proxy for the resource service. Parties which
wish to register bytes can use the proxy in this service's
attribute. If the resource service does not register with any
special attributes, the service is assumed to be read only.
- See Also:
- Serialized Form
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Constructor Summary |
ResourceServiceImpl(ByteStore byteStore,
InputStreamFactory inputFactory)
Constructs a ResourceServiceImpl which loads
resources from the supplied byte store and serves resources
remotely using the parameter inputFactory. |
Method Summary |
static void |
create(HttpServer httpd,
ByteStore byteStore,
JrapURLParser parser)
Enables the creation of a resource service. |
ResourceAccess |
getAccess()
Obtain a ResourceAccess object which can be used
to download resource bytes from a corresponding resource
service. |
java.lang.String[] |
list()
List the names of the resources that have been created in this
resource service. |
ResourceHandle |
newResource(java.lang.String resourceName)
Create a new resource in the resource service that will serve
as a placeholder until the resource is filled with bytes from a
registering service. |
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 |
ResourceServiceImpl
public ResourceServiceImpl(ByteStore byteStore,
InputStreamFactory inputFactory)
throws java.io.IOException
- Constructs a
ResourceServiceImpl
which loads
resources from the supplied byte store and serves resources
remotely using the parameter inputFactory.
- Parameters:
byteStore
- store into which registered resources are
placed and from which served resources are obtained.inputFactory
- factory to create remote input stream which
are used to serve resource bytes to requesting clients.
newResource
public ResourceHandle newResource(java.lang.String resourceName)
throws java.io.IOException
- Description copied from interface:
ResourceService
- Create a new resource in the resource service that will serve
as a placeholder until the resource is filled with bytes from a
registering service. Initially the resource is created empty.
- Specified by:
newResource
in interface ResourceService
- Following copied from interface:
net.gloin.resource.ResourceService
- Parameters:
name
- of the resource which should be created.- Returns:
- a handle to the newly created resource
getAccess
public ResourceAccess getAccess()
throws java.io.IOException
- Description copied from interface:
ResourceService
- Obtain a
ResourceAccess
object which can be used
to download resource bytes from a corresponding resource
service.
- Specified by:
getAccess
in interface ResourceService
- Following copied from interface:
net.gloin.resource.ResourceService
- Returns:
ResourceAccess
object for downloading
resources.
list
public java.lang.String[] list()
throws java.io.IOException
- Description copied from interface:
ResourceService
- List the names of the resources that have been created in this
resource service.
- Specified by:
list
in interface ResourceService
- Following copied from interface:
net.gloin.resource.ResourceService
- Returns:
- array of names of resources created in this resource
service.
create
public static void create(HttpServer httpd,
ByteStore byteStore,
JrapURLParser parser)
throws java.lang.Exception
- Enables the creation of a resource service. This method is
invoked by reflection from
StartResourceService
in
order to create a resource service.
- Parameters:
httpd
- the http server that the resource service uses to
serve resources.byteStore
- the byte store used to store resources and
serve clients.parser
- the JrapURLParser
from which this
service determines information about how the service should
register itself with Jini federations.