edu.utah.further.core.api.context
Class Bordello

java.lang.Object
  extended by edu.utah.further.core.api.context.Bordello

Deprecated.

@Utility
@Api
@Deprecated
public final class Bordello
extends Object

A provider of services that implements the generic service locator pattern. Service implementations are assumed to have a public no-argument constructor.

Personally, I feel this approach is inferior to DI, except perhaps in case of injecting services into domain entities. In that case, using a static Bordello method in contrast to Spring's Configurable annotation may be simpler, as it does not require any start-up initialization overhead of the Spring framework, and does not require a JVM javaagent that may be needed to be reserved for something else (e.g. performance testing agents). On the other hand, Bordello has many disadvantages, e.g. the default implementation must be declared in a maven API module rather than hidden from clients in a maven implementation module.

In sum, use Bordello for simple DI cases. It will be faster than LTW. Use LTW with Configurable to minimize dependencies between API and implementation modules, and when performance is not super-critical. -----------------------------------------------------------------------------------
(c) 2008-2011 FURTHeR Project, AVP Health Sciences IT Office, University of Utah
Contact: Dr. Scott Narus <scott.narus@hsc.utah.edu>
Biomedical Informatics, 26 South 2000 East
Room 5775 HSEB, Salt Lake City, UT 84112
Day Phone: 1-801-213-3288
-----------------------------------------------------------------------------------

Version:
Feb 13, 2009
Author:
Oren E. Livne <oren.livne@utah.edu>
See Also:
http://www.artima.com/weblogs/viewpost.jsp?thread=238562

Method Summary
static
<T> T
getService(Class<T> interfaceClass)
          Deprecated. Acquire an implementation of a service.
static
<T> void
setService(Class<T> interfaceClass, T provider)
          Deprecated. Set an alternate service implementation.
 
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> interfaceClass)
Deprecated. 
Acquire an implementation of a service. If one has not already been instantiated, instantiate the class defined by the Implementor annotation on the interface

Type Parameters:
T - service interface type
Parameters:
interfaceClass - service interface class
Returns:
service implementation instance

setService

public static <T> void setService(Class<T> interfaceClass,
                                  T provider)
Deprecated. 
Set an alternate service implementation. Typically only called in unit tests.

Type Parameters:
T - service interface type
Parameters:
interfaceClass - service interface class
provider - service implementation class to set as the one returned from getService(Class).


Copyright © 2011 Office of the AVP for Health Sci. IT. All Rights Reserved.