org.jboss.services.binding.impl
Class PojoServiceBindingStore

java.lang.Object
  extended by org.jboss.services.binding.impl.PojoServiceBindingStore
All Implemented Interfaces:
ServiceBindingStore

public class PojoServiceBindingStore
extends Object
implements ServiceBindingStore

A Pojo implementation of ServiceBindingStore.

Version:
$Revision: 89765 $
Author:
Brian Stansberry

Constructor Summary
PojoServiceBindingStore()
          Creates a new PojoServiceBindingStore
PojoServiceBindingStore(Set<ServiceBindingSet> bindingSets, Set<ServiceBindingMetadata> standardBindings)
           
 
Method Summary
 void addServiceBinding(ServiceBindingMetadata metadata)
          Add a ServiceBinding to all binding sets in the store.
 void addServiceBinding(String serverName, ServiceBindingMetadata metadata)
          Add a ServiceBinding to the store for the given serverName.
 void addServiceBinding(String serviceName, String bindingName, String hostName, int port, boolean fixedPort)
          Creates a new ServiceBindingMetadata from the given params and calls addServiceBinding(ServiceBindingMetadata).
 void addServiceBinding(String serviceName, String bindingName, String description, String hostName, int port, boolean fixedHostName, boolean fixedPort)
          Creates a new ServiceBindingMetadata from the given params and calls addServiceBinding(ServiceBindingMetadata).
 Set<ServiceBindingSet> getBindingSets()
          Deprecated. use getServiceBindingSets()
 String getDefaultHostName(String serverName)
          Gets the default value to use as the host name for the given serverName.
 int getDefaultPortOffset(String serverName)
          Gets the offset from a base value that by default should be added to port values for a given serverName.
 ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
          Obtain a ServiceBinding object for the given server name, target service and binding name.
 Set<ServiceBinding> getServiceBindings(String serverName)
          Gets all service bindings for the given server name.
 Set<ServiceBindingSet> getServiceBindingSets()
          Gets the ServiceBindingSets associated with this store.
 Set<ServiceBindingMetadata> getStandardBindings()
          Gets the base set of bindings that should be associated with each binding set, but with that binding set's port offset applied to the port value.
 void removeServiceBinding(ServiceBindingMetadata metadata)
          Remove a service configuration from all binding sets in the store.
 void removeServiceBinding(String serverName, ServiceBindingMetadata metadata)
          Remove a ServiceBinding from the store for the given serverName.
 void removeServiceBinding(String serviceName, String bindingName)
          Remove a service configuration from all binding sets in the store.
 void setServiceBindingSets(Set<ServiceBindingSet> sets)
           
 void setStandardBindings(Set<ServiceBindingMetadata> bindings)
          Sets the base set of bindings that should be associated with each binding set, adjusted to conform to the binding set's defaultHostName and offset.
 void start()
          Builds the runtime sets of bindings from the injected base bindings and ServiceBindingSets.
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PojoServiceBindingStore

public PojoServiceBindingStore()
Creates a new PojoServiceBindingStore


PojoServiceBindingStore

public PojoServiceBindingStore(Set<ServiceBindingSet> bindingSets,
                               Set<ServiceBindingMetadata> standardBindings)
Method Detail

addServiceBinding

public void addServiceBinding(String serverName,
                              ServiceBindingMetadata metadata)
                       throws DuplicateServiceException,
                              UnknownHostException
Description copied from interface: ServiceBindingStore
Add a ServiceBinding to the store for the given serverName.

Specified by:
addServiceBinding in interface ServiceBindingStore
Parameters:
serverName - the name identifying the JBoss server instance in which the service is running.
metadata - metadata for the binding to add
Throws:
DuplicateServiceException - thrown if a configuration for the pair already exists.
UnknownHostException - if the host specified by the metadata is unknown

getServiceBinding

public ServiceBinding getServiceBinding(String serverName,
                                        String serviceName,
                                        String bindingName)
                                 throws NoSuchBindingException
Description copied from interface: ServiceBindingStore
Obtain a ServiceBinding object for the given server name, target service and binding name.

Specified by:
getServiceBinding in interface ServiceBindingStore
Parameters:
serverName - the name identifying the server instance in which the service is running.
serviceName - the name of the service
bindingName - the name of the binding, or null to indicate the default binding.
Returns:
the ServiceBinding if one exists for the tuple.
Throws:
NoSuchBindingException - if no matching binding exists

getServiceBindings

public Set<ServiceBinding> getServiceBindings(String serverName)
Description copied from interface: ServiceBindingStore
Gets all service bindings for the given server name.

Specified by:
getServiceBindings in interface ServiceBindingStore
Parameters:
serverName - the name identifying the server instance in which the service is running. Cannot be null.
Returns:
the set of service bindings for the server name. Will not be null.

removeServiceBinding

public void removeServiceBinding(String serverName,
                                 ServiceBindingMetadata metadata)
Description copied from interface: ServiceBindingStore
Remove a ServiceBinding from the store for the given serverName.

Specified by:
removeServiceBinding in interface ServiceBindingStore
Parameters:
serverName - the name identifying the JBoss server instance in which the service is running.
metadata - the binding

getDefaultHostName

public String getDefaultHostName(String serverName)
Description copied from interface: ServiceBindingStore
Gets the default value to use as the host name for the given serverName.

Specified by:
getDefaultHostName in interface ServiceBindingStore
Parameters:
serverName - the name of the binding set
Returns:
the host name

getDefaultPortOffset

public int getDefaultPortOffset(String serverName)
Description copied from interface: ServiceBindingStore
Gets the offset from a base value that by default should be added to port values for a given serverName.

Specified by:
getDefaultPortOffset in interface ServiceBindingStore
Parameters:
serverName - the name of the binding set
Returns:
the offset

setStandardBindings

public void setStandardBindings(Set<ServiceBindingMetadata> bindings)
                         throws UnknownHostException,
                                DuplicateServiceException
Sets the base set of bindings that should be associated with each binding set, adjusted to conform to the binding set's defaultHostName and offset.

Parameters:
bindings - the set of base bindings. May be null
Throws:
DuplicateServiceException
UnknownHostException
IllegalStateException - if invoked after start()

setServiceBindingSets

public void setServiceBindingSets(Set<ServiceBindingSet> sets)
                           throws UnknownHostException,
                                  DuplicateServiceException
Throws:
UnknownHostException
DuplicateServiceException

start

public void start()
           throws DuplicateServiceException,
                  UnknownHostException
Builds the runtime sets of bindings from the injected base bindings and ServiceBindingSets.

Throws:
DuplicateServiceException
UnknownHostException

stop

public void stop()

getStandardBindings

public Set<ServiceBindingMetadata> getStandardBindings()
Gets the base set of bindings that should be associated with each binding set, but with that binding set's port offset applied to the port value.

Returns:
the set of base bindings

getBindingSets

public Set<ServiceBindingSet> getBindingSets()
Deprecated. use getServiceBindingSets()

See getServiceBindingSets()

Returns:
the binding sets

getServiceBindingSets

public Set<ServiceBindingSet> getServiceBindingSets()
Gets the ServiceBindingSets associated with this store.

Returns:
the binding sets. Will not return null

addServiceBinding

public void addServiceBinding(ServiceBindingMetadata metadata)
                       throws DuplicateServiceException
Add a ServiceBinding to all binding sets in the store. For each binding set, a new ServiceBinding is added whose serviceName and bindingName properties match the passed binding. If binding's fixeHostName property is false, the new binding's hostName matches the target set's default host name. If binding's fixedPort property is false, the new binding's port is derived by taking the port from the passed binding and incrementing it by the target set's default port offset.

Parameters:
metadata - metadata about the binding to add
Throws:
DuplicateServiceException - thrown if a configuration for the pair already exists.

addServiceBinding

public void addServiceBinding(String serviceName,
                              String bindingName,
                              String hostName,
                              int port,
                              boolean fixedPort)
                       throws DuplicateServiceException,
                              UnknownHostException
Creates a new ServiceBindingMetadata from the given params and calls addServiceBinding(ServiceBindingMetadata).

Parameters:
serviceName - the name of the service. Cannot be null
bindingName - name qualifier for the binding within the service. May be null
hostName - hostname or IP address to which the binding should be bound. Use null to indicate the host name should be the default host name for each binding set
serviceConfig - the configuration to add
fixed - true if the binding's port should remain fixed when added to each binding set; false if it should be offset by the binding set's port offset
Throws:
DuplicateServiceException - thrown if a configuration for the pair already exists.
UnknownHostException

addServiceBinding

public void addServiceBinding(String serviceName,
                              String bindingName,
                              String description,
                              String hostName,
                              int port,
                              boolean fixedHostName,
                              boolean fixedPort)
                       throws DuplicateServiceException,
                              UnknownHostException
Creates a new ServiceBindingMetadata from the given params and calls addServiceBinding(ServiceBindingMetadata).

Parameters:
serviceName - the name of the service. Cannot be null
bindingName - name qualifier for the binding within the service. May be null
description - helpful description of the binding; may be null
hostName - hostname or IP address to which the binding should be bound. Often null since the host name typically comes from the default host name for each binding set
port - port the binding should use
fixedHostName - true if the binding's hostName should remain fixed when added to each binding set; false if it should be changed to the binding set's default host name
fixedPort - true if the binding's port should remain fixed when added to each binding set; false if it should be offset by the binding set's port offset
Throws:
DuplicateServiceException - thrown if a configuration for the pair already exists.
UnknownHostException

removeServiceBinding

public void removeServiceBinding(ServiceBindingMetadata metadata)
Remove a service configuration from all binding sets in the store.

Parameters:
metadata - the binding

removeServiceBinding

public void removeServiceBinding(String serviceName,
                                 String bindingName)
Remove a service configuration from all binding sets in the store.

Parameters:
serviceName - the name of the service. Cannot be null
bindingName - name qualifier for the binding within the service. May be null


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.