org.apache.muse.core
Class SimpleResource

java.lang.Object
  extended by org.apache.muse.core.SimpleResource
All Implemented Interfaces:
Initialization, InitializationParameters, Resource, Shutdown
Direct Known Subclasses:
SimpleWsResource

public class SimpleResource
extends Object
implements Resource

SimpleResource is Muse's default implementation of the core resource type component. It provides all the code needed to collect capabilities and delegate request to them, as well as a central place for them to find and contact each other.

Author:
Dan Jemiolo (danj)

Constructor Summary
SimpleResource()
           
 
Method Summary
 void addCapability(Capability capability)
          Registers the given capability instance with the resource.
 Capability getCapability(String capabilityURI)
           
protected  Collection getCapabilityActions()
           
protected  Capability getCapabilityForAction(String action)
           
 Collection getCapabilityURIs()
           
 String getContextPath()
           
 EndpointReference getEndpointReference()
           
 Environment getEnvironment()
           
 String getInitializationParameter(String name)
           
 Map getInitializationParameters()
           
 Logger getLog()
           
 ResourceManager getResourceManager()
           
 String getWsdlPath()
           
 QName getWsdlPortType()
           
 boolean hasBeenInitialized()
           
 boolean hasBeenShutdown()
           
 boolean hasCapability(String capabilityURI)
           
 void initialize()
           
protected  void initializeCapabilities()
          This method can be overridden to provide additional capability initialization logic that applies generally to all capabilities.
 Element invoke(Element soapBody)
          This is a generic method invocation mechanism that can be used to delegate request handling to a capability or some other component.
 void setContextPath(String contextPath)
           
 void setEndpointReference(EndpointReference epr)
           
 void setEnvironment(Environment environment)
           
 void setInitializationParameters(Map parameters)
          Allows the resource's creator to provide it with arbitrary name-value pairs that may be used during initialization.
 void setLog(Logger log)
           
 void setResourceManager(ResourceManager manager)
           
 void setWsdlPath(String wsdlPath)
           
 void setWsdlPortType(QName wsdlPortType)
           
 void shutdown()
          

This implementation double-checks to make sure the resource hasn't already been destroyed and then nulls-out all references to internal data structures (this will highlight bugs caused by stale references and prevent "undefined behavior").
protected  void shutdownCapabilities()
          This method can be overridden to provide additional capability shutdown logic that applies generally to all capabilities.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleResource

public SimpleResource()
Method Detail

addCapability

public void addCapability(Capability capability)
Registers the given capability instance with the resource.


getCapability

public final Capability getCapability(String capabilityURI)
Returns:
The Capability associated with the given URI, or null if no such capability exists.

getCapabilityActions

protected Collection getCapabilityActions()
Returns:
All of the WS-A Action URIs supported by this resource.

getCapabilityForAction

protected Capability getCapabilityForAction(String action)
Parameters:
action - A WS-A Action URI.
Returns:
The Capability object with the method that maps to the given WS-A Action URI.

getCapabilityURIs

public final Collection getCapabilityURIs()
Returns:
A collection with all of the capabilities' URIs.

getContextPath

public final String getContextPath()
Specified by:
getContextPath in interface Resource
Returns:
The unique part of the SOAP endpoint URL that defines this resource's type. Every resource type should have a unique SOAP endpoint. This value should map to a context-path value in muse.

getEndpointReference

public EndpointReference getEndpointReference()
Specified by:
getEndpointReference in interface Resource
Returns:
The unique EPR of the resource instance.

getEnvironment

public final Environment getEnvironment()
Specified by:
getEnvironment in interface Resource
Returns:
The resource's access point for things such as the WS-Addressing context, file system resources, and more.

getInitializationParameter

public final String getInitializationParameter(String name)
Specified by:
getInitializationParameter in interface InitializationParameters
Returns:
The value of the initialization parameter, or null if it does not exist.

getInitializationParameters

public final Map getInitializationParameters()
Specified by:
getInitializationParameters in interface InitializationParameters
Returns:
The set of name-value pairs provided at initialization time. The Map may be empty.

getLog

public final Logger getLog()
Specified by:
getLog in interface Resource
Returns:
The JDK logger that writes to the Muse log file.

getResourceManager

public ResourceManager getResourceManager()
Specified by:
getResourceManager in interface Resource
Returns:
The ResourceManager that stores all of the resource type definitions and all current resource instances.

getWsdlPath

public final String getWsdlPath()
Specified by:
getWsdlPath in interface Resource
Returns:
The relative path of the WSDL file with the resource's portType.

getWsdlPortType

public final QName getWsdlPortType()
Specified by:
getWsdlPortType in interface Resource
Returns:
The WSDL portType that defines the resource.

hasBeenInitialized

public final boolean hasBeenInitialized()
Specified by:
hasBeenInitialized in interface Initialization
Returns:
True, if the initialize() method has been called and run to completion successfully.

hasBeenShutdown

public final boolean hasBeenShutdown()
Specified by:
hasBeenShutdown in interface Shutdown
Returns:
True, if the shutdown() method has been called and run to completion successfully. If true, no other methods should be called on this Resource object.

hasCapability

public final boolean hasCapability(String capabilityURI)
Returns:
True, if getCapability(String) returns a non-null value.

initialize

public void initialize()
                throws SoapFault
Specified by:
initialize in interface Initialization
Throws:
SoapFault

initializeCapabilities

protected void initializeCapabilities()
                               throws SoapFault
This method can be overridden to provide additional capability initialization logic that applies generally to all capabilities. Capability-specific initialization logic should be provided by overriding Capability.initialize().

Throws:
SoapFault

invoke

public Element invoke(Element soapBody)
Description copied from interface: Resource
This is a generic method invocation mechanism that can be used to delegate request handling to a capability or some other component. It is intended to be used by code that is handling external requests, and it may not allow the invocation of all methods defined by the type. Internal clients should make 'normal' Java method calls with the actual method parameters; the getCapability(String) method provides access to the Capability objects that make up the resource type, all of which will have 'normal' Java methods for their operations.

Specified by:
invoke in interface Resource
Parameters:
soapBody - The parameters for the method, still in their SOAP Body form.
Returns:
The return value of the method, in SOAP Body form. If the operation resulted in a fault, the response XML should be the fault XML.

setContextPath

public final void setContextPath(String contextPath)
Specified by:
setContextPath in interface Resource

setEndpointReference

public final void setEndpointReference(EndpointReference epr)
Specified by:
setEndpointReference in interface Resource

setEnvironment

public final void setEnvironment(Environment environment)
Specified by:
setEnvironment in interface Resource

setInitializationParameters

public final void setInitializationParameters(Map parameters)
Description copied from interface: InitializationParameters
Allows the resource's creator to provide it with arbitrary name-value pairs that may be used during initialization. The way that these values are used and/or stored is an implementation detail, and there is no requirement that this feature be used - it is a generic way to specify deployment/initialization parameters. This method should be called before the resource is initialized.

Specified by:
setInitializationParameters in interface InitializationParameters
Parameters:
parameters - A simple set of name-value pairs - Map[String, String] - that contains initialization parameters for the resource.

setLog

public final void setLog(Logger log)
Specified by:
setLog in interface Resource

setResourceManager

public void setResourceManager(ResourceManager manager)
Specified by:
setResourceManager in interface Resource

setWsdlPath

public final void setWsdlPath(String wsdlPath)
Specified by:
setWsdlPath in interface Resource

setWsdlPortType

public final void setWsdlPortType(QName wsdlPortType)
Specified by:
setWsdlPortType in interface Resource

shutdown

public void shutdown()
              throws SoapFault


This implementation double-checks to make sure the resource hasn't already been destroyed and then nulls-out all references to internal data structures (this will highlight bugs caused by stale references and prevent "undefined behavior").

Specified by:
shutdown in interface Shutdown
Throws:
SoapFault

shutdownCapabilities

protected void shutdownCapabilities()
                             throws SoapFault
This method can be overridden to provide additional capability shutdown logic that applies generally to all capabilities. Capability-specific shutdown logic should be provided by overriding Capability.shutdown().

Throws:
SoapFault

toString

public String toString()
Overrides:
toString in class Object
Returns:
The resource's EPR, in string form.


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