/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public final synchronized Lookup getLookup() { if (lookup == null) { lookup = createLookup(); } return lookup; }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public <T> T as (final @Nonnull Class<T> type) { return as(type, As.Defaults.throwAsException(type)); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override @Nonnull public String toString() { return childrenPM.isEmpty() ? super.toString() : String.format("%s@%x[%d children]", getClass().getSimpleName(), System.identityHashCode(this), childrenPM.size()); }
result = getLookup().lookup(type); result = getLookup().lookup(type); log.trace(">>>> {}.as({}) took {} msec.", new Object[]{ toShortString(), type.getSimpleName(), System.currentTimeMillis() - time });
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull protected Lookup createLookup() { final long time = System.currentTimeMillis(); Lookup result = LookupFactory.createLookup(owner, Lookups.fixed(instanceCapabilities)); if (threadLocalLookup != null) { result = LookupFactory.createLookup(threadLocalLookup, this, result); threadLocalLookup = null; } log.trace(">>>> createLookup() - for {} took {} msec.", toShortString(), System.currentTimeMillis() - time); return result; }
@Override public void onCreate() { super.onCreate(); try { AsLookupSupport.setUseCache(true); // This trick was an old one for setting mock Lookups in tests, but works well here. final Field defaultLookup = Lookup.class.getDeclaredField("defaultLookup"); defaultLookup.setAccessible(true); final BlueBillLookup blueBillLookup = new BlueBillLookup(); blueBillLookup.setContext(this); defaultLookup.set(null, blueBillLookup); ((AndroidSmartAssetManager)Locator.find(SmartAssetManager.class)).setVersion(2); } catch (Exception e) { throw new RuntimeException(e); } } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override @Nonnull protected Lookup createLookup() { return (composite == null) ? super.createLookup() : new ProxyLookup(Lookups.fixed(composite), super.createLookup()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override @Nonnull protected Lookup createLookup() { return (capabilities.length == 0) ? super.createLookup() : new ProxyLookup(Lookups.fixed(capabilities), super.createLookup()); } }
@Override @Nonnull protected Lookup createLookup() { final Lookup superLookup = super.createLookup(); Composite<?, ?> delegateComposite = superLookup.lookup(Composite.class); if (delegateComposite == null) { delegateComposite = Composite.DEFAULT; } composite = new PresentationModelComposite(delegateComposite); return new ProxyLookup(Lookups.fixed(composite), superLookup); } }