WebObjects 5.2.3

com.webobjects.webservices.support.xml
Class WOEnterpriseObjectSerializationStrategy

java.lang.Object
  extended bycom.webobjects.webservices.support.xml.WOEnterpriseObjectSerializationStrategy
All Implemented Interfaces:
WOSoapConstants
Direct Known Subclasses:
WORuleSerializationStrategy

public class WOEnterpriseObjectSerializationStrategy
extends Object
implements WOSoapConstants


Nested Class Summary
 
Nested classes inherited from class com.webobjects.webservices.support.xml.WOSoapConstants
WOSoapConstants.WOXMLAttributes
 
Field Summary
static String AnyServiceNameIdentifier
           
static String ContextPropertyName
          The string constant used within an org.apache.axis.MessageContext
 
Fields inherited from interface com.webobjects.webservices.support.xml.WOSoapConstants
EOENTERPRISEOBJECT_QNAME, EOGLOBALID_QNAME, NSKVCNULL_QNAME, NSRANGE_QNAME, NSTIMESTAMP_QNAME, NSTIMEZONE_QNAME, SOAP_ENC_PREFIX, SOAP_URI, WOSOAP_URI, WOSTRINGKEYMAP_QNAME, XSD_URI, XSI_TYPE, XSI_URI
 
Constructor Summary
WOEnterpriseObjectSerializationStrategy()
           
 
Method Summary
 Class classForKeyPath(EOEnterpriseObject eo, String keyPath)
          The default implementation simply returns the Class associated with the final component of the keyPath's EOClassDescription's classForAttributeKey() result.
 EOEditingContext editingContextForDeserialization(String entityName, EOGlobalID gid)
          The default implementation returns EOEditingContext.substitutionEditingContext() If that is null it creates a new one and sets it as the substitution editing context.
 Object elementAttributesForKeyPath(EOEnterpriseObject eo, String keyPath)
          The default implementation returns null which indicates that the SOAP-XML engine should fill in its own defaults for the element attributes.
 String elementNameForKeyPath(EOEnterpriseObject eo, String keyPath)
          The default implementation just returns the keyPath argument.
 Object instantiateSubject(String entityName, EOGlobalID gid, EOEditingContext ec)
          Invoked during deserialization to create the target object.
 NSArray keyPathsForSerialization(EOEnterpriseObject eo)
          The default implementation returns all the attribute class properties sorted alphabetically and none of the EO's relationships.
 EOEnterpriseObject promoteGlobalIDToObject(String entityName, EOGlobalID gid, EOEditingContext ec, boolean shouldAttemptFetch)
          A utility method to attempt several different ways to promote a EOGlobalID into an EOEnterpriseObject.
 Object proxyForKeyPath(EOEnterpriseObject eo, String keyPath)
          The default implementation simply returns eo.valueForKeyPath(keyPath) but a replacement for this can be substituted as the XML element value.
 boolean serializeAsCompleteEOEnterpriseObject()
          Invoked during serialization.
 void setPropertyForKeyPath(Object eo, String keyPath, Object value)
          This method is invoked during the deserialization process after parsing the SOAP-XML message.
static void setStrategyForService(WOEnterpriseObjectSerializationStrategy rules, String serviceName, String operationName)
          A convenience method which gets the current org.apache.axis.MessageContext for the serialization/deserializtion operation in this thread, and sets the WOEnterpriseObjectSerializationStrategy.ContextPropertyName to rules
static WOEnterpriseObjectSerializationStrategy strategyForMessageContext(org.apache.axis.MessageContext msgContext)
           
 String translatedKeyPath(Object eo, String keyPath)
          Returns the key path to supply to key-value coding methods when setting or getting the value at keyPath of eo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AnyServiceNameIdentifier

public static final String AnyServiceNameIdentifier

ContextPropertyName

public static final String ContextPropertyName
The string constant used within an org.apache.axis.MessageContext

Constructor Detail

WOEnterpriseObjectSerializationStrategy

public WOEnterpriseObjectSerializationStrategy()
Method Detail

classForKeyPath

public Class classForKeyPath(EOEnterpriseObject eo,
                             String keyPath)
The default implementation simply returns the Class associated with the final component of the keyPath's EOClassDescription's classForAttributeKey() result. A replacement for this can be substituted to change how the object at key path keyPath will be serialized. This is typically done to replace an object with a pretty printed or formatted value.

Parameters:
eo - the enterprise object about to be serialized
keyPath - the key path about to be serialized
Returns:
the Class of the object at keyPath to serialize
See Also:
proxyForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject, java.lang.String), EOClassDescription.classDescriptionForKeyPath(java.lang.String), EOClassDescription.classForAttributeKey(java.lang.String)

editingContextForDeserialization

public EOEditingContext editingContextForDeserialization(String entityName,
                                                         EOGlobalID gid)
The default implementation returns EOEditingContext.substitutionEditingContext() If that is null it creates a new one and sets it as the substitution editing context.

Parameters:
entityName - the entity name for the eo about to be deserialized
gid - the globalID for the eo about to be deserialized
Returns:
an EOEditingContext to place the deserialized EO within.
See Also:
EOEditingContext.substitutionEditingContext()

elementAttributesForKeyPath

public Object elementAttributesForKeyPath(EOEnterpriseObject eo,
                                          String keyPath)
The default implementation returns null which indicates that the SOAP-XML engine should fill in its own defaults for the element attributes. The return value must be assignment compatible with org.xml.sax.Attributes

Parameters:
eo - the enterprise object about to be serialized
keyPath - the key path about to be serialized
Returns:
null or an object which can be type cast to org.xml.sax.Attributes

elementNameForKeyPath

public String elementNameForKeyPath(EOEnterpriseObject eo,
                                    String keyPath)
The default implementation just returns the keyPath argument. It provides an opportunity to map the internal KeyValueCoding path to a public name for the XML. This method is essentially the inverse of translatedKeyPath

Parameters:
eo - the enterprise object about to be serialized
keyPath - the key path about to be serialized
Returns:
the external name to use in the as the XML-SOAP element name
See Also:
translatedKeyPath(java.lang.Object, java.lang.String)

instantiateSubject

public Object instantiateSubject(String entityName,
                                 EOGlobalID gid,
                                 EOEditingContext ec)
Invoked during deserialization to create the target object. The default implementation first attempts to reuse an object matching the gid already in the editing context parameter. If none exists, it attempts to fetch an object matching that gid. If the fetch fails, it creates and inserts a new EO of entityName. If nothing else is successful, it returns a WOStringKeyMap to hold the deserialized properties.

Parameters:
entityName - the entity name for the eo about to be deserialized
gid - the globalID for the eo about to be deserialized
ec - the EOEditingContext to place the deserialized EO within.
Returns:
the actual object to hold the deserialized properties.

keyPathsForSerialization

public NSArray keyPathsForSerialization(EOEnterpriseObject eo)
The default implementation returns all the attribute class properties sorted alphabetically and none of the EO's relationships.

Parameters:
eo - the enterprise object about to be serialized
Returns:
an ordered set of key paths to be serialized into SOAP-XML

promoteGlobalIDToObject

public EOEnterpriseObject promoteGlobalIDToObject(String entityName,
                                                  EOGlobalID gid,
                                                  EOEditingContext ec,
                                                  boolean shouldAttemptFetch)
A utility method to attempt several different ways to promote a EOGlobalID into an EOEnterpriseObject. The default implementation first attempts to reuse an object matching the gid already in the editing context parameter. If none exists, it attempts to fetch an object matching that gid. If the fetch fails, it creates and inserts a new EO of entityName. If nothing else is successful, it returns null.

Parameters:
entityName - the entity name for the eo about to be deserialized
gid - the globalID for the eo about to be deserialized
ec - the EOEditingContext to place the deserialized EO within.
shouldAttemptFetch - whether or not a fetch should be attempted at all.
Returns:
the actual object to hold the deserialized properties.

proxyForKeyPath

public Object proxyForKeyPath(EOEnterpriseObject eo,
                              String keyPath)
The default implementation simply returns eo.valueForKeyPath(keyPath) but a replacement for this can be substituted as the XML element value. This is typically done to replace an object with a pretty printed or formatted value. The result must be assignment compatible with the Class returned by classForKeyPath

Parameters:
eo - the enterprise object about to be serialized
keyPath - the key path about to be serialized
Returns:
the external name to use in the as the XML-SOAP element name
See Also:
classForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject, java.lang.String), NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)

serializeAsCompleteEOEnterpriseObject

public boolean serializeAsCompleteEOEnterpriseObject()
Invoked during serialization. If true the xsi type will represent an EOEnterpriseObject, and the generate XML will be sufficient to deserialize the result as an EO. If false the xsi type will represent a raw SOAP struct, and the gid and entity will be omitted.

Returns:
true if the XML should be for an EOEnterpriseObject, or false if it should serialize as a raw SOAP Struct

setPropertyForKeyPath

public void setPropertyForKeyPath(Object eo,
                                  String keyPath,
                                  Object value)
This method is invoked during the deserialization process after parsing the SOAP-XML message. The default implementation simply invokes takeValueForKeyPath()

Parameters:
eo - the enterprise object which was deserialized
keyPath - the keyPath to the property
value - the deserialized value for the property
See Also:
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)

setStrategyForService

public static void setStrategyForService(WOEnterpriseObjectSerializationStrategy rules,
                                         String serviceName,
                                         String operationName)
A convenience method which gets the current org.apache.axis.MessageContext for the serialization/deserializtion operation in this thread, and sets the WOEnterpriseObjectSerializationStrategy.ContextPropertyName to rules

Parameters:
rules - An instance of this class.
serviceName - the webservices service name associated with the rules
operationName - the webservices operation name. May be null
See Also:
ContextPropertyName

strategyForMessageContext

public static WOEnterpriseObjectSerializationStrategy strategyForMessageContext(org.apache.axis.MessageContext msgContext)

translatedKeyPath

public String translatedKeyPath(Object eo,
                                String keyPath)
Returns the key path to supply to key-value coding methods when setting or getting the value at keyPath of eo. This method is essentially the inverse of elementNameForKeyPath. The XML element name of each of a serialized EO's property can be different from the key path used to access that property. In order to perform Key-Value-Coding operations for some public key path, represented by keyPath, a "translated" key path that represents path of an EOProperty must be available.

Parameters:
eo - the enterprise object that is being deserialized
keyPath - the key path that is being deserialized
Returns:
the key path to use for key-value coding operations with eo
See Also:
elementNameForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject, java.lang.String)

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.