Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.net
Class CompositeAddressProvider

    java.lang.Object
      java.util.AbstractCollection
          com.tangosol.net.CompositeAddressProvider

All Implemented Interfaces:
  AddressProvider, java.lang.Iterable, java.util.Collection, java.util.Set

    public class CompositeAddressProvider

extends java.util.AbstractCollection
implements AddressProvider, java.util.Set

CompositeAddressProvider is a composite of one or more AddressProviders or addresses that also implements the Set interface. This AddressProvider will provide addresses from all registered AddressProviders or Addresses.

This class implements the Set interface, but the contents are not checked to determine whether each element is unique. It is the responsibility of the user to ensure that the elements are unique if the object is used as a Set.

This implementation is thread-safe for consumers of the Set interface, but allows no more than one consumer of the AddressProvider interface.

Since:
  Coherence 3.5
Author:
  rhl 2008-12-05

Nested Class Summary
`protected static class` | `CompositeAddressProvider.AddressIterator` An Iterator over the addresses in this AddressProvider.
`protected class` | `CompositeAddressProvider.SingleProvider` AddressProvider wrapper for a single address dynamically added to this AddressSet.

Field Summary
`protected CompositeAddressProvider.AddressIterator` | `m_iterInternal` The default iterator used to implement the AddressProvider interface.

Constructor Summary
`CompositeAddressProvider()` Default constructor.

Method Summary
`void` | `accept()` This method should be called by the client immediately after it determines that it can successfully use an address returned by the `AddressProvider.getNextAddress()` method.
`boolean` | `add(java.lang.Object o)` Ensures that this collection contains the specified element (optional operation).
`void` | `addAddress(java.net.InetSocketAddress address)` Add an address.
`void` | `addProvider(AddressProvider provider)` Add an AddressProvider.
`protected CompositeAddressProvider.AddressIterator` | `ensureInternalIterator()` Create (if necessary) and return the default iterator.
`boolean` | `equals(java.lang.Object o)` AddressProvider instances are considered equivalent iff they consistently produce the same resulting set of addresses.
`java.net.InetSocketAddress` | `getNextAddress()` Obtain a next available address to use.
`protected java.util.List` | `getProviderList()` Return the provider list.
`int` | `hashCode()` Return the hash code for this AddressProvider.
`java.util.Iterator` | `iterator()` Returns an iterator over the elements contained in this collection.
`void` | `reject(java.lang.Throwable eCause)` This method should be called by the client immediately after it determines that an attempt to use an address returned by the `AddressProvider.getNextAddress()` method has failed.
`boolean` | `remove(java.lang.Object o)` Removes the specified element from this set if it is present (optional operation).
`int` | `size()` Returns the number of elements in this collection.

Methods inherited from class java.util.AbstractCollection
`addAll, clear, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString`

Methods inherited from interface java.util.Set
`addAll, clear, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray`

Field Detail

### m_iterInternal

    protected CompositeAddressProvider.AddressIterator m_iterInternal

  The default iterator used to implement the AddressProvider interface.

Constructor Detail

### CompositeAddressProvider

    public CompositeAddressProvider()

  Default constructor.

Method Detail

### addProvider

    public void addProvider(AddressProvider provider)

  Add an AddressProvider.

  Parameters:
    `provider` - the AddressProvider to add

### addAddress

    public void addAddress(java.net.InetSocketAddress address)

  Add an address.

  Parameters:
    `address` - the address to add

### getProviderList

    protected java.util.List getProviderList()

  Return the provider list.

  Returns:
    the provider list

### getNextAddress

    public java.net.InetSocketAddress getNextAddress()

  Obtain a next available address to use. If the caller can successfully use the returned address (e.g. a connection was established), it should call the AddressProvider's `AddressProvider.accept()` method.

  Specified by:
    `getNextAddress` in interface `AddressProvider`
  Returns:
    the next available address or null if the list of available addresses was exhausted

### accept

    public void accept()

  This method should be called by the client immediately after it determines that it can successfully use an address returned by the `AddressProvider.getNextAddress()` method.

  Specified by:
    `accept` in interface `AddressProvider`

### reject

    public void reject(java.lang.Throwable eCause)

  This method should be called by the client immediately after it determines that an attempt to use an address returned by the `AddressProvider.getNextAddress()` method has failed.

  Specified by:
    `reject` in interface `AddressProvider`
  Parameters:
    `eCause` - (optional) an exception that carries the reason why the the caller rejected the previously returned address

### equals

    public boolean equals(java.lang.Object o)

  AddressProvider instances are considered equivalent iff they consistently produce the same resulting set of addresses.

  Note: the general contract of `hashCode` and `equals()` should be preserved; AddressProviders that are "equal" should produce the same hashCode.

  Specified by:
    `equals` in interface `AddressProvider`
  Specified by:
    `equals` in interface `java.util.Collection`
  Specified by:
    `equals` in interface `java.util.Set`
  Parameters:
    `o` - the Object to compare this AddressProvider to for equality
  Returns:
    true iff this AddressProvider is equal to the specified object

### hashCode

    public int hashCode()

  Return the hash code for this AddressProvider.

  Specified by:
    `hashCode` in interface `AddressProvider`
  Specified by:
    `hashCode` in interface `java.util.Collection`
  Specified by:
    `hashCode` in interface `java.util.Set`
  Returns:
    the hash code for this AddressProvider

### iterator

    public java.util.Iterator iterator()

  Returns an iterator over the elements contained in this collection.

  Specified by:
    `iterator` in interface `java.lang.Iterable`
  Specified by:
    `iterator` in interface `java.util.Collection`
  Specified by:
    `iterator` in interface `java.util.Set`
  Specified by:
    `iterator` in class `java.util.AbstractCollection`
  Returns:
    an iterator over the elements contained in this collection.

### size

    public int size()

  Returns the number of elements in this collection. If the collection contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

  Specified by:
    `size` in interface `java.util.Collection`
  Specified by:
    `size` in interface `java.util.Set`
  Specified by:
    `size` in class `java.util.AbstractCollection`
  Returns:
    the number of elements in this collection

### add

    public boolean add(java.lang.Object o)

  Ensures that this collection contains the specified element (optional operation). Returns `true` if the collection changed as a result of the call. (Returns `false` if this collection does not permit duplicates and already contains the specified element.) Collections that support this operation may place limitations on what elements may be added to the collection. In particular, some collections will refuse to add `null` elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

  This implementation always throws an `UnsupportedOperationException`.

  Specified by:
    `add` in interface `java.util.Collection`
  Specified by:
    `add` in interface `java.util.Set`
  Overrides:
    `add` in class `java.util.AbstractCollection`
  Parameters:
    `o` - element whose presence in this collection is to be ensured.
  Returns:
    `true` if the collection changed as a result of the call.
  Throws:
    `java.lang.UnsupportedOperationException` - if the `add` method is not supported by this collection.
    `java.lang.NullPointerException` - if this collection does not permit `null` elements, and the specified element is `null`.
    `java.lang.ClassCastException` - if the class of the specified element prevents it from being added to this collection.
    `java.lang.IllegalArgumentException` - if some aspect of this element prevents it from being added to this collection.

### remove

    public boolean remove(java.lang.Object o)

  Removes the specified element from this set if it is present (optional operation). More formally, removes an element `e` such that `(o==null ? e==null : o.equals(e))`, if the set contains such an element. Returns `true` if the set contained the specified element (or equivalently, if the set changed as a result of the call). (The set will not contain the specified element once the call returns.)

  Specified by:
    `remove` in interface `java.util.Collection`
  Specified by:
    `remove` in interface `java.util.Set`
  Overrides:
    `remove` in class `java.util.AbstractCollection`
  Parameters:
    `o` - object to be removed from this set, if present.
  Returns:
    true if the set contained the specified element.
  Throws:
    `java.lang.ClassCastException` - if the type of the specified element is incompatible with this set (optional).
    `java.lang.NullPointerException` - if the specified element is null and this set does not support null elements (optional).
    `java.lang.UnsupportedOperationException` - if the `remove` method is not supported by this set.

### ensureInternalIterator

    protected CompositeAddressProvider.AddressIterator ensureInternalIterator()

  Create (if necessary) and return the default iterator.

  Returns:
    the default iterator

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.