SunSPOT API V3.0


com.sun.spot.resourcesharing
Class SimpleResource

java.lang.Object
  extended by com.sun.spot.resourcesharing.SimpleResource
All Implemented Interfaces:
IResource

public class SimpleResource
extends Object
implements IResource

A simple implementation of the IResource interface that can be used as it is, or extended for a more complex use. By default uses SimpleResourceHandle: if an extension needs to use a different IResourceHandle then it should override createNewHandle().


Constructor Summary
SimpleResource(String name)
           
 
Method Summary
protected  IResourceHandle createNewHandle()
           
 IResourceHandle getHandle(ResourceSharingScheme scheme, boolean isLockedInADifferentIsolate)
          Generate a handle for this resource.
 String getResourceName()
           
 IResourceHandle lockAdjusted(IResourceHandle handle, ResourceSharingScheme oldScheme, ResourceSharingScheme newScheme)
          A previously generated handle is adjusting its ResourceSharingScheme.
 void unlocked(IResourceHandle handle)
          A previously generated handle has been unlocked, and the handle can be reused.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleResource

public SimpleResource(String name)
Method Detail

getHandle

public IResourceHandle getHandle(ResourceSharingScheme scheme,
                                 boolean isLockedInADifferentIsolate)
                          throws ResourceUnavailableException
Description copied from interface: IResource
Generate a handle for this resource. This method is called on the resource by the resource registry when the registry has determined that a handle should be generated according to the rules of the requested scheme, taking into account locks held in all isolates. The receiver should generate a handle or throw an exception if it is unable to do so. The handle generated should not be the same object as any other handle for this resource that is still in use.

Specified by:
getHandle in interface IResource
Parameters:
scheme - The scheme that the requestor intends to follow for this handle
isLockedInADifferentIsolate - true if a lock for this resource already exists in another isolate
Returns:
the new handle
Throws:
ResourceUnavailableException - if, despite the checks already performed by the registry, the resource still thinks the handle shouldn't be generated because it would conflict with other usage

getResourceName

public String getResourceName()
Specified by:
getResourceName in interface IResource
Returns:
the name of the this resource

unlocked

public void unlocked(IResourceHandle handle)
Description copied from interface: IResource
A previously generated handle has been unlocked, and the handle can be reused. This method is called by the registry when it receives the unlock(handle) call.

Specified by:
unlocked in interface IResource
Parameters:
handle - The handle that has been unlocked.

lockAdjusted

public IResourceHandle lockAdjusted(IResourceHandle handle,
                                    ResourceSharingScheme oldScheme,
                                    ResourceSharingScheme newScheme)
                             throws ResourceSharingException,
                                    ResourceUnavailableException
Description copied from interface: IResource
A previously generated handle is adjusting its ResourceSharingScheme. Returns a handle that has the new lock status (which might or might not be the same handle passed as the input parameter).

Specified by:
lockAdjusted in interface IResource
Returns:
the handle that reflects the adjusted lock
Throws:
ResourceSharingException - if the scheme is not supported or there is some other problem
ResourceUnavailableException - if, despite the checks already performed by the registry, the resource still thinks the scheme shouldn't be adjusted because it would conflict with other usage

createNewHandle

protected IResourceHandle createNewHandle()

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.