com.atlassian.spring.container
Class LazyComponentReference<T>

java.lang.Object
  extended by java.lang.ref.Reference<T>
      extended by java.lang.ref.WeakReference<T>
          extended by com.atlassian.util.concurrent.LazyReference<T>
              extended by com.atlassian.spring.container.LazyComponentReference<T>
Type Parameters:
T -
All Implemented Interfaces:
com.atlassian.util.concurrent.Supplier<T>

public class LazyComponentReference<T>
extends com.atlassian.util.concurrent.LazyReference<T>

Lazily loaded reference to a component that is not constructed until required. This class is not an alternative to correctly using dependency injection but is a replacement for the necessary evil of loading components in places such as servlets where all sense of best practices breaks down.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.atlassian.util.concurrent.LazyReference
com.atlassian.util.concurrent.LazyReference.InitializationException
 
Constructor Summary
LazyComponentReference(java.lang.String key)
           
 
Method Summary
protected  T create()
          Calls ContainerManager.getComponent(String)
 
Methods inherited from class com.atlassian.util.concurrent.LazyReference
cancel, get, getInterruptibly, isInitialized
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyComponentReference

public LazyComponentReference(java.lang.String key)
Parameters:
key - of the component
Method Detail

create

protected T create()
            throws java.lang.Exception
Calls ContainerManager.getComponent(String)

Specified by:
create in class com.atlassian.util.concurrent.LazyReference<T>
Returns:
component
Throws:
java.lang.IllegalStateException - if container is not yet setup
java.lang.Exception


Copyright © 2006-2011 Atlassian. All Rights Reserved.