org.apache.muse.core
Class AbstractCapability

java.lang.Object
  extended by org.apache.muse.core.AbstractCapability
All Implemented Interfaces:
Capability, Initialization, InitializationParameters, Shutdown
Direct Known Subclasses:
AbstractAdvertisement, AbstractWsResourceCapability, SimpleMetadataExchange, SimpleNotificationConsumer

public abstract class AbstractCapability
extends Object
implements Capability

AbstractCapability provides a foundation for user-defined capabilities by allowing users to focus on their operations and capability-specific logic without having to worry about maintaining Muse components and other plumbing work.

The implementations of the initialization and shutdown routines are mostly no-ops. Nevertheless, if these methods are overridden by concrete capability classes, the implementations should be sure to call the parent class version (via 'super') before executing their own logic; for example, a new version of the initialize() method should always start with a call to super.initialize(). As the class hierarchy grows, this ensures that startup and shutdown tasks are always performed in the proper order.

Author:
Dan Jemiolo (danj)

Constructor Summary
AbstractCapability()
           
 
Method Summary
 Collection getActions()
           
 String getCapabilityURI()
           
 Environment getEnvironment()
           
 String getInitializationParameter(String name)
           
 Map getInitializationParameters()
           
 Logger getLog()
           
 MessageHandler getMessageHandler(String action)
           
 Persistence getPersistence()
           
 Resource getResource()
           
 boolean hasBeenInitialized()
           
 boolean hasBeenShutdown()
           
 void initialize()
           
 void initializeCompleted()
          This method is called by the containing Resource after all other capabilities have been initialized via initialize().
 void prepareShutdown()
          This method is called prior to shutdown() and allows the capability to do any shutdown tasks that require the presence of certain other capabilities.
 void setCapabilityURI(String capabilityURI)
           
 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)
           
protected  void setMessageHandler(MessageHandler handler)
           
 void setMessageHandlers(Collection handlers)
           
 void setPersistence(Persistence persistence)
           
 void setResource(Resource resource)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCapability

public AbstractCapability()
Method Detail

getActions

public Collection getActions()
Specified by:
getActions in interface Capability
Returns:
All of the WS-A Action URIs for which the capability has a MessageHandler.
See Also:
Capability.getMessageHandler(String)

getCapabilityURI

public String getCapabilityURI()
Specified by:
getCapabilityURI in interface Capability
Returns:
The unique URI (within the resource type) that defines this capability.

getEnvironment

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

getInitializationParameter

public 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 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 Logger getLog()
Specified by:
getLog in interface Capability
Returns:
The JDK logger that writes to the Muse log file.

getMessageHandler

public MessageHandler getMessageHandler(String action)
Specified by:
getMessageHandler in interface Capability
Returns:
This method is called as part of the containing Resource's method invocation process; it allows the capability to specify the handler that will parse the request/response for the method.
See Also:
Capability.getActions()

getPersistence

public Persistence getPersistence()
Specified by:
getPersistence in interface Capability
Returns:
The persistence mechanism for this capability, or null if none was defined.

getResource

public Resource getResource()
Specified by:
getResource in interface Capability
Returns:
The resource that contains this capability instance.

hasBeenInitialized

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

hasBeenShutdown

public 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.

initialize

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

initializeCompleted

public void initializeCompleted()
                         throws SoapFault
Description copied from interface: Capability
This method is called by the containing Resource after all other capabilities have been initialized via initialize(). It allows the Capability to do initialization work that requires the presence of certain other capabilities. This "post-initialization" state is necessary because capability definition and creation is non-deterministic, and users cannot make any assumptions about the order of those tasks.

Specified by:
initializeCompleted in interface Capability
Throws:
SoapFault

prepareShutdown

public void prepareShutdown()
                     throws SoapFault
Description copied from interface: Capability
This method is called prior to shutdown() and allows the capability to do any shutdown tasks that require the presence of certain other capabilities. Once shutdown() is called, the capability cannot be certain that the other capabilities it depends on have not already been shutdown as well, so this "pre-shutdown" state gives it this opportunity.

Specified by:
prepareShutdown in interface Capability
Throws:
SoapFault

setCapabilityURI

public void setCapabilityURI(String capabilityURI)
Specified by:
setCapabilityURI in interface Capability

setEnvironment

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

setInitializationParameters

public 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 void setLog(Logger log)
Specified by:
setLog in interface Capability

setMessageHandler

protected void setMessageHandler(MessageHandler handler)

setMessageHandlers

public void setMessageHandlers(Collection handlers)
Specified by:
setMessageHandlers in interface Capability

setPersistence

public void setPersistence(Persistence persistence)
Specified by:
setPersistence in interface Capability

setResource

public void setResource(Resource resource)
Specified by:
setResource in interface Capability

shutdown

public void shutdown()
              throws SoapFault
Specified by:
shutdown in interface Shutdown
Throws:
SoapFault


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