org.spicefactory.cinnamon.client
Class AbstractServiceChannel

java.lang.Object
  extended by org.spicefactory.cinnamon.client.AbstractServiceChannel
All Implemented Interfaces:
ServiceChannel
Direct Known Subclasses:
SpringServiceChannel, XmlServiceChannel

public abstract class AbstractServiceChannel
extends Object
implements ServiceChannel

Common base class for factories that create Cinnamon client proxies. Uses JDK dynamic proxies to dynamically implement the service interfaces.

Author:
Jens Halm

Constructor Summary
AbstractServiceChannel()
           
 
Method Summary
 void configure()
          Method that should be called once after all properties have been set on this instance but before any service instances will be created.
protected abstract  ConfigurationBuilder createBuilder(Resource resource)
          Create a new ConfigurationBuilder instance for the specified Resource.
<T> T
createService(Class<T> serviceInterface, String serviceName)
          Creates a client service proxy that implements the specified service interface.
 CinnamonConfig getConfig()
          Returns the Cinnamon configuration.
 Set<String> getHeaderNames()
          Returns an unmodifiable Set containing all header names for this message.
 Object getHeaderValue(String name)
          Returns the header value for the given name.
 String getServiceUrl()
          Returns the service URL that client proxies should connect to.
 void removeHeader(String name)
          Removes the header for the given name.
 void setConfigResource(Resource resource)
          Sets the resource to load the Cinnamonn configuration from.
 void setHeader(String name, Object value)
          Sets a header for this message.
 void setServiceUrl(String serviceUrl)
          Sets the service URL that client proxies should connect to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractServiceChannel

public AbstractServiceChannel()
Method Detail

setConfigResource

public void setConfigResource(Resource resource)
Description copied from interface: ServiceChannel
Sets the resource to load the Cinnamonn configuration from.

Specified by:
setConfigResource in interface ServiceChannel
Parameters:
resource - the resource to load the Cinnamonn configuration from

setServiceUrl

public void setServiceUrl(String serviceUrl)
Description copied from interface: ServiceChannel
Sets the service URL that client proxies should connect to.

Specified by:
setServiceUrl in interface ServiceChannel
Parameters:
serviceUrl - the service URL that client proxies should connect to

getServiceUrl

public String getServiceUrl()
Description copied from interface: ServiceChannel
Returns the service URL that client proxies should connect to.

Specified by:
getServiceUrl in interface ServiceChannel
Returns:
the service URL that client proxies should connect to

getConfig

public CinnamonConfig getConfig()
Description copied from interface: ServiceChannel
Returns the Cinnamon configuration. This method will throw an Exception if the factory is not fully initialized yet.

Specified by:
getConfig in interface ServiceChannel
Returns:
the Cinnamon configuration

configure

public void configure()
Description copied from interface: ServiceChannel
Method that should be called once after all properties have been set on this instance but before any service instances will be created.

Specified by:
configure in interface ServiceChannel

setHeader

public void setHeader(String name,
                      Object value)
Description copied from interface: ServiceChannel
Sets a header for this message. This is a custom message header and does not relate to HTTP headers or AMF0 headers.

Specified by:
setHeader in interface ServiceChannel

removeHeader

public void removeHeader(String name)
Description copied from interface: ServiceChannel
Removes the header for the given name.

Specified by:
removeHeader in interface ServiceChannel
Parameters:
name - the name of the header to remove

getHeaderNames

public Set<String> getHeaderNames()
Description copied from interface: ServiceChannel
Returns an unmodifiable Set containing all header names for this message.

Specified by:
getHeaderNames in interface ServiceChannel
Returns:
an unmodifiable Set containing all header names for this message

getHeaderValue

public Object getHeaderValue(String name)
Description copied from interface: ServiceChannel
Returns the header value for the given name. This is a custom message header and does not relate to HTTP headers or AMF0 headers.

Specified by:
getHeaderValue in interface ServiceChannel
Parameters:
name - the name of the header
Returns:
the header value for the given name or null if no such header exists

createBuilder

protected abstract ConfigurationBuilder createBuilder(Resource resource)
Create a new ConfigurationBuilder instance for the specified Resource.

Parameters:
resource - the resource to read configuration data from
Returns:
a new ConfigurationBuilder instance

createService

public <T> T createService(Class<T> serviceInterface,
                           String serviceName)
Description copied from interface: ServiceChannel
Creates a client service proxy that implements the specified service interface.

Specified by:
createService in interface ServiceChannel
Parameters:
serviceInterface - the service interface
serviceName - the name of the service as specified in the Cinnamon configuration
Returns:
a client service proxy