throw new IllegalStateException("No Scope registered for scope name '" + mbd.getScope() + "'"); scope.registerDestructionCallback(beanName, new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), acc));
@Override public void destroyScopedBean(String beanName) { RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); if (mbd.isSingleton() || mbd.isPrototype()) { throw new IllegalArgumentException( "Bean name '" + beanName + "' does not correspond to an object in a mutable scope"); } String scopeName = mbd.getScope(); Scope scope = this.scopes.get(scopeName); if (scope == null) { throw new IllegalStateException("No Scope SPI registered for scope name '" + scopeName + "'"); } Object bean = scope.remove(beanName); if (bean != null) { destroyBean(beanName, bean, mbd); } }
Object scopedInstance = scope.get(beanName, () -> { beforePrototypeCreation(beanName); try {
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
/** @see org.springframework.web.context.request.SessionScope#getConversationId() */ @Override public String getConversationId() { try { return this.delegateScope.getConversationId(); } catch (IllegalStateException ise) { return "NO_SESSION_SINGLETON"; } }
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
@Override public String getConversationId() { return getCurrectScope().getConversationId(); }
@Override public void destroyScopedBean(String beanName) { RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); if (mbd.isSingleton() || mbd.isPrototype()) { throw new IllegalArgumentException( "Bean name '" + beanName + "' does not correspond to an object in a mutable scope"); } String scopeName = mbd.getScope(); Scope scope = this.scopes.get(scopeName); if (scope == null) { throw new IllegalStateException("No Scope SPI registered for scope name '" + scopeName + "'"); } Object bean = scope.remove(beanName); if (bean != null) { destroyBean(beanName, bean, mbd); } }
throw new IllegalStateException("No Scope registered for scope name '" + mbd.getScope() + "'"); scope.registerDestructionCallback(beanName, new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), acc));
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
Object scopedInstance = scope.get(beanName, () -> { beforePrototypeCreation(beanName); try {
assertSame(bean2a, context.getBean(DerivedTestBean.class)); assertNotSame(bean2, bean2a); context.getBeanFactory().getRegisteredScope("tx").remove("txScopedObject2"); assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); assertFalse(bean2a.wasDestroyed());
throw new IllegalStateException("No Scope registered for scope '" + mbd.getScope() + "'"); scope.registerDestructionCallback(beanName, new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), acc));
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() { public Object getObject() throws BeansException { beforePrototypeCreation(beanName);
public void destroyScopedBean(String beanName) { RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); if (mbd.isSingleton() || mbd.isPrototype()) { throw new IllegalArgumentException( "Bean name '" + beanName + "' does not correspond to an object in a mutable scope"); } String scopeName = mbd.getScope(); Scope scope = this.scopes.get(scopeName); if (scope == null) { throw new IllegalStateException("No Scope SPI registered for scope '" + scopeName + "'"); } Object bean = scope.remove(beanName); if (bean != null) { destroyBean(beanName, bean, mbd); } }
@Override public void registerDestructionCallback(final String name, final Runnable callback) { getCurrectScope().registerDestructionCallback(name, callback); }
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
@Override public Object get(final String name, final ObjectFactory<?> objectFactory) { final Scope currectScope = getCurrectScope(); if (currectScope == null) { logger.warn("Using bean {} without scope in stateful service. Assuming stateless call."); return objectFactory.getObject(); } return currectScope.get(name, objectFactory); }
assertSame(bean2a, context.getBean(DerivedTestBean.class)); assertNotSame(bean2, bean2a); context.getBeanFactory().getRegisteredScope("tx").remove("txScopedObject2"); assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); assertFalse(bean2a.wasDestroyed());