Package org.apache.tapestry5.ioc

## Interface ServiceBinder

- All Known Implementing Classes:
    `ServiceBinderImpl`

      public interface ServiceBinder

  Allows a module to bind service interfaces to service implementation classes in support of autobuilding services. A ServiceBinder is passed to to a method with the following signature: `public static void bind(ServiceBinder binder)`. This is an adaptation of ideas from Guice.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<T> ServiceBindingOptions` | `bind​(java.lang.Class<T> interfaceClassOrImplementationClass)` | Binds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.
    `<T> ServiceBindingOptions` | `bind​(java.lang.Class<T> serviceInterface, java.lang.Class<? extends T> serviceImplementation)` | Binds the service interface to a service implementation class.
    `<T> ServiceBindingOptions` | `bind​(java.lang.Class<T> serviceInterface, ServiceBuilder<T> builder)` | Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.

- - ### Method Detail

    - #### bind

          <T> ServiceBindingOptions bind​(java.lang.Class<T> interfaceClassOrImplementationClass)

      Binds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.

      The conventional name for the service implementation class is the same as the name of the service interface with "Impl" appended. For example, `bind(Service.class)` will implicitly attempt to bind to `ServiceImpl.class`. Use `bind(Class, Class)` if the name of the service implementation class does not follow the convention.

      In case the service is defined through the implementation class, the service will not be proxiable (proxying requires a service interface) and `ServiceDef.getServiceInterface()` will return the implementation class. In this situation, the service will not be proxied; it will be instantiated fully on first reference (ignoring its scope, if any) and will not be decorated.

      Type Parameters:
        `T` -
      Parameters:
        `interfaceClassOrImplementationClass` - service interface class to bind implicitly or implementation class to instantiate as the service
      Returns:
        binding options, used to specify additional details about the service
      See Also:
        `bind(Class, Class)`

    - #### bind

          <T> ServiceBindingOptions bind​(java.lang.Class<T> serviceInterface,
                                         ServiceBuilder<T> builder)

      Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.
      Parameters:
        `serviceInterface` - interface implemented by the service
        `builder` - constructs the core service implementation
      Returns:
        binding options, used to specify additional details about the service

    - #### bind

          <T> ServiceBindingOptions bind​(java.lang.Class<T> serviceInterface,
                                         java.lang.Class<? extends T> serviceImplementation)

      Binds the service interface to a service implementation class. The default service name is the unqualified name of the service interface. The default service scope is "singleton", unless the service implementation class includes the `Scope` annotation.

      The service implementation class may be omitted (in other words, `bind(Class)` used instead) if the name of the service implementation class is the same as the name of the service interface with "Impl" appended.

      Type Parameters:
        `T` -
      Parameters:
        `serviceInterface` - service interface (used when locating services, and when building proxies)
        `serviceImplementation` - implementation class that implements the service interface
      Returns:
        binding options, used to specify additional details about the service
      See Also:
        `bind(Class)`