org.jibx.ws.io.handler
Class ContextAttributeMarshallingOutHandler

java.lang.Object
  extended by org.jibx.ws.io.handler.ContextAttributeMarshallingOutHandler
All Implemented Interfaces:
OutHandler

public final class ContextAttributeMarshallingOutHandler
extends Object
implements OutHandler

A marshaller that retrieves the object to be marshalled from the current OutContext. The object is retrieved from the attribute using the attribute name passed in the constructor as a key.


Constructor Summary
ContextAttributeMarshallingOutHandler(Class clazz, String attributeName)
          Create the marshaller using the binding factory for the "target class".
ContextAttributeMarshallingOutHandler(IBindingFactory factory, String attributeName)
          Create the marshaller using the specified binding factory.
ContextAttributeMarshallingOutHandler(String className, String attributeName)
          Create the marshaller using the binding factory for the "target class".
ContextAttributeMarshallingOutHandler(String bindingName, String packageName, String attributeName)
          Create the marshaller using the binding factory for the specified binding name and binding package name.
 
Method Summary
 void invoke(OutContext context, IXMLWriter xmlWriter)
          Invokes the handler.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextAttributeMarshallingOutHandler

public ContextAttributeMarshallingOutHandler(Class clazz,
                                             String attributeName)
                                      throws WsBindingException
Create the marshaller using the binding factory for the "target class". This method can only be used with target classes that are mapped in only one binding. Note that there is no restriction on the "payload class" being the same as the target class. The only restriction is that the binding factory for the target class must include a binding for the payload class.

Parameters:
clazz - the target class
attributeName - the key to retrieve the object to be marshalled from the current context
Throws:
WsBindingException - on any error in finding or accessing factory, or creating marshaller

ContextAttributeMarshallingOutHandler

public ContextAttributeMarshallingOutHandler(String className,
                                             String attributeName)
                                      throws WsBindingException,
                                             WsConfigurationException
Create the marshaller using the binding factory for the "target class". This method can only be used with target classes that are mapped in only one binding. Note that there is no restriction on the "payload class" being the same as the target class. The only restriction is that the binding factory for the target class must include a binding for the payload class.

Parameters:
className - the name of the target class
attributeName - the key to retrieve the object to be marshalled from the current context
Throws:
WsBindingException - on any error in finding or accessing factory, or creating marshaller
WsConfigurationException - if specified class cannot be found

ContextAttributeMarshallingOutHandler

public ContextAttributeMarshallingOutHandler(String bindingName,
                                             String packageName,
                                             String attributeName)
                                      throws WsBindingException
Create the marshaller using the binding factory for the specified binding name and binding package name. See BindingDirectory.getFactory(String, String) for further definition of the required binding name and binding package name.

Parameters:
bindingName - binding name
packageName - target package for binding
attributeName - the key to retrieve the object to be marshalled from the current context
Throws:
WsBindingException - on any error in finding or accessing factory, or creating marshaller

ContextAttributeMarshallingOutHandler

public ContextAttributeMarshallingOutHandler(IBindingFactory factory,
                                             String attributeName)
                                      throws WsBindingException
Create the marshaller using the specified binding factory.

Parameters:
factory - the binding factory
attributeName - the key to retrieve the object to be marshalled from the current context
Throws:
WsBindingException - on any error in creating marshaller
Method Detail

invoke

public void invoke(OutContext context,
                   IXMLWriter xmlWriter)
            throws IOException,
                   WsException
Invokes the handler. Retrieves the object from the OutContext and marshals it. The object is retrieved using the attributeName specified in the constructor.

Specified by:
invoke in interface OutHandler
Parameters:
context - the context of the current message being sent
xmlWriter - a writer for the XML message positioned at the start of the XML content for which the handler is configured
Throws:
IOException - on I/O error writing the XML content
WsException - on errors other than I/O errors


Project Web Site