@SuppressWarnings("unchecked") @Override public void shutdown() { List<ActiveDescriptor<?>> all = locator.getDescriptors(BuilderHelper.allFilter()); long myLocatorId = locator.getLocatorId(); TreeSet<SystemDescriptor<Object>> singlesOnly = new TreeSet<SystemDescriptor<Object>>( new GenerationComparator()); for (ActiveDescriptor<?> one : all) { if (one.getScope() == null || !one.getScope().equals(Singleton.class.getName())) continue; synchronized (this) { if (one.getCache() == null) continue; } if (one.getLocatorId() == null || one.getLocatorId().longValue() != myLocatorId) continue; SystemDescriptor<Object> oneAsObject = (SystemDescriptor<Object>) one; singlesOnly.add(oneAsObject); } for (SystemDescriptor<Object> one : singlesOnly) { destroyOne(one); } }
@SuppressWarnings("unchecked") @Override public void shutdown() { List<ActiveDescriptor<?>> all = locator.getDescriptors(BuilderHelper.allFilter()); long myLocatorId = locator.getLocatorId(); TreeSet<SystemDescriptor<Object>> singlesOnly = new TreeSet<SystemDescriptor<Object>>( new GenerationComparator()); for (ActiveDescriptor<?> one : all) { if (one.getScope() == null || !one.getScope().equals(Singleton.class.getName())) continue; synchronized (this) { if (one.getCache() == null) continue; } if (one.getLocatorId() == null || one.getLocatorId().longValue() != myLocatorId) continue; SystemDescriptor<Object> oneAsObject = (SystemDescriptor<Object>) one; singlesOnly.add(oneAsObject); } for (SystemDescriptor<Object> one : singlesOnly) { destroyOne(one); } }
@SuppressWarnings("unchecked") @Override public void shutdown() { List<ActiveDescriptor<?>> all = locator.getDescriptors(BuilderHelper.allFilter()); long myLocatorId = locator.getLocatorId(); TreeSet<SystemDescriptor<Object>> singlesOnly = new TreeSet<SystemDescriptor<Object>>( new GenerationComparator()); for (ActiveDescriptor<?> one : all) { if (one.getScope() == null || !one.getScope().equals(Singleton.class.getName())) continue; synchronized (this) { if (one.getCache() == null) continue; } if (one.getLocatorId() == null || one.getLocatorId().longValue() != myLocatorId) continue; SystemDescriptor<Object> oneAsObject = (SystemDescriptor<Object>) one; singlesOnly.add(oneAsObject); } for (SystemDescriptor<Object> one : singlesOnly) { destroyOne(one); } }
@SuppressWarnings("unchecked") @Override public void shutdown() { List<ActiveDescriptor<?>> all = locator.getDescriptors(BuilderHelper.allFilter()); long myLocatorId = locator.getLocatorId(); TreeSet<SystemDescriptor<Object>> singlesOnly = new TreeSet<SystemDescriptor<Object>>( new GenerationComparator()); for (ActiveDescriptor<?> one : all) { if (one.getScope() == null || !one.getScope().equals(Singleton.class.getName())) continue; synchronized (this) { if (one.getCache() == null) continue; } if (one.getLocatorId() == null || one.getLocatorId().longValue() != myLocatorId) continue; SystemDescriptor<Object> oneAsObject = (SystemDescriptor<Object>) one; singlesOnly.add(oneAsObject); } for (SystemDescriptor<Object> one : singlesOnly) { destroyOne(one); } }
@Override public Object compute(ContextualInput<Object> a) { final ActiveDescriptor<Object> activeDescriptor = a.getDescriptor(); final Object cachedVal = activeDescriptor.getCache(); if (cachedVal != null) { return cachedVal; } final Object createdVal = activeDescriptor.create(a.getRoot()); activeDescriptor.setCache(createdVal); if (activeDescriptor instanceof SystemDescriptor) { ((SystemDescriptor<?>) activeDescriptor).setSingletonGeneration(generationNumber++); } return createdVal; } }, new Cache.CycleHandler<ContextualInput<Object>>(){
@Override public Object compute(ContextualInput<Object> a) { final ActiveDescriptor<Object> activeDescriptor = a.getDescriptor(); final Object cachedVal = activeDescriptor.getCache(); if (cachedVal != null) { return cachedVal; } final Object createdVal = activeDescriptor.create(a.getRoot()); activeDescriptor.setCache(createdVal); if (activeDescriptor instanceof SystemDescriptor) { ((SystemDescriptor<?>) activeDescriptor).setSingletonGeneration(generationNumber++); } return createdVal; } }, new Cache.CycleHandler<ContextualInput<Object>>(){
@Override public Object compute(ContextualInput<Object> a) { final ActiveDescriptor<Object> activeDescriptor = a.getDescriptor(); final Object cachedVal = activeDescriptor.getCache(); if (cachedVal != null) { return cachedVal; } final Object createdVal = activeDescriptor.create(a.getRoot()); activeDescriptor.setCache(createdVal); if (activeDescriptor instanceof SystemDescriptor) { ((SystemDescriptor<?>) activeDescriptor).setSingletonGeneration(generationNumber++); } return createdVal; } }, new Cache.CycleHandler<ContextualInput<Object>>(){
@Override public Object compute(ContextualInput<Object> a) { final ActiveDescriptor<Object> activeDescriptor = a.getDescriptor(); final Object cachedVal = activeDescriptor.getCache(); if (cachedVal != null) { return cachedVal; } final Object createdVal = activeDescriptor.create(a.getRoot()); activeDescriptor.setCache(createdVal); if (activeDescriptor instanceof SystemDescriptor) { ((SystemDescriptor<?>) activeDescriptor).setSingletonGeneration(generationNumber++); } return createdVal; } }, new Cache.CycleHandler<ContextualInput<Object>>(){
/** * Release one system descriptor * * @param one The descriptor to release (may not be null). Further, the cache MUST be set */ @SuppressWarnings("unchecked") @Override public void destroyOne(ActiveDescriptor<?> one) { Object value; valueCache.remove(new ContextualInput<Object>((ActiveDescriptor<Object>) one, null)); value = one.getCache(); one.releaseCache(); if (value == null) return; try { ((ActiveDescriptor<Object>) one).dispose(value); } catch (Throwable th) { Logger.getLogger().debug("SingletonContext", "releaseOne", th); } }
/** * Release one system descriptor * * @param one The descriptor to release (may not be null). Further, the cache MUST be set */ @SuppressWarnings("unchecked") @Override public void destroyOne(ActiveDescriptor<?> one) { Object value; valueCache.remove(new ContextualInput<Object>((ActiveDescriptor<Object>) one, null)); value = one.getCache(); one.releaseCache(); if (value == null) return; try { ((ActiveDescriptor<Object>) one).dispose(value); } catch (Throwable th) { Logger.getLogger().debug("SingletonContext", "releaseOne", th); } }
/** * Release one system descriptor * * @param one The descriptor to release (may not be null). Further, the cache MUST be set */ @SuppressWarnings("unchecked") @Override public void destroyOne(ActiveDescriptor<?> one) { Object value; valueCache.remove(new ContextualInput<Object>((ActiveDescriptor<Object>) one, null)); value = one.getCache(); one.releaseCache(); if (value == null) return; try { ((ActiveDescriptor<Object>) one).dispose(value); } catch (Throwable th) { Logger.getLogger().debug("SingletonContext", "releaseOne", th); } }
/** * Release one system descriptor * * @param one The descriptor to release (may not be null). Further, the cache MUST be set */ @SuppressWarnings("unchecked") @Override public void destroyOne(ActiveDescriptor<?> one) { Object value; valueCache.remove(new ContextualInput<Object>((ActiveDescriptor<Object>) one, null)); value = one.getCache(); one.releaseCache(); if (value == null) return; try { ((ActiveDescriptor<Object>) one).dispose(value); } catch (Throwable th) { Logger.getLogger().debug("SingletonContext", "releaseOne", th); } }