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:com.nagopy.android.xposed.SettingChangedReceiver.java

protected SettingChangedReceiver(Object dataObject, String action) {
    this.dataObject = new WeakReference<Object>(dataObject);
    this.action = action;
}

From source file:de.sevenpass.sample.AuthStateManager.java

@AnyThread
public static AuthStateManager getInstance(@NonNull Context context) {
    AuthStateManager manager = INSTANCE_REF.get().get();
    if (manager == null) {
        manager = new AuthStateManager(context.getApplicationContext());
        INSTANCE_REF.set(new WeakReference<>(manager));
    }//from  ww  w .  j  a v  a 2 s  .c  o  m

    return manager;
}

From source file:architecture.ee.util.ApplicationHelper.java

@SuppressWarnings("unchecked")
public static <T> T getComponent(Class<T> requiredType) throws ComponentNotFoundException {
    if (ApplicationHelper.references.get(requiredType) == null) {
        ApplicationHelper.references.put(requiredType, new WeakReference<T>(
                ApplicationHelperFactory.getApplicationHelper().getComponent(requiredType)));
    }/*w w w  .j a  va 2  s.co m*/
    return (T) ApplicationHelper.references.get(requiredType).get();
}

From source file:ac.robinson.paperchains.SoundCloudUrlFetcherTask.java

public SoundCloudUrlFetcherTask(PaperChainsActivity context, ApiWrapper wrapper) {
    mContext = new WeakReference<>(context);
    mWrapper = wrapper;
}

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

/**
 *
 * @return The Spring application context
 *//* ww w .j  av a 2  s  .  com*/
public static ApplicationContext getInstance() {

    final ApplicationContextLocator applicationContextLocator;

    synchronized (MAP) {

        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        final WeakReference<ApplicationContextLocator> weakReference = MAP.get(contextClassLoader);

        if (weakReference == null || weakReference.get() == null) {
            applicationContextLocator = new ApplicationContextLocatorImpl();
            MAP.put(contextClassLoader,
                    new WeakReference<ApplicationContextLocator>(applicationContextLocator));
        } else {
            applicationContextLocator = weakReference.get();
        }
    }
    return applicationContextLocator.locateApplicationContext();
}

From source file:co.paralleluniverse.common.monitoring.Monitor.java

public Monitor(String name, T monitored) {
    this.name = name;
    this.monitored = new WeakReference<T>(monitored);
}

From source file:hu.sztaki.lpds.storage.service.carmen.server.upload.ProgressMonitorFileItemFactory.java

/**
 * Constructor/*from  ww  w. j  a va 2s .  co m*/
 * @param request http request
 */
public ProgressMonitorFileItemFactory(HttpServletRequest request) {
    super();
    temporaryDirectory = (File) request.getSession().getServletContext()
            .getAttribute("javax.servlet.context.tempdir");
    requestRef = new WeakReference(request);
    String contentLength = request.getHeader("content-length");
    if (contentLength != null) {
        requestLength = Long.parseLong(contentLength.trim());
    }
}

From source file:com.liferay.social.task.PortraitAsyncTask.java

public PortraitAsyncTask(Session session, User user, ImageView imageView) {
    _session = session;
    _user = user;
    _imageView = new WeakReference<ImageView>(imageView);
}

From source file:com.mi.xserv.XservBase.java

public XservBase() {
    mDelegate = new WeakReference<>(null);
}

From source file:de.matzefratze123.heavyspleef.core.player.SpleefPlayer.java

public SpleefPlayer(Player bukkitPlayer) {
    this.bukkitPlayerRef = new WeakReference<Player>(bukkitPlayer);
    this.online = bukkitPlayer.isOnline();
    this.playerStates = Maps.newHashMap();
    this.name = bukkitPlayer.getName();
}