Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 76610 invoked from network); 30 Jun 2008 18:32:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Jun 2008 18:32:11 -0000 Received: (qmail 76236 invoked by uid 500); 30 Jun 2008 18:32:12 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 76197 invoked by uid 500); 30 Jun 2008 18:32:12 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 76188 invoked by uid 99); 30 Jun 2008 18:32:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2008 11:32:12 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2008 18:31:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ED39223889C2; Mon, 30 Jun 2008 11:31:19 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r672858 - /cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java Date: Mon, 30 Jun 2008 18:31:19 -0000 To: cvs@cocoon.apache.org From: lgawron@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080630183119.ED39223889C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lgawron Date: Mon Jun 30 11:31:19 2008 New Revision: 672858 URL: http://svn.apache.org/viewvc?rev=672858&view=rev Log: consistent whitespace Modified: cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java Modified: cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java URL: http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java?rev=672858&r1=672857&r2=672858&view=diff ============================================================================== --- cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java (original) +++ cocoon/trunk/subprojects/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java Mon Jun 30 11:31:19 2008 @@ -36,21 +36,21 @@ /** * This is a map implementation collecting all beans of a specific type (class) - * from a spring bean factory. - * The beans are available through their configured bean id. + * from a spring bean factory. The beans are available through their configured + * bean id. * - * The map has a lazy implementation: the beans are not searched on instantiation - * but the first time the map is accessed. This avoids any startup ordering problems. + * The map has a lazy implementation: the beans are not searched on + * instantiation but the first time the map is accessed. This avoids any startup + * ordering problems. * - * By default the map searches in the bean factory it is used in and in all the parent - * bean factories (if there are any). This behaviour can be changed by calling the - * {@link #setCheckParent(boolean)} method. + * By default the map searches in the bean factory it is used in and in all the + * parent bean factories (if there are any). This behaviour can be changed by + * calling the {@link #setCheckParent(boolean)} method. * * @version $Id$ * @since 1.0.1 */ -public class BeanMap - implements Map, BeanFactoryAware { +public class BeanMap implements Map, BeanFactoryAware { /** The real map. */ protected final Map beanMap = new HashMap(); @@ -77,33 +77,36 @@ protected String keyProperty; /** - * Get all the bean's from the bean factory and put them into - * a map using their id. - * @param beanNames The bean names to load. + * Get all the bean's from the bean factory and put them into a map using + * their id. + * + * @param beanNames + * The bean names to load. */ protected void load(Set beanNames) { final String prefix1 = this.beanClass.getName() + '.'; final String prefix2 = this.beanClass.getName() + '/'; final Iterator i = beanNames.iterator(); - while ( i.hasNext() ) { - final String beanName = (String)i.next(); + while (i.hasNext()) { + final String beanName = (String) i.next(); Object key = beanName; - if ( this.stripPrefix && (beanName.startsWith(prefix1) || beanName.startsWith(prefix2)) ) { + if (this.stripPrefix && (beanName.startsWith(prefix1) || beanName.startsWith(prefix2))) { key = beanName.substring(prefix1.length()); } - if(this.hasProperties.size() > 0) { + if (this.hasProperties.size() > 0) { final Object bean = this.beanFactory.getBean(beanName); final BeanWrapperImpl wrapper = new BeanWrapperImpl(bean); boolean isOk = true; final Iterator iter = this.hasProperties.iterator(); - while(iter.hasNext()) { - final String propName = (String)iter.next(); - if(!wrapper.isReadableProperty(propName)) { + while (iter.hasNext()) { + final String propName = (String) iter.next(); + if (!wrapper.isReadableProperty(propName)) { isOk = false; } } - if(isOk) { - if( this.keyProperty != null && this.keyProperty.length() > 0 && wrapper.isReadableProperty(this.keyProperty)) { + if (isOk) { + if (this.keyProperty != null && this.keyProperty.length() > 0 + && wrapper.isReadableProperty(this.keyProperty)) { key = wrapper.getPropertyValue(this.keyProperty); } this.beanMap.put(key, bean); @@ -111,7 +114,8 @@ } else { final Object bean = this.beanFactory.getBean(beanName); final BeanWrapperImpl wrapper = new BeanWrapperImpl(bean); - if( this.keyProperty != null && this.keyProperty.length() > 0 && wrapper.isReadableProperty(this.keyProperty)) { + if (this.keyProperty != null && this.keyProperty.length() > 0 + && wrapper.isReadableProperty(this.keyProperty)) { key = wrapper.getPropertyValue(this.keyProperty); } this.beanMap.put(key, bean); @@ -120,16 +124,17 @@ } /** - * Check if the bean is already initialized. - * If not, the bean's are searched in the bean factory. + * Check if the bean is already initialized. If not, the bean's are searched + * in the bean factory. */ protected void checkInit() { - if ( !this.initialized ) { + if (!this.initialized) { synchronized (this) { - if ( !this.initialized ) { - // although it is unlikely, but if this bean is used outside spring + if (!this.initialized) { + // although it is unlikely, but if this bean is used outside + // spring // it will just contain an empty map - if ( this.beanFactory != null ) { + if (this.beanFactory != null) { final Set beanNames = new HashSet(); this.getBeanNames(this.beanFactory, beanNames); this.load(beanNames); @@ -142,15 +147,19 @@ /** * Get all bean names for the given type. - * @param factory The bean factory. - * @param beanNames The set containing the resulting bean names. + * + * @param factory + * The bean factory. + * @param beanNames + * The set containing the resulting bean names. */ protected void getBeanNames(ListableBeanFactory factory, Set beanNames) { // check parent first - if ( this.checkParent ) { - if ( factory instanceof HierarchicalBeanFactory ) { - if ( ((HierarchicalBeanFactory)factory).getParentBeanFactory() != null ) { - this.getBeanNames((ListableBeanFactory)((HierarchicalBeanFactory)factory).getParentBeanFactory(), beanNames); + if (this.checkParent) { + if (factory instanceof HierarchicalBeanFactory) { + if (((HierarchicalBeanFactory) factory).getParentBeanFactory() != null) { + this.getBeanNames((ListableBeanFactory) ((HierarchicalBeanFactory) factory).getParentBeanFactory(), + beanNames); } } } @@ -165,10 +174,10 @@ * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory) */ public void setBeanFactory(BeanFactory factory) throws BeansException { - if ( !(factory instanceof ListableBeanFactory) ) { + if (!(factory instanceof ListableBeanFactory)) { throw new BeanDefinitionStoreException("BeanFactory must be listable."); } - this.beanFactory = (ListableBeanFactory)factory; + this.beanFactory = (ListableBeanFactory) factory; } public void setStripPrefix(boolean stripPrefix) { @@ -182,8 +191,8 @@ public void setHasProperties(String pHasProperties) { final StringTokenizer tokenizer = new StringTokenizer(pHasProperties, " \t\n\r\f,"); final List propNames = new ArrayList(); - while(tokenizer.hasMoreTokens()) { - propNames.add( tokenizer.nextToken() ); + while (tokenizer.hasMoreTokens()) { + propNames.add(tokenizer.nextToken()); } this.hasProperties = propNames; }