|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.globus.wsrf.impl.ReflectionResource
An implementation of ResourceProperties and
ResourceIdentifier which
frees the developer from having to write a getter and possibly a setter
to implement every resource property (RP).
This class uses an Axis-generated JavaBean class based on the Schema
definition of the RP set used by the service port type in WSDL.
Since the generated class contain a JavaBean property as well as QName and
Schema type metadata (such as occurence cardinality) for each RP, it is
possible to automatically create ReflectionResourceProperty
objects to provide an implementation of the RPs. This is what
ReflectionResource does.
Advantages of using this class:
Usage:
The specialized resource home class should do the following when creating a resource:
Reuse approach:
Typical goals when extending the class:
Classes directly or indirectly extending ReflectionResource property must be
allow instanciation without parameter. If a parameterless constructor is
present it must not do any initialization whatsoever. The reason is to
decouple object creation from initialization so as to match the requirements
of Resource Home classes such as PersistentResourceHome, which, when
materializing a previously stored persistent resource, creates the resource
object first using a parameterless constructor, and then initializes the
object.
Code that creates the key of the resource automatically (for instance
a UUID) - in domain-specific cases where it makes sense - should not be
put inside a parameterless constructor but in an a overriding version of the
initialize() method, or inside
the Resource Home class. In this way
a Persistent Resource object can be brought back from a passivated state
and be given the ID it used to have in activated mode, as opposed to a
newly generated ID.
Known limitations:
This class does not provide a getter to the implementation JavaBean, because
it is good practice to access the value of a resource property
by obtaining the ResourceProperty
object first, as opposed to calling the getters and setters of its
implementation Bean.
In fact:
getCurrentTime,
and the resource properties from wsnt:NotificationProducer are
implemented directly or indirectly by a
SimpleTopicList).
ResourceProperty object generic accessors
may do extra processing such as firing change notification events
(for instance if it is a
ResourcePropertyTopic).
| Constructor Summary | |
ReflectionResource()
|
|
| Method Summary | |
protected ResourceProperty |
createNewResourceProperty(QName rpQName,
Object resourceBean)
Override this callback method to specialize the implementation of the resource property value accessors on a per resource property basis. |
Calendar |
getCurrentTime()
A default implementation for the wsrl:CurrentTime Resource Property. |
Object |
getID()
See ResourceIdentifier. |
protected Object |
getResourceBean()
|
ResourcePropertySet |
getResourcePropertySet()
See ResourceProperties. |
void |
initialize(Object resourceBean,
QName resourceElementQName,
Object key)
This should be called before any other resource property addition is made as it will create resource properties object based on the resource properties defined in the schema. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ReflectionResource()
| Method Detail |
public void initialize(Object resourceBean,
QName resourceElementQName,
Object key)
throws ResourceException
resourceBean - Object An instance of the Axis-generated class
corresponding to the resource property set
global Schema type or element (with local
type) used by the port type definition. That
class has JavaBean properties matching all
the resource properties of the port type.
The ReflectionResource constructor creates the
ResourceProperty objects based on the resource
bean, which JavaBean properties SHOULD thus
have been initialized beforehand. This object
provides an easy way to initialize the values
of the resource properties.resourceElementQName - QName The QName of the resource properties
element used by the port type. This
corresponds to the value of the
'wsrp:ResourceProperties' attribute.
If the type of this element is
anonymous (i.e. inlined in the element
declaration) then this parameter is
optional. If it is non-null though,
its value takes precedence over
Axis-generated metadata.key - Object The resource key object for this resource. This is used
to set the ID property of this object as a
ResourceIdentifier, if the resource class doesn't
create it automatically.
protected ResourceProperty createNewResourceProperty(QName rpQName,
Object resourceBean)
throws Exception
The default behavior is to create a new
ReflectionResourceProperty
constructed with the QName of the resource property and the
resource implementation Bean used to construct this ReflectionResource
object.
This function handles a few special cases:
rpQName - the QName of the resource property objectresourceBean - same as passed to constructor or initializepublic Calendar getCurrentTime()
public ResourcePropertySet getResourcePropertySet()
getResourcePropertySet in interface ResourcePropertiespublic Object getID()
getID in interface ResourceIdentifierprotected Object getResourceBean()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||