Example usage for java.lang.ref WeakReference WeakReference

List of usage examples for java.lang.ref WeakReference WeakReference

Introduction

In this page you can find the example usage for java.lang.ref WeakReference WeakReference.

Prototype

public WeakReference(T referent) 

Source Link

Document

Creates a new weak reference that refers to the given object.

Usage

From source file:io.fabric8.karaf.core.Support.java

public static StringBuilder acquireStringBuilder() {
    WeakReference<StringBuilder> ref = SBPOOL.get();
    StringBuilder sb = null;//  w ww .j  a  v  a2  s  .  c o m

    if (ref != null) {
        sb = ref.get();
    }

    if (sb == null) {
        sb = new StringBuilder(1024);
        SBPOOL.set(new WeakReference<>(sb));
    }

    return sb;
}

From source file:com.booksaround.me.title.util.listener.BaseClickListener.java

public BaseClickListener(T fragment) {
    this.fragmentRef = new WeakReference<T>(fragment);
}

From source file:nl.tjonahen.javaee7.cdi.springbridge.springsupport.ApplicationContextLocatorImpl.java

/**
 *
 * @param context the application context to be associated with the current classloader.
 *///from   w ww . j  av a2s.  c o m
public static void putContext(ApplicationContext context) {
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    MAP.put(contextClassLoader, new WeakReference<ApplicationContext>(context));
}

From source file:com.halzhang.android.apps.startupnews.ui.SNApiHelper.java

public SNApiHelper(Activity activity) {
    mActivityRef = new WeakReference<Activity>(activity);
}

From source file:io.github.moosbusch.lumpi.application.event.impl.ApplicationWindowLoadedEvent.java

public ApplicationWindowLoadedEvent(ApplicationContext source) {
    super(new WeakReference<>(source));
}

From source file:com.nhn.android.archetype.base.AABaseApplicationOrg.java

public static void addActivity(BaseApplicationListener activity) {
    activityList.add(new WeakReference<BaseApplicationListener>(activity));
}

From source file:com.almende.eve.instantiation.HibernationHandler.java

/**
 * Instantiates a new wake handler./*from  w w w.  j a  v  a 2 s. co  m*/
 * 
 * @param referent
 *            the referent
 * @param wakeKey
 *            the wake key
 * @param service
 *            the wake service where this referent is registered.
 */
public HibernationHandler(final T referent, final String wakeKey, final InstantiationService service) {
    this.referent = new WeakReference<T>(referent);
    this.setWakeKey(wakeKey);
    this.service = service;
}

From source file:io.github.moosbusch.lumpi.gui.impl.SelectionAdapter.java

public SelectionAdapter(Component eventSource, T value, String expr) {
    this.eventSourceRef = new WeakReference<>(Objects.requireNonNull(eventSource));
    this.data = new Dictionary.Pair<>(new Expression(expr), new WeakReference<>(Objects.requireNonNull(value)));
}

From source file:de.incoherent.osaac.tasks.LoadHolidaysTask.java

public LoadHolidaysTask(MainActivity activity) {
    mActivity = new WeakReference<MainActivity>(activity);
    this.mDb = new Database(mActivity.get());
    mDb.open();//from   w  w w .ja  v a 2s  .c o m
    mDialog = ProgressDialog.show(mActivity.get(), "", "Importing holidays, please wait...", true);
}

From source file:com.parse.GCMService.java

GCMService(Service parent) {
    this.parent = new WeakReference<>(parent);
}