ro.isdc.wro.util
Class LazyInitializer<T>

java.lang.Object
  extended by ro.isdc.wro.util.LazyInitializer<T>
Direct Known Subclasses:
DestroyableLazyInitializer

public abstract class LazyInitializer<T>
extends Object

A clone of LazyInitializer, which doesn't throw any checked exception when get method is invoked.

Since:
1.4.6
Author:
Alex Objelean

Field Summary
protected  T object
          Stores the managed object.
 
Constructor Summary
LazyInitializer()
           
 
Method Summary
 T get()
          Returns the object wrapped by this instance.
protected abstract  T initialize()
          Creates and initializes the object managed by this LazyInitializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

object

protected volatile T object
Stores the managed object.

Constructor Detail

LazyInitializer

public LazyInitializer()
Method Detail

get

public final T get()
Returns the object wrapped by this instance. On first access the object is created. After that it is cached and can be accessed pretty fast.

Returns:
the object initialized by this LazyInitializer the object

initialize

protected abstract T initialize()
Creates and initializes the object managed by this LazyInitializer. This method is called by get() when the object is accessed for the first time. An implementation can focus on the creation of the object. No synchronization is needed, as this is already handled by get().

Returns:
the managed data object


Copyright © 2008-2013. All Rights Reserved.