org.richfaces.application

## Class ServiceTracker

- java.lang.Object
- - org.richfaces.application.ServiceTracker

-     public final class ServiceTracker
      extends Object

  Tracker class to provide access to various framework implementation services. Examples of such services are: `SkinFactory`, TBD.

  This class managess application-scoped service factories that are stored in the map with `Thread.currentThread()` Context classloader as the key. Therefore, there is only one instance per JEE application in the current JVM.

  actuall cal for the service instance delegated to the current factory

  Note: in initial state this class is not synchronized and presumes that all modification operations are done in a context of single-thread (in JSF initialization listener).

  Since:
    4.0
  Author:
    Nick Belaevski

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `getProxy(Class<T> targetService)` Provides proxy which delegates to the given targetService interface once the method is invoked on the targetService.
    `static <T> T` | `getService(Class<T> target)` Get service instance for given type.
    `static <T> T` | `getService(javax.faces.context.FacesContext context, Class<T> target)` Get service instance for given type.
    `static void` | `release()` Release factory service associated with current context.
    `static void` | `setFactory(ServicesFactory factory)` Set service factory implementation for the current context.

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

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

- - ### Method Detail

    - #### getService

          public static <T> T getService(Class<T> target)

      Get service instance for given type. This is a wrapper method for `getService(FacesContext, Class)` that gets faces context by `FacesContext.getCurrentInstance()` call, if needed.

      Type Parameters:
        `T` - The service type, usually interface.
      Parameters:
        `target` - Service type class.
      Returns:
        service implementation instance.

    - #### getService

          public static <T> T getService(javax.faces.context.FacesContext context,
                         Class<T> target)

      Get service instance for given type.

      Type Parameters:
        `T` - The service type, usually interface.
      Parameters:
        `context` - current `FacesContext`.
        `target` - Service type class.
      Returns:
        service instance.

    - #### setFactory

          public static void setFactory(ServicesFactory factory)

      Set service factory implementation for the current context.

      Parameters:
        `factory` -

    - #### release

          public static void release()

      Release factory service associated with current context.

    - #### getProxy

          public static <T> T getProxy(Class<T> targetService)

      Provides proxy which delegates to the given targetService interface once the method is invoked on the targetService.
      Parameters:
        `targetService` - the service to delegate operations to
      Returns:
        proxy which delegates to the given targetService

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.