WebObjects 5.2

com.webobjects.webservices.generation
Class WORuleSerializationStrategy

java.lang.Object
  |
  +--com.webobjects.webservices.support.xml.WOEnterpriseObjectSerializationStrategy
        |
        +--com.webobjects.webservices.generation.WORuleSerializationStrategy
All Implemented Interfaces:
WOServiceUtilities.RuleSystemConstants, WOSoapConstants

public class WORuleSerializationStrategy
extends WOEnterpriseObjectSerializationStrategy
implements WOServiceUtilities.RuleSystemConstants

The WORuleSerializationStrategy implements WOEnterpriseObjectSerializationStrategy methods by using information from a D2WContext. When an operation invocation gets to the JavaWebServicesGeneration framework, a WOOperation is created and is given a chance to supply its own WOEnterpriseObjectSerializationStrategy strategy. If the WOOperation returns null (the default) for its strategy, a WORuleSerializationStrategy is created with a D2WContext that contains rule based information about the operation being invoked and the types and names of the operation's input and output parts. The rule based strategy can override methods from WOEnterpriseObjectSerializationStrategy so that the behaviour is goverened by the rules in the D2WContext's model and the D2WContext's state.


Inner classes inherited from class com.webobjects.webservices.support.xml.WOSoapConstants
WOSoapConstants.WOXMLAttributes
 
Fields inherited from class com.webobjects.webservices.support.xml.WOEnterpriseObjectSerializationStrategy
AnyServiceNameIdentifier, ContextPropertyName
 
Fields inherited from interface com.webobjects.webservices.generation.WOServiceUtilities.RuleSystemConstants
AllOperationNamesKey, AllServiceNamesKey, AssistantComparisonKeyKey, AssistantTaskNameKey, ClassForPropertyKeyKey, ClassNameForPropertyKeyKey, ComparisonKeyKey, EntityNameKey, FetchLimitKey, FetchSpecificationNameKey, GidArgumentKeyKey, InputPartNamesKey, InputPartValuesKey, IsDefaultOperatorKey, IsDefaultServiceKey, IsOperationEnabledKey, IsOperationFrozenKey, IsServiceEnabledKey, IsTransactionEnabledKey, ModelGroupKey, OperationClassNameKey, OperationNameKey, OperationNamesKey, OperatorNameKey, OutputPartNamesKey, PropertyKeyKey, PublicEntityNamesKey, ReturnsSOAPStructKey, ServiceNameKey, TranslatedAttributeNameKey, UnspecifiedArgumentKeyKey, UsesNamedFetchSpecificationKey, WOContextKey, WODefaultWebServiceKey, WSDLComponentNameKey
 
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
WORuleSerializationStrategy()
          Default constructor.
WORuleSerializationStrategy(D2WContext context)
          Creates a new WORuleSerializationStrategy that uses context to implement its strategy.
 
Method Summary
 Class classForKeyPath(EOEnterpriseObject eo, String keyPath)
          Returns the Class associated with the final component of the path, keyPath, of eo.
 D2WContext d2wContext()
          Returns the D2WContext this object uses to implement its serialization strategy.
 EOEditingContext editingContextForDeserialization(String entityName, EOGlobalID gid)
          Returns the current Session's EOEditingContext if the request has a session.
 NSArray keyPathsForSerialization(EOEnterpriseObject eo)
          Returns an array of output part names that will be added to the serialized content of EOEnterpriseObjects (specifically those EO's whose entity name match the D2WContext value for key WOServiceUtilities.RuleSystemConstants.EntityNameKey).
 Object proxyForKeyPath(EOEnterpriseObject eo, String keyPath)
          Overrides proxyForKeyPath in WOEnterpriseObjectSerializationStrategy to replace the EO(s) at key path keyPath of EO eo with the globalID(s) of the EO(s) at keyPath.
 boolean serializeAsCompleteEOEnterpriseObject()
          Overrides serializeAsCompleteEOEnterpriseObject in WOEnterpriseObjectSerializationStrategy.
 void setD2wContext(D2WContext context)
          Sets the D2WContext this object uses to implement its serialization strategy.
 void setPropertyForKeyPath(Object eo, String keyPath, Object value)
          This method is invoked during the deserialization process after parsing the SOAP-XML message.
 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 com.webobjects.webservices.support.xml.WOEnterpriseObjectSerializationStrategy
elementAttributesForKeyPath, elementNameForKeyPath, instantiateSubject, promoteGlobalIDToObject, setStrategyForService, strategyForMessageContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WORuleSerializationStrategy

public WORuleSerializationStrategy()
Default constructor.

WORuleSerializationStrategy

public WORuleSerializationStrategy(D2WContext context)
Creates a new WORuleSerializationStrategy that uses context to implement its strategy.
Method Detail

classForKeyPath

public Class classForKeyPath(EOEnterpriseObject eo,
                             String keyPath)
Returns the Class associated with the final component of the path, keyPath, of eo. The value for key PropertyKeyKey is set in the D2WContext and then the value of the D2WContext key ClassForPropertyKeyKey is returned.
Overrides:
classForKeyPath in class WOEnterpriseObjectSerializationStrategy
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)

d2wContext

public D2WContext d2wContext()
Returns the D2WContext this object uses to implement its serialization strategy.
Returns:
this strategy object's D2WContext

editingContextForDeserialization

public EOEditingContext editingContextForDeserialization(String entityName,
                                                         EOGlobalID gid)
Returns the current Session's EOEditingContext if the request has a session. otherwise returns the result of super's implementation.
Overrides:
editingContextForDeserialization in class WOEnterpriseObjectSerializationStrategy
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()

keyPathsForSerialization

public NSArray keyPathsForSerialization(EOEnterpriseObject eo)

Returns an array of output part names that will be added to the serialized content of EOEnterpriseObjects (specifically those EO's whose entity name match the D2WContext value for key WOServiceUtilities.RuleSystemConstants.EntityNameKey).

The output part names returned by this method do not include names that translate to aggregate key paths. Values for aggrregate key paths are returned as a seperate WOStringKeyMap.

Overrides:
keyPathsForSerialization in class WOEnterpriseObjectSerializationStrategy
Parameters:
eo - the enterprise object about to be serialized
Returns:
an ordered set of output part names to be serialized into SOAP-XML
See Also:
WOOperation.aggregateValuesResult(com.webobjects.foundation.NSArray)

proxyForKeyPath

public Object proxyForKeyPath(EOEnterpriseObject eo,
                              String keyPath)
Overrides proxyForKeyPath in WOEnterpriseObjectSerializationStrategy to replace the EO(s) at key path keyPath of EO eo with the globalID(s) of the EO(s) at keyPath. This ensures that only the EO eo is serialized as an EOEnterpriseObject and that all destination EOs are serialized as EOGlobalIDs.
Overrides:
proxyForKeyPath in class WOEnterpriseObjectSerializationStrategy
Parameters:
eo - the enterprise object about to be serialized
keyPath - the key path about to be serialized
Returns:
the object to serialize in place of eo
See Also:
classForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject, java.lang.String), NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)

serializeAsCompleteEOEnterpriseObject

public boolean serializeAsCompleteEOEnterpriseObject()
Overrides serializeAsCompleteEOEnterpriseObject in WOEnterpriseObjectSerializationStrategy. returns false if the D2WContext value for key ReturnsSOAPStructKey is true. Returns true otherwise.
Overrides:
serializeAsCompleteEOEnterpriseObject in class WOEnterpriseObjectSerializationStrategy
Returns:
true if the XML should be for an EOEnterpriseObject, or false if it should serialize as a raw SOAP Struct

setD2wContext

public void setD2wContext(D2WContext context)
Sets the D2WContext this object uses to implement its serialization strategy.
Parameters:
context - a new D2WContext

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 WORuleSerializationStrategy implementation invokes super's implementation using the translated key path based on keyPath.
Overrides:
setPropertyForKeyPath in class WOEnterpriseObjectSerializationStrategy
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), translatedKeyPath(java.lang.Object, java.lang.String)

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. 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. The WORuleSerializationStrategy implementation sets the value of the key PropertyKeyKey in its D2WContext to keyPath and then gets the value for the D2WContext's key, TranslatedAttributeNameKey. If result is null, no translation is needed and the original keyPath is returned.
Overrides:
translatedKeyPath in class WOEnterpriseObjectSerializationStrategy
Parameters:
eo - the enterprise object that is being serialized or deserialized
keyPath - the key path that is being serialized or deserialized
Returns:
the key path to use for key-value coding operations with eo

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.