Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 36617 invoked from network); 5 Oct 2010 09:52:32 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Oct 2010 09:52:32 -0000 Received: (qmail 44067 invoked by uid 500); 5 Oct 2010 09:52:32 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44007 invoked by uid 500); 5 Oct 2010 09:52:30 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 44000 invoked by uid 99); 5 Oct 2010 09:52:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Oct 2010 09:52:30 +0000 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; Tue, 05 Oct 2010 09:52:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 663A023889F1; Tue, 5 Oct 2010 09:52:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1004595 - in /directory/apacheds/trunk/server-config/src: main/java/org/apache/directory/server/config/ConfigPartitionReader.java test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java Date: Tue, 05 Oct 2010 09:52:09 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101005095209.663A023889F1@eris.apache.org> Author: elecharny Date: Tue Oct 5 09:52:09 2010 New Revision: 1004595 URL: http://svn.apache.org/viewvc?rev=1004595&view=rev Log: Added the readTransports() method Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1004595&r1=1004594&r2=1004595&view=diff ============================================================================== --- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original) +++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Tue Oct 5 09:52:09 2010 @@ -290,7 +290,7 @@ public class ConfigPartitionReader cursor.close(); - // read the extnded operation handlers' config + // read the extended operation handlers' config filter = new EqualityNode( OBJECT_CLASS_AT, new StringValue( ConfigSchemaConstants.ADS_LDAP_SERVER_EXT_OP_HANDLER_OC ) ); cursor = se.cursor( ldapServerEntry.getDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ); @@ -1221,8 +1221,7 @@ public class ConfigPartitionReader return index; } - - private Transport[] createTransports( DN adsServerDN ) throws Exception + private TransportBean[] readTransports( DN adsServerDN ) throws Exception { AttributeType adsTransportIdAt = schemaManager.getAttributeType( ConfigSchemaConstants.ADS_TRANSPORT_ID ); PresenceNode filter = new PresenceNode( adsTransportIdAt ); @@ -1231,27 +1230,50 @@ public class ConfigPartitionReader IndexCursor cursor = se.cursor( adsServerDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ); - List transports = new ArrayList(); + List transports = new ArrayList(); while ( cursor.next() ) { - ForwardIndexEntry forwardEntry = ( ForwardIndexEntry ) cursor - .get(); + ForwardIndexEntry forwardEntry = ( ForwardIndexEntry ) cursor.get(); Entry transportEntry = configPartition.lookup( forwardEntry.getId() ); - + if ( !isEnabled( transportEntry ) ) { continue; } - - transports.add( createTransport( transportEntry ) ); + + transports.add( readTransport( transportEntry ) ); } - return transports.toArray( new Transport[] - {} ); + return transports.toArray( new TransportBean[] + {} ); + } + + /** + * Creates the array of transports read from the DIT + */ + private Transport[] createTransports( DN adsServerDN ) throws Exception + { + TransportBean[] transportBeans = readTransports( adsServerDN ); + Transport[] transports = new Transport[ transportBeans.length ]; + int i = 0; + + for ( TransportBean transportBean : transportBeans ) + { + transports[i++] = createTransport( transportBean ); + } + + return transports; } + /** + * Read a Transport for the DIT + * + * @param transportEntry The Entry containing the transport's configuration + * @return A instance containing the transport configuration + * @throws Exception If the configuration cannot be read + */ public TransportBean readTransport( Entry transportEntry ) throws Exception { TransportBean transportBean = null; @@ -1304,14 +1326,17 @@ public class ConfigPartitionReader } - //This will suppress PMD.AvoidUsingHardCodedIP warnings in this class - @SuppressWarnings("PMD.AvoidUsingHardCodedIP") - public Transport createTransport( Entry transportEntry ) throws Exception + /** + * Creates a Transport reading its configuration from the DIT + * + * @param transportBean The created instance of transport + * @return An instance of transport + * @throws Exception If the instance cannot be read + */ + public Transport createTransport( TransportBean transportBean ) throws Exception { Transport transport = null; - TransportBean transportBean = readTransport( transportEntry ); - if ( transportBean instanceof TcpTransportBean ) { transport = new TcpTransport(); @@ -1761,6 +1786,7 @@ public class ConfigPartitionReader private boolean isEnabled( Entry entry ) throws Exception { EntryAttribute enabledAttr = entry.get( ConfigSchemaConstants.ADS_ENABLED ); + if ( enabledAttr != null ) { return Boolean.parseBoolean( enabledAttr.getString() ); Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java?rev=1004595&r1=1004594&r2=1004595&view=diff ============================================================================== --- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java (original) +++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java Tue Oct 5 09:52:09 2010 @@ -136,6 +136,7 @@ public class ConfigPartitionReaderTest // configured in the actual configuration data // in case the configured port is already in use during the test run Transport[] transports = server.getTransports(); + for( Transport t : transports ) { int port = t.getPort();