org.apache.muse.core
Class AbstractEnvironment

java.lang.Object
  extended by org.apache.muse.core.AbstractEnvironment
All Implemented Interfaces:
Environment
Direct Known Subclasses:
AxisEnvironment, LocalEnvironment, MiniEnvironment, OSGiEnvironmentImpl

public abstract class AbstractEnvironment
extends Object
implements Environment

AbstractEnvironment is an abstract class that defines features related to the underlying platform as well as the endpoint's configuration. Its major responsibilities include storing request context on a per-thread basis and providing generic deployment information. Concrete isolation layers should provide concrete Environments that implement the abstract methods using the APIs of the underlying web services platform.

Author:
Dan Jemiolo (danj)
See Also:
AbstractIsolationLayer

Constructor Summary
AbstractEnvironment()
          The default constructor calls this('true').
AbstractEnvironment(boolean createSoapClient)
          Initializes the AbstractEnvironment with its own ClassLoader.
AbstractEnvironment(ClassLoader classLoader)
          This constructor calls this(classLoader, 'true').
AbstractEnvironment(ClassLoader classLoader, boolean createSoapClient)
           
 
Method Summary
 void addAddressingContext(MessageHeaders context)
          Records the WS-Addressing data for the current request.
 String createRelativePath(String originalPath, String relativePath)
          Merges the two paths to create a valid version of the second path.
protected  SoapClient createSoapClient()
          This method can be overridden by concrete Environments to provide a different implementation of SoapClient for use by the application.
 MessageHeaders getAddressingContext()
           
 ClassLoader getClassLoader()
           
 URL getDataResource(String path)
           
 InputStream getDataResourceStream(String path)
           
protected  EndpointReference getDefaultEPR()
           
 String getDefaultURI()
           
protected  String getDeploymentURI(String uriString)
           
 Document getDocument(String path)
          This is a convenience method that loads an InputStream using getDataResourceStream() and turns it into a DOM Document.
 SoapClient getSoapClient()
           
 void removeAddressingContext()
          Removes the context object for the current request.
 void setDefaultURI(String defaultURI)
           
 void setSoapClient(SoapClient soapClient)
          Provides a new SOAP client for use by other components in the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.muse.core.Environment
getDeploymentEPR, getRealDirectory
 

Constructor Detail

AbstractEnvironment

public AbstractEnvironment()
The default constructor calls this('true').


AbstractEnvironment

public AbstractEnvironment(boolean createSoapClient)
Initializes the AbstractEnvironment with its own ClassLoader.

Parameters:
createSoapClient - True if you want the SOAP client to be initialized. This requires that you have a valid JAX-RPC SOAP implementation (not just the interfaces) on the classpath.

AbstractEnvironment

public AbstractEnvironment(ClassLoader classLoader)
This constructor calls this(classLoader, 'true').


AbstractEnvironment

public AbstractEnvironment(ClassLoader classLoader,
                           boolean createSoapClient)
Parameters:
classLoader - The ClassLoader that will be used to load all Java classes as well as all file system resources.
createSoapClient - True if you want the SOAP client to be initialized. This requires that you have a valid JAX-RPC SOAP implementation (not just the interfaces) on the classpath.
Method Detail

addAddressingContext

public void addAddressingContext(MessageHeaders context)
Description copied from interface: Environment
Records the WS-Addressing data for the current request.

Specified by:
addAddressingContext in interface Environment
Parameters:
context - An object that can provide platform-specific information and which is thread-unique or thread-safe.

createRelativePath

public String createRelativePath(String originalPath,
                                 String relativePath)
Description copied from interface: Environment
Merges the two paths to create a valid version of the second path. This method should be used when you encounter a relative path in a document and must resolve it based on the path of the current file.

Specified by:
createRelativePath in interface Environment

createSoapClient

protected SoapClient createSoapClient()
This method can be overridden by concrete Environments to provide a different implementation of SoapClient for use by the application.

Returns:
A concrete SoapClient. This implementation of Environment returns a SimpleSoapClient object.

getAddressingContext

public MessageHeaders getAddressingContext()
Specified by:
getAddressingContext in interface Environment
Returns:
The WS-Addressing context for the current request.

getClassLoader

public ClassLoader getClassLoader()
Specified by:
getClassLoader in interface Environment
Returns:
The ClassLoader used to load all classes and file system resources.

getDataResource

public URL getDataResource(String path)
Specified by:
getDataResource in interface Environment
Parameters:
path - A path that is relative to the environment's context root. In J2EE applications this is the WAR root, in OSGi applications this is the bundle's root.
Returns:
The URL of the "data resource" found at the given path. If no such resource is found, the method throws a RuntimeException.

getDataResourceStream

public InputStream getDataResourceStream(String path)
Specified by:
getDataResourceStream in interface Environment
Parameters:
path - A path that is relative to the environment's context root. In J2EE applications this is the WAR root, in OSGi applications this is the bundle's root.
Returns:
An open InputStream that can read the "data resource" found at the given path. If no such resource is found, the method throws a RuntimeException.

getDefaultEPR

protected EndpointReference getDefaultEPR()
Returns:
An EPR whose URI is the value returned by getDefaultURI().

getDefaultURI

public String getDefaultURI()
Specified by:
getDefaultURI in interface Environment
Returns:
The address of a resource type hosted by this application. This can be used to gather some data about the wsa:Address of a resource, although it is not guaranteed to be an exact match. The purpose of this URI is to provide some address context when none is available from an incoming request.

getDeploymentURI

protected String getDeploymentURI(String uriString)
Parameters:
uriString -
Returns:
The URI being targeted by the current request. This URI includes an IP address rather than a host name, because we often use it to create EPRs/URIs for remote users based on the results of a local request. Returning an IP means that remote systems don't have to have a hosts lookup that includes our endpoint's machine.

getDocument

public Document getDocument(String path)
Description copied from interface: Environment
This is a convenience method that loads an InputStream using getDataResourceStream() and turns it into a DOM Document.

Specified by:
getDocument in interface Environment
See Also:
Environment.getDataResourceStream(String)

getSoapClient

public SoapClient getSoapClient()
Specified by:
getSoapClient in interface Environment
Returns:
The SOAP client that should be used by components wishing to make web service calls. The default client provided by this class is an instance of SimpleSoapClient.
See Also:
SimpleSoapClient

removeAddressingContext

public void removeAddressingContext()
Description copied from interface: Environment
Removes the context object for the current request.

Specified by:
removeAddressingContext in interface Environment

setDefaultURI

public void setDefaultURI(String defaultURI)
Specified by:
setDefaultURI in interface Environment
Parameters:
defaultURI - The URI to use when some address context is needed, but there is no request data to provide it.

setSoapClient

public void setSoapClient(SoapClient soapClient)
Provides a new SOAP client for use by other components in the system. The default SOAP client is an instance of SimpleSoapClient.

Specified by:
setSoapClient in interface Environment
Parameters:
soapClient - The SOAP client that should be used by components needing to invoke other web services.
See Also:
SimpleSoapClient


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.