You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/08/08 08:01:32 UTC
svn commit: r230758 - in
/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server: authn/
configuration/ interceptor/ jndi/ partition/
Author: trustin
Date: Sun Aug 7 23:01:21 2005
New Revision: 230758
URL: http://svn.apache.org/viewcvs?rev=230758&view=rev
Log:
* Added: ContextPartitionNexus.add/removeContextPartition()
* Added: AddContextPartitionConfiguration and RemoveContextPartitionConfiguration
* Now you can use Add/RemoveContextPartitionConfiguration to add or remove context partitions in runtime.
Added:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java (with props)
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java (with props)
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java Sun Aug 7 23:01:21 2005
@@ -38,6 +38,7 @@
import org.apache.ldap.common.util.StringTools;
import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
import org.apache.ldap.server.configuration.InterceptorConfiguration;
+import org.apache.ldap.server.interceptor.BaseInterceptor;
import org.apache.ldap.server.interceptor.Interceptor;
import org.apache.ldap.server.interceptor.NextInterceptor;
import org.apache.ldap.server.invocation.InvocationStack;
@@ -53,7 +54,7 @@
* @author Trustin Lee (trustin@apache.org)
* @version $Rev$, $Date$
*/
-public class AuthenticationService implements Interceptor
+public class AuthenticationService extends BaseInterceptor
{
/** authenticators **/
public Map authenticators = new HashMap();
Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java?rev=230758&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java Sun Aug 7 23:01:21 2005
@@ -0,0 +1,56 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.ldap.server.configuration;
+
+import org.apache.ldap.server.partition.ContextPartition;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
+
+/**
+ * A {@link Configuration} that adds a new {@link ContextPartition} to
+ * the current {@link ContextPartitionNexus}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddContextPartitionConfiguration extends Configuration
+{
+ private static final long serialVersionUID = -6690435863387769527L;
+
+ private final ContextPartitionConfiguration contextPartitionConfiguration;
+
+ public AddContextPartitionConfiguration( ContextPartitionConfiguration contextPartitionConfiguration )
+ {
+ if( contextPartitionConfiguration == null )
+ {
+ throw new NullPointerException( "contextPartitionConfiguration" );
+ }
+
+ this.contextPartitionConfiguration = contextPartitionConfiguration;
+ }
+
+ public ContextPartitionConfiguration getContextPartitionConfiguration()
+ {
+ return contextPartitionConfiguration;
+ }
+
+ public void validate()
+ {
+ contextPartitionConfiguration.validate();
+ }
+}
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/AddContextPartitionConfiguration.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java Sun Aug 7 23:01:21 2005
@@ -192,7 +192,7 @@
*/
public void validate()
{
- if( getName() == null )
+ if( getName() == null || getName().length() == 0 )
{
throw new ConfigurationException( "Name is not specified." );
}
Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java?rev=230758&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java Sun Aug 7 23:01:21 2005
@@ -0,0 +1,60 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.ldap.server.configuration;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.partition.ContextPartition;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
+
+/**
+ * A {@link Configuration} that removed the attached {@link ContextPartition} in
+ * the current {@link ContextPartitionNexus}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RemoveContextPartitionConfiguration extends Configuration
+{
+ private static final long serialVersionUID = -6690435863387769527L;
+
+ private final Name suffix;
+
+ public RemoveContextPartitionConfiguration( String suffix ) throws NamingException
+ {
+ this( new LdapName( suffix.trim() ) );
+ }
+
+ public RemoveContextPartitionConfiguration( Name suffix )
+ {
+ if( suffix == null )
+ {
+ throw new NullPointerException( "suffix" );
+ }
+
+ this.suffix = suffix;
+ }
+
+ public Name getSuffix()
+ {
+ return suffix;
+ }
+}
Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/RemoveContextPartitionConfiguration.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java Sun Aug 7 23:01:21 2005
@@ -31,6 +31,7 @@
import org.apache.ldap.common.filter.ExprNode;
import org.apache.ldap.server.authn.LdapPrincipal;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
import org.apache.ldap.server.configuration.InterceptorConfiguration;
import org.apache.ldap.server.invocation.InvocationStack;
import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
@@ -192,5 +193,15 @@
public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
{
return next.search( base, env, filter, searchCtls );
+ }
+
+ public void addContextPartition( NextInterceptor next, ContextPartitionConfiguration cfg ) throws NamingException
+ {
+ next.addContextPartition( cfg );
+ }
+
+ public void removeContextPartition( NextInterceptor next, Name suffix ) throws NamingException
+ {
+ next.removeContextPartition( suffix );
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java Sun Aug 7 23:01:21 2005
@@ -28,6 +28,7 @@
import javax.naming.directory.SearchControls;
import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
import org.apache.ldap.server.configuration.InterceptorConfiguration;
import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
import org.apache.ldap.server.partition.ContextPartition;
@@ -128,6 +129,14 @@
* Filters {@link ContextPartitionNexus#listSuffixes(boolean)} call.
*/
Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException;
+ /**
+ * Filters {@link ContextPartitionNexus#addContextPartition(ContextPartitionConfiguration)} call.
+ */
+ void addContextPartition( NextInterceptor next, ContextPartitionConfiguration cfg ) throws NamingException;
+ /**
+ * Filters {@link ContextPartitionNexus#removeContextPartition(Name)} call.
+ */
+ void removeContextPartition( NextInterceptor next, Name suffix ) throws NamingException;
/**
* Filters {@link ContextPartition#delete(Name)} call.
*/
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java Sun Aug 7 23:01:21 2005
@@ -33,6 +33,7 @@
import javax.naming.directory.SearchControls;
import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
import org.apache.ldap.server.configuration.InterceptorConfiguration;
import org.apache.ldap.server.configuration.MutableInterceptorConfiguration;
import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
@@ -163,6 +164,18 @@
{
nexus.move( oriChildName, newParentName, newRn, deleteOldRn );
}
+
+
+ public void addContextPartition( NextInterceptor next, ContextPartitionConfiguration cfg ) throws NamingException
+ {
+ nexus.addContextPartition( cfg );
+ }
+
+
+ public void removeContextPartition( NextInterceptor next, Name suffix ) throws NamingException
+ {
+ nexus.removeContextPartition( suffix );
+ }
};
private final Map name2entry = new HashMap();
@@ -472,6 +485,43 @@
}
}
+ public void addContextPartition( ContextPartitionConfiguration cfg ) throws NamingException
+ {
+ Interceptor head = this.head.configuration.getInterceptor();
+ NextInterceptor next = this.head.nextInterceptor;
+ try
+ {
+ head.addContextPartition( next, cfg );
+ }
+ catch ( NamingException ne )
+ {
+ throw ne;
+ }
+ catch ( Throwable e )
+ {
+ throwInterceptorException( head, e );
+ throw new InternalError(); // Should be unreachable
+ }
+ }
+
+ public void removeContextPartition( Name suffix ) throws NamingException
+ {
+ Interceptor head = this.head.configuration.getInterceptor();
+ NextInterceptor next = this.head.nextInterceptor;
+ try
+ {
+ head.removeContextPartition( next, suffix );
+ }
+ catch ( NamingException ne )
+ {
+ throw ne;
+ }
+ catch ( Throwable e )
+ {
+ throwInterceptorException( head, e );
+ throw new InternalError(); // Should be unreachable
+ }
+ }
public void delete( Name name ) throws NamingException
{
@@ -1069,6 +1119,44 @@
catch ( Throwable e )
{
throwInterceptorException( interceptor, e );
+ }
+ }
+
+ public void addContextPartition( ContextPartitionConfiguration cfg ) throws NamingException
+ {
+ Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+ try
+ {
+ interceptor.addContextPartition( Entry.this.nextEntry.nextInterceptor, cfg );
+ }
+ catch ( NamingException ne )
+ {
+ throw ne;
+ }
+ catch ( Throwable e )
+ {
+ throwInterceptorException( interceptor, e );
+ throw new InternalError(); // Should be unreachable
+ }
+ }
+
+ public void removeContextPartition( Name suffix ) throws NamingException
+ {
+ Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+ try
+ {
+ interceptor.removeContextPartition( Entry.this.nextEntry.nextInterceptor, suffix );
+ }
+ catch ( NamingException ne )
+ {
+ throw ne;
+ }
+ catch ( Throwable e )
+ {
+ throwInterceptorException( interceptor, e );
+ throw new InternalError(); // Should be unreachable
}
}
};
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java Sun Aug 7 23:01:21 2005
@@ -28,6 +28,8 @@
import javax.naming.directory.SearchControls;
import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
/**
@@ -56,6 +58,14 @@
* Calls the next interceptor's {@link Interceptor#listSuffixes(NextInterceptor, boolean)}.
*/
Iterator listSuffixes( boolean normalized ) throws NamingException;
+ /**
+ * Calls the next interceptor's {@link ContextPartitionNexus#addContextPartition(ContextPartitionConfiguration)}.
+ */
+ void addContextPartition( ContextPartitionConfiguration cfg ) throws NamingException;
+ /**
+ * Calls the next interceptor's {@link ContextPartitionNexus#removeContextPartition(Name)}.
+ */
+ void removeContextPartition( Name suffix ) throws NamingException;
/**
* Calls the next interceptor's {@link Interceptor#delete(NextInterceptor, Name)}.
*/
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java Sun Aug 7 23:01:21 2005
@@ -25,7 +25,9 @@
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
+import org.apache.ldap.server.configuration.AddContextPartitionConfiguration;
import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.RemoveContextPartitionConfiguration;
import org.apache.ldap.server.configuration.ShutdownConfiguration;
import org.apache.ldap.server.configuration.StartupConfiguration;
import org.apache.ldap.server.configuration.SyncConfiguration;
@@ -81,7 +83,7 @@
String authentication = getAuthentication( env );
String providerUrl = getProviderUrl( env );
- ContextFactoryService service = ContextFactoryService.getInstance();
+ ContextFactoryService service = ContextFactoryService.getInstance( cfg.getInstanceId() );
// Execute configuration
if( cfg instanceof ShutdownConfiguration )
@@ -95,6 +97,18 @@
else if( cfg instanceof StartupConfiguration )
{
service.startup( this, env );
+ }
+ else if( cfg instanceof AddContextPartitionConfiguration )
+ {
+ new ContextPartitionNexusProxy(
+ service.getJndiContext( principal, credential, authentication, providerUrl ),
+ service).addContextPartition( ( ( AddContextPartitionConfiguration ) cfg ).getContextPartitionConfiguration() );
+ }
+ else if( cfg instanceof RemoveContextPartitionConfiguration )
+ {
+ new ContextPartitionNexusProxy(
+ service.getJndiContext( principal, credential, authentication, providerUrl ),
+ service).removeContextPartition( ( ( RemoveContextPartitionConfiguration ) cfg ).getSuffix() );
}
else if( service == null )
{
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java Sun Aug 7 23:01:21 2005
@@ -65,7 +65,8 @@
GlobalRegistries getGlobalRegistries();
/**
- * Returns the {@link ContextPartitionNexus} of the {@link ContextFactoryService}.
+ * Returns the {@link ContextPartitionNexus} of the {@link ContextFactoryService}
+ * which bypasses the interceptor chain.
*/
ContextPartitionNexus getPartitionNexus();
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java Sun Aug 7 23:01:21 2005
@@ -353,4 +353,36 @@
stack.pop();
}
}
+
+ public void addContextPartition( ContextPartitionConfiguration config ) throws NamingException
+ {
+ InvocationStack stack = InvocationStack.getInstance();
+ stack.push( new Invocation(
+ caller, "addContextPartition",
+ new Object[] { config } ) );
+ try
+ {
+ this.configuration.getInterceptorChain().addContextPartition( config );
+ }
+ finally
+ {
+ stack.pop();
+ }
+ }
+
+ public void removeContextPartition( Name suffix ) throws NamingException
+ {
+ InvocationStack stack = InvocationStack.getInstance();
+ stack.push( new Invocation(
+ caller, "removeContextPartition",
+ new Object[] { suffix } ) );
+ try
+ {
+ this.configuration.getInterceptorChain().removeContextPartition( suffix );
+ }
+ finally
+ {
+ stack.pop();
+ }
+ }
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java Sun Aug 7 23:01:21 2005
@@ -25,6 +25,7 @@
import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
/**
@@ -132,7 +133,11 @@
*
* @return the attributes of the RootDSE
*/
- public abstract Attributes getRootDSE() throws NamingException;
+ public abstract Attributes getRootDSE() throws NamingException;
+
+ public abstract void addContextPartition( ContextPartitionConfiguration config ) throws NamingException;
+
+ public abstract void removeContextPartition( Name suffix ) throws NamingException;
public abstract ContextPartition getSystemPartition();
@@ -167,7 +172,7 @@
/**
* Gets an iteration over the Name suffixes of the Backends managed by this
- * BackendNexus.
+ * {@link ContextPartitionNexus}.
*
* @param normalized if true the returned Iterator contains normalized Dn
* but, if false, it returns the original user provided distinguished names
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java?rev=230758&r1=230757&r2=230758&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java Sun Aug 7 23:01:21 2005
@@ -82,6 +82,8 @@
/** the closed state of this partition */
private boolean initialized;
+ private ContextFactoryConfiguration factoryCfg;
+
/** the system backend */
private ContextPartition system;
@@ -138,8 +140,10 @@
return;
}
+ this.factoryCfg = factoryCfg;
+
List initializedPartitions = new ArrayList();
- initializeSystemPartition( factoryCfg );
+ initializeSystemPartition();
initializedPartitions.add( system );
Iterator i = factoryCfg.getStartupConfiguration().getContextPartitionConfigurations().iterator();
@@ -147,30 +151,9 @@
{
while( i.hasNext() )
{
- cfg = ( ContextPartitionConfiguration ) i.next();
- ContextPartition partition = cfg.getContextPartition();
-
- // Turn on default indices
- MutableContextPartitionConfiguration mcfg =
- new MutableContextPartitionConfiguration();
- mcfg.setName( cfg.getName() );
- mcfg.setSuffix( cfg.getSuffix() );
- mcfg.setContextEntry( cfg.getContextEntry() );
- mcfg.setContextPartition( partition );
-
- Set indexedAttrs = cfg.getIndexedAttributes();
- indexedAttrs.add( Oid.ALIAS );
- indexedAttrs.add( Oid.EXISTANCE );
- indexedAttrs.add( Oid.HIERARCHY );
- indexedAttrs.add( Oid.NDN );
- indexedAttrs.add( Oid.ONEALIAS );
- indexedAttrs.add( Oid.SUBALIAS );
- indexedAttrs.add( Oid.UPDN );
- mcfg.setIndexedAttributes( indexedAttrs );
-
- partition.init( factoryCfg, mcfg );
- initializedPartitions.add( 0, partition );
- register( partition );
+ ContextPartitionConfiguration c = ( ContextPartitionConfiguration ) i.next();
+ addContextPartition( c );
+ initializedPartitions.add( 0, c.getContextPartition() );
}
initialized = true;
}
@@ -201,7 +184,7 @@
}
- private void initializeSystemPartition( ContextFactoryConfiguration factoryCfg ) throws NamingException
+ private void initializeSystemPartition() throws NamingException
{
// initialize system partition first
MutableContextPartitionConfiguration systemCfg = new MutableContextPartitionConfiguration();
@@ -235,7 +218,15 @@
systemCfg.setContextEntry( systemEntry );
system.init( factoryCfg, systemCfg );
- register( system );
+ String key = system.getSuffix( true ).toString();
+ if( partitions.containsKey( key ) )
+ {
+ throw new ConfigurationException( "Duplicate partition suffix: " + key );
+ }
+ partitions.put( key, system );
+
+ Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
+ namingContexts.add( system.getSuffix( false ).toString() );
}
@@ -338,9 +329,62 @@
// ------------------------------------------------------------------------
- // BackendNexus Interface Method Implementations
+ // ContextPartitionNexus Interface Method Implementations
// ------------------------------------------------------------------------
+
+
+ public synchronized void addContextPartition( ContextPartitionConfiguration config ) throws NamingException
+ {
+ ContextPartition partition = config.getContextPartition();
+
+ // Turn on default indices
+ MutableContextPartitionConfiguration mcfg =
+ new MutableContextPartitionConfiguration();
+ mcfg.setName( config.getName() );
+ mcfg.setSuffix( config.getSuffix() );
+ mcfg.setContextEntry( config.getContextEntry() );
+ mcfg.setContextPartition( partition );
+
+ Set indexedAttrs = config.getIndexedAttributes();
+ indexedAttrs.add( Oid.ALIAS );
+ indexedAttrs.add( Oid.EXISTANCE );
+ indexedAttrs.add( Oid.HIERARCHY );
+ indexedAttrs.add( Oid.NDN );
+ indexedAttrs.add( Oid.ONEALIAS );
+ indexedAttrs.add( Oid.SUBALIAS );
+ indexedAttrs.add( Oid.UPDN );
+ mcfg.setIndexedAttributes( indexedAttrs );
+
+ String key = partition.getSuffix( true ).toString();
+ if( partitions.containsKey( key ) )
+ {
+ throw new ConfigurationException( "Duplicate partition suffix: " + key );
+ }
+
+ partition.init( factoryCfg, mcfg );
+ partitions.put( key, partition );
+
+ Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
+ namingContexts.add( partition.getSuffix( false ).toString() );
+ }
+
+
+ public synchronized void removeContextPartition( Name suffix ) throws NamingException
+ {
+ String key = suffix.toString();
+ ContextPartition partition = (ContextPartition) partitions.get( key );
+ if( partition == null )
+ {
+ throw new NameNotFoundException( "No partition with suffix: " + key );
+ }
+
+ partition.destroy();
+ partitions.remove( key );
+
+ Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
+ namingContexts.remove( partition.getSuffix( false ).toString() );
+ }
public ContextPartition getSystemPartition()
{
@@ -406,33 +450,6 @@
public Attributes getRootDSE()
{
return rootDSE;
- }
-
-
- /**
- * Registers an ContextPartition with this BackendManager. Called by each
- * ContextPartition implementation after it has started to register for
- * backend operation calls. This method effectively puts the
- * ContextPartition's naming context online.
- *
- * Operations against the naming context should result in an LDAP BUSY
- * result code in the returnValue if the naming context is not online.
- *
- * @param partition ContextPartition component to register with this
- * BackendNexus.
- * @throws ConfigurationException
- */
- private void register( ContextPartition partition ) throws NamingException
- {
- String key = partition.getSuffix( true ).toString();
- if( partitions.containsKey( key ) )
- {
- throw new ConfigurationException( "Duplicate partition suffix: " + key );
- }
- partitions.put( key, partition );
-
- Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
- namingContexts.add( partition.getSuffix( false ).toString() );
}