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 2004/03/06 03:49:38 UTC
svn commit: rev 7026 - in incubator/directory/eve/trunk/eve/frontend/decoder: pojo-impl pojo-impl/src pojo-impl/src/java pojo-impl/src/java/org pojo-impl/src/java/org/apache pojo-impl/src/java/org/apache/eve pojo-impl/src/java/org/apache/eve/decoder pojo-impl/src/java/org/apache/eve/decoder/impl spi/src/java/org/apache/eve/decoder
Author: akarasulu
Date: Fri Mar 5 18:49:35 2004
New Revision: 7026
Added:
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/ (props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.properties
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.xml
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DecodeStageHandler.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DefaultDecoderManager.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/ClientDecoder.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderConfig.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitor.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitorAdapter.java (contents, props changed)
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/NoOpDecoder.java (contents, props changed)
Modified:
incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManager.java
Log:
Added the pojo stub implementation of the decoder which only generates a
bind request as a hard coded request every time some data is read.
Also fixed the license headers on some files as well as the @author tags for
them.
Added: incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.properties
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.properties Fri Mar 5 18:49:35 2004
@@ -0,0 +1,2 @@
+maven.xdoc.date=left
+maven.xdoc.version=${pom.currentVersion}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.xml
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/project.xml Fri Mar 5 18:49:35 2004
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+ <extend>${basedir}/../../../project.xml</extend>
+ <groupId>directory</groupId>
+ <id>eve-frontend-decoder-pojo-impl</id>
+
+ <name>Eve Frontend DecoderManager Implementation</name>
+ <package>org.apache.eve.decoder.impl</package>
+ <currentVersion>SNAPSHOT</currentVersion>
+ <inceptionYear>2003</inceptionYear>
+
+ <shortDescription>
+ Eve's Frontend DecoderManager Implementation
+ </shortDescription>
+
+ <description>
+ Eve's frontend decoder manager decodes input from client sockets
+ bound to the server. The decoder responds to input events generated
+ by the input manager.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>ldap-common</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-common-api</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-event-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-event-pojo-impl</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-event-merlin-impl</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-input-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-decoder-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-buffer-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-buffer-pojo-impl</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <url>http://junit.org</url>
+ </dependency>
+ </dependencies>
+</project>
+
Added: incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DecodeStageHandler.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DecodeStageHandler.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder.impl ;
+
+
+import java.nio.ByteBuffer ;
+import java.util.EventObject ;
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+import org.apache.eve.event.InputEvent ;
+import org.apache.eve.seda.StageHandler ;
+import org.apache.eve.listener.ClientKey ;
+
+
+/**
+ * A decoder manager's decode StageHandler for use only with enqueued
+ * InputEvents.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DecodeStageHandler implements StageHandler
+{
+ /** reference to the decoder manager this handler is used by */
+ private final DefaultDecoderManager manager ;
+
+
+ /**
+ * Creates the decoder manager's decode stage handler.
+ *
+ * @param manager the decoder manager this handler is for
+ */
+ public DecodeStageHandler( DefaultDecoderManager manager )
+ {
+ this.manager = manager ;
+ }
+
+
+ /**
+ * Uses the client key to have the decoder manager lookup the client's
+ * stateful decoder. The decoder's decode method is called and control is
+ * returned. Error handling is left upto the decoder's monitor.
+ *
+ * @see org.apache.eve.seda.StageHandler#handleEvent(java.util.EventObject)
+ */
+ public void handleEvent( EventObject event )
+ {
+ InputEvent e = ( InputEvent ) event ;
+ ClientKey key = e.getClientKey() ;
+ ByteBuffer buf = e.claimInterest( this ) ;
+ StatefulDecoder decoder = ( StatefulDecoder ) manager.getDecoder( key );
+
+ try
+ {
+ decoder.decode( buf ) ;
+ }
+ catch( DecoderException ex )
+ {
+ /*
+ * monitor should be handling errors already for us and rethrowing
+ * so we shouldn't have to do anything here but return control
+ */
+ }
+ }
+}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DefaultDecoderManager.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/pojo-impl/src/java/org/apache/eve/decoder/impl/DefaultDecoderManager.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,326 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder.impl ;
+
+
+import java.math.BigInteger;
+import java.nio.ByteBuffer ;
+
+import java.util.Map ;
+import java.util.HashMap ;
+import java.util.EventObject ;
+
+import org.apache.eve.event.InputEvent ;
+import org.apache.eve.event.Subscriber ;
+import org.apache.eve.seda.StageConfig ;
+import org.apache.eve.event.EventRouter ;
+import org.apache.eve.seda.DefaultStage ;
+import org.apache.eve.listener.ClientKey ;
+import org.apache.eve.event.ConnectEvent ;
+import org.apache.eve.decoder.NoOpDecoder ;
+import org.apache.eve.decoder.ClientDecoder ;
+import org.apache.eve.event.DisconnectEvent ;
+import org.apache.eve.event.InputSubscriber ;
+import org.apache.eve.decoder.DecoderManager ;
+import org.apache.eve.event.RequestEvent;
+import org.apache.eve.event.SubscriberMonitor ;
+import org.apache.eve.event.ConnectSubscriber ;
+import org.apache.eve.event.AbstractSubscriber ;
+import org.apache.eve.event.DisconnectSubscriber ;
+import org.apache.eve.decoder.DecoderManagerMonitor ;
+import org.apache.eve.decoder.DecoderManagerMonitorAdapter ;
+import org.apache.ldap.common.message.BindRequestImpl;
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
+
+
+/**
+ * Default decoder managing component implementation.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DefaultDecoderManager extends DefaultStage
+ implements
+ DecoderManager,
+ DecoderCallback,
+ InputSubscriber,
+ ConnectSubscriber,
+ DisconnectSubscriber
+{
+ /** event router or bus this component subscribes and publishes events on */
+ private final EventRouter router ;
+ /** map of decoders for client keys */
+ private final Map decoders = new HashMap() ;
+ /** the monitor used for this decoder manager */
+ private DecoderManagerMonitor monitor ;
+ /** the monitor used for this subscriber */
+ private SubscriberMonitor subscriberMonitor ;
+ /** the monitor for this decoder */
+ private DecoderMonitor decoderMonitor ;
+
+
+ /**
+ * Creates a instance of the default decoder manager implementation.
+ *
+ * @param router the event bus or router component depended upon
+ * @param bp the buffer this decoder depends upon
+ */
+ public DefaultDecoderManager( EventRouter router, StageConfig config )
+ {
+ super( config ) ;
+
+ this.router = router ;
+ this.monitor = new DecoderManagerMonitorAdapter() ;
+ this.subscriberMonitor = new SubscriberMonitor()
+ {
+ public void failedOnInform( Subscriber subscriber,
+ EventObject eventObject,
+ Throwable throwable )
+ {
+ if ( monitor == null )
+ {
+ return ;
+ }
+
+ monitor.failedOnInform( subscriber, eventObject, throwable ) ;
+ }
+ } ;
+
+ this.decoderMonitor = new DecoderMonitorAdapter() ;
+
+ router.subscribe( InputEvent.class, this ) ;
+ router.subscribe( ConnectEvent.class, this ) ;
+ router.subscribe( DisconnectEvent.class, this ) ;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Subscriber Methods
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Routes the event to the appropriate typed <code>inform()</code> method.
+ *
+ * @see org.apache.eve.event.Subscriber#inform(java.util.EventObject)
+ * @see org.apache.eve.event.AbstractSubscriber.inform(
+ * org.apache.eve.event.Subscriber, java.util.EventObject,
+ * org.apache.eve.event.SubscriberMonitor ) ;
+ */
+ public void inform( EventObject event )
+ {
+ AbstractSubscriber.inform( this, event, subscriberMonitor ) ;
+ }
+
+
+ /**
+ * Enqueues the event onto this Stages event queue for processing.
+ *
+ * @see org.apache.eve.event.InputSubscriber#inform(
+ * org.apache.eve.event.InputEvent)
+ */
+ public void inform( InputEvent event )
+ {
+ // claim interest and release after asynchronous processing of event
+ ByteBuffer buffer = event.claimInterest( this ) ;
+ enqueue( event ) ;
+ }
+
+
+ /**
+ * Removes the clients decoder from the map of decoders.
+ *
+ * @see org.apache.eve.event.DisconnectSubscriber#inform(
+ * org.apache.eve.event.DisconnectEvent)
+ */
+ public void inform( DisconnectEvent event )
+ {
+ decoders.remove( event.getClientKey() ) ;
+ }
+
+
+ /**
+ * We basically create a new client decoder and put it into a map for
+ * use later when we are processing input events from the client.
+ *
+ * @see org.apache.eve.event.ConnectSubscriber#inform(
+ * org.apache.eve.event.ConnectEvent)
+ */
+ public void inform( ConnectEvent event )
+ {
+ ClientKey key = event.getClientKey() ;
+ StatefulDecoder noop = new NoOpDecoder() ;
+ StatefulDecoder decoder = new ClientDecoder( key, noop ) ;
+ decoders.put( key, decoder ) ;
+ }
+
+
+ /**
+ * Here the decoder informs us that a unit of data is decoded. In the case
+ * of the snickers decoder we're using decoding an LDAP message envelope
+ * for a request. We use this request to create a RequestEvent and publish
+ * the event on the queue.
+ *
+ * We are just hard coding the generation of a bind request for the moment.
+ *
+ * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
+ * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
+ */
+ public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+ {
+ /*
+ * This is where the decoded object is really a request Message
+ * enveloper object which we just need to package as a RequestEvent
+ * and publish on the EventRouter.
+ */
+ BindRequestImpl bind = new BindRequestImpl( BigInteger.ONE ) ;
+ bind.setCredentials( "password".getBytes() ) ;
+ bind.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+ bind.setSimple( true ) ;
+ bind.setVersion3( true ) ;
+
+ ClientKey key = ( ( ClientDecoder ) decoder ).getClientKey() ;
+ RequestEvent event = new RequestEvent( this, key, bind ) ;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Service Interface Methods
+ // ------------------------------------------------------------------------
+
+
+ /* (non-Javadoc)
+ * @see org.apache.eve.decoder.DecoderManager#setCallback(
+ * org.apache.eve.listener.ClientKey,
+ * org.apache.commons.codec.stateful.DecoderCallback)
+ */
+ public void setCallback( ClientKey key, DecoderCallback cb )
+ {
+ StatefulDecoder decoder = ( StatefulDecoder ) decoders.get( key ) ;
+ decoder.setCallback( cb ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.eve.decoder.DecoderManager#setDecoderMonitor(
+ * org.apache.eve.listener.ClientKey,
+ * org.apache.commons.codec.stateful.DecoderMonitor)
+ */
+ public void setDecoderMonitor( ClientKey key, DecoderMonitor monitor )
+ {
+ StatefulDecoder decoder = ( StatefulDecoder ) decoders.get( key ) ;
+ decoder.setDecoderMonitor( monitor ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.eve.decoder.DecoderManager#disable(
+ * org.apache.eve.listener.ClientKey)
+ */
+ public boolean disable( ClientKey key )
+ {
+ StatefulDecoder decoder = ( StatefulDecoder ) decoders.remove( key ) ;
+ return decoder != null ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.eve.decoder.DecoderManager#decode(
+ * org.apache.eve.listener.ClientKey, java.nio.ByteBuffer)
+ */
+ public void decode( ClientKey key, ByteBuffer buffer )
+ throws DecoderException
+ {
+ StatefulDecoder decoder = ( StatefulDecoder ) decoders.remove( key ) ;
+ decoder.decode( buffer ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.eve.decoder.DecoderManager#decode(java.nio.ByteBuffer)
+ */
+ public Object decode( ByteBuffer buffer ) throws DecoderException
+ {
+ // replace this decoder with a real one later
+ StatefulDecoder decoder = new NoOpDecoder() ;
+ // used array to set a value on final variable and get by compiler
+ final Object[] decoded = new Object[1] ;
+
+ decoder.setCallback( new DecoderCallback()
+ {
+ public void decodeOccurred( StatefulDecoder decoder, Object obj )
+ {
+ decoded[0] = obj ;
+ }
+ });
+
+ // force synchronous callback
+ decoder.decode( buffer ) ;
+
+ // the decoded value should be set
+ if ( decoded[0] == null )
+ {
+ throw new DecoderException( "Expected a complete encoded unit of "
+ + "data but got a partial" ) ;
+ }
+
+ return decoded[0] ;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Additional Methods
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Gets the monitor for this DecoderManager.
+ *
+ * @return the monitor
+ */
+ public DecoderManagerMonitor getMonitor()
+ {
+ return monitor ;
+ }
+
+
+ /**
+ * @param monitor the monitor to set
+ */
+ public void setMonitor( DecoderManagerMonitor monitor )
+ {
+ this.monitor = monitor ;
+ }
+
+
+ /**
+ * Gets a stateful decoder for a particular client.
+ *
+ * @param key the client's key
+ * @return the stateful decoder for the client
+ */
+ StatefulDecoder getDecoder( ClientKey key )
+ {
+ return ( StatefulDecoder ) decoders.get( key ) ;
+ }
+}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/ClientDecoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/ClientDecoder.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder ;
+
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+
+import org.apache.eve.listener.ClientKey ;
+
+
+/**
+ * A stateful decoder dedicated to a specific client.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ClientDecoder implements StatefulDecoder
+{
+ /** the key of the client this decoder is associated with */
+ private final ClientKey key ;
+ /** the actual decoder doing the work for us */
+ private final StatefulDecoder decoder ;
+
+
+ /**
+ * Creates a client dedicated stateful decoder.
+ *
+ * @param key the key of the client this decoder is for
+ * @param decoder the underlying decoder doing the work
+ */
+ public ClientDecoder( ClientKey key, StatefulDecoder decoder )
+ {
+ this.key = key ;
+ this.decoder = decoder ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
+ * java.lang.Object)
+ */
+ public void decode( Object encoded ) throws DecoderException
+ {
+ decoder.decode( encoded ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
+ * org.apache.commons.codec.stateful.DecoderCallback)
+ */
+ public void setCallback( DecoderCallback cb )
+ {
+ decoder.setCallback( cb ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
+ * org.apache.commons.codec.stateful.DecoderMonitor)
+ */
+ public void setDecoderMonitor( DecoderMonitor monitor )
+ {
+ decoder.setDecoderMonitor( monitor ) ;
+ }
+
+
+ /**
+ * Gets the key of the client this stateful decoder is dedicated to.
+ *
+ * @return the key of the client for this stateful decoder
+ */
+ public ClientKey getClientKey()
+ {
+ return key ;
+ }
+}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderConfig.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderConfig.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder ;
+
+
+/**
+ * A configuration for decoders.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface DecoderConfig
+{
+ /**
+ * Gets this Decoder's decoded object size limit for in memory objects. If
+ * this limit in bytes is reached then the data is streamed to a temporary
+ * data store on disk for use later. In such situations rather than
+ * returning the object itself a reference to access the object is returned.
+ *
+ * @return the in memory size limit to decoded data before it is streamed
+ * to disk
+ */
+ int getDecodeLimit() ;
+}
Modified: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManager.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManager.java (original)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManager.java Fri Mar 5 18:49:35 2004
@@ -21,7 +21,8 @@
import org.apache.eve.listener.ClientKey ;
-import org.apache.commons.codec.stateful.ErrorHandler ;
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
import org.apache.commons.codec.stateful.DecoderCallback ;
@@ -48,12 +49,12 @@
void setCallback( ClientKey key, DecoderCallback cb ) ;
/**
- * Sets a client decoder's error handler.
+ * Sets a client decoder's monitor.
*
* @param key the unique key associated with the client
- * @param cb the callback used to deliver error events
+ * @param monitor the monitor used to deliver events
*/
- void setErrorHandler( ClientKey key, ErrorHandler handler ) ;
+ void setDecoderMonitor( ClientKey key, DecoderMonitor monitor ) ;
/**
* Disables callback events for a client destroying decoding state if any.
@@ -68,14 +69,17 @@
* @param key the unique key associated with the client
* @param buffer the buffer of encoded data
* @return the set of keys for decoding sessions
+ * @throws DecoderException if there is a failure while decoding
*/
- void decode( ClientKey key, ByteBuffer buffer ) ;
+ void decode( ClientKey key, ByteBuffer buffer ) throws DecoderException ;
/**
- * All in one shot synchronous decode operation requiring entire set of data
+ * One shot synchronous decode operation requiring a complete unit of
+ * encoded data to return the decoded equivalent immediately.
*
* @param buffer the buffer containing all the encoded data
* @return the decoded object
+ * @throws DecoderException if there is a failure while decoding
*/
- Object decode( ByteBuffer buffer ) ;
+ Object decode( ByteBuffer buffer ) throws DecoderException ;
}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitor.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder ;
+
+
+import java.util.EventObject ;
+
+import org.apache.eve.event.Subscriber ;
+
+
+/**
+ * Monitors DecoderManagers.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface DecoderManagerMonitor
+{
+ /**
+ * Monitors failures while processing inform methods if any.
+ *
+ * @param subscriber the subscriber
+ * @param event the event being delievered
+ * @param t the throwable that prevented delivery
+ */
+ void failedOnInform( Subscriber subscriber, EventObject event,
+ Throwable t ) ;
+}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/DecoderManagerMonitorAdapter.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder ;
+
+
+import java.util.EventObject ;
+
+import org.apache.eve.event.Subscriber ;
+
+
+/**
+ * An adapter for decoder manager monitors.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DecoderManagerMonitorAdapter implements DecoderManagerMonitor
+{
+ /* (non-Javadoc)
+ * @see org.apache.eve.event.SubscriberMonitor#failedOnInform(
+ * org.apache.eve.event.Subscriber,
+ * java.util.EventObject, java.lang.Throwable)
+ */
+ public void
+ failedOnInform( Subscriber subscriber, EventObject event, Throwable t )
+ {
+ }
+}
Added: incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/NoOpDecoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/decoder/spi/src/java/org/apache/eve/decoder/NoOpDecoder.java Fri Mar 5 18:49:35 2004
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.decoder ;
+
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+
+/**
+ * A decoder that does not really do anything but return the data you give it
+ * calling the callback if one exists with every call to decode.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class NoOpDecoder implements StatefulDecoder
+{
+ /** the callback for this decoder */
+ private DecoderCallback cb = null ;
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
+ * java.lang.Object)
+ */
+ public void decode( Object encoded ) throws DecoderException
+ {
+ if ( cb == null )
+ {
+ return ;
+ }
+
+ cb.decodeOccurred( this, encoded ) ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
+ * org.apache.commons.codec.stateful.DecoderCallback)
+ */
+ public void setCallback( DecoderCallback cb )
+ {
+ this.cb = cb ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
+ * org.apache.commons.codec.stateful.DecoderMonitor)
+ */
+ public void setDecoderMonitor( DecoderMonitor monitor )
+ {
+ // don't care this does nothing anyway
+ }
+}