org.restlet.util

## Class ServiceList

- java.lang.Object
- - org.restlet.util.WrapperList<Service>
  - - org.restlet.util.ServiceList

All Implemented Interfaces:
  java.lang.Iterable<Service>, java.util.Collection<Service>, java.util.List<Service>

    public final class ServiceList
    extends WrapperList<Service>

Modifiable list of services.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`ServiceList(Context context)` Constructor.

### Method Summary

Methods
`void` `add(int index, Service service)` Inserts the specified element at the specified position in this list.
`boolean` `add(Service service)` Adds a element at the end of the list.
`boolean` `addAll(java.util.Collection<? extends Service> services)` Appends all of the elements in the specified collection to the end of this list.
`boolean` `addAll(int index, java.util.Collection<? extends Service> services)` Inserts all of the elements in the specified collection into this list at the specified position.
`<T extends Service> T` `get(java.lang.Class<T> clazz)` Returns a service matching a given service class.
`Context` `getContext()` Returns the context.
`void` `set(java.util.List<Service> services)` Sets the list of services.
`void` `set(Service newService)` Replaces or adds a service.
`void` `setContext(Context context)` Sets the context.
`void` `start()` Starts each service.
`void` `stop()` Stops each service.

### Methods inherited from class org.restlet.util.WrapperList

`clear, contains, containsAll, equals, get, getDelegate, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ServiceList

    public ServiceList(Context context)

Constructor.

Parameters:
  `context` - The context.

### Method Detail

#### add

    public void add(int index,
           Service service)

Description copied from class: `WrapperList`
Inserts the specified element at the specified position in this list.

Specified by:
  `add` in interface `java.util.List<Service>`
Overrides:
  `add` in class `WrapperList<Service>`
Parameters:
  `index` - The insertion position.
  `service` - The element to insert.

#### add

    public boolean add(Service service)

Description copied from class: `WrapperList`
Adds a element at the end of the list.

Specified by:
  `add` in interface `java.util.Collection<Service>`
Specified by:
  `add` in interface `java.util.List<Service>`
Overrides:
  `add` in class `WrapperList<Service>`
Returns:
  True (as per the general contract of the Collection.add method).

#### addAll

    public boolean addAll(java.util.Collection<? extends Service> services)

Description copied from class: `WrapperList`
Appends all of the elements in the specified collection to the end of this list.

Specified by:
  `addAll` in interface `java.util.Collection<Service>`
Specified by:
  `addAll` in interface `java.util.List<Service>`
Overrides:
  `addAll` in class `WrapperList<Service>`
Parameters:
  `services` - The collection of elements to append.

#### addAll

    public boolean addAll(int index,
                 java.util.Collection<? extends Service> services)

Description copied from class: `WrapperList`
Inserts all of the elements in the specified collection into this list at the specified position.

Specified by:
  `addAll` in interface `java.util.List<Service>`
Overrides:
  `addAll` in class `WrapperList<Service>`
Parameters:
  `index` - The insertion position.
  `services` - The collection of elements to insert.

#### get

    public <T extends Service> T get(java.lang.Class<T> clazz)

Returns a service matching a given service class.

Type Parameters:
  `T` - The service type.
Parameters:
  `clazz` - The service class to match.
Returns:
  The matched service instance.

#### getContext

    public Context getContext()

Returns the context.

Returns:
  The context.

#### set

    public void set(java.util.List<Service> services)

Sets the list of services.

Parameters:
  `services` - The list of services.

#### set

    public void set(Service newService)

Replaces or adds a service. The replacement is based on the service class.

Parameters:
  `newService` - The new service to set.

#### setContext

    public void setContext(Context context)

Sets the context. By default, it also updates the context of already registered services.

Parameters:
  `context` - The context.

#### start

    public void start()
               throws java.lang.Exception

Starts each service.

Throws:
  `java.lang.Exception`

#### stop

    public void stop()
              throws java.lang.Exception

Stops each service.

Throws:
  `java.lang.Exception`