List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:br.com.anteros.social.linkedin.AnterosLinkedInSession.java
public AnterosLinkedInSession(AnterosLinkedInConfiguration configuration) { setActivity(configuration.getActivity()); this.onLoginListener = new WeakReference<>(configuration.getOnLoginListener()); this.onLogoutListener = new WeakReference<>(configuration.getOnLogoutListener()); }
From source file:br.com.anteros.social.google.AnterosGoogleSession.java
public AnterosGoogleSession(AnterosGoogleConfiguration configuration) { this.configuration = configuration; this.onLoginListener = new WeakReference<OnLoginListener>(configuration.getOnLoginListener()); this.onLogoutListener = new WeakReference<OnLogoutListener>(configuration.getOnLogoutListener()); setActivity(configuration.getActivity()); }
From source file:com.digium.respokesdk.RespokeEndpoint.java
/** * The constructor for this class//from w w w . j av a2 s . c o m * * @param channel The signaling channel managing communications with this endpoint * @param newEndpointID The ID for this endpoint * @param client The client to which this endpoint instance belongs */ public RespokeEndpoint(RespokeSignalingChannel channel, String newEndpointID, RespokeClient client) { endpointID = newEndpointID; signalingChannel = channel; connections = new ArrayList<RespokeConnection>(); clientReference = new WeakReference<RespokeClient>(client); }
From source file:org.cloudfoundry.tools.timeout.TimeoutResourceHttpRequestHandler.java
private String getContent(Resource resource) throws IOException { WeakReference<String> contentReference = this.cache.get(resource); String content = contentReference == null ? null : contentReference.get(); if (content == null) { Assert.notNull(this.timeoutValues, "TimeoutValues must not be null"); content = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream())); content = content.replace("{polltimeout}", String.valueOf(this.timeoutValues.getThreshold() + ONE_SECOND)); content = content.replace("{failtimeout}", String.valueOf(this.timeoutValues.getFailTimeout())); this.cache.put(resource, new WeakReference<String>(content)); }//from ww w . j a v a2 s .c om return content; }
From source file:com.android.tabcarouseldemo.PagerAdapter.java
/** * {@inheritDoc}/* w w w . j av a 2 s . c o m*/ */ @Override public Object instantiateItem(ViewGroup container, int position) { final Fragment fragment = (Fragment) super.instantiateItem(container, position); final WeakReference<Fragment> weakFragment = mFragmentArray.get(position); if (weakFragment != null) { weakFragment.clear(); } mFragmentArray.put(position, new WeakReference<Fragment>(fragment)); return fragment; }
From source file:com.gh.bmd.jrt.android.v4.core.DefaultInvocationContextChannelBuilder.java
/** * Constructor./*from w w w . j av a2 s . c o m*/ * * @param context the context instance. * @param invocationId the invocation ID. * @throws java.lang.NullPointerException if the context is null. */ @SuppressWarnings("ConstantConditions") private DefaultInvocationContextChannelBuilder(@Nonnull final Object context, final int invocationId) { if (context == null) { throw new NullPointerException("the channel context must not be null"); } mContext = new WeakReference<Object>(context); mInvocationId = invocationId; }
From source file:org.agatom.springatom.data.oid.creators.PersistableSOidCreator.java
@Override @SuppressWarnings("unchecked") protected SOid getOidObject(final String oidPrefix, final Class<?> oidClass, final String oidId) { final SRepository<?> repositoryFor = (SRepository<?>) this.repositoriesHelper.getRepositoryFor(oidClass); final Object one = repositoryFor.findOne(Long.valueOf(oidId)); return new PersistableOid().setReference(new WeakReference<Persistable<?>>((Persistable<?>) one)) .setObjectPrefix(oidPrefix).setObjectClass((Class<Persistable<?>>) oidClass) .setObjectId(Long.valueOf(oidId)); }
From source file:com.obidea.semantika.app.DefaultSettingFactory.java
@Override /* package *///from w ww .j a va 2 s. c o m void loadDatabaseFromProperties(PropertiesConfiguration properties, Settings settings) throws SemantikaException { try { /* * Register the Connection object as a weak reference to ease garbage collection. This * connection is used to fetch database metadata on-demand when parsing the mappings. Manual * connection closing is not feasible. */ IConnectionProvider provider = createConnectionProvider(properties); WeakReference<Connection> weakConnection = new WeakReference<Connection>(provider.getConnection()); JdbcDatabase database = new JdbcDatabase(weakConnection.get()); database.setDialect(determineDialect(properties, weakConnection.get())); settings.setDatabase(database); settings.setConnectionProvider(provider); } catch (SQLException e) { throw new SemantikaException("Exception occurred when initializing database object", e); //$NON-NLS-1$ } }
From source file:io.kristal.pubsubplugin.PubSubReceiver.java
/** * Creates and return a PubSubReceiver for the specified CobaltFragment registered to no channel. * @param fragment the CobaltFragment containing the WebView to which send messages. *//*from w ww .ja v a2 s . c o m*/ public PubSubReceiver(CobaltFragment fragment) { fragmentReference = new WeakReference<CobaltFragment>(fragment); callbackForChannel = new SimpleArrayMap<>(); }
From source file:com.bilibili.magicasakura.utils.TintManager.java
private TintManager(Context context) { mContextRef = new WeakReference<>(context); }