|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.globus.wsrf.impl.ReflectionResource
public class 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 ResourceHomeImpl, 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).
| Field Summary | |
|---|---|
private java.lang.reflect.Method |
getTerminationTimeMethod
|
private static org.globus.util.I18n |
i18n
|
private java.lang.Object |
ID
|
private static org.apache.commons.logging.Log |
logger
|
private static org.apache.axis.utils.cache.MethodCache |
methodCache
|
private java.lang.Object |
resourceBean
|
private ResourcePropertySet |
resourcePropertySet
|
private static java.lang.Class[] |
SET_TERM_TIME_PARAM
|
private java.lang.reflect.Method |
setTerminationTimeMethod
|
| Constructor Summary | |
|---|---|
ReflectionResource()
|
|
| Method Summary | |
|---|---|
protected ResourceProperty |
createNewResourceProperty(javax.xml.namespace.QName rpQName,
java.lang.Object resourceBean)
Warning: this is not a callback (but maybe it should be). |
protected ResourceProperty |
createNewResourceProperty(ResourcePropertyMetaData metaData,
java.lang.Object resourceBean)
Override this callback method to specialize the implementation of the resource property value accessors on a per resource property basis. |
java.util.Calendar |
getCurrentTime()
Get the current time |
java.lang.Object |
getID()
See ResourceIdentifier. |
java.lang.Object |
getResourceBean()
|
ResourcePropertySet |
getResourcePropertySet()
See ResourceProperties. |
java.util.Calendar |
getTerminationTime()
Get the termination time |
void |
initialize(java.lang.Object resourceBean,
javax.xml.namespace.QName resourceElementQName,
java.lang.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. |
private void |
initializeResourceProperties(java.lang.Object resourceBean,
javax.xml.namespace.QName resourceElementQName)
|
void |
setTerminationTime(java.util.Calendar time)
Set the termination time |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static org.apache.commons.logging.Log logger
private static org.globus.util.I18n i18n
private static final java.lang.Class[] SET_TERM_TIME_PARAM
private static org.apache.axis.utils.cache.MethodCache methodCache
private ResourcePropertySet resourcePropertySet
private java.lang.Object ID
private java.lang.Object resourceBean
private java.lang.reflect.Method setTerminationTimeMethod
private java.lang.reflect.Method getTerminationTimeMethod
| Constructor Detail |
|---|
public ReflectionResource()
| Method Detail |
|---|
public void initialize(java.lang.Object resourceBean,
javax.xml.namespace.QName resourceElementQName,
java.lang.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.
ResourceException
private void initializeResourceProperties(java.lang.Object resourceBean,
javax.xml.namespace.QName resourceElementQName)
throws ResourceException
ResourceException
protected ResourceProperty createNewResourceProperty(javax.xml.namespace.QName rpQName,
java.lang.Object resourceBean)
throws java.lang.Exception
rpQName - QNameresourceBean - Object
java.lang.Exception
protected ResourceProperty createNewResourceProperty(ResourcePropertyMetaData metaData,
java.lang.Object resourceBean)
throws java.lang.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:
metaData - Meta data associated with the resource property objectresourceBean - same as passed to constructor or initialize
java.lang.Exceptionpublic void setTerminationTime(java.util.Calendar time)
ResourceLifetime
setTerminationTime in interface ResourceLifetimetime - The termination time to setpublic java.util.Calendar getTerminationTime()
ResourceLifetime
getTerminationTime in interface ResourceLifetimepublic java.util.Calendar getCurrentTime()
ResourceLifetime
getCurrentTime in interface ResourceLifetimepublic ResourcePropertySet getResourcePropertySet()
getResourcePropertySet in interface ResourcePropertiespublic java.lang.Object getID()
getID in interface ResourceIdentifierpublic java.lang.Object getResourceBean()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||