/** * Releases any resources held by this state. * * @param permanent * is the state being destroyed forever, i.e. should persisted values be removed? On server shutdown, * this value would be <code>false</code>, whereas on the removal of a dynamically created instance, * this value would be <code>true</code>. */ public void destroy(boolean permanent) { // Cascade the destroy / shutdown for (Map<String, CompositeDataBean> beans : this.compositeProperties.values()) { for (CompositeDataBean bean : beans.values()) { bean.lock.writeLock().lock(); try { bean.destroy(permanent); } finally { bean.lock.writeLock().unlock(); } } } }
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ListFactoryBean && ChildApplicationContextFactory.this.compositePropertyTypes.containsKey(beanName)) { Map<String, CompositeDataBean> beans = ChildApplicationContext.this.compositeProperties .get(beanName); List<Object> beanList; if (beans != null) { beanList = new ArrayList<Object>(beans.size()); for (CompositeDataBean wrapped : beans.values()) { beanList.add(wrapped.getBean()); } } else { beanList = Collections.emptyList(); } ((ListFactoryBean) bean).setSourceList(beanList); } return bean; } });
/** * Instantiates a new composite data bean state. */ protected CompositeDataBeanState() { try { this.bean = CompositeDataBean.this.type.newInstance(); // Tell the bean its name if it cares if (this.bean instanceof BeanNameAware) { ((BeanNameAware) this.bean).setBeanName(getId().get(getId().size() - 1)); } this.wrappedBean = new BeanWrapperImpl(this.bean); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
Properties propertyDefaults, String category, Class<?> type, List<String> instancePath) throws IOException setApplicationContext(parent); setRegistry(registry); setPropertyDefaults(propertyDefaults); setCategory(category); setInstancePath(instancePath); this.owner = owner; this.type = type; afterPropertiesSet();
child = new CompositeDataBean(getParent(), ChildApplicationContextFactory.this, getRegistry(), getPropertyDefaults(), getCategory(), type, childPath); try child.destroy(true);
/** * Gets the wrapped Java bean. * * @return the Java bean */ protected Object getBean() { this.lock.readLock().lock(); try { return ((CompositeDataBeanState) getState(true)).getBean(); } finally { this.lock.readLock().unlock(); } }
@Override public void afterPropertiesSet() throws Exception { // Derive a default and instance key prefix of the form "<parent>.default." and "<parent>.value.<this>." StringBuilder defaultKeyPrefixBuff = new StringBuilder(200); StringBuilder instanceKeyPrefixBuff = new StringBuilder(200); List<String> id = getInstancePath(); int size = id.size(); if (size > 1) { defaultKeyPrefixBuff.append(id.get(size - 2)).append('.'); instanceKeyPrefixBuff.append(defaultKeyPrefixBuff); } defaultKeyPrefixBuff.append("default."); instanceKeyPrefixBuff.append("value.").append(id.get(size - 1)).append('.'); this.defaultKeyPrefix = defaultKeyPrefixBuff.toString(); this.instanceKeyPrefix = instanceKeyPrefixBuff.toString(); // Set initial values according to property defaults. super.afterPropertiesSet(); }
Properties propertyDefaults, String category, Class<?> type, List<String> instancePath) throws IOException setApplicationContext(parent); setRegistry(registry); setPropertyDefaults(propertyDefaults); setCategory(category); setInstancePath(instancePath); this.owner = owner; this.type = type; afterPropertiesSet();
child = new CompositeDataBean(getParent(), ChildApplicationContextFactory.this, getRegistry(), getPropertyDefaults(), getCategory(), type, childPath); try child.destroy(true);
/** * Gets the wrapped Java bean. * * @return the Java bean */ protected Object getBean() { this.lock.readLock().lock(); try { return ((CompositeDataBeanState) getState(true)).getBean(); } finally { this.lock.readLock().unlock(); } }
@Override public void afterPropertiesSet() throws Exception { // Derive a default and instance key prefix of the form "<parent>.default." and "<parent>.value.<this>." StringBuilder defaultKeyPrefixBuff = new StringBuilder(200); StringBuilder instanceKeyPrefixBuff = new StringBuilder(200); List<String> id = getInstancePath(); int size = id.size(); if (size > 1) { defaultKeyPrefixBuff.append(id.get(size - 2)).append('.'); instanceKeyPrefixBuff.append(defaultKeyPrefixBuff); } defaultKeyPrefixBuff.append("default."); instanceKeyPrefixBuff.append("value.").append(id.get(size - 1)).append('.'); this.defaultKeyPrefix = defaultKeyPrefixBuff.toString(); this.instanceKeyPrefix = instanceKeyPrefixBuff.toString(); // Set initial values according to property defaults. super.afterPropertiesSet(); }
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ListFactoryBean && ChildApplicationContextFactory.this.compositePropertyTypes.containsKey(beanName)) { Map<String, CompositeDataBean> beans = ChildApplicationContext.this.compositeProperties .get(beanName); List<Object> beanList; if (beans != null) { beanList = new ArrayList<Object>(beans.size()); for (CompositeDataBean wrapped : beans.values()) { beanList.add(wrapped.getBean()); } } else { beanList = Collections.emptyList(); } ((ListFactoryBean) bean).setSourceList(beanList); } return bean; } });
/** * Instantiates a new composite data bean state. */ protected CompositeDataBeanState() { try { this.bean = CompositeDataBean.this.type.newInstance(); // Tell the bean its name if it cares if (this.bean instanceof BeanNameAware) { ((BeanNameAware) this.bean).setBeanName(getId().get(getId().size() - 1)); } this.wrappedBean = new BeanWrapperImpl(this.bean); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Releases any resources held by this state. * * @param permanent * is the state being destroyed forever, i.e. should persisted values be removed? On server shutdown, * this value would be <code>false</code>, whereas on the removal of a dynamically created instance, * this value would be <code>true</code>. */ public void destroy(boolean permanent) { // Cascade the destroy / shutdown for (Map<String, CompositeDataBean> beans : this.compositeProperties.values()) { for (CompositeDataBean bean : beans.values()) { bean.lock.writeLock().lock(); try { bean.destroy(permanent); } finally { bean.lock.writeLock().unlock(); } } } }