Author: akarasulu Date: Mon Dec 6 23:42:59 2004 New Revision: 110095 URL: http://svn.apache.org/viewcvs?view=rev&rev=110095 Log: Changes ...
o refactored out some JNDI environment constants into new EnvKeys o created new configuration bean for ContextPartitions o created builder which builds a ContextPartitionConfig from a Hashtable o added documentation on partitions and how to create user partitions Added: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/ContextPartitionConfig.java incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EnvKeys.java incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java incubator/directory/eve/trunk/xdocs/partitions.xml Modified: incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java Modified: incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java&r1=110094&p2=incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java (original) +++ incubator/directory/eve/trunk/eve/src/java/org/apache/eve/EveMain.java Mon Dec 6 23:42:59 2004 @@ -25,7 +25,7 @@ import javax.naming.directory.InitialDirContext; import org.apache.ldap.common.util.PropertiesUtils; -import org.apache.eve.jndi.EveContextFactory; +import org.apache.eve.jndi.EnvKeys; import org.apache.seda.listener.AvailablePortFinder; @@ -62,7 +62,7 @@ env = new Properties(); } - if ( ! env.containsKey( EveContextFactory.EVE_LDAP_PORT ) ) + if ( ! env.containsKey( EnvKeys.EVE_LDAP_PORT ) ) { int port = LDAP_PORT; @@ -73,7 +73,7 @@ + " is not available, using " + port + " instead" ); } - env.setProperty( EveContextFactory.EVE_LDAP_PORT, String.valueOf( port ) ); + env.setProperty( EnvKeys.EVE_LDAP_PORT, String.valueOf( port ) ); } env.setProperty( Context.PROVIDER_URL, "ou=system" ); @@ -101,7 +101,7 @@ try { - env.setProperty( EveContextFactory.SYNC_OP_ENV, "true" ); + env.setProperty( EnvKeys.SYNC, "true" ); new InitialDirContext( env ); } catch ( NamingException e ) Added: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/ContextPartitionConfig.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/ContextPartitionConfig.java?view=auto&rev=110095 ============================================================================== --- (empty file) +++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/ContextPartitionConfig.java Mon Dec 6 23:42:59 2004 @@ -0,0 +1,83 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.eve; + + +import javax.naming.directory.Attributes; + + +/** + * A configuration bean for ContextPartitions. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a> + * @version $Rev$ + */ +public class ContextPartitionConfig +{ + private String suffix; + private String id; + private String[] indices; + private Attributes attributes; + + + public String getSuffix() + { + return suffix; + } + + + public void setSuffix( String suffix ) + { + this.suffix = suffix; + } + + + public String getId() + { + return id; + } + + + public void setId( String id ) + { + this.id = id; + } + + + public String[] getIndices() + { + return indices; + } + + + public void setIndices( String[] indices ) + { + this.indices = indices; + } + + + public Attributes getAttributes() + { + return attributes; + } + + + public void setAttributes( Attributes attributes ) + { + this.attributes = attributes; + } +} Added: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EnvKeys.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EnvKeys.java?view=auto&rev=110095 ============================================================================== --- (empty file) +++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EnvKeys.java Mon Dec 6 23:42:59 2004 @@ -0,0 +1,67 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.eve.jndi; + + +/** + * JNDI environment property key constants. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a> + * @version $Rev$ + */ +public class EnvKeys +{ + // ------------------------------------------------------------------------ + // Properties for operations + // ------------------------------------------------------------------------ + + /** property used to shutdown the system */ + public static final String SHUTDOWN = "eve.operation.shutdown"; + /** property used to sync the system with disk */ + public static final String SYNC = "eve.operation.sync"; + + + // ------------------------------------------------------------------------ + // Properties for + // ------------------------------------------------------------------------ + + /** bootstrap prop: path to eve's working directory - relative or absolute */ + public static final String WKDIR = "eve.wkdir"; + /** a comma separated list of schema class files to load */ + public static final String SCHEMAS = "eve.schemas"; + /** bootstrap prop: if key is present it enables anonymous users */ + public static final String DISABLE_ANONYMOUS = "eve.disable.anonymous"; + + + /** key used to disable the networking layer (wire protocol) */ + public static final String DISABLE_PROTOCOL = "eve.net.disable.protocol"; + public static final String EVE_LDAP_PORT = "eve.net.ldap.port"; + public static final String EVE_LDAPS_PORT = "eve.net.ldaps.port"; + + // ------------------------------------------------------------------------ + // Properties for partition configuration + // ------------------------------------------------------------------------ + + /** a comma separated list of partition names */ + public static final String PARTITIONS = "eve.db.partitions"; + /** the envprop key base to the suffix of a partition */ + public static final String SUFFIX = "eve.db.partition.suffix."; + /** the envprop key base to the space separated list of indices for a partition */ + public static final String INDICES = "eve.db.partition.indices."; + /** the envprop key base to the Attributes for the context nexus entry */ + public static final String ATTRIBUTES = "eve.db.partition.attributes."; +} Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java Mon Dec 6 23:42:59 2004 @@ -83,6 +83,8 @@ { /** the default LDAP port to use */ private static final int LDAP_PORT = 389; + /** default path to working directory if WKDIR_ENV property is not set */ + public static final String DEFAULT_WKDIR = "eve"; // for convenience private static final String TYPE = Context.SECURITY_AUTHENTICATION; @@ -91,43 +93,6 @@ private static final String ADMIN = SystemPartition.ADMIN_PRINCIPAL; private static final Name ADMIN_NAME = SystemPartition.getAdminDn(); - // ------------------------------------------------------------------------ - // Custom JNDI properties - // ------------------------------------------------------------------------ - - /** property used to shutdown the system */ - public static final String SHUTDOWN_OP_ENV = "eve.operation.shutdown"; - /** property used to sync the system with disk */ - public static final String SYNC_OP_ENV = "eve.operation.sync"; - /** key base for a set of user indices provided as comma sep list of attribute names or oids */ - public static final String USER_INDICES_ENV_BASE = "eve.user.db.indices"; - /** bootstrap prop: path to eve's working directory - relative or absolute */ - public static final String WKDIR_ENV = "eve.wkdir"; - /** default path to working directory if WKDIR_ENV property is not set */ - public static final String DEFAULT_WKDIR = "eve"; - /** a comma separated list of schema class files to load */ - public static final String SCHEMAS_ENV = "eve.schemas"; - /** bootstrap prop: if key is present it enables anonymous users */ - public static final String DISABLE_ANONYMOUS_ENV = "eve.disable.anonymous"; - - - /** key used to disable the networking layer (wire protocol) */ - public static final String DISABLE_PROTOCOL = "eve.net.disable.protocol"; - public static final String EVE_LDAP_PORT = "eve.net.ldap.port"; - public static final String EVE_LDAPS_PORT = "eve.net.ldaps.port"; - - // ------------------------------------------------------------------------ - // Custom JNDI properties for adding new application partitions - // ------------------------------------------------------------------------ - - /** a comma separated list of partition names */ - public static final String PARTITIONS_ENV = "eve.db.partitions"; - /** the envprop key base to the suffix of a partition */ - public static final String SUFFIX_BASE_ENV = "eve.db.partition.suffix."; - /** the envprop key base to the space separated list of indices for a partition */ - public static final String INDICES_BASE_ENV = "eve.db.partition.indices."; - /** the envprop key base to the Attributes for the context nexus entry */ - public static final String ATTRIBUTES_BASE_ENV = "eve.db.partition.attributes."; /** default schema classes for the SCHEMAS_ENV property if not set */ private static final String[] DEFAULT_SCHEMAS = new String[] { @@ -194,7 +159,7 @@ env = ( Hashtable ) env.clone(); Context ctx = null; - if ( env.containsKey( SHUTDOWN_OP_ENV ) ) + if ( env.containsKey( EnvKeys.SHUTDOWN ) ) { if ( this.provider == null ) { @@ -225,7 +190,7 @@ return ctx; } - if ( env.containsKey( SYNC_OP_ENV ) ) + if ( env.containsKey( EnvKeys.SYNC ) ) { provider.sync(); return provider.getLdapContext( env ); @@ -243,11 +208,11 @@ { // we need to check this here instead of in AuthenticationService // because otherwise we are going to start up the system incorrectly - if ( isAnonymous( env ) && env.containsKey( DISABLE_ANONYMOUS_ENV ) ) + if ( isAnonymous( env ) && env.containsKey( EnvKeys.DISABLE_ANONYMOUS ) ) { throw new LdapNoPermissionException( "cannot bind as anonymous " + "on startup while disabling anonymous binds w/ property: " - + DISABLE_ANONYMOUS_ENV ); + + EnvKeys.DISABLE_ANONYMOUS ); } this.initialEnv = env; @@ -261,7 +226,7 @@ } // fire up the front end if we have not explicitly disabled it - if ( ! initialEnv.containsKey( DISABLE_PROTOCOL ) ) + if ( ! initialEnv.containsKey( EnvKeys.DISABLE_PROTOCOL ) ) { startUpWireProtocol(); } @@ -419,9 +384,9 @@ BootstrapSchemaLoader loader = new BootstrapSchemaLoader(); String[] schemas = DEFAULT_SCHEMAS; - if ( initialEnv.containsKey( SCHEMAS_ENV ) ) + if ( initialEnv.containsKey( EnvKeys.SCHEMAS ) ) { - schemas = ( ( String ) initialEnv.get( SCHEMAS_ENV ) ).split( "," ); + schemas = ( ( String ) initialEnv.get( EnvKeys.SCHEMAS ) ).split( "," ); for ( int ii = 0; ii < schemas.length; ii++ ) { schemas[ii] = schemas[ii].trim(); @@ -443,9 +408,9 @@ String wkdir = DEFAULT_WKDIR; - if ( initialEnv.containsKey( WKDIR_ENV ) ) + if ( initialEnv.containsKey( EnvKeys.WKDIR ) ) { - wkdir = ( ( String ) initialEnv.get( WKDIR_ENV ) ).trim(); + wkdir = ( ( String ) initialEnv.get( EnvKeys.WKDIR ) ).trim(); } File wkdirFile = new File( wkdir ); @@ -507,7 +472,7 @@ InvocationStateEnum[] state = new InvocationStateEnum[]{ InvocationStateEnum.PREINVOCATION }; - boolean allowAnonymous = ! initialEnv.containsKey( DISABLE_ANONYMOUS_ENV ); + boolean allowAnonymous = ! initialEnv.containsKey( EnvKeys.DISABLE_ANONYMOUS ); Interceptor interceptor = new AuthenticationService( nexus, allowAnonymous ); provider.addInterceptor( interceptor, state ); @@ -561,7 +526,7 @@ provider.addInterceptor( interceptor, state ); // fire up the app partitions now! - if ( initialEnv.get( PARTITIONS_ENV ) != null ) + if ( initialEnv.get( EnvKeys.PARTITIONS ) != null ) { startUpAppPartitions( wkdir ); } @@ -585,7 +550,7 @@ proto = new LdapProtocolProvider( ( Hashtable) initialEnv.clone(), fe.getEventRouter() ); - int port = PropertiesUtils.get( initialEnv, EVE_LDAP_PORT, LDAP_PORT ); + int port = PropertiesUtils.get( initialEnv, EnvKeys.EVE_LDAP_PORT, LDAP_PORT ); srvEntry = new InetServiceEntry( proto.getName(), port, proto, TransportTypeEnum.TCP ); ( ( DefaultInetServicesDatabase ) fe.getInetServicesDatabase()).addEntry( srvEntry ); @@ -632,7 +597,7 @@ MatchingRuleRegistry reg = globalRegistries.getMatchingRuleRegistry(); // start getting all the parameters from the initial environment - String[] names = ( ( String ) initialEnv.get( PARTITIONS_ENV ) ).split( " " ); + String[] names = ( ( String ) initialEnv.get( EnvKeys.PARTITIONS ) ).split( " " ); for ( int ii = 0; ii < names.length; ii++ ) { @@ -640,7 +605,7 @@ // create working directory under eve directory for app partition // ---------------------------------------------------------------- - String suffix = ( String ) initialEnv.get( SUFFIX_BASE_ENV + names[ii] ); + String suffix = ( String ) initialEnv.get( EnvKeys.SUFFIX + names[ii] ); String wkdir = eveWkdir + File.separator + names[ii]; mkdirs( eveWkdir, names[ii] ); @@ -680,9 +645,9 @@ // if user indices are specified add those attribute types as well // ---------------------------------------------------------------- - if ( initialEnv.containsKey( INDICES_BASE_ENV + names[ii] ) ) + if ( initialEnv.containsKey( EnvKeys.INDICES + names[ii] ) ) { - String[] indices = ( ( String ) initialEnv.get( INDICES_BASE_ENV + String[] indices = ( ( String ) initialEnv.get( EnvKeys.INDICES + names[ii] ) ).split( " " ); for ( int jj = 0; jj < indices.length; jj++ ) @@ -706,7 +671,7 @@ // ---------------------------------------------------------------- Attributes rootAttrs; - Object rootEntry = initialEnv.get( ATTRIBUTES_BASE_ENV + names[ii] ); + Object rootEntry = initialEnv.get( EnvKeys.ATTRIBUTES + names[ii] ); if ( rootEntry instanceof String ) { Added: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java?view=auto&rev=110095 ============================================================================== --- (empty file) +++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java Mon Dec 6 23:42:59 2004 @@ -0,0 +1,103 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.eve.jndi; + + +import java.util.Hashtable; +import java.util.Enumeration; + +import org.apache.eve.ContextPartitionConfig; +import org.apache.ldap.common.message.LockableAttributesImpl; +import org.apache.ldap.common.message.LockableAttributeImpl; + + +/** + * A partition configuration builder which produces ContextPartitionConfig + * objects from various configuration formats, namely Hashtables. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a> + * @version $Rev$ + */ +public class PartitionConfigBuilder +{ + /** + * Extracts properties from a Hashtable and builds a configuration bean for + * a ContextPartition. + * + * @param id the id of the partition to extract configs for + * @param env the Hastable containing usually JNDI environment settings + * @return the extracted configuration object + */ + public static ContextPartitionConfig getContextPartitionConfig( String id, Hashtable env ) + { + StringBuffer buf = new StringBuffer(); + ContextPartitionConfig config = new ContextPartitionConfig(); + LockableAttributesImpl attrs = new LockableAttributesImpl(); + + config.setId( id ); + + buf.append( EnvKeys.SUFFIX ).append( id ); + config.setSuffix( ( String ) env.get( buf.toString() ) ); + + buf.setLength( 0 ); + buf.append( EnvKeys.INDICES ).append( id ); + config.setIndices( ( ( String ) env.get( buf.toString() ) ).split( " " ) ); + + buf.setLength( 0 ); + buf.append( EnvKeys.ATTRIBUTES ).append( id ).append( "." ); + + String keyBase = buf.toString(); + for ( Enumeration list = env.keys(); list.hasMoreElements(); ) + { + String attrKey = ( String ) list.nextElement(); + + if ( attrKey.startsWith( keyBase ) ) + { + LockableAttributeImpl attr = new LockableAttributeImpl( attrs, + attrKey.substring( attrKey.length() ) ) ; + String[] values = ( String[] ) env.get( attrKey ); + for ( int ii = 0; ii < values.length; ii++ ) + { + attr.add( values[ii] ); + } + } + } + + return config; + } + + + /** + * Extracts properties from a Hashtable and builds a set of configurations + * bean for ContextPartitions. + * + * @param env the Hastable containing usually JNDI environment settings + * @return all the extracted configuration objects configured + */ + public static ContextPartitionConfig[] getContextPartitionConfigs( Hashtable env ) + { + final String[] ids = ( String[] ) env.get( EnvKeys.PARTITIONS ); + final ContextPartitionConfig[] configs = new ContextPartitionConfig[ids.length]; + + for ( int ii = 0; ii < configs.length; ii++ ) + { + configs[ii] = getContextPartitionConfig( ids[ii], env ); + } + + return configs; + } +} Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java Mon Dec 6 23:42:59 2004 @@ -63,7 +63,7 @@ super.setUp(); doDelete( new File( "target" + File.separator + "eve" ) ); - extras.put( EveContextFactory.EVE_LDAP_PORT, + extras.put( EnvKeys.EVE_LDAP_PORT, String.valueOf( AvailablePortFinder.getNextAvailable( 1024 ) ) ); setSysRoot( "uid=admin,ou=system", "secret" ); @@ -126,7 +126,7 @@ envFinal.putAll( extras ); envFinal.putAll( env ); envFinal.put( Context.PROVIDER_URL, "ou=system" ); - envFinal.put( EveContextFactory.WKDIR_ENV, "target" + File.separator + "eve" ); + envFinal.put( EnvKeys.WKDIR, "target" + File.separator + "eve" ); envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory" ); envFinal.putAll( overrides ); return sysRoot = new InitialLdapContext( envFinal, null ); @@ -144,7 +144,7 @@ Hashtable env = new Hashtable(); env.put( Context.PROVIDER_URL, "ou=system" ); env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory" ); - env.put( EveContextFactory.SHUTDOWN_OP_ENV, "" ); + env.put( EnvKeys.SHUTDOWN, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); try { new InitialContext( env ); } catch( Exception e ) {} Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/EveContextFactoryTest.java Mon Dec 6 23:42:59 2004 @@ -45,10 +45,10 @@ attr.add( "testing" ); attrs.put( attr ); - extras.put( EveContextFactory.PARTITIONS_ENV, "testing example" ); - extras.put( EveContextFactory.SUFFIX_BASE_ENV + "testing", "ou=testing" ); - extras.put( EveContextFactory.INDICES_BASE_ENV + "testing", "ou objectClass" ); - extras.put( EveContextFactory.ATTRIBUTES_BASE_ENV + "testing", attrs ); + extras.put( EnvKeys.PARTITIONS, "testing example" ); + extras.put( EnvKeys.SUFFIX + "testing", "ou=testing" ); + extras.put( EnvKeys.INDICES + "testing", "ou objectClass" ); + extras.put( EnvKeys.ATTRIBUTES + "testing", attrs ); attrs = new BasicAttributes( true ); attr = new BasicAttribute( "objectClass" ); @@ -60,9 +60,9 @@ attr.add( "example" ); attrs.put( attr ); - extras.put( EveContextFactory.SUFFIX_BASE_ENV + "example", "dc=example" ); - extras.put( EveContextFactory.INDICES_BASE_ENV + "example", "ou dc objectClass" ); - extras.put( EveContextFactory.ATTRIBUTES_BASE_ENV + "example", attrs ); + extras.put( EnvKeys.SUFFIX + "example", "dc=example" ); + extras.put( EnvKeys.INDICES + "example", "ou dc objectClass" ); + extras.put( EnvKeys.ATTRIBUTES + "example", attrs ); } Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/RootDSETest.java Mon Dec 6 23:42:59 2004 @@ -86,7 +86,7 @@ Hashtable env = new Hashtable(); env.put( Context.PROVIDER_URL, "ou=system" ); env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory" ); - env.put( EveContextFactory.SHUTDOWN_OP_ENV, "" ); + env.put( EnvKeys.SHUTDOWN, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); try { new InitialContext( env ); } catch( Exception e ) {} @@ -102,7 +102,7 @@ public void testGetInitialContext() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -121,7 +121,7 @@ public void testGetInitialContextLookupAttributes() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -143,7 +143,7 @@ public void testGetInitialContextLookupAttributesByName() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -168,7 +168,7 @@ public void testDelete() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -202,7 +202,7 @@ public void testRename() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -236,7 +236,7 @@ public void testModify() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); @@ -272,7 +272,7 @@ public void testModify2() throws NamingException { Hashtable env = new Hashtable(); - env.put( EveContextFactory.WKDIR_ENV, "target/eve" ); + env.put( EnvKeys.WKDIR, "target/eve" ); env.put( Context.PROVIDER_URL, "" ); env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" ); env.put( Context.SECURITY_CREDENTIALS, "secret" ); Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java Mon Dec 6 23:42:59 2004 @@ -40,7 +40,7 @@ */ public void testShutdownNonNullContext() throws Exception { - overrides.put( EveContextFactory.SHUTDOWN_OP_ENV, "true" ); + overrides.put( EnvKeys.SHUTDOWN, "true" ); try { @@ -48,7 +48,7 @@ } finally { - overrides.remove( EveContextFactory.SHUTDOWN_OP_ENV ); + overrides.remove( EnvKeys.SHUTDOWN ); } assertNotNull( sysRoot ); @@ -62,7 +62,7 @@ */ public void testShutdownRestart() throws Exception { - overrides.put( EveContextFactory.SHUTDOWN_OP_ENV, "true" ); + overrides.put( EnvKeys.SHUTDOWN, "true" ); try { @@ -70,7 +70,7 @@ } finally { - overrides.remove( EveContextFactory.SHUTDOWN_OP_ENV ); + overrides.remove( EnvKeys.SHUTDOWN ); } assertNotNull( sysRoot ); Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SimpleAuthenticationTest.java Mon Dec 6 23:42:59 2004 @@ -178,7 +178,7 @@ doDelete( new File( "target" + File.separator + "eve" ) ); Hashtable env = new Hashtable(); env.put( Context.SECURITY_AUTHENTICATION, "none" ); - env.put( EveContextFactory.DISABLE_ANONYMOUS_ENV, "true" ); + env.put( EnvKeys.DISABLE_ANONYMOUS, "true" ); try { Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java?view=diff&rev=110095&p1=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java&r1=110094&p2=incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java&r2=110095 ============================================================================== --- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java (original) +++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java Mon Dec 6 23:42:59 2004 @@ -36,7 +36,7 @@ */ public void testSyncNoException() throws Exception { - overrides.put( EveContextFactory.SYNC_OP_ENV, "true" ); + overrides.put( EnvKeys.SYNC, "true" ); sysRoot = setSysRoot( "uid=admin,ou=system", "secret" ); assertNotNull( sysRoot ); } @@ -50,7 +50,7 @@ */ public void testPostSyncLookup() throws Exception { - overrides.put( EveContextFactory.SYNC_OP_ENV, "true" ); + overrides.put( EnvKeys.SYNC, "true" ); sysRoot = setSysRoot( "uid=admin,ou=system", "secret" ); Attributes users = sysRoot.getAttributes( "ou=users" ); Added: incubator/directory/eve/trunk/xdocs/partitions.xml Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/xdocs/partitions.xml?view=auto&rev=110095 ============================================================================== --- (empty file) +++ incubator/directory/eve/trunk/xdocs/partitions.xml Mon Dec 6 23:42:59 2004 @@ -0,0 +1,189 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document> + <properties> + <author email="[EMAIL PROTECTED]">Alex Karasulu</author> + <title>Partitions</title> + </properties> + + <body> + <section name="Partitions"> + <p> + Partitions are entry stores assigned to a naming context. The idea + behind a partition is that it stores a subset of the Directory + Information Base (DIB). Partitions can be implemented in any way so + long as they adhere to interfaces. + </p> + + <subsection name="Status"> + <p> + Presently Eve has a single partition implementation which is used for + both the system partition and user partitions. It uses + <a href="http://jdbm.sourceforge.net/">JDBM</a> as the underlying + B+Tree implementation for storing entries. + </p> + + <p> + Other implementations are possible. I'm particularly interested in + memory based partitions either BTree based or based on something like + Prevayer. + </p> + + <p> + Partitions have simple interfaces that can be used to align any data + source to the LDAP data model thereby accessing it via JNDI or via + LDAP over the wire. This makes Eve very flexible as a bridge to + standardize access to disparate data sources and formats. Dynamic + mapping based backends are also interesting. + </p> + </subsection> + + <subsection name="System Partition"> + <p> + The system partition is a very special partition that is hardcoded to + hang off of the <b>ou=system</b> naming context. It is always present + and contains administrative and operational information needed by the + server to operate. Hence its name. + </p> + + <p> + Eve's subsystems will use this partition to store information critical + to their operation. Things like triggers, stored procedures, access + control instructions and schema information can be maintained here. + </p> + </subsection> + + <subsection name="Root Nexus"> + <p> + Several partitions can be assigned to different naming contexts within + Eve so long as their names do not overlap such that one partition's + naming context is contained within anothers. The root nexus is a fake + partition that does not really store entries. It maps other entry + storing partitions to naming contexts and routes backing store calls + to the partition containing the entry associated with the operation. + </p> + </subsection> + + <subsection name="User/Application Partitions"> + <p> + User partitions are partitions added by users. When you download and + start using Eve you may want to create a separate partition to store + the entries of your application. To us user and application partition + means the same thing: not the system partition! + </p> + + <p> + Adding new application partitions to the server is a matter of + setting the right JNDI environment properties. These properties are + used in both standalone and in embedded configurations. Below is an + example of a properties configuration for two partitions hanging off + of the naming contexts <code>dc=apache,dc=org</code> and + <code>ou=test</code>: + </p> + + <source> +# all multivalued properties are space separated like the list of partions here +eve.db.partitions=apache test + +# apache partition configuration +eve.db.partition.suffix.apache=dc=apache,dc=org +eve.db.partition.indices.apache=ou cn objectClass uid +eve.db.partition.attributes.apache.dc=apache +eve.db.partition.attributes.apache.objectClass=top domain extensibleObject + +# test partition configuration +eve.db.partition.suffix.test=ou=test +eve.db.partition.indices.test=ou objectClass +eve.db.partition.attributes.test.ou=test +eve.db.partition.attributes.test.objectClass=top organizationalUnit extensibleObject + </source> + + <p> + Although somewhat ugly the way we use properties for settings does + work and hopefully we can build a tool on top of this to save the + user some hassle. Another approach may be to use XML or something + easier to generate these properties from them. For now its the best + non-specific means we have to inject settings through JNDI env + Hashtables while still being able to load settings via properties + files. Ultimately JNDI properties are the common denominator. + </p> + + <p> + Breifly we'll explain these properties. All partition properties + are associated with one another using some partition id. All + partition ids are listed as a space separated list using the <b> + eve.db.partitions</b> property: above it lists the ids for the too + partitions, <i>apache</i> and <i>test</i>. + </p> + + <p> + Partitions need to know the naming context they will store entries + for. This naming context is also referred to as the suffix since all + entries in the partition have this common suffix. You guessed it, + the suffix is a distinguished name. The property key for the suffix + of a partition is composed of the following property key base + <b>eve.db.partition.suffix.</b> concatenated with the id of the + partition: <b>eve.db.partition.suffix.</b><i>${id}</i>. For example + if the partition id is foo, then the suffix key would be, + <b>eve.db.partition.suffix.foo</b>. + </p> + + <p> + Partitions can have indices on attributes. Unlike OpenLDAP where you + can build specific types of indices, Eve indices are of a single type. + For each partition a key is assembled from the partition id and the + property key base: <b>eve.db.partition.indices.</b><i>${id}</i>. So + again for foo the key for attribute indices would be + <b>eve.db.partition.indices.foo</b>. This value is a space separated + list of attributeType names to index. For example the apache + partition has indices built on top of <b>ou</b>, <b>objectClass</b> + and <b>uid</b>. + </p> + + <p> + When creating a context the root entry of the context corresponding + to the suffix of the partition must be created. This entry is + composed of single-valued and multi-valued attributes. We must + specify these attributes as well as their values. To do so we again + use a key composed of a base, however this time we use both the id + of the partition and the name of the attribute: + <b>eve.db.partition.attributes.</b><i>${id}</i>.<i>${name}</i>. So + for partition foo and attribute bar the following key would be used: + <b>eve.db.partition.attributes.foo.bar</b>. The value of the key + is a space separated list of values for the bar attribute. For + example the apache partition's suffix has an objectClass attribute + and its values are set to: top domain extensibleObject. + </p> + </subsection> + + <subsection name="Future Progress"> + <p> + Today we have some limitations to the way we can partition the DIB. + Namely we can't have a partition within a partition and sometimes this + makes sense. Eventually we intend to enable this kind of + functionality using a special type of nexus which is both a router + and a backing store for entries. It's smart enough to know what to + route verses when to use its own database. Here's a <a href= + "http://nagoya.apache.org/jira/browse/DIREVE-23">JIRA improvement</a> + specifically aimed at achieving this goal. + </p> + + <p> + Obviously we want as many different kinds of partitions as possible. + Ones using RDBMS' and ones using LDAP servers are welcome as well + so we can serve their content as well in one unified view. + </p> + + <p> + Other aspirations include entry partitioning within a container + context. Imagine having 250 million entries under + <code>ou=citizens,dc=census,dc=gov</code>. You don't want all 250 + million in one partition but would like to sub partition these entries + under the same context based on some attribute. Basically we will be + using the attribute value to implement sub partitioning where within + a single context we are partitioning entries. + </p> + </subsection> + + </section> + </body> +</document>
