You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/20 04:58:21 UTC
svn commit: r379013 [40/45] - in /directory/trunks/apacheds: ./ core-plugin/
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/ core-shared/src/...
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractBackingStoreTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractBackingStoreTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractBackingStoreTest.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractBackingStoreTest.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.protocol.shared;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -63,6 +64,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* Base class for testing protocol providers against the JNDI provider.
*
@@ -83,6 +85,7 @@
protected CoreContextFactory factory;
protected Hashtable env;
+
protected void setUp() throws Exception
{
env = new Hashtable( setUpPartition() );
@@ -96,13 +99,15 @@
factory = new CoreContextFactory();
}
+
protected void loadPartition( String partition, String ldifFile ) throws NamingException
{
env.put( Context.PROVIDER_URL, partition );
- DirContext ctx = (DirContext) factory.getInitialContext( env );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
load( ctx, ldifFile );
}
+
/**
* Test that the system partition was set up properly.
*
@@ -111,27 +116,30 @@
protected void doTestSystemPartition() throws Exception
{
env.put( Context.PROVIDER_URL, "ou=system" );
- DirContext ctx = (DirContext) factory.getInitialContext( env );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
Attributes attributes = ctx.getAttributes( "cn=A,dc=www,dc=apache,dc=org,ou=Zones" );
assertEquals( 3, attributes.size() );
}
+
protected void doTestApacheZone() throws Exception
{
env.put( Context.PROVIDER_URL, "dc=apache,dc=org" );
- DirContext ctx = (DirContext) factory.getInitialContext( env );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
Attributes attributes = ctx.getAttributes( "cn=A,dc=www,dc=apache,dc=org,ou=Zones" );
assertEquals( 3, attributes.size() );
}
+
protected void doTestExampleZone() throws Exception
{
env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
- DirContext ctx = (DirContext) factory.getInitialContext( env );
+ DirContext ctx = ( DirContext ) factory.getInitialContext( env );
Attributes attributes = ctx.getAttributes( "cn=A,dc=www,dc=example,dc=com,ou=Zones" );
assertEquals( 3, attributes.size() );
}
+
protected Hashtable setUpPartition()
{
config = new MutableStartupConfiguration();
@@ -155,6 +163,7 @@
return config.toJndiEnvironment();
}
+
private DirectoryPartitionConfiguration getExamplePartition()
{
MutableDirectoryPartitionConfiguration partConfig = new MutableDirectoryPartitionConfiguration();
@@ -181,6 +190,7 @@
return partConfig;
}
+
private DirectoryPartitionConfiguration getApachePartition()
{
MutableDirectoryPartitionConfiguration partConfig = new MutableDirectoryPartitionConfiguration();
@@ -207,6 +217,7 @@
return partConfig;
}
+
/**
* Shuts down the backing store, optionally deleting the database directory.
*
@@ -230,6 +241,7 @@
doDelete( config.getWorkingDirectory() );
}
+
/**
* Deletes the working directory.
*/
@@ -249,6 +261,7 @@
}
}
+
private void recursiveRemoveDir( File directory )
{
String[] filelist = directory.list();
@@ -256,7 +269,7 @@
for ( int ii = 0; ii < filelist.length; ii++ )
{
- tmpFile = new File( directory.getAbsolutePath(), filelist[ ii ] );
+ tmpFile = new File( directory.getAbsolutePath(), filelist[ii] );
if ( tmpFile.isDirectory() )
{
recursiveRemoveDir( tmpFile );
@@ -273,6 +286,7 @@
directory.delete();
}
+
/**
* Opens the LDIF file and loads the entries into the context.
*/
@@ -290,17 +304,17 @@
while ( iterator.hasNext() )
{
- String ldif = (String) iterator.next();
+ String ldif = ( String ) iterator.next();
Attributes attributes = new LockableAttributesImpl();
ldifParser.parse( attributes, ldif );
- String dn = (String) attributes.remove( "dn" ).get();
+ String dn = ( String ) attributes.remove( "dn" ).get();
if ( attributes.get( "objectClass" ).contains( "krb5KDCEntry" ) )
{
- String pw = (String) attributes.get( "userpassword" ).get();
- String krbPrincipal = (String) attributes.get( KerberosAttribute.PRINCIPAL ).get();
+ String pw = ( String ) attributes.get( "userpassword" ).get();
+ String krbPrincipal = ( String ) attributes.get( KerberosAttribute.PRINCIPAL ).get();
KerberosPrincipal principal = new KerberosPrincipal( krbPrincipal );
KerberosKey key = new KerberosKey( principal, pw.toCharArray(), "DES" );
@@ -354,13 +368,13 @@
while ( iterator.hasNext() )
{
- String ldif = (String) iterator.next();
+ String ldif = ( String ) iterator.next();
Attributes attributes = new LockableAttributesImpl();
ldifParser.parse( attributes, ldif );
- String dn = (String) attributes.remove( "dn" ).get();
+ String dn = ( String ) attributes.remove( "dn" ).get();
rdn = getRelativeName( ctx.getNameInNamespace(), dn );
@@ -393,6 +407,7 @@
}
}
+
/**
* Tries to find an LDIF file either on the file system or packaged within a jar.
*
@@ -425,6 +440,7 @@
return in;
}
+
protected Name getRelativeName( String nameInNamespace, String baseDn ) throws NamingException
{
Properties props = new Properties();
@@ -451,6 +467,7 @@
return searchBaseDn;
}
+
/*
* escape LDAP filter characters as \HH (hex value).
*/
@@ -481,6 +498,7 @@
return escapedBuf.toString();
}
+
protected void printAttr( Attributes attrs, String id )
{
if ( attrs == null || id == null )
@@ -492,7 +510,7 @@
try
{
Attribute attr;
- String a = ( attr = attrs.get( id ) ) != null ? (String) attr.get() : null;
+ String a = ( attr = attrs.get( id ) ) != null ? ( String ) attr.get() : null;
System.out.println( attr.getID() + ":\t" + a );
}
catch ( NamingException e )
@@ -501,6 +519,7 @@
}
}
+
protected void printAttrs( Attributes attrs )
{
if ( attrs == null )
@@ -513,7 +532,7 @@
{
for ( NamingEnumeration ae = attrs.getAll(); ae.hasMore(); )
{
- final Attribute attr = (Attribute) ae.next();
+ final Attribute attr = ( Attribute ) ae.next();
for ( NamingEnumeration e = attr.getAll(); e.hasMore(); )
{
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractBackingStoreTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LdapLoader.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LdapLoader.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LdapLoader.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LdapLoader.java Sun Feb 19 19:57:02 2006
@@ -17,7 +17,9 @@
package org.apache.directory.server.protocol.shared;
+
import java.util.Map;
+
/**
* Load strategy for configuration properties coming from LDAP.
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LdapLoader.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LoadStrategy.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LoadStrategy.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LoadStrategy.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LoadStrategy.java Sun Feb 19 19:57:02 2006
@@ -17,8 +17,10 @@
package org.apache.directory.server.protocol.shared;
+
import java.util.Map;
+
/**
* Load strategy interface for configuration properties.
*
@@ -29,6 +31,7 @@
{
public static final int LDAP = 1;
public static final int PROPS = 2;
+
public Map load( String prefix, Map properties );
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/LoadStrategy.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/MapAdapter.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/MapAdapter.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/MapAdapter.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/MapAdapter.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.protocol.shared;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
@@ -28,6 +29,7 @@
import java.util.Map;
import java.util.Set;
+
/**
* Adapter to add the Map interface to Dictionary's. Many of the OSGi interfaces use
* Dictionary's for legacy reasons, but the Dictionary is obsolete.
@@ -39,11 +41,13 @@
{
private Dictionary dictionary;
- public MapAdapter( Dictionary dictionary )
+
+ public MapAdapter(Dictionary dictionary)
{
this.dictionary = dictionary;
}
+
/**
* @see java.util.Map#clear()
*/
@@ -52,6 +56,7 @@
dictionary = new Hashtable();
}
+
/**
* @see java.util.Map#containsKey(java.lang.Object)
*/
@@ -60,6 +65,7 @@
return Collections.list( dictionary.keys() ).contains( key );
}
+
/**
* @see java.util.Map#containsValue(java.lang.Object)
*/
@@ -68,6 +74,7 @@
return Collections.list( dictionary.elements() ).contains( value );
}
+
/**
* @see java.util.Map#entrySet()
*/
@@ -87,6 +94,7 @@
return map.entrySet();
}
+
/**
* @see java.util.Map#get(java.lang.Object)
*/
@@ -95,6 +103,7 @@
return dictionary.get( key );
}
+
/**
* @see java.util.Map#isEmpty()
*/
@@ -103,6 +112,7 @@
return dictionary.isEmpty();
}
+
/**
* @see java.util.Map#keySet()
*/
@@ -111,6 +121,7 @@
return new HashSet( Collections.list( dictionary.keys() ) );
}
+
/**
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
@@ -119,6 +130,7 @@
return dictionary.put( arg0, arg1 );
}
+
/**
* @see java.util.Map#putAll(java.util.Map)
*/
@@ -128,11 +140,12 @@
while ( it.hasNext() )
{
- Map.Entry entry = (Map.Entry) it.next();
+ Map.Entry entry = ( Map.Entry ) it.next();
dictionary.put( entry.getKey(), entry.getValue() );
}
}
+
/**
* @see java.util.Map#remove(java.lang.Object)
*/
@@ -141,6 +154,7 @@
return dictionary.remove( key );
}
+
/**
* @see java.util.Map#size()
*/
@@ -148,6 +162,7 @@
{
return dictionary.size();
}
+
/**
* @see java.util.Map#values()
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/MapAdapter.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/PropsLoader.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/PropsLoader.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/PropsLoader.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/PropsLoader.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.protocol.shared;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+
/**
* Load strategy for configuration properties coming from a properties file.
*
@@ -37,11 +39,11 @@
while ( it.hasNext() )
{
- String key = (String) it.next();
+ String key = ( String ) it.next();
if ( properties.get( key ) instanceof String )
{
- String value = (String) properties.get( key );
+ String value = ( String ) properties.get( key );
if ( key.startsWith( prefix ) )
{
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/PropsLoader.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java Sun Feb 19 19:57:02 2006
@@ -17,12 +17,14 @@
package org.apache.directory.server.protocol.shared;
+
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import org.apache.directory.server.core.configuration.Configuration;
+
/**
* Base class shared by all protocol providers for configuration.
*
@@ -73,6 +75,7 @@
/** the map of configuration */
protected Map configuration = new HashMap();
+
public String getCatalogBaseDn()
{
String key = CATALOG_BASEDN_KEY;
@@ -85,6 +88,7 @@
return null;
}
+
public String getEntryBaseDn()
{
String key = ENTRY_BASEDN_KEY;
@@ -97,6 +101,7 @@
return DEFAULT_ENTRY_BASEDN;
}
+
public String getInitialContextFactory()
{
String key = INITIAL_CONTEXT_FACTORY_KEY;
@@ -109,6 +114,7 @@
return DEFAULT_INITIAL_CONTEXT_FACTORY;
}
+
public Hashtable toJndiEnvironment()
{
Hashtable env = new Hashtable();
@@ -118,6 +124,7 @@
return env;
}
+
protected void loadProperties( String prefix, Map properties, int strategy )
{
LoadStrategy loader;
@@ -136,8 +143,9 @@
configuration.putAll( loader.load( prefix, properties ) );
}
+
protected String get( String key )
{
- return (String) configuration.get( key );
+ return ( String ) configuration.get( key );
}
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/Catalog.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/Catalog.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/Catalog.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/Catalog.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.protocol.shared.catalog;
+
/**
* The interface for resolving search-base DN's from zone or realm names.
*
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/Catalog.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/GetCatalog.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/GetCatalog.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/GetCatalog.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/GetCatalog.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.protocol.shared.catalog;
+
import java.util.HashMap;
import java.util.Map;
@@ -30,6 +31,7 @@
import org.apache.directory.server.protocol.shared.store.ContextOperation;
+
/**
* A JNDI context operation for building a catalog.
*
@@ -43,6 +45,7 @@
private static final String ENTRY_NAME = "apacheCatalogEntryName";
private static final String ENTRY_BASEDN = "apacheCatalogEntryBaseDn";
+
/**
* Note that the base is relative to the existing context.
*/
@@ -59,13 +62,13 @@
while ( list.hasMore() )
{
- SearchResult result = (SearchResult) list.next();
+ SearchResult result = ( SearchResult ) list.next();
Attributes attrs = result.getAttributes();
Attribute attr;
- String name = ( attr = attrs.get( ENTRY_NAME ) ) != null ? (String) attr.get() : null;
- String basedn = ( attr = attrs.get( ENTRY_BASEDN ) ) != null ? (String) attr.get() : null;
+ String name = ( attr = attrs.get( ENTRY_NAME ) ) != null ? ( String ) attr.get() : null;
+ String basedn = ( attr = attrs.get( ENTRY_BASEDN ) ) != null ? ( String ) attr.get() : null;
catalog.put( name, basedn );
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/catalog/GetCatalog.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java Sun Feb 19 19:57:02 2006
@@ -1,111 +1,113 @@
-/*
- * Copyright 2003-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.directory.server.protocol.shared.chain;
-
-/**
- * <p>A {@link Chain} represents a configured list of
- * {@link Command}s that will be executed in order to perform processing
- * on a specified {@link Context}. Each included {@link Command} will be
- * executed in turn, until either one of them returns <code>true</code>,
- * one of the executed {@link Command}s throws an exception,
- * or the end of the chain has been reached. The {@link Chain} itself will
- * return the return value of the last {@link Command} that was executed
- * (if no exception was thrown), or rethrow the thrown exception.</p>
- *
- * <p>Note that {@link Chain} extends {@link Command}, so that the two can
- * be used interchangeably when a {@link Command} is expected. This makes it
- * easy to assemble workflows in a hierarchical manner by combining subchains
- * into an overall processing chain.</p>
- *
- * <p>To protect applications from evolution of this interface, specialized
- * implementations of {@link Chain} should generally be created by extending
- * the provided base class {@link org.apache.directory.server.protocol.shared.chain.impl.ChainBase})
- * rather than directly implementing this interface.</p>
- *
- * <p>{@link Chain} implementations should be designed in a thread-safe
- * manner, suitable for execution on multiple threads simultaneously. In
- * general, this implies that the state information identifying which
- * {@link Command} is currently being executed should be maintained in a
- * local variable inside the <code>execute()</code> method, rather than
- * in an instance variable. The {@link Command}s in a {@link Chain} may be
- * configured (via calls to <code>addCommand()</code>) at any time before
- * the <code>execute()</code> method of the {@link Chain} is first called.
- * After that, the configuration of the {@link Chain} is frozen.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public interface Chain extends Command
-{
- /**
- * <p>Add a {@link Command} to the list of {@link Command}s that will
- * be called in turn when this {@link Chain}'s <code>execute()</code>
- * method is called. Once <code>execute()</code> has been called
- * at least once, it is no longer possible to add additional
- * {@link Command}s; instead, an exception will be thrown.</p>
- *
- * @param command The {@link Command} to be added
- *
- * @exception IllegalArgumentException if <code>command</code>
- * is <code>null</code>
- * @exception IllegalStateException if this {@link Chain} has already
- * been executed at least once, so no further configuration is allowed
- */
- void addCommand( Command command );
-
- /**
- * <p>Execute the processing represented by this {@link Chain} according
- * to the following algorithm.</p>
- * <ul>
- * <li>If there are no configured {@link Command}s in the {@link Chain},
- * return <code>false</code>.</li>
- * <li>Call the <code>execute()</code> method of each {@link Command}
- * configured on this chain, in the order they were added via calls
- * to the <code>addCommand()</code> method, until the end of the
- * configured {@link Command}s is encountered, or until one of
- * the executed {@link Command}s returns <code>true</code>
- * or throws an exception.</li>
- * <li>Walk backwards through the {@link Command}s whose
- * <code>execute()</code> methods, starting with the last one that
- * was executed. If this {@link Command} instance is also a
- * {@link Filter}, call its <code>postprocess()</code> method,
- * discarding any exception that is thrown.</li>
- * <li>If the last {@link Command} whose <code>execute()</code> method
- * was called threw an exception, rethrow that exception.</li>
- * <li>Otherwise, return the value returned by the <code>execute()</code>
- * method of the last {@link Command} that was executed. This will be
- * <code>true</code> if the last {@link Command} indicated that
- * processing of this {@link Context} has been completed, or
- * <code>false</code> if none of the called {@link Command}s
- * returned <code>true</code>.</li>
- * </ul>
- *
- * @param context The {@link Context} to be processed by this
- * {@link Chain}
- *
- * @exception Exception if thrown by one of the {@link Command}s
- * in this {@link Chain} but not handled by a <code>postprocess()</code>
- * method of a {@link Filter}
- * @exception IllegalArgumentException if <code>context</code>
- * is <code>null</code>
- *
- * @return <code>true</code> if the processing of this {@link Context}
- * has been completed, or <code>false</code> if the processing
- * of this {@link Context} should be delegated to a subsequent
- * {@link Command} in an enclosing {@link Chain}
- */
- boolean execute( Context context ) throws Exception;
+/*
+ * Copyright 2003-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.directory.server.protocol.shared.chain;
+
+
+/**
+ * <p>A {@link Chain} represents a configured list of
+ * {@link Command}s that will be executed in order to perform processing
+ * on a specified {@link Context}. Each included {@link Command} will be
+ * executed in turn, until either one of them returns <code>true</code>,
+ * one of the executed {@link Command}s throws an exception,
+ * or the end of the chain has been reached. The {@link Chain} itself will
+ * return the return value of the last {@link Command} that was executed
+ * (if no exception was thrown), or rethrow the thrown exception.</p>
+ *
+ * <p>Note that {@link Chain} extends {@link Command}, so that the two can
+ * be used interchangeably when a {@link Command} is expected. This makes it
+ * easy to assemble workflows in a hierarchical manner by combining subchains
+ * into an overall processing chain.</p>
+ *
+ * <p>To protect applications from evolution of this interface, specialized
+ * implementations of {@link Chain} should generally be created by extending
+ * the provided base class {@link org.apache.directory.server.protocol.shared.chain.impl.ChainBase})
+ * rather than directly implementing this interface.</p>
+ *
+ * <p>{@link Chain} implementations should be designed in a thread-safe
+ * manner, suitable for execution on multiple threads simultaneously. In
+ * general, this implies that the state information identifying which
+ * {@link Command} is currently being executed should be maintained in a
+ * local variable inside the <code>execute()</code> method, rather than
+ * in an instance variable. The {@link Command}s in a {@link Chain} may be
+ * configured (via calls to <code>addCommand()</code>) at any time before
+ * the <code>execute()</code> method of the {@link Chain} is first called.
+ * After that, the configuration of the {@link Chain} is frozen.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+public interface Chain extends Command
+{
+ /**
+ * <p>Add a {@link Command} to the list of {@link Command}s that will
+ * be called in turn when this {@link Chain}'s <code>execute()</code>
+ * method is called. Once <code>execute()</code> has been called
+ * at least once, it is no longer possible to add additional
+ * {@link Command}s; instead, an exception will be thrown.</p>
+ *
+ * @param command The {@link Command} to be added
+ *
+ * @exception IllegalArgumentException if <code>command</code>
+ * is <code>null</code>
+ * @exception IllegalStateException if this {@link Chain} has already
+ * been executed at least once, so no further configuration is allowed
+ */
+ void addCommand( Command command );
+
+
+ /**
+ * <p>Execute the processing represented by this {@link Chain} according
+ * to the following algorithm.</p>
+ * <ul>
+ * <li>If there are no configured {@link Command}s in the {@link Chain},
+ * return <code>false</code>.</li>
+ * <li>Call the <code>execute()</code> method of each {@link Command}
+ * configured on this chain, in the order they were added via calls
+ * to the <code>addCommand()</code> method, until the end of the
+ * configured {@link Command}s is encountered, or until one of
+ * the executed {@link Command}s returns <code>true</code>
+ * or throws an exception.</li>
+ * <li>Walk backwards through the {@link Command}s whose
+ * <code>execute()</code> methods, starting with the last one that
+ * was executed. If this {@link Command} instance is also a
+ * {@link Filter}, call its <code>postprocess()</code> method,
+ * discarding any exception that is thrown.</li>
+ * <li>If the last {@link Command} whose <code>execute()</code> method
+ * was called threw an exception, rethrow that exception.</li>
+ * <li>Otherwise, return the value returned by the <code>execute()</code>
+ * method of the last {@link Command} that was executed. This will be
+ * <code>true</code> if the last {@link Command} indicated that
+ * processing of this {@link Context} has been completed, or
+ * <code>false</code> if none of the called {@link Command}s
+ * returned <code>true</code>.</li>
+ * </ul>
+ *
+ * @param context The {@link Context} to be processed by this
+ * {@link Chain}
+ *
+ * @exception Exception if thrown by one of the {@link Command}s
+ * in this {@link Chain} but not handled by a <code>postprocess()</code>
+ * method of a {@link Filter}
+ * @exception IllegalArgumentException if <code>context</code>
+ * is <code>null</code>
+ *
+ * @return <code>true</code> if the processing of this {@link Context}
+ * has been completed, or <code>false</code> if the processing
+ * of this {@link Context} should be delegated to a subsequent
+ * {@link Command} in an enclosing {@link Chain}
+ */
+ boolean execute( Context context ) throws Exception;
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Chain.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java Sun Feb 19 19:57:02 2006
@@ -1,100 +1,101 @@
-/*
- * Copyright 2003-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.directory.server.protocol.shared.chain;
-
-/**
- * <p>A {@link Command} encapsulates a unit of processing work to be
- * performed, whose purpose is to examine and/or modify the state of a
- * transaction that is represented by a {@link Context}. Individual
- * {@link Command}s can be assembled into a {@link Chain}, which allows
- * them to either complete the required processing or delegate further
- * processing to the next {@link Command} in the {@link Chain}.</p>
- *
- * <p>{@link Command} implementations should be designed in a thread-safe
- * manner, suitable for inclusion in multiple {@link Chain}s that might be
- * processed by different threads simultaneously. In general, this implies
- * that {@link Command} classes should not maintain state information in
- * instance variables. Instead, state information should be maintained via
- * suitable modifications to the attributes of the {@link Context} that is
- * passed to the <code>execute()</code> command.</p>
- *
- * <p>{@link Command} implementations typically retrieve and store state
- * information in the {@link Context} instance that is passed as a parameter
- * to the <code>execute()</code> method, using particular keys into the
- * <code>Map</code> that can be acquired via
- * <code>Context.getAttributes()</code>. To improve interoperability of
- * {@link Command} implementations, a useful design pattern is to expose the
- * key values used as JavaBeans properties of the {@link Command}
- * implementation class itself. For example, a {@link Command} that requires
- * an input and an output key might implement the following properties:</p>
- *
- * <pre>
- * private String inputKey = "input";
- * public String getInputKey() {
- * return (this.inputKey);
- * }
- * public void setInputKey(String inputKey) {
- * this.inputKey = inputKey;
- * }
- *
- * private String outputKey = "output";
- * public String getOutputKey() {
- * return (this.outputKey);
- * }
- * public void setOutputKey(String outputKey) {
- * this.outputKey = outputKey;
- * }
- * </pre>
- *
- * <p>And the operation of accessing the "input" information in the context
- * would be executed by calling:</p>
- *
- * <pre>
- * String input = (String) context.get(getInputKey());
- * </pre>
- *
- * <p>instead of hard coding the attribute name. The use of the "Key"
- * suffix on such property names is a useful convention to identify properties
- * being used in this fashion, as opposed to JavaBeans properties that simply
- * configure the internal operation of this {@link Command}.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public interface Command
-{
- /**
- * <p>Execute a unit of processing work to be performed. This
- * {@link Command} may either complete the required processing
- * and return <code>true</code>, or delegate remaining processing
- * to the next {@link Command} in a {@link Chain} containing this
- * {@link Command} by returning <code>false</code>
- *
- * @param context The {@link Context} to be processed by this
- * {@link Command}
- *
- * @exception Exception general purpose exception return
- * to indicate abnormal termination
- * @exception IllegalArgumentException if <code>context</code>
- * is <code>null</code>
- *
- * @return <code>true</code> if the processing of this {@link Context}
- * has been completed, or <code>false</code> if the processing
- * of this {@link Context} should be delegated to a subsequent
- * {@link Command} in an enclosing {@link Chain}
- */
- boolean execute( Context context ) throws Exception;
+/*
+ * Copyright 2003-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.directory.server.protocol.shared.chain;
+
+
+/**
+ * <p>A {@link Command} encapsulates a unit of processing work to be
+ * performed, whose purpose is to examine and/or modify the state of a
+ * transaction that is represented by a {@link Context}. Individual
+ * {@link Command}s can be assembled into a {@link Chain}, which allows
+ * them to either complete the required processing or delegate further
+ * processing to the next {@link Command} in the {@link Chain}.</p>
+ *
+ * <p>{@link Command} implementations should be designed in a thread-safe
+ * manner, suitable for inclusion in multiple {@link Chain}s that might be
+ * processed by different threads simultaneously. In general, this implies
+ * that {@link Command} classes should not maintain state information in
+ * instance variables. Instead, state information should be maintained via
+ * suitable modifications to the attributes of the {@link Context} that is
+ * passed to the <code>execute()</code> command.</p>
+ *
+ * <p>{@link Command} implementations typically retrieve and store state
+ * information in the {@link Context} instance that is passed as a parameter
+ * to the <code>execute()</code> method, using particular keys into the
+ * <code>Map</code> that can be acquired via
+ * <code>Context.getAttributes()</code>. To improve interoperability of
+ * {@link Command} implementations, a useful design pattern is to expose the
+ * key values used as JavaBeans properties of the {@link Command}
+ * implementation class itself. For example, a {@link Command} that requires
+ * an input and an output key might implement the following properties:</p>
+ *
+ * <pre>
+ * private String inputKey = "input";
+ * public String getInputKey() {
+ * return (this.inputKey);
+ * }
+ * public void setInputKey(String inputKey) {
+ * this.inputKey = inputKey;
+ * }
+ *
+ * private String outputKey = "output";
+ * public String getOutputKey() {
+ * return (this.outputKey);
+ * }
+ * public void setOutputKey(String outputKey) {
+ * this.outputKey = outputKey;
+ * }
+ * </pre>
+ *
+ * <p>And the operation of accessing the "input" information in the context
+ * would be executed by calling:</p>
+ *
+ * <pre>
+ * String input = (String) context.get(getInputKey());
+ * </pre>
+ *
+ * <p>instead of hard coding the attribute name. The use of the "Key"
+ * suffix on such property names is a useful convention to identify properties
+ * being used in this fashion, as opposed to JavaBeans properties that simply
+ * configure the internal operation of this {@link Command}.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+public interface Command
+{
+ /**
+ * <p>Execute a unit of processing work to be performed. This
+ * {@link Command} may either complete the required processing
+ * and return <code>true</code>, or delegate remaining processing
+ * to the next {@link Command} in a {@link Chain} containing this
+ * {@link Command} by returning <code>false</code>
+ *
+ * @param context The {@link Context} to be processed by this
+ * {@link Command}
+ *
+ * @exception Exception general purpose exception return
+ * to indicate abnormal termination
+ * @exception IllegalArgumentException if <code>context</code>
+ * is <code>null</code>
+ *
+ * @return <code>true</code> if the processing of this {@link Context}
+ * has been completed, or <code>false</code> if the processing
+ * of this {@link Context} should be delegated to a subsequent
+ * {@link Command} in an enclosing {@link Chain}
+ */
+ boolean execute( Context context ) throws Exception;
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Command.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java Sun Feb 19 19:57:02 2006
@@ -1,62 +1,64 @@
-/*
- * Copyright 2003-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.directory.server.protocol.shared.chain;
-
-import java.util.Map;
-
-/**
- * <p>A {@link Context} represents the state information that is
- * accessed and manipulated by the execution of a {@link Command} or a
- * {@link Chain}. Specialized implementations of {@link Context} will
- * typically add JavaBeans properties that contain typesafe accessors
- * to information that is relevant to a particular use case for this
- * context, and/or add operations that affect the state information
- * that is saved in the context.</p>
- *
- * <p>Implementations of {@link Context} must also implement all of the
- * required and optional contracts of the <code>java.util.Map</code>
- * interface.</p>
- *
- * <p>It is strongly recommended, but not required, that JavaBeans
- * properties added to a particular {@link Context} implementation exhibit
- * <em>Attribute-Property Transparency</em>. In other words,
- * a value stored via a call to <code>setFoo(value)</code> should be visible
- * by calling <code>get("foo")</code>, and a value stored
- * via a call to <code>put("foo", value)</code> should be
- * visible by calling <code>getFoo()</code>. If your {@link Context}
- * implementation class exhibits this featue, it becomes easier to reuse the
- * implementation in multiple environments, without the need to cast to a
- * particular implementation class in order to access the property getter
- * and setter methods.</p>
- *
- * <p>To protect applications from evolution of this interface, specialized
- * implementations of {@link Context} should generally be created by extending
- * the provided base class ({@link org.apache.directory.server.protocol.shared.chain.impl.ContextBase})
- * rather than directly implementing this interface.</p>
- *
- * <p>Applications should <strong>NOT</strong> assume that
- * {@link Context} implementations, or the values stored in its
- * attributes, may be accessed from multiple threads
- * simultaneously unless this is explicitly documented for a particular
- * implementation.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public interface Context extends Map
-{
-
+/*
+ * Copyright 2003-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.directory.server.protocol.shared.chain;
+
+
+import java.util.Map;
+
+
+/**
+ * <p>A {@link Context} represents the state information that is
+ * accessed and manipulated by the execution of a {@link Command} or a
+ * {@link Chain}. Specialized implementations of {@link Context} will
+ * typically add JavaBeans properties that contain typesafe accessors
+ * to information that is relevant to a particular use case for this
+ * context, and/or add operations that affect the state information
+ * that is saved in the context.</p>
+ *
+ * <p>Implementations of {@link Context} must also implement all of the
+ * required and optional contracts of the <code>java.util.Map</code>
+ * interface.</p>
+ *
+ * <p>It is strongly recommended, but not required, that JavaBeans
+ * properties added to a particular {@link Context} implementation exhibit
+ * <em>Attribute-Property Transparency</em>. In other words,
+ * a value stored via a call to <code>setFoo(value)</code> should be visible
+ * by calling <code>get("foo")</code>, and a value stored
+ * via a call to <code>put("foo", value)</code> should be
+ * visible by calling <code>getFoo()</code>. If your {@link Context}
+ * implementation class exhibits this featue, it becomes easier to reuse the
+ * implementation in multiple environments, without the need to cast to a
+ * particular implementation class in order to access the property getter
+ * and setter methods.</p>
+ *
+ * <p>To protect applications from evolution of this interface, specialized
+ * implementations of {@link Context} should generally be created by extending
+ * the provided base class ({@link org.apache.directory.server.protocol.shared.chain.impl.ContextBase})
+ * rather than directly implementing this interface.</p>
+ *
+ * <p>Applications should <strong>NOT</strong> assume that
+ * {@link Context} implementations, or the values stored in its
+ * attributes, may be accessed from multiple threads
+ * simultaneously unless this is explicitly documented for a particular
+ * implementation.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+public interface Context extends Map
+{
+
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Context.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java Sun Feb 19 19:57:02 2006
@@ -1,62 +1,63 @@
-/*
- * Copyright 2003-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.directory.server.protocol.shared.chain;
-
-/**
- * <p>A {@link Filter} is a specialized {@link Command} that also expects
- * the {@link Chain} that is executing it to call the
- * <code>postprocess()</code> method if it called the <code>execute()</code>
- * method. This promise must be fulfilled in spite of any possible
- * exceptions thrown by the <code>execute()</code> method of this
- * {@link Command}, or any subsequent {@link Command} whose
- * <code>execute()</code> method was called. The owning {@link Chain}
- * must call the <code>postprocess()</code> method of each {@link Filter}
- * in a {@link Chain} in reverse order of the invocation of their
- * <code>execute()</code> methods.</p>
- *
- * <p>The most common use case for a {@link Filter}, as opposed to a
- * {@link Command}, is where potentially expensive resources must be acquired
- * and held until the processing of a particular request has been completed,
- * even it execution is delegated to a subsequent {@link Command} via the
- * <code>execute()</code> returning <code>false</code>. A {@link Filter}
- * can reliably release such resources in the <code>postprocess()</code>
- * method, which is guaranteed to be called by the owning {@link Chain}.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public interface Filter extends Command
-{
- /**
- * <p>Execute any cleanup activities, such as releasing resources that
- * were acquired during the <code>execute()</code> method of this
- * {@link Filter} instance.</p>
- *
- * @param context The {@link Context} to be processed by this
- * {@link Filter}
- * @param exception The <code>Exception</code> (if any) that was thrown
- * by the last {@link Command} that was executed; otherwise
- * <code>null</code>
- *
- * @exception IllegalArgumentException if <code>context</code>
- * is <code>null</code>
- *
- * @return If a non-null <code>exception</code> was "handled" by this
- * method (and therefore need not be rethrown), return <code>true</code>;
- * otherwise return <code>false</code>
- */
- boolean postprocess( Context context, Exception exception );
+/*
+ * Copyright 2003-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.directory.server.protocol.shared.chain;
+
+
+/**
+ * <p>A {@link Filter} is a specialized {@link Command} that also expects
+ * the {@link Chain} that is executing it to call the
+ * <code>postprocess()</code> method if it called the <code>execute()</code>
+ * method. This promise must be fulfilled in spite of any possible
+ * exceptions thrown by the <code>execute()</code> method of this
+ * {@link Command}, or any subsequent {@link Command} whose
+ * <code>execute()</code> method was called. The owning {@link Chain}
+ * must call the <code>postprocess()</code> method of each {@link Filter}
+ * in a {@link Chain} in reverse order of the invocation of their
+ * <code>execute()</code> methods.</p>
+ *
+ * <p>The most common use case for a {@link Filter}, as opposed to a
+ * {@link Command}, is where potentially expensive resources must be acquired
+ * and held until the processing of a particular request has been completed,
+ * even it execution is delegated to a subsequent {@link Command} via the
+ * <code>execute()</code> returning <code>false</code>. A {@link Filter}
+ * can reliably release such resources in the <code>postprocess()</code>
+ * method, which is guaranteed to be called by the owning {@link Chain}.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+public interface Filter extends Command
+{
+ /**
+ * <p>Execute any cleanup activities, such as releasing resources that
+ * were acquired during the <code>execute()</code> method of this
+ * {@link Filter} instance.</p>
+ *
+ * @param context The {@link Context} to be processed by this
+ * {@link Filter}
+ * @param exception The <code>Exception</code> (if any) that was thrown
+ * by the last {@link Command} that was executed; otherwise
+ * <code>null</code>
+ *
+ * @exception IllegalArgumentException if <code>context</code>
+ * is <code>null</code>
+ *
+ * @return If a non-null <code>exception</code> was "handled" by this
+ * method (and therefore need not be rethrown), return <code>true</code>;
+ * otherwise return <code>false</code>
+ */
+ boolean postprocess( Context context, Exception exception );
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/Filter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java Sun Feb 19 19:57:02 2006
@@ -1,225 +1,233 @@
-/*
- * Copyright 1999-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.directory.server.protocol.shared.chain.impl;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.directory.server.protocol.shared.chain.Chain;
-import org.apache.directory.server.protocol.shared.chain.Command;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.Filter;
-
-/**
- * <p>Convenience base class for {@link Chain} implementations.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public class ChainBase implements Chain
-{
- // ----------------------------------------------------------- Constructors
-
- /**
- * <p>Construct a {@link Chain} with no configured {@link Command}s.</p>
- */
- public ChainBase()
- {
-
- }
-
- /**
- * <p>Construct a {@link Chain} configured with the specified
- * {@link Command}.</p>
- *
- * @param command The {@link Command} to be configured
- *
- * @exception IllegalArgumentException if <code>command</code>
- * is <code>null</code>
- */
- public ChainBase( Command command )
- {
- addCommand( command );
- }
-
- /**
- * <p>Construct a {@link Chain} configured with the specified
- * {@link Command}s.</p>
- *
- * @param commands The {@link Command}s to be configured
- *
- * @exception IllegalArgumentException if <code>commands</code>,
- * or one of the individual {@link Command} elements,
- * is <code>null</code>
- */
- public ChainBase( Command[] commands )
- {
- if ( commands == null )
- {
- throw new IllegalArgumentException();
- }
-
- for ( int i = 0; i < commands.length; i++ )
- {
- addCommand( commands[ i ] );
- }
- }
-
- /**
- * <p>Construct a {@link Chain} configured with the specified
- * {@link Command}s.</p>
- *
- * @param commands The {@link Command}s to be configured
- *
- * @exception IllegalArgumentException if <code>commands</code>,
- * or one of the individual {@link Command} elements,
- * is <code>null</code>
- */
- public ChainBase( Collection commands )
- {
- if ( commands == null )
- {
- throw new IllegalArgumentException();
- }
-
- Iterator elements = commands.iterator();
- while ( elements.hasNext() )
- {
- addCommand( (Command) elements.next() );
- }
- }
-
- // ----------------------------------------------------- Instance Variables
-
- /**
- * <p>The list of {@link Command}s configured for this {@link Chain}, in
- * the order in which they may delegate processing to the remainder of
- * the {@link Chain}.</p>
- */
- protected Command[] commands = new Command[ 0 ];
-
- /**
- * <p>Flag indicating whether the configuration of our commands list
- * has been frozen by a call to the <code>execute()</code> method.</p>
- */
- protected boolean frozen = false;
-
- // ---------------------------------------------------------- Chain Methods
-
- // Documented in Chain interface
- public void addCommand( Command command )
- {
- if ( command == null )
- {
- throw new IllegalArgumentException();
- }
-
- if ( frozen )
- {
- throw new IllegalStateException();
- }
-
- Command[] results = new Command[ commands.length + 1 ];
- System.arraycopy( commands, 0, results, 0, commands.length );
- results[ commands.length ] = command;
- commands = results;
- }
-
- // Documented in Chain interface
- public boolean execute( Context context ) throws Exception
- {
- // Verify our parameters
- if ( context == null )
- {
- throw new IllegalArgumentException();
- }
-
- // Freeze the configuration of the command list
- frozen = true;
-
- // Execute the commands in this list until one returns true
- // or throws an exception
- boolean saveResult = false;
- Exception saveException = null;
- int i = 0;
- int n = commands.length;
- ;
- for ( i = 0; i < n; i++ )
- {
- try
- {
- saveResult = commands[ i ].execute( context );
- if ( saveResult )
- {
- break;
- }
- }
- catch ( Exception e )
- {
- saveException = e;
- break;
- }
- }
-
- // Call postprocess methods on Filters in reverse order
- if ( i >= n )
- { // Fell off the end of the chain
- i--;
- }
- boolean handled = false;
- boolean result = false;
- for ( int j = i; j >= 0; j-- )
- {
- if ( commands[ j ] instanceof Filter )
- {
- try
- {
- result = ( (Filter) commands[ j ] ).postprocess( context, saveException );
- if ( result )
- {
- handled = true;
- }
- }
- catch ( Exception e )
- {
- ; // Silently ignore
- }
- }
- }
-
- // Return the exception or result state from the last execute()
- if ( ( saveException != null ) && !handled )
- {
- throw saveException;
- }
- else
- {
- return ( saveResult );
- }
- }
-
- // -------------------------------------------------------- Package Methods
-
- /**
- * <p>Return an array of the configured {@link Command}s for this
- * {@link Chain}. This method is package private, and is used only
- * for the unit tests.</p>
- */
- Command[] getCommands()
- {
- return ( commands );
- }
+/*
+ * Copyright 1999-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.directory.server.protocol.shared.chain.impl;
+
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.directory.server.protocol.shared.chain.Chain;
+import org.apache.directory.server.protocol.shared.chain.Command;
+import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.directory.server.protocol.shared.chain.Filter;
+
+
+/**
+ * <p>Convenience base class for {@link Chain} implementations.</p>
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision$ $Date$
+ */
+public class ChainBase implements Chain
+{
+ // ----------------------------------------------------------- Constructors
+
+ /**
+ * <p>Construct a {@link Chain} with no configured {@link Command}s.</p>
+ */
+ public ChainBase()
+ {
+
+ }
+
+
+ /**
+ * <p>Construct a {@link Chain} configured with the specified
+ * {@link Command}.</p>
+ *
+ * @param command The {@link Command} to be configured
+ *
+ * @exception IllegalArgumentException if <code>command</code>
+ * is <code>null</code>
+ */
+ public ChainBase(Command command)
+ {
+ addCommand( command );
+ }
+
+
+ /**
+ * <p>Construct a {@link Chain} configured with the specified
+ * {@link Command}s.</p>
+ *
+ * @param commands The {@link Command}s to be configured
+ *
+ * @exception IllegalArgumentException if <code>commands</code>,
+ * or one of the individual {@link Command} elements,
+ * is <code>null</code>
+ */
+ public ChainBase(Command[] commands)
+ {
+ if ( commands == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ for ( int i = 0; i < commands.length; i++ )
+ {
+ addCommand( commands[i] );
+ }
+ }
+
+
+ /**
+ * <p>Construct a {@link Chain} configured with the specified
+ * {@link Command}s.</p>
+ *
+ * @param commands The {@link Command}s to be configured
+ *
+ * @exception IllegalArgumentException if <code>commands</code>,
+ * or one of the individual {@link Command} elements,
+ * is <code>null</code>
+ */
+ public ChainBase(Collection commands)
+ {
+ if ( commands == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ Iterator elements = commands.iterator();
+ while ( elements.hasNext() )
+ {
+ addCommand( ( Command ) elements.next() );
+ }
+ }
+
+ // ----------------------------------------------------- Instance Variables
+
+ /**
+ * <p>The list of {@link Command}s configured for this {@link Chain}, in
+ * the order in which they may delegate processing to the remainder of
+ * the {@link Chain}.</p>
+ */
+ protected Command[] commands = new Command[0];
+
+ /**
+ * <p>Flag indicating whether the configuration of our commands list
+ * has been frozen by a call to the <code>execute()</code> method.</p>
+ */
+ protected boolean frozen = false;
+
+
+ // ---------------------------------------------------------- Chain Methods
+
+ // Documented in Chain interface
+ public void addCommand( Command command )
+ {
+ if ( command == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ if ( frozen )
+ {
+ throw new IllegalStateException();
+ }
+
+ Command[] results = new Command[commands.length + 1];
+ System.arraycopy( commands, 0, results, 0, commands.length );
+ results[commands.length] = command;
+ commands = results;
+ }
+
+
+ // Documented in Chain interface
+ public boolean execute( Context context ) throws Exception
+ {
+ // Verify our parameters
+ if ( context == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ // Freeze the configuration of the command list
+ frozen = true;
+
+ // Execute the commands in this list until one returns true
+ // or throws an exception
+ boolean saveResult = false;
+ Exception saveException = null;
+ int i = 0;
+ int n = commands.length;
+ ;
+ for ( i = 0; i < n; i++ )
+ {
+ try
+ {
+ saveResult = commands[i].execute( context );
+ if ( saveResult )
+ {
+ break;
+ }
+ }
+ catch ( Exception e )
+ {
+ saveException = e;
+ break;
+ }
+ }
+
+ // Call postprocess methods on Filters in reverse order
+ if ( i >= n )
+ { // Fell off the end of the chain
+ i--;
+ }
+ boolean handled = false;
+ boolean result = false;
+ for ( int j = i; j >= 0; j-- )
+ {
+ if ( commands[j] instanceof Filter )
+ {
+ try
+ {
+ result = ( ( Filter ) commands[j] ).postprocess( context, saveException );
+ if ( result )
+ {
+ handled = true;
+ }
+ }
+ catch ( Exception e )
+ {
+ ; // Silently ignore
+ }
+ }
+ }
+
+ // Return the exception or result state from the last execute()
+ if ( ( saveException != null ) && !handled )
+ {
+ throw saveException;
+ }
+ else
+ {
+ return ( saveResult );
+ }
+ }
+
+
+ // -------------------------------------------------------- Package Methods
+
+ /**
+ * <p>Return an array of the configured {@link Command}s for this
+ * {@link Chain}. This method is package private, and is used only
+ * for the unit tests.</p>
+ */
+ Command[] getCommands()
+ {
+ return ( commands );
+ }
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/ChainBase.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java (original)
+++ directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java Sun Feb 19 19:57:02 2006
@@ -1,31 +1,33 @@
-/*
- * Copyright 2005 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.directory.server.protocol.shared.chain.impl;
-
-import org.apache.directory.server.protocol.shared.chain.Command;
-
-/**
- * <p>Convenience base class for {@link Command} implementations.</p>
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public abstract class CommandBase implements Command
-{
- public static final boolean STOP_CHAIN = true;
- public static final boolean CONTINUE_CHAIN = false;
+/*
+ * Copyright 2005 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.directory.server.protocol.shared.chain.impl;
+
+
+import org.apache.directory.server.protocol.shared.chain.Command;
+
+
+/**
+ * <p>Convenience base class for {@link Command} implementations.</p>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class CommandBase implements Command
+{
+ public static final boolean STOP_CHAIN = true;
+ public static final boolean CONTINUE_CHAIN = false;
}
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/chain/impl/CommandBase.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id