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.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator.java

private ViewPropertyObjectAnimator(View view) {
    mView = new WeakReference<View>(view);
}

From source file:com.fatelon.partyphotobooth.setup.fragments.ShareServicesSetupFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mCallbacks = new WeakReference<ShareServicesSetupFragment.ICallbacks>(
            (ShareServicesSetupFragment.ICallbacks) activity);
}

From source file:ch.entwine.weblounge.common.impl.content.image.ImageContentReader.java

/**
 * Creates a new file content reader that will parse serialized XML version of
 * the file content and store it in the/*w w w  .j av  a  2s .c  om*/
 * {@link ch.entwine.weblounge.common.content.ResourceContent} that is
 * returned by the {@link #read} method.
 * 
 * @throws ParserConfigurationException
 *           if the SAX parser setup failed
 * @throws SAXException
 *           if an error occurs while parsing
 * 
 * @see #createFromXml(InputStream)
 */
public ImageContentReader() throws ParserConfigurationException, SAXException {
    parserRef = new WeakReference<SAXParser>(parserFactory.newSAXParser());
}

From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.java

public BaseHttpResponse(ExtendedHttpMethod httpMethod, AbstractHttpRequestInterface<?> httpRequest,
        PropertyExpansionContext context) {
    this.httpRequest = new WeakReference<AbstractHttpRequestInterface<?>>(httpRequest);
    this.timeTaken = httpMethod.getTimeTaken();

    method = httpMethod.getMethod();//from w w w  .j a v  a 2s .com
    version = httpMethod.getParams().getVersion().toString();
    try {
        this.url = new URL(httpMethod.getURI().toString());
    } catch (Exception e1) {
        SoapUI.logError(e1);
    }

    if (!httpMethod.isFailed()) {
        Settings settings = httpRequest.getSettings();
        if (settings.getBoolean(HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN)) {
            try {
                httpMethod.getResponseBody();
            } catch (IOException e) {
                e.printStackTrace();
            }
            timeTaken += httpMethod.getResponseReadTime();
        }

        try {
            this.timestamp = System.currentTimeMillis();
            this.contentType = httpMethod.getResponseContentType();

            if (httpMethod.hasResponse()) {
                this.statusCode = httpMethod.getStatusCode();
                this.sslInfo = httpMethod.getSSLInfo();
            }

            this.url = new URL(httpMethod.getURI().toString());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    if (httpRequest instanceof TestRequest) {
        TestCase tc = ((TestRequest) httpRequest).getTestStep().getTestCase();
        if (tc instanceof WsdlTestCase && ((WsdlTestCase) tc).isForLoadTest()) {
            initHeadersForLoadTest(httpMethod);
            return;
        }
    }

    initHeaders(httpMethod);
    if (this.httpRequest.get() instanceof HttpRequest) {
        downloadIncludedResources = ((HttpRequest) this.httpRequest.get()).getDownloadIncludedResources();
        if (downloadIncludedResources) {
            long before = (new Date()).getTime();
            addIncludedContentsAsAttachments();
            long after = (new Date()).getTime();
            timeTaken += (after - before);
            context.setProperty(HTMLPageSourceDownloader.MISSING_RESOURCES_LIST,
                    downloader.getMissingResourcesList());
        }
    }
}

From source file:com.fatelon.partyphotobooth.fragments.NoticeFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mCallbacks = new WeakReference<NoticeFragment.ICallbacks>((NoticeFragment.ICallbacks) activity);
}

From source file:com.dubsar_dictionary.Dubsar.model.Sense.java

/**
 * Constructor for senses in word parsing
 * @param id a sense ID// ww  w  .jav a 2 s  .  c o  m
 * @param gloss the associated synset's gloss
 * @param synonyms a list of Sense objects belonging to the same synset
 * @param word the associated word
 */
public Sense(int id, String gloss, List<Sense> synonyms, Word word) {
    super(word.getPartOfSpeech());
    mId = id;
    mGloss = new String(gloss);
    mSynonyms = new ArrayList<Sense>(synonyms);

    mIsWeakWordReference = true;
    mWordReference = new WeakReference<Word>(word);

    mName = new String(getWord().getName());

    setupUrl();
}

From source file:com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.java

/**
 * Creates a new instance.//from   w ww  .  ja v a  2  s .  co  m
 *
 * @param window the window associated with the new job manager
 */
JavaScriptJobManagerImpl(final WebWindow window) {
    window_ = new WeakReference<>(window);
}

From source file:com.digium.respokesdk.RespokeDirectConnection.java

/**
 *  Set a receiver for the Listener interface
 *
 *  @param listener  The new receiver for events from the Listener interface for this instance
 *///  w w  w.j  a  v a 2s  . c  o m
public void setListener(Listener listener) {
    if (null != listener) {
        listenerReference = new WeakReference<Listener>(listener);
    } else {
        listenerReference = null;
    }
}

From source file:org.brekka.stillingar.spring.pc.ConstructorArgDefChangeListener.java

/**
 * @param beanName//from ww w .j a  va2  s .com
 *            The name of the bean that will be used to lookup its bean definition in the beanFactory.
 * @param constructorArgIndex
 *            The index of this constructor argument (may be null).
 * @param constructorArgType
 *            The type of the constructor argument.
 * @param beanFactory
 *            Bean factory to lookup the bean definition in.
 * @param fragment
 *            the fragment that will be used to evaluate and obtain the value which will be passed to
 *            {@link #onChange(String)}
 */
public ConstructorArgDefChangeListener(String beanName, Integer constructorArgIndex, String constructorArgType,
        ConfigurableListableBeanFactory beanFactory, Fragment fragment) {
    super(fragment);
    this.beanName = beanName;
    this.constructorArgIndex = constructorArgIndex;
    this.constructorArgType = constructorArgType;
    this.beanFactoryRef = new WeakReference<ConfigurableListableBeanFactory>(beanFactory);
}

From source file:com.rapidminer.gui.viewer.metadata.model.AbstractAttributeStatisticsModel.java

/**
 * Inits the//from www  . j a va 2 s . co m
 * 
 * @param exampleSet
 * @param attribute
 */
protected AbstractAttributeStatisticsModel(final ExampleSet exampleSet, final Attribute attribute) {
    this.attribute = attribute;
    this.weakExampleSet = new WeakReference<>(exampleSet);
    this.specialAttName = exampleSet.getAttributes().findRoleByName(attribute.getName()).getSpecialName();
    this.construction = attribute.getConstruction();

    this.eventListener = new EventListenerList();
}