Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.core
Class Association<T>

    java.lang.Object
      org.jini.rio.core.Association<T>

All Implemented Interfaces:
  Iterable<T>

    public class Association<T>

extends Object
implements Iterable<T>

Associations provide a mechanism to model and enforce uses and requires associations between services in an `OperationalString`. Associations take 5 forms:

- Uses
  A weak association relationship where if A uses B exists then, then B may be present for A
- Requires
  A stronger association relationship where if A requires B exists then B must be present for A
- Colocated
  An association which requires that A be colocated with B in the same JVM. If B does not exist, or cannot be located, A shall not be created without B
- Opposed
  An association which requires that A exist in a different JVM then B.
- Isolated
  An association which requires that A exist in a different machine then B.

Associations are optional and may be declared as part of a service's OperationalString declaration. An example :

<Associations>
<Association Type="requires"
Name="JavaSpace"
OperationalString="Outrigger"/>
<Association Type="uses"
Name="Space Worker"/>
</Associations>

The example above shows 2 Associations, a required Association to a JavaSpace declared in an OperationalString with the name of "Outrigger", and a uses Association to a service named "Space Worker" in the same OperationalString as the declaring service.

Once provisioned a service can obtain it's Associations from the `ServiceBeanContext.getAssociationManagement()` method.

Nested Class Summary
`static class` | `Association.State` Association State enums indicate the following: PENDING: Indicates that an associated service has not been discovered DISCOVERED: Indicates that an associated service has been discovered CHANGED: Indicates that an associated service has changed, that is an end-point has changed, and the association now points a different service BROKEN: Indicates that the association is broken

Constructor Summary
`Association(AssociationDescriptor aDesc)` Create an Association

Method Summary
`boolean` | `addServiceItem(ServiceItem item)` Add a service to the Association
`AssociationDescriptor` | `getAssociationDescriptor()` Get the AssociationDescriptor
`AssociationType` | `getAssociationType()` Get the AssociationType
`String` | `getName()` Get the associated service's name
`String` | `getOperationalStringName()` Get the associated service's OperationalString name
`T` | `getService()` Get the first service Object that can be used to communicate to the associated service.
`int` | `getServiceCount()` Get the number of associated services
`ServiceItem` | `getServiceItem()` Get the ServiceItem for the service thats first in the List of services.
`ServiceItem` | `getServiceItem(T service)` Get the ServiceItem for the associated service.
`ServiceItem[]` | `getServiceItems()` Get ServiceItem instances for all known associated service instances.
`Collection<T>` | `getServices()` Get all Objects that can be used to communicate to all known associated services.
`Association.State` | `getState()` Get the Association state
`Iterator<T>` | `iterator()` Satifies the contract of an `Iterable`, allowing the associated services to be the target of a "foreach" statement
`ServiceItem` | `removeService(T service)` Remove a service from the Association
`boolean` | `removeServiceItem(ServiceItem item)` Remove a ServiceItem from the Association
`void` | `setState(Association.State state)` Set the Association state

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Association

    public Association(AssociationDescriptor aDesc)

  Create an Association

  Parameters:
    `aDesc` - The `AssociationDescriptor` for this association

Method Detail

### getAssociationType

    public AssociationType getAssociationType()

  Get the AssociationType

  Returns:
    The AssociationType

### setState

    public void setState(Association.State state)

  Set the Association state

  Parameters:
    `state` - The Association state

### getState

    public Association.State getState()

  Get the Association state

  Returns:
    The Association state

### getName

    public String getName()

  Get the associated service's name

  Returns:
    The associated service's name

### getOperationalStringName

    public String getOperationalStringName()

  Get the associated service's OperationalString name

  Returns:
    The associated service's OperationalString name

### getAssociationDescriptor

    public AssociationDescriptor getAssociationDescriptor()

  Get the AssociationDescriptor

  Returns:
    The `AssociationDescriptor` used to create this Association

### getServiceCount

    public int getServiceCount()

  Get the number of associated services

  Returns:
    The number of associated services

### getService

    public T getService()

  Get the first service Object that can be used to communicate to the associated service.

  Returns:
    The first service (proxy) Object in the collection of associated services. If there are no services a null will be returned.

### getServices

    public Collection<T> getServices()

  Get all Objects that can be used to communicate to all known associated services.

  Returns:
    Array of service Object instances that can be used to communicate to all known associated service instances. A new collection is allocated each time. If there are no services, an empty collection will be returned

### iterator

    public Iterator<T> iterator()

  Satifies the contract of an `Iterable`, allowing the associated services to be the target of a "foreach" statement

  Specified by:
    `iterator` in interface `Iterable<T>`
  Returns:
    An `Iterable` that can be used to iterate over the collection of assoiated services. A new `Iterable` is created each time.

### getServiceItem

    public ServiceItem getServiceItem()

  Get the ServiceItem for the service thats first in the List of services.

  Returns:
    The ServiceItem for an associated service. If there are no services, a null will be returned

### getServiceItem

    public ServiceItem getServiceItem(T service)

  Get the ServiceItem for the associated service. The collection of associated services will be searched anf if the service proxy is equal to a known associated service proxy, the `ServiceID` for that service will be returned

  Parameters:
    `service` - The proxy of an associated service
  Returns:
    The ServiceItem for an associated service. If the service is unknown, a null will be returned

### getServiceItems

    public ServiceItem[] getServiceItems()

  Get ServiceItem instances for all known associated service instances.

  Returns:
    Array of ServiceItem instances for all known associated service instances. A new array is allocated each time. If there are no services, an empty array will be returned

### addServiceItem

    public boolean addServiceItem(ServiceItem item)

  Add a service to the Association

  Parameters:
    `item` - The ServiceItem for the service to add
  Returns:
    True if added, false if the ServiceItem already exists

### removeServiceItem

    public boolean removeServiceItem(ServiceItem item)

  Remove a ServiceItem from the Association

  Parameters:
    `item` - The ServiceItem to remove
  Returns:
    true if the item was removed

### removeService

    public ServiceItem removeService(T service)

  Remove a service from the Association

  Parameters:
    `service` - The proxy for the Service to remove
  Returns:
    The ServiceItem of the removed service

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.