org.apache.tamaya.integration.cdi.internal

## Class CDIAwareServiceContext

- java.lang.Object
- - org.apache.tamaya.integration.cdi.internal.CDIAwareServiceContext

- All Implemented Interfaces:
    org.apache.tamaya.spi.ServiceContext

      public class CDIAwareServiceContext
      extends Object
      implements org.apache.tamaya.spi.ServiceContext

  This class implements a `ServiceContext`, which basically provides a similar loading mechanism as used by the `ServiceLoader`. Whereas the `ServiceLoader` only loads configurations and instances from one classloader, this loader manages configs found and the related instances for each classloader along the classloader hierarchies individually. It ensures instances are loaded on the classloader level, where they first are visible. Additionally it ensures the same configuration resource (and its declared services) are loaded multiple times, when going up the classloader hierarchy.

  Finally classloaders are not stored by reference by this class, to ensure they still can be garbage collected. Refer also the inherited parent class for further details.

  This class uses an ordinal of `10`, so it overrides any default `ServiceContext` implementations provided with the Tamaya core modules.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CDIAwareServiceContext()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getPriority(Object o)` Checks the given instance for a @Priority annotation.
    `<T> T` | `getService(Class<T> serviceType)`
    `<T> List<T>` | `getServices(Class<T> serviceType)` Loads and registers services.
    `int` | `ordinal()` Returns ordinal of 20, overriding defaults as well as the inherited (internally used) CLAwareServiceContext instance.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CDIAwareServiceContext

          public CDIAwareServiceContext()

  - ### Method Detail

    - #### getService

          public <T> T getService(Class<T> serviceType)

      Specified by:
        `getService` in interface `org.apache.tamaya.spi.ServiceContext`

    - #### getServices

          public <T> List<T> getServices(Class<T> serviceType)

      Loads and registers services.
      Specified by:
        `getServices` in interface `org.apache.tamaya.spi.ServiceContext`
      Type Parameters:
        `T` - the concrete type.
      Parameters:
        `serviceType` - The service type.
      Returns:
        the items found, never `null`.

    - #### getPriority

          public static int getPriority(Object o)

      Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such annotation is present, a default priority is returned (1);
      Parameters:
        `o` - the instance, not null.
      Returns:
        a priority, by default 1.

    - #### ordinal

          public int ordinal()

      Returns ordinal of 20, overriding defaults as well as the inherited (internally used) CLAwareServiceContext instance.
      Specified by:
        `ordinal` in interface `org.apache.tamaya.spi.ServiceContext`
      Returns:
        ordinal of 20.

Copyright © 2014–2016 Apache Software Foundation. All rights reserved.