org.ofbiz.service
Class DispatchContext

java.lang.Object
  extended by org.ofbiz.service.DispatchContext
All Implemented Interfaces:
java.io.Serializable

public class DispatchContext
extends java.lang.Object
implements java.io.Serializable

Dispatcher Context

See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object> attributes
           
protected  LocalDispatcher dispatcher
           
protected static java.lang.String GLOBAL_KEY
           
protected  java.lang.ClassLoader loader
           
protected  java.util.Collection<java.net.URL> localReaders
           
static UtilCache<java.lang.String,java.util.Map<java.lang.String,ModelService>> modelServiceMapByDispatcher
           
static java.lang.String module
           
protected  java.lang.String name
           
 
Constructor Summary
DispatchContext(java.lang.String name, java.util.Collection<java.net.URL> localReaders, java.lang.ClassLoader loader, LocalDispatcher dispatcher)
          Creates new DispatchContext
 
Method Summary
 java.util.Set<java.lang.String> getAllServiceNames()
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns the service attribute for the given name, or null if there is no attribute by that name.
 java.lang.ClassLoader getClassLoader()
          Gets the classloader of this context
 GenericDelegator getDelegator()
          Gets the GenericDelegator associated with this context/dispatcher
 LocalDispatcher getDispatcher()
          Gets the LocalDispatcher used with this context
 ModelService getModelService(java.lang.String serviceName)
          Gets the ModelService instance that corresponds to given the name
 java.lang.String getName()
          Gets the name of the local dispatcher
 java.util.Collection<java.net.URL> getReaders()
          Gets the collection of readers associated with this context
 Security getSecurity()
          Gets the Security object associated with this dispatcher
 org.w3c.dom.Document getWSDL(java.lang.String serviceName, java.lang.String locationURI)
           
 void loadReaders()
           
 java.util.Map<java.lang.String,java.lang.Object> makeValidContext(ModelService model, java.lang.String mode, java.util.Map<java.lang.String,? extends java.lang.Object> context)
          Uses an existing map of name value pairs and extracts the keys which are used in serviceName Note: This goes not guarantee the context will be 100% valid, there may be missing fields
 java.util.Map<java.lang.String,java.lang.Object> makeValidContext(java.lang.String serviceName, java.lang.String mode, java.util.Map<java.lang.String,? extends java.lang.Object> context)
          Uses an existing map of name value pairs and extracts the keys which are used in serviceName Note: This goes not guarantee the context will be 100% valid, there may be missing fields
 void setAttribute(java.lang.String name, java.lang.Object object)
          Binds an object to a given attribute name in this context.
 void setDispatcher(LocalDispatcher dispatcher)
          Sets the LocalDispatcher used with this context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

GLOBAL_KEY

protected static final java.lang.String GLOBAL_KEY
See Also:
Constant Field Values

modelServiceMapByDispatcher

public static UtilCache<java.lang.String,java.util.Map<java.lang.String,ModelService>> modelServiceMapByDispatcher

dispatcher

protected transient LocalDispatcher dispatcher

loader

protected transient java.lang.ClassLoader loader

localReaders

protected java.util.Collection<java.net.URL> localReaders

attributes

protected java.util.Map<java.lang.String,java.lang.Object> attributes

name

protected java.lang.String name
Constructor Detail

DispatchContext

public DispatchContext(java.lang.String name,
                       java.util.Collection<java.net.URL> localReaders,
                       java.lang.ClassLoader loader,
                       LocalDispatcher dispatcher)
Creates new DispatchContext

Parameters:
localReaders - a collection of reader URLs
loader - the classloader to use for dispatched services
Method Detail

loadReaders

public void loadReaders()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the service attribute for the given name, or null if there is no attribute by that name.

Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if there is no attribute by that name.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object object)
Binds an object to a given attribute name in this context.

Parameters:
name - a String specifying the name of the attribute
object - an Object representing the attribute to be bound.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader of this context

Returns:
ClassLoader of the context

getReaders

public java.util.Collection<java.net.URL> getReaders()
Gets the collection of readers associated with this context

Returns:
Collection of reader URLs

getName

public java.lang.String getName()
Gets the name of the local dispatcher

Returns:
String name of the LocalDispatcher object

makeValidContext

public java.util.Map<java.lang.String,java.lang.Object> makeValidContext(java.lang.String serviceName,
                                                                         java.lang.String mode,
                                                                         java.util.Map<java.lang.String,? extends java.lang.Object> context)
                                                                  throws GenericServiceException
Uses an existing map of name value pairs and extracts the keys which are used in serviceName Note: This goes not guarantee the context will be 100% valid, there may be missing fields

Parameters:
serviceName - The name of the service to obtain parameters for
mode - The mode to use for building the new map (i.e. can be IN or OUT)
context - The initial set of values to pull from
Returns:
Map contains any valid values
Throws:
GenericServiceException

makeValidContext

public java.util.Map<java.lang.String,java.lang.Object> makeValidContext(ModelService model,
                                                                         java.lang.String mode,
                                                                         java.util.Map<java.lang.String,? extends java.lang.Object> context)
                                                                  throws GenericServiceException
Uses an existing map of name value pairs and extracts the keys which are used in serviceName Note: This goes not guarantee the context will be 100% valid, there may be missing fields

Parameters:
model - The ModelService object of the service to obtain parameters for
mode - The mode to use for building the new map (i.e. can be IN or OUT)
context - The initial set of values to pull from
Returns:
Map contains any valid values
Throws:
GenericServiceException

getModelService

public ModelService getModelService(java.lang.String serviceName)
                             throws GenericServiceException
Gets the ModelService instance that corresponds to given the name

Parameters:
serviceName - Name of the service
Returns:
GenericServiceModel that corresponds to the serviceName
Throws:
GenericServiceException

getDispatcher

public LocalDispatcher getDispatcher()
Gets the LocalDispatcher used with this context

Returns:
LocalDispatcher that was used to create this context

setDispatcher

public void setDispatcher(LocalDispatcher dispatcher)
Sets the LocalDispatcher used with this context

Parameters:
dispatcher - The LocalDispatcher to re-assign to this context

getDelegator

public GenericDelegator getDelegator()
Gets the GenericDelegator associated with this context/dispatcher

Returns:
GenericDelegator associated with this context

getSecurity

public Security getSecurity()
Gets the Security object associated with this dispatcher

Returns:
Security object associated with this dispatcher

getAllServiceNames

public java.util.Set<java.lang.String> getAllServiceNames()

getWSDL

public org.w3c.dom.Document getWSDL(java.lang.String serviceName,
                                    java.lang.String locationURI)
                             throws GenericServiceException,
                                    WSDLException
Throws:
GenericServiceException
WSDLException