Author: trustin
Date: Sat Oct 30 18:49:56 2004
New Revision: 56106
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/DiscardProtocolProvider.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoProtocolProvider.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoTest.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullDecoder.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullEncoder.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruDecoder.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruEncoder.java
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
incubator/directory/seda/trunk/src/java/org/apache/seda/Frontend.java
incubator/directory/seda/trunk/src/java/org/apache/seda/FrontendFactory.java
incubator/directory/seda/trunk/src/java/org/apache/seda/ResourceException.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPool.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPool.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPoolConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/LoggingBufferMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/ClientDecoder.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecodeStageHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/ClientEncoder.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncodeStageHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AbstractSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AddProtocolEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ClientEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RoutingAdvice.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationSubscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionListener.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscription.java
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/Enum.java
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/EnumUtils.java
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/ValuedEnum.java
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/input/TCPInputManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/LoggingOutputMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultInetServicesDatabase.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultRequestProcessor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServiceEntry.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServicesDatabase.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ManyReplyHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/NoReplyHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ProtocolProvider.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/SingleReplyHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/TransportTypeEnum.java
incubator/directory/seda/trunk/src/java/org/apache/seda/session/ClientSession.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
incubator/directory/seda/trunk/src/java/org/apache/seda/thread/ThreadPool.java
incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
incubator/directory/seda/trunk/src/test/org/apache/seda/buffer/DefaultBufferPoolTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/event/AbstractSubscriberTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/AvailablePortFinderTest.java
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
Log:
* Reformatted using new Jalopy settings responding to Alex's request. :)
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/DiscardProtocolProvider.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/DiscardProtocolProvider.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/DiscardProtocolProvider.java
Sat Oct 30 18:49:56 2004
@@ -35,7 +35,8 @@
* @version $Rev$
*/
public class DiscardProtocolProvider implements ProtocolProvider,
- DecoderFactory, EncoderFactory
{
+ DecoderFactory, EncoderFactory
+{
/** a null do nothing decoder that swallows all input */
public static final StatefulDecoder NULL_DECODER = new NullDecoder();
@@ -45,24 +46,31 @@
// ------------------------------------------------------------------------
// ProtocolProvider Methods
// ------------------------------------------------------------------------
- public String getName() {
+ public String getName()
+ {
return "discard";
}
- public DecoderFactory getDecoderFactory() {
+ public DecoderFactory getDecoderFactory()
+ {
return this;
}
- public EncoderFactory getEncoderFactory() {
+ public EncoderFactory getEncoderFactory()
+ {
return this;
}
- public RequestHandler getHandler(Object request) {
- return new NoReplyHandler() {
- public void handle(Object request) {
+ public RequestHandler getHandler(Object request)
+ {
+ return new NoReplyHandler()
+ {
+ public void handle(Object request)
+ {
}
- public HandlerTypeEnum getHandlerType() {
+ public HandlerTypeEnum getHandlerType()
+ {
return HandlerTypeEnum.NOREPLY;
}
};
@@ -71,11 +79,13 @@
// ------------------------------------------------------------------------
// Factory Methods
// ------------------------------------------------------------------------
- public StatefulDecoder createDecoder() {
+ public StatefulDecoder createDecoder()
+ {
return NULL_DECODER;
}
- public StatefulEncoder createEncoder() {
+ public StatefulEncoder createEncoder()
+ {
return NULL_ENCODER;
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoProtocolProvider.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoProtocolProvider.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoProtocolProvider.java
Sat Oct 30 18:49:56 2004
@@ -30,7 +30,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public final class EchoProtocolProvider implements ProtocolProvider {
+public final class EchoProtocolProvider implements ProtocolProvider
+{
/** the authoritative service name of this internet protocol: 'echo' */
public static final String NAME = "echo";
@@ -51,7 +52,8 @@
*
* @return the authoritative service name
*/
- public final String getName() {
+ public final String getName()
+ {
return NAME;
}
@@ -61,8 +63,10 @@
*
* @return a new StatefulDecoder for this service's protocol
*/
- public final DecoderFactory getDecoderFactory() {
- return new DecoderFactory() {
+ public final DecoderFactory getDecoderFactory()
+ {
+ return new DecoderFactory()
+ {
/**
* Creates a really simple factory for decoders that return
back
* thir request in the same decode call; 1:1 decode to
callback.
@@ -71,7 +75,8 @@
*
* @return a chunking state based decoder
*/
- public StatefulDecoder createDecoder() {
+ public StatefulDecoder createDecoder()
+ {
return PASSTHRU_DECODER;
}
};
@@ -83,8 +88,10 @@
*
* @return a new StatefulEncoder for this service's protocol
*/
- public EncoderFactory getEncoderFactory() {
- return new EncoderFactory() {
+ public EncoderFactory getEncoderFactory()
+ {
+ return new EncoderFactory()
+ {
/**
* Creates a factory that always returns the same encoder which
* never really maintains any state. This encoder simply
returns
@@ -92,7 +99,8 @@
*
* @return a new chunking state based encoder
*/
- public StatefulEncoder createEncoder() {
+ public StatefulEncoder createEncoder()
+ {
return PASSTHRU_ENCODER;
}
};
@@ -109,7 +117,8 @@
* @param request the ByteBuffer containing the data to echo
* @return the same ByteBuffer without any changes
*/
- public RequestHandler getHandler(Object request) {
+ public RequestHandler getHandler(Object request)
+ {
return PASSTHRU_HANDLER;
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoTest.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/EchoTest.java
Sat Oct 30 18:49:56 2004
@@ -20,11 +20,14 @@
import org.apache.commons.net.EchoTCPClient;
-public class EchoTest {
- public static void main(String[] args) {
+public class EchoTest
+{
+ public static void main(String[] args)
+ {
byte[] recieved = null;
- try {
+ try
+ {
EchoTCPClient client = new EchoTCPClient();
client.connect(args[0], 7);
@@ -33,14 +36,17 @@
client.getOutputStream().write(toSend);
client.getInputStream().read(recieved);
client.disconnect();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
System.out.println("echo of '" + args[1] + "' to " + args[0]
+ " failed!");
System.exit(1);
}
- if (args[1].equals(new String(recieved))) {
+ if (args[1].equals(new String(recieved)))
+ {
System.out.println("Successfully echo'd '" + args[1] + "' to "
+ args[0]);
System.exit(0);
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullDecoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullDecoder.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullDecoder.java
Sat Oct 30 18:49:56 2004
@@ -26,12 +26,14 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class NullDecoder extends AbstractStatefulDecoder {
+public class NullDecoder extends AbstractStatefulDecoder
+{
/**
* Does nothing at all.
*
* @param encoded the object
*/
- public void decode(Object encoded) {
+ public void decode(Object encoded)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullEncoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullEncoder.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/NullEncoder.java
Sat Oct 30 18:49:56 2004
@@ -26,12 +26,14 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class NullEncoder extends AbstractStatefulEncoder {
+public class NullEncoder extends AbstractStatefulEncoder
+{
/**
* Does nothing at all.
*
* @param substrate the object to encode which is just ignored
*/
- public void encode(Object substrate) {
+ public void encode(Object substrate)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruDecoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruDecoder.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruDecoder.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class PassThruDecoder extends AbstractStatefulDecoder {
+public class PassThruDecoder extends AbstractStatefulDecoder
+{
/**
* Simply returns back the encoded data as is. The codec is an identity
* operation. Each decode call triggers a callback since we're presuming
@@ -35,7 +36,8 @@
*
* @param encoded the object to return which is a buffer
*/
- public void decode(Object encoded) {
+ public void decode(Object encoded)
+ {
super.decodeOccurred(encoded);
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruEncoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruEncoder.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruEncoder.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class PassThruEncoder extends AbstractStatefulEncoder {
+public class PassThruEncoder extends AbstractStatefulEncoder
+{
/**
* Simply returns back the decoded data as is. The codec is an identity
* operation. Each encode call triggers a callback since we're presuming
@@ -36,7 +37,8 @@
*
* @param substrate the object to return which is a buffer
*/
- public void encode(Object substrate) {
+ public void encode(Object substrate)
+ {
super.encodeOccurred(substrate);
}
}
Modified:
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruHandler.java
(original)
+++
incubator/directory/seda/trunk/src/examples/org/apache/seda/examples/PassThruHandler.java
Sat Oct 30 18:49:56 2004
@@ -28,14 +28,16 @@
* Project</a>
* @version $Rev$
*/
-public class PassThruHandler implements SingleReplyHandler {
+public class PassThruHandler implements SingleReplyHandler
+{
/**
* Returns the request back without any changes as a response.
*
* @param request the buffer of data to be echo'd.
* @return the response to the request but resp = req here.
*/
- public Object handle(Object request) {
+ public Object handle(Object request)
+ {
return request;
}
@@ -44,7 +46,8 @@
*
* @return a HandlerTypeEnum constant.
*/
- public HandlerTypeEnum getHandlerType() {
+ public HandlerTypeEnum getHandlerType()
+ {
return HandlerTypeEnum.SINGLEREPLY;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
Sat Oct 30 18:49:56 2004
@@ -45,7 +45,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultFrontend implements Frontend {
+public class DefaultFrontend implements Frontend
+{
private final BufferPool bp;
private final DecoderManager decMan;
private final EncoderManager encMan;
@@ -60,7 +61,8 @@
BufferPool bp, DecoderManager decMan, EncoderManager
encMan,
EventRouter router, InputManager inMan,
ListenerManager srvMan, OutputManager outMan,
- RequestProcessor reqProc, InetServicesDatabase inetDb) {
+ RequestProcessor reqProc, InetServicesDatabase inetDb)
+ {
this.bp = bp;
this.decMan = decMan;
this.encMan = encMan;
@@ -72,12 +74,14 @@
this.inetDb = inetDb;
}
- public void register(ProtocolProvider provider) {
+ public void register(ProtocolProvider provider)
+ {
AddProtocolEvent event = new AddProtocolEvent(provider);
router.publish(event);
}
- public void stop() throws Exception {
+ public void stop() throws Exception
+ {
((TCPListenerManager) srvMan).stop();
((TCPInputManager) inMan).stop();
((TCPOutputManager) outMan).stop();
@@ -86,39 +90,48 @@
((DefaultEncoderManager) encMan).stop();
}
- public BufferPool getBufferPool() {
+ public BufferPool getBufferPool()
+ {
return bp;
}
- public DecoderManager getDecoderManager() {
+ public DecoderManager getDecoderManager()
+ {
return decMan;
}
- public EncoderManager getEncoderManager() {
+ public EncoderManager getEncoderManager()
+ {
return encMan;
}
- public EventRouter getEventRouter() {
+ public EventRouter getEventRouter()
+ {
return router;
}
- public InputManager getInputManager() {
+ public InputManager getInputManager()
+ {
return inMan;
}
- public ListenerManager getListenerManager() {
+ public ListenerManager getListenerManager()
+ {
return srvMan;
}
- public OutputManager getOutputManager() {
+ public OutputManager getOutputManager()
+ {
return outMan;
}
- public RequestProcessor getRequestProcessor() {
+ public RequestProcessor getRequestProcessor()
+ {
return reqProc;
}
- public InetServicesDatabase getInetServicesDatabase() {
+ public InetServicesDatabase getInetServicesDatabase()
+ {
return inetDb;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
Sat Oct 30 18:49:56 2004
@@ -53,8 +53,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultFrontendFactory implements FrontendFactory {
- public Frontend create() throws Exception {
+public class DefaultFrontendFactory implements FrontendFactory
+{
+ public Frontend create() throws Exception
+ {
// create all services that do not have any deps on other services
BufferPool bp = createBufferPool();
EventRouter router = createEventRouter();
@@ -76,7 +78,8 @@
}
// no deps
- private BufferPool createBufferPool() {
+ private BufferPool createBufferPool()
+ {
DefaultBufferPoolConfig config =
new DefaultBufferPoolConfig("", 10, 100, 20, 20);
DefaultBufferPool bp = new DefaultBufferPool(config);
@@ -85,7 +88,8 @@
}
// no deps
- private EventRouter createEventRouter() {
+ private EventRouter createEventRouter()
+ {
DefaultEventRouter router = new DefaultEventRouter();
// @todo start using a logging monitor for event router
@@ -94,7 +98,8 @@
}
// no deps
- private InetServicesDatabase createServicesDatabase() {
+ private InetServicesDatabase createServicesDatabase()
+ {
InetServiceEntry[] entries =
{ new InetServiceEntry("echo", 7), new InetServiceEntry(
"ldap",
389) };
@@ -105,13 +110,16 @@
}
// no deps
- private ThreadPool createThreadPool(int threads) {
+ private ThreadPool createThreadPool(int threads)
+ {
CommonsLoggingThreadPoolMonitor monitor =
new CommonsLoggingThreadPoolMonitor();
final DefaultThreadPool ctp = new DefaultThreadPool(monitor, threads);
ThreadPool pool =
- new ThreadPool() {
- public void execute(Runnable runnable) {
+ new ThreadPool()
+ {
+ public void execute(Runnable runnable)
+ {
ctp.invokeLater(runnable);
}
};
@@ -122,7 +130,8 @@
// deps on router, inetDb, and listener
private DecoderManager createDecoderManager(
EventRouter router,
- InetServicesDatabase inetDb) {
+ InetServicesDatabase inetDb)
+ {
DefaultStageConfig config =
new DefaultStageConfig("decoderManager", createThreadPool(3));
DefaultDecoderManager decMan =
@@ -136,7 +145,8 @@
// deps on router, inetDb, and listener
private EncoderManager createEncoderManager(
EventRouter router,
- InetServicesDatabase inetDb) {
+ InetServicesDatabase inetDb)
+ {
DefaultStageConfig config =
new DefaultStageConfig("encoderManager", createThreadPool(3));
DefaultEncoderManager encMan =
@@ -148,20 +158,23 @@
}
private ListenerManager createListenerManager(EventRouter router)
- throws IOException {
+ throws IOException
+ {
TCPListenerManager listMan = new TCPListenerManager(router);
listMan.start();
return listMan;
}
private InputManager createInputManager(EventRouter router, BufferPool bp)
- throws IOException {
+ throws IOException
+ {
TCPInputManager inMan = new TCPInputManager(router, bp);
inMan.start();
return inMan;
}
- private OutputManager createOutputManager(EventRouter router) {
+ private OutputManager createOutputManager(EventRouter router)
+ {
DefaultStageConfig config =
new DefaultStageConfig("outputManager", createThreadPool(3));
TCPOutputManager outMan = new TCPOutputManager(router, config);
@@ -171,7 +184,8 @@
private RequestProcessor createRequestProcessor(
EventRouter router,
- InetServicesDatabase
inetDb) {
+ InetServicesDatabase
inetDb)
+ {
DefaultStageConfig config =
new DefaultStageConfig("requestProcessor", createThreadPool(3));
DefaultRequestProcessor reqProc =
Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/Frontend.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/Frontend.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/Frontend.java
Sat Oct 30 18:49:56 2004
@@ -26,5 +26,6 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Frontend {
+public interface Frontend
+{
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/FrontendFactory.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/FrontendFactory.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/FrontendFactory.java
Sat Oct 30 18:49:56 2004
@@ -24,6 +24,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface FrontendFactory {
+public interface FrontendFactory
+{
Frontend create() throws Exception;
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/ResourceException.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/ResourceException.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/ResourceException.java
Sat Oct 30 18:49:56 2004
@@ -24,11 +24,13 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ResourceException extends Exception {
+public class ResourceException extends Exception
+{
/**
* Creates a simple ResourceException without any details.
*/
- public ResourceException() {
+ public ResourceException()
+ {
super();
}
@@ -37,7 +39,8 @@
*
* @param message a detailed message
*/
- public ResourceException(String message) {
+ public ResourceException(String message)
+ {
super(message);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPool.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPool.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPool.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface BufferPool {
+public interface BufferPool
+{
/**
* Acquires a dedicated buffer from the buffer pool and claims interest
with
* the buffer using an object representing the interested party.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolConfig.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface BufferPoolConfig {
+public interface BufferPoolConfig
+{
/**
* Gets the name of this BufferPool configuration.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitor.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface BufferPoolMonitor {
+public interface BufferPoolMonitor
+{
/**
* Monitors the augmentation of a BufferPool.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/BufferPoolMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -27,19 +27,22 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class BufferPoolMonitorAdapter implements BufferPoolMonitor {
+public class BufferPoolMonitorAdapter implements BufferPoolMonitor
+{
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPoolMonitor#augmented(
* org.apache.seda.buffer.BufferPool)
*/
- public void augmented(BufferPool bp) {
+ public void augmented(BufferPool bp)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPoolMonitor#bufferTaken(
* org.apache.seda.buffer.BufferPool, java.nio.ByteBuffer,
java.lang.Object)
*/
- public void bufferTaken(BufferPool bp, ByteBuffer buffer, Object taker) {
+ public void bufferTaken(BufferPool bp, ByteBuffer buffer, Object taker)
+ {
}
/* (non-Javadoc)
@@ -48,7 +51,8 @@
*/
public void bufferReleased(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
+ Object releaser)
+ {
}
/* (non-Javadoc)
@@ -57,7 +61,8 @@
*/
public void interestClaimed(
BufferPool bp, ByteBuffer buffer,
- Object claimer) {
+ Object claimer)
+ {
}
/* (non-Javadoc)
@@ -66,7 +71,8 @@
*/
public void interestReleased(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
+ Object releaser)
+ {
}
/*
@@ -74,7 +80,8 @@
* @see org.apache.seda.buffer.BufferPoolMonitor#resourceUnavailable(
* org.apache.seda.buffer.BufferPool, java.lang.Object)
*/
- public void resourceUnavailable(BufferPool bp, Object party) {
+ public void resourceUnavailable(BufferPool bp, Object party)
+ {
}
/*
@@ -84,7 +91,8 @@
*/
public void unregisteredParty(
BufferPool bp, ByteBuffer buffer,
- Object party) {
+ Object party)
+ {
}
/*
@@ -93,7 +101,8 @@
* org.apache.seda.buffer.BufferPool, java.nio.ByteBuffer,
java.lang.Object)
*/
public void nonPooledBuffer(
- BufferPool bp, ByteBuffer buffer, Object
party) {
+ BufferPool bp, ByteBuffer buffer, Object party)
+ {
}
/* (non-Javadoc)
@@ -102,6 +111,7 @@
*/
public void releaseOfUnclaimed(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
+ Object releaser)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPool.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPool.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPool.java
Sat Oct 30 18:49:56 2004
@@ -31,7 +31,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultBufferPool implements BufferPool {
+public class DefaultBufferPool implements BufferPool
+{
/** a configuration bean */
private final BufferPoolConfig config;
@@ -52,7 +53,8 @@
*
* @param config the pool configuration bean
*/
- public DefaultBufferPool(BufferPoolConfig config) {
+ public DefaultBufferPool(BufferPoolConfig config)
+ {
super();
this.config = config;
@@ -60,7 +62,8 @@
this.inUseList = new ArrayList(config.getMaximumSize());
this.allList = new ArrayList(config.getMaximumSize());
- for (int ii = 0; ii < this.config.getInitialSize(); ii++) {
+ for (int ii = 0; ii < this.config.getInitialSize(); ii++)
+ {
BufferListPair list = new BufferListPair();
this.freeList.add(list);
this.allList.add(list);
@@ -71,17 +74,23 @@
* @see org.apache.seda.buffer.BufferPool#getBuffer(java.lang.Object)
*/
public synchronized ByteBuffer getBuffer(Object party)
- throws ResourceException {
+ throws ResourceException
+ {
BufferListPair list = null;
- if (freeList.size() == 0) {
- if (config.getIncrement() <= config.getMaximumSize()) {
- for (int ii = 0; ii < config.getIncrement(); ii++) {
+ if (freeList.size() == 0)
+ {
+ if (config.getIncrement() <= config.getMaximumSize())
+ {
+ for (int ii = 0; ii < config.getIncrement(); ii++)
+ {
list = new BufferListPair();
freeList.add(list);
allList.add(list);
}
- } else {
+ }
+ else
+ {
monitor.resourceUnavailable(this, party);
throw new ResourceException("Free Buffers unavailable");
}
@@ -102,10 +111,12 @@
* @see
org.apache.seda.buffer.BufferPool#claimInterest(java.nio.ByteBuffer,
* java.lang.Object)
*/
- public synchronized void claimInterest(ByteBuffer buffer, Object party) {
+ public synchronized void claimInterest(ByteBuffer buffer, Object party)
+ {
BufferListPair list = getBufferListPair(buffer);
- if (null == list) {
+ if (null == list)
+ {
monitor.nonPooledBuffer(this, buffer, party);
throw new IllegalStateException("Not a BufferPool resource");
}
@@ -118,15 +129,18 @@
* @see org.apache.seda.buffer.BufferPool#releaseClaim(java.nio.ByteBuffer,
* java.lang.Object)
*/
- public synchronized void releaseClaim(ByteBuffer buffer, Object party) {
+ public synchronized void releaseClaim(ByteBuffer buffer, Object party)
+ {
BufferListPair list = getBufferListPair(buffer);
- if (null == list) {
+ if (null == list)
+ {
monitor.releaseOfUnclaimed(this, buffer, party);
throw new IllegalArgumentException("Not a pooled resource");
}
- if (!list.contains(party)) {
+ if (!list.contains(party))
+ {
monitor.unregisteredParty(this, buffer, party);
throw new IllegalStateException("Party nsedar registered interest
with buffer");
}
@@ -135,7 +149,8 @@
monitor.interestReleased(this, buffer, party);
// if the list of interested parties hits zero then we release buf
- if (list.size() == 0) {
+ if (list.size() == 0)
+ {
inUseList.remove(list);
freeList.add(list);
monitor.bufferReleased(this, buffer, party);
@@ -146,35 +161,40 @@
* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPool#getConfig()
*/
- public BufferPoolConfig getConfig() {
+ public BufferPoolConfig getConfig()
+ {
return config;
}
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPool#size()
*/
- public synchronized int size() {
+ public synchronized int size()
+ {
return allList.size();
}
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPool#getName()
*/
- public String getName() {
+ public String getName()
+ {
return config.getName();
}
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPool#getFreeCount()
*/
- public synchronized int getFreeCount() {
+ public synchronized int getFreeCount()
+ {
return freeList.size();
}
/* (non-Javadoc)
* @see org.apache.seda.buffer.BufferPool#getInUseCount()
*/
- public synchronized int getInUseCount() {
+ public synchronized int getInUseCount()
+ {
return inUseList.size();
}
@@ -182,10 +202,12 @@
* @see org.apache.seda.buffer.BufferPool#getInterestedCount(
* java.nio.ByteBuffer)
*/
- public int getInterestedCount(ByteBuffer buffer) {
+ public int getInterestedCount(ByteBuffer buffer)
+ {
BufferListPair list = getBufferListPair(buffer);
- if (list == null) {
+ if (list == null)
+ {
throw new IllegalArgumentException("not a buffer from this pool");
}
@@ -197,7 +219,8 @@
*
* @return returns the monitor
*/
- public BufferPoolMonitor getMonitor() {
+ public BufferPoolMonitor getMonitor()
+ {
return monitor;
}
@@ -206,7 +229,8 @@
*
* @param monitor the monitor to set
*/
- public void setMonitor(BufferPoolMonitor monitor) {
+ public void setMonitor(BufferPoolMonitor monitor)
+ {
this.monitor = monitor;
}
@@ -214,7 +238,8 @@
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
- public String toString() {
+ public String toString()
+ {
StringBuffer buf = new StringBuffer(config.getName());
buf.append(" buffer pool");
return buf.toString();
@@ -231,13 +256,16 @@
* @param buffer the buffer to search for in the list of pairs
* @return null if the buffer does not exist or the pair containing it
*/
- BufferListPair getBufferListPair(ByteBuffer buffer) {
+ BufferListPair getBufferListPair(ByteBuffer buffer)
+ {
BufferListPair list = null;
- for (int ii = 0; ii < allList.size(); ii++) {
+ for (int ii = 0; ii < allList.size(); ii++)
+ {
list = (BufferListPair) allList.get(ii);
- if (buffer == list.getBuffer()) {
+ if (buffer == list.getBuffer())
+ {
return list;
}
}
@@ -249,46 +277,56 @@
* Class used to pair up a buffer with a list to track the parties
* interested in the buffer.
*/
- class BufferListPair {
+ class BufferListPair
+ {
final ArrayList list;
final ByteBuffer buffer;
- BufferListPair() {
+ BufferListPair()
+ {
this(
new ArrayList(3),
ByteBuffer.allocateDirect(config.getBufferSize()));
}
- BufferListPair(ByteBuffer buffer) {
+ BufferListPair(ByteBuffer buffer)
+ {
this(new ArrayList(3), buffer);
}
- BufferListPair(ArrayList list, ByteBuffer buffer) {
+ BufferListPair(ArrayList list, ByteBuffer buffer)
+ {
this.list = list;
this.buffer = buffer;
}
- ByteBuffer getBuffer() {
+ ByteBuffer getBuffer()
+ {
return buffer;
}
- ArrayList getList() {
+ ArrayList getList()
+ {
return list;
}
- void add(Object party) {
+ void add(Object party)
+ {
list.add(party);
}
- boolean contains(Object party) {
+ boolean contains(Object party)
+ {
return list.contains(party);
}
- boolean remove(Object party) {
+ boolean remove(Object party)
+ {
return list.remove(party);
}
- int size() {
+ int size()
+ {
return list.size();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPoolConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPoolConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/DefaultBufferPoolConfig.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultBufferPoolConfig implements BufferPoolConfig {
+public class DefaultBufferPoolConfig implements BufferPoolConfig
+{
/** the name */
private final String name;
@@ -52,7 +53,8 @@
*/
public DefaultBufferPoolConfig(
String name, int inc, int max, int ini,
- int size) {
+ int size)
+ {
this.name = name;
this.inc = inc;
this.max = max;
@@ -63,35 +65,40 @@
/* (non-Javadoc)
* @see org.apache.stage.buffer.BufferPoolConfig#getIncrement()
*/
- public int getIncrement() {
+ public int getIncrement()
+ {
return inc;
}
/* (non-Javadoc)
* @see org.apache.stage.buffer.BufferPoolConfig#getBufferSize()
*/
- public int getBufferSize() {
+ public int getBufferSize()
+ {
return size;
}
/* (non-Javadoc)
* @see org.apache.stage.buffer.BufferPoolConfig#getInitialSize()
*/
- public int getInitialSize() {
+ public int getInitialSize()
+ {
return ini;
}
/* (non-Javadoc)
* @see org.apache.stage.buffer.BufferPoolConfig#getMaximumSize()
*/
- public int getMaximumSize() {
+ public int getMaximumSize()
+ {
return max;
}
/* (non-Javadoc)
* @see org.apache.stage.buffer.BufferPoolConfig#getName()
*/
- public String getName() {
+ public String getName()
+ {
return name;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/LoggingBufferMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/LoggingBufferMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/buffer/LoggingBufferMonitor.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class LoggingBufferMonitor implements BufferPoolMonitor {
+public class LoggingBufferMonitor implements BufferPoolMonitor
+{
/** the default name for the logging channel */
private final String DEFAULT = "BufferPool";
@@ -39,7 +40,8 @@
/**
* Creates a buffer pool logging monitor.
*/
- public LoggingBufferMonitor() {
+ public LoggingBufferMonitor()
+ {
log = LogFactory.getLog(DEFAULT);
}
@@ -48,7 +50,8 @@
*
* @param name the logging channel name
*/
- public LoggingBufferMonitor(String name) {
+ public LoggingBufferMonitor(String name)
+ {
log = LogFactory.getLog(name);
}
@@ -56,8 +59,10 @@
* @see org.apache.seda.buffer.BufferPoolMonitor#
* augmented(org.apache.seda.buffer.BufferPool)
*/
- public void augmented(BufferPool bp) {
- if (log.isDebugEnabled()) {
+ public void augmented(BufferPool bp)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug("Just augmented the buffer pool");
}
}
@@ -68,8 +73,10 @@
*/
public void bufferReleased(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
- if (log.isDebugEnabled()) {
+ Object releaser)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(releaser + " released " + buffer + " from pool " + bp);
}
}
@@ -78,8 +85,10 @@
* @see org.apache.seda.buffer.BufferPoolMonitor#bufferTaken(
* org.apache.seda.buffer.BufferPool, java.nio.ByteBuffer,
java.lang.Object)
*/
- public void bufferTaken(BufferPool bp, ByteBuffer buffer, Object taker) {
- if (log.isDebugEnabled()) {
+ public void bufferTaken(BufferPool bp, ByteBuffer buffer, Object taker)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(taker + " took " + buffer + " from pool " + bp);
}
}
@@ -90,8 +99,10 @@
*/
public void interestClaimed(
BufferPool bp, ByteBuffer buffer,
- Object claimer) {
- if (log.isDebugEnabled()) {
+ Object claimer)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(claimer + " claimed interest in " + buffer
+ " from pool " + bp);
}
@@ -103,8 +114,10 @@
*/
public void interestReleased(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
- if (log.isDebugEnabled()) {
+ Object releaser)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(releaser + " released interest in " + buffer
+ " from pool " + bp);
}
@@ -115,8 +128,10 @@
* org.apache.seda.buffer.BufferPool, java.nio.ByteBuffer,
java.lang.Object)
*/
public void nonPooledBuffer(
- BufferPool bp, ByteBuffer buffer, Object
party) {
- if (log.isErrorEnabled()) {
+ BufferPool bp, ByteBuffer buffer, Object party)
+ {
+ if (log.isErrorEnabled())
+ {
log.error(party + " tried to release interest in " + buffer
+ " from pool " + bp
+ " but resouce was not from this pool.");
@@ -127,8 +142,10 @@
* @see org.apache.seda.buffer.BufferPoolMonitor#resourceUnavailable(
* org.apache.seda.buffer.BufferPool, java.lang.Object)
*/
- public void resourceUnavailable(BufferPool bp, Object party) {
- if (log.isErrorEnabled()) {
+ public void resourceUnavailable(BufferPool bp, Object party)
+ {
+ if (log.isErrorEnabled())
+ {
log.error("BufferPool " + bp
+ " is at capacity - cannot allocate buffer resouce to "
+ party);
@@ -141,8 +158,10 @@
*/
public void unregisteredParty(
BufferPool bp, ByteBuffer buffer,
- Object party) {
- if (log.isDebugEnabled()) {
+ Object party)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(party + " has not registered as claiming interest on "
+ buffer + " from pool " + bp);
}
@@ -154,8 +173,10 @@
*/
public void releaseOfUnclaimed(
BufferPool bp, ByteBuffer buffer,
- Object releaser) {
- if (log.isDebugEnabled()) {
+ Object releaser)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(releaser + " attempted to release interest in " + buffer
+ " from pool " + bp
+ " when the buffer was not claimed.");
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/ClientDecoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/ClientDecoder.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/ClientDecoder.java
Sat Oct 30 18:49:56 2004
@@ -30,7 +30,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ClientDecoder implements StatefulDecoder, DecoderCallback {
+public class ClientDecoder implements StatefulDecoder, DecoderCallback
+{
/** the key of the client this decoder is associated with */
private final ClientKey key;
@@ -46,7 +47,8 @@
* @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) {
+ public ClientDecoder(ClientKey key, StatefulDecoder decoder)
+ {
this.key = key;
this.decoder = decoder;
this.decoder.setCallback(this);
@@ -56,7 +58,8 @@
* @see
org.apache.commons.codec.stateful.StatefulDecoder#decodeNonBlocking(
* java.lang.Object)
*/
- public void decode(Object encoded) throws DecoderException {
+ public void decode(Object encoded) throws DecoderException
+ {
decoder.decode(encoded);
}
@@ -64,7 +67,8 @@
* @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
* org.apache.commons.codec.stateful.DecoderCallback)
*/
- public void setCallback(DecoderCallback cb) {
+ public void setCallback(DecoderCallback cb)
+ {
this.cb = cb;
}
@@ -72,7 +76,8 @@
* @see
org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
* org.apache.commons.codec.stateful.DecoderMonitor)
*/
- public void setDecoderMonitor(DecoderMonitor monitor) {
+ public void setDecoderMonitor(DecoderMonitor monitor)
+ {
decoder.setDecoderMonitor(monitor);
}
@@ -81,7 +86,8 @@
*
* @return the key of the client for this stateful decoder
*/
- public ClientKey getClientKey() {
+ public ClientKey getClientKey()
+ {
return key;
}
@@ -89,7 +95,8 @@
* @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
* org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
*/
- public void decodeOccurred(StatefulDecoder decoder, Object decoded) {
+ public void decodeOccurred(StatefulDecoder decoder, Object decoded)
+ {
cb.decodeOccurred(this, decoded);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecodeStageHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecodeStageHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecodeStageHandler.java
Sat Oct 30 18:49:56 2004
@@ -35,7 +35,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DecodeStageHandler implements StageHandler {
+public class DecodeStageHandler implements StageHandler
+{
/** reference to the decoder manager this handler is used by */
private final DefaultDecoderManager manager;
@@ -44,7 +45,8 @@
*
* @param manager the decoder manager this handler is for
*/
- public DecodeStageHandler(DefaultDecoderManager manager) {
+ public DecodeStageHandler(DefaultDecoderManager manager)
+ {
this.manager = manager;
}
@@ -55,15 +57,19 @@
*
* @see
org.apache.seda.stage.StageHandler#handleEvent(java.util.EventObject)
*/
- public void handleEvent(EventObject event) {
+ public void handleEvent(EventObject event)
+ {
InputEvent e = (InputEvent) event;
ClientKey key = e.getClientKey();
ByteBuffer buf = e.claimInterest(this);
StatefulDecoder decoder = manager.getDecoder(key);
- try {
+ try
+ {
decoder.decode(buf);
- } catch (DecoderException ex) {
+ }
+ 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
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManager.java
Sat Oct 30 18:49:56 2004
@@ -32,7 +32,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface DecoderManager {
+public interface DecoderManager
+{
/**
* Decodes a chunk buffer of encoded data without blocking. The chunk may
* contain one or more fragments of a message without necessarily
containing
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface DecoderManagerMonitor {
+public interface DecoderManagerMonitor
+{
/**
* Monitors failures while processing inform methods if any.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DecoderManagerMonitorAdapter implements DecoderManagerMonitor {
+public class DecoderManagerMonitorAdapter implements DecoderManagerMonitor
+{
/* (non-Javadoc)
* @see org.apache.seda.event.SubscriberMonitor#failedOnInform(
* org.apache.seda.event.Subscriber,
@@ -37,8 +38,10 @@
*/
public void failedOnInform(
Subscriber subscriber, EventObject event,
- Throwable t) {
- if (t != null) {
+ Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
Sat Oct 30 18:49:56 2004
@@ -44,7 +44,8 @@
*/
public class DefaultDecoderManager extends DefaultStage
implements DecoderManager, InputSubscriber, ConnectSubscriber,
- ProtocolSubscriber, DisconnectSubscriber {
+ ProtocolSubscriber, DisconnectSubscriber
+{
/** event router or bus this component subscribes and publishes events on
*/
private final EventRouter router;
@@ -68,7 +69,8 @@
*/
public DefaultDecoderManager(
EventRouter router, StageConfig config,
- InetServicesDatabase inetdb) {
+ InetServicesDatabase inetdb)
+ {
super(config);
this.router = router;
@@ -93,10 +95,14 @@
* @see org.apache.seda.event.AbstractSubscriber#inform(
* org.apache.seda.event.Subscriber, java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.failedOnInform(this, event, t);
}
}
@@ -109,8 +115,10 @@
*
* @param event the protocol event to be informed of
*/
- public void inform(ProtocolEvent event) {
- if (event instanceof AddProtocolEvent) {
+ public void inform(ProtocolEvent event)
+ {
+ if (event instanceof AddProtocolEvent)
+ {
factories.put(
event.getProtocolProvider().getName(),
event.getProtocolProvider().getDecoderFactory());
@@ -123,7 +131,8 @@
* @see org.apache.seda.event.InputSubscriber#inform(
* org.apache.seda.event.InputEvent)
*/
- public void inform(InputEvent event) {
+ public void inform(InputEvent event)
+ {
// claim interest and release after asynchronous processing of event
event.claimInterest(this);
enqueue(event);
@@ -135,7 +144,8 @@
* @see org.apache.seda.event.DisconnectSubscriber#inform(
* org.apache.seda.event.DisconnectEvent)
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
decoders.remove(event.getClientKey());
}
@@ -147,7 +157,8 @@
* @return the new stateful nonblocking protocol specific decoder
*/
private StatefulDecoder createDecoder(ClientKey key)
- throws KeyExpiryException {
+ throws KeyExpiryException
+ {
String proto = inetdb.getProtoByPort(key.getLocalAddress().getPort());
DecoderFactory factory = (DecoderFactory) factories.get(proto);
return factory.createDecoder();
@@ -160,13 +171,17 @@
* @see org.apache.seda.event.ConnectSubscriber#inform(
* org.apache.seda.event.ConnectEvent)
*/
- public void inform(ConnectEvent event) {
+ public void inform(ConnectEvent event)
+ {
StatefulDecoder decoder = null;
ClientKey key = event.getClientKey();
- try {
+ try
+ {
decoder = new ClientDecoder(key, createDecoder(key));
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.failedOnInform(this, event, e);
return;
}
@@ -177,10 +192,12 @@
* for a request. We use this request to create a RequestEvent and
* publish the event on the queue.
*/
- decoder.setCallback(new DecoderCallback() {
+ decoder.setCallback(new DecoderCallback()
+ {
public void decodeOccurred(
StatefulDecoder decoder,
- Object decoded) {
+ Object decoded)
+ {
ClientKey key = ((ClientDecoder) decoder).getClientKey();
RequestEvent event = new RequestEvent(this, key, decoded);
router.publish(event);
@@ -194,7 +211,8 @@
* for a client decoder in the decoders map will wait on the map until
* awoken.
*/
- synchronized (decoders) {
+ synchronized (decoders)
+ {
decoders.put(key, decoder);
decoders.notifyAll();
}
@@ -209,7 +227,8 @@
* org.apache.seda.listener.ClientKey, java.nio.ByteBuffer)
*/
public void decodeNonBlocking(ClientKey key, ByteBuffer buffer)
- throws DecoderException {
+ throws DecoderException
+ {
StatefulDecoder decoder = (StatefulDecoder) decoders.get(key);
decoder.decode(buffer);
}
@@ -219,22 +238,28 @@
* decodeNonBlocking(java.nio.ByteBuffer)
*/
public Object decodeBlocking(ClientKey key, ByteBuffer buffer)
- throws DecoderException {
+ throws DecoderException
+ {
// replace this decoder with a real one later
StatefulDecoder decoder = null;
- try {
+ try
+ {
decoder = createDecoder(key);
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
throw new DecoderException("client key has expired");
}
// used array to set a value on final variable and get by compiler
final Object[] decoded = new Object[1];
- decoder.setCallback(new DecoderCallback() {
+ decoder.setCallback(new DecoderCallback()
+ {
public void decodeOccurred(
- StatefulDecoder decoder, Object
obj) {
+ StatefulDecoder decoder, Object obj)
+ {
decoded[0] = obj;
}
});
@@ -243,7 +268,8 @@
decoder.decode(buffer);
// the decoded value should be set
- if (decoded[0] == null) {
+ if (decoded[0] == null)
+ {
throw new DecoderException("Expected a complete encoded unit of "
+ "data but got a partial encoding in
buffer arg");
}
@@ -260,14 +286,16 @@
*
* @return the monitor
*/
- public DecoderManagerMonitor getMonitor() {
+ public DecoderManagerMonitor getMonitor()
+ {
return monitor;
}
/**
* @param monitor the monitor to set
*/
- public void setMonitor(DecoderManagerMonitor monitor) {
+ public void setMonitor(DecoderManagerMonitor monitor)
+ {
this.monitor = monitor;
}
@@ -277,7 +305,8 @@
* @param key the client's key
* @return the stateful decoder for the client
*/
- StatefulDecoder getDecoder(ClientKey key) {
+ StatefulDecoder getDecoder(ClientKey key)
+ {
StatefulDecoder decoder = null;
/*
@@ -287,13 +316,18 @@
* has not been created yet. When processing of the ConnectEvent is
* complete we are awoken via a notifyAll in the inform() method.
*/
- synchronized (decoders) {
+ synchronized (decoders)
+ {
decoder = (StatefulDecoder) decoders.get(key);
- while (decoder == null) {
- try {
+ while (decoder == null)
+ {
+ try
+ {
decoders.wait();
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
e.printStackTrace();
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/ClientEncoder.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/ClientEncoder.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/ClientEncoder.java
Sat Oct 30 18:49:56 2004
@@ -31,7 +31,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class ClientEncoder implements StatefulEncoder, EncoderCallback {
+public class ClientEncoder implements StatefulEncoder, EncoderCallback
+{
/** the key of the client this encoder is associated with */
private final ClientKey key;
@@ -47,21 +48,25 @@
* @param key the key of the client this encoder is for
* @param encoder the underlying encoder doing the work
*/
- public ClientEncoder(ClientKey key, StatefulEncoder encoder) {
+ public ClientEncoder(ClientKey key, StatefulEncoder encoder)
+ {
this.key = key;
this.encoder = encoder;
this.encoder.setCallback(this);
}
- public void encode(Object encoded) throws EncoderException {
+ public void encode(Object encoded) throws EncoderException
+ {
encoder.encode(encoded);
}
- public void setCallback(EncoderCallback cb) {
+ public void setCallback(EncoderCallback cb)
+ {
this.cb = cb;
}
- public void setEncoderMonitor(EncoderMonitor monitor) {
+ public void setEncoderMonitor(EncoderMonitor monitor)
+ {
encoder.setEncoderMonitor(monitor);
}
@@ -70,11 +75,13 @@
*
* @return the key of the client for this stateful encoder
*/
- public ClientKey getClientKey() {
+ public ClientKey getClientKey()
+ {
return key;
}
- public void encodeOccurred(StatefulEncoder encoder, Object encoded) {
+ public void encodeOccurred(StatefulEncoder encoder, Object encoded)
+ {
cb.encodeOccurred(this, encoded);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
Sat Oct 30 18:49:56 2004
@@ -43,7 +43,8 @@
*/
public class DefaultEncoderManager extends DefaultStage
implements EncoderManager, ConnectSubscriber, ResponseSubscriber,
- ProtocolSubscriber, DisconnectSubscriber {
+ ProtocolSubscriber, DisconnectSubscriber
+{
/** the event router used to publish and subscribe to events on */
private final EventRouter router;
@@ -66,7 +67,8 @@
*/
public DefaultEncoderManager(
EventRouter router, StageConfig config,
- InetServicesDatabase inetdb) {
+ InetServicesDatabase inetdb)
+ {
super(config);
super.setMonitor(new LoggingStageMonitor(this.getClass()));
monitor = new EncoderManagerMonitorAdapter();
@@ -80,10 +82,14 @@
/* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.failedOnInform(this, event, t);
}
}
@@ -94,7 +100,8 @@
* @see org.apache.seda.event.DisconnectSubscriber#inform(
* org.apache.seda.event.DisconnectEvent)
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
encoders.remove(event.getClientKey());
}
@@ -102,12 +109,15 @@
* @see org.apache.seda.event.ResponseSubscriber#inform(
* org.apache.seda.event.ResponseEvent)
*/
- public void inform(ResponseEvent event) {
+ public void inform(ResponseEvent event)
+ {
super.enqueue(event);
}
- public void inform(ProtocolEvent event) {
- if (event instanceof AddProtocolEvent) {
+ public void inform(ProtocolEvent event)
+ {
+ if (event instanceof AddProtocolEvent)
+ {
factories.put(
event.getProtocolProvider().getName(),
event.getProtocolProvider().getEncoderFactory());
@@ -122,7 +132,8 @@
* @return the new stateful nonblocking protocol specific encoder
*/
private StatefulEncoder createEncoder(ClientKey key)
- throws KeyExpiryException {
+ throws KeyExpiryException
+ {
String proto = inetdb.getProtoByPort(key.getLocalAddress().getPort());
EncoderFactory factory = (EncoderFactory) factories.get(proto);
return factory.createEncoder();
@@ -135,13 +146,17 @@
* @see org.apache.seda.event.ConnectSubscriber#inform(
* org.apache.seda.event.ConnectEvent)
*/
- public void inform(ConnectEvent event) {
+ public void inform(ConnectEvent event)
+ {
StatefulEncoder encoder = null;
ClientKey key = event.getClientKey();
- try {
+ try
+ {
encoder = new ClientEncoder(key, createEncoder(key));
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.failedOnInform(this, event, e);
return;
}
@@ -149,10 +164,12 @@
/*
* Here the encoder informs us that a response encoded.
*/
- encoder.setCallback(new EncoderCallback() {
+ encoder.setCallback(new EncoderCallback()
+ {
public void encodeOccurred(
StatefulEncoder encoder,
- Object encoded) {
+ Object encoded)
+ {
ClientKey key = ((ClientEncoder) encoder).getClientKey();
OutputEvent event =
new OutputEvent(this, key, (ByteBuffer) encoded);
@@ -163,12 +180,16 @@
}
public ByteBuffer encodeBlocking(ClientKey key, Object response)
- throws EncoderException {
+ throws EncoderException
+ {
int port = -1;
- try {
+ try
+ {
port = key.getLocalAddress().getPort();
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.failedOnEncode(this, key, response, e);
}
@@ -179,9 +200,11 @@
// used array to set a value on final variable and get by compiler
final Object[] encoded = new Object[1];
- encoder.setCallback(new EncoderCallback() {
+ encoder.setCallback(new EncoderCallback()
+ {
public void encodeOccurred(
- StatefulEncoder encoder, Object
obj) {
+ StatefulEncoder encoder, Object obj)
+ {
encoded[0] = obj;
}
});
@@ -189,7 +212,8 @@
encoder.encode(response);
// the encoded value should be set
- if (encoded[0] == null) {
+ if (encoded[0] == null)
+ {
throw new EncoderException("Expected a complete encoded object"
+ " but encoder did not produce one");
}
@@ -198,16 +222,19 @@
}
public void encodeNonBlocking(ClientKey key, Object response)
- throws EncoderException {
+ throws EncoderException
+ {
StatefulEncoder encoder = (StatefulEncoder) encoders.get(key);
encoder.encode(response);
}
- EncoderManagerMonitor getMonitor() {
+ EncoderManagerMonitor getMonitor()
+ {
return monitor;
}
- StatefulEncoder getEncoder(ClientKey key) {
+ StatefulEncoder getEncoder(ClientKey key)
+ {
return (StatefulEncoder) encoders.get(key);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncodeStageHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncodeStageHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncodeStageHandler.java
Sat Oct 30 18:49:56 2004
@@ -32,10 +32,12 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class EncodeStageHandler implements StageHandler {
+public class EncodeStageHandler implements StageHandler
+{
private final DefaultEncoderManager encMan;
- public EncodeStageHandler(DefaultEncoderManager encMan) {
+ public EncodeStageHandler(DefaultEncoderManager encMan)
+ {
this.encMan = encMan;
}
@@ -44,14 +46,18 @@
*
* @param event the event to process or handle.
*/
- public void handleEvent(EventObject event) {
+ public void handleEvent(EventObject event)
+ {
ResponseEvent re = (ResponseEvent) event;
ClientKey key = re.getClientKey();
StatefulEncoder encoder = encMan.getEncoder(key);
- try {
+ try
+ {
encoder.encode(re.getResponse());
- } catch (EncoderException e) {
+ }
+ catch (EncoderException e)
+ {
encMan.getMonitor().failedOnEncode(encMan, event, e);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManager.java
Sat Oct 30 18:49:56 2004
@@ -31,7 +31,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface EncoderManager {
+public interface EncoderManager
+{
/**
* Encodes a protocol response without blocking.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitor.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface EncoderManagerMonitor {
+public interface EncoderManagerMonitor
+{
void failedOnInform(
EncoderManager manager, EventObject event, Throwable
t);
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncoderManagerMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -28,27 +28,34 @@
* @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory Project</a>
* @version $Rev$
*/
-public class EncoderManagerMonitorAdapter implements EncoderManagerMonitor {
+public class EncoderManagerMonitorAdapter implements EncoderManagerMonitor
+{
public void failedOnInform(
EncoderManager manager, EventObject event,
- Throwable t) {
- if (t != null) {
+ Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
public void failedOnEncode(
EncoderManager manager, EventObject event,
- Throwable t) {
- if (t != null) {
+ Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
public void failedOnEncode(
EncoderManager manager, ClientKey key,
- Object response, Throwable t) {
- if (t != null) {
+ Object response, Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AbstractSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AbstractSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AbstractSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -35,7 +35,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class AbstractSubscriber implements Subscriber {
+public class AbstractSubscriber implements Subscriber
+{
/** cached inform methods for subscribers */
private static final HashMap methods = new HashMap();
@@ -45,7 +46,8 @@
/**
* Creates a Subscriber that does not monitor failures to inform.
*/
- public AbstractSubscriber() {
+ public AbstractSubscriber()
+ {
monitor = null;
}
@@ -54,20 +56,28 @@
*
* @param monitor the monitor to use on failures
*/
- public AbstractSubscriber(SubscriberMonitor monitor) {
+ public AbstractSubscriber(SubscriberMonitor monitor)
+ {
this.monitor = monitor;
}
/* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
inform(this, event);
- } catch (Throwable t) {
- if (monitor != null) {
+ }
+ catch (Throwable t)
+ {
+ if (monitor != null)
+ {
monitor.failedOnInform(this, event, t);
- } else {
+ }
+ else
+ {
System.err.println("Failed to inform this Subscriber " + this
+ " about event " + event);
System.err.println("To prevent the above println use a non "
@@ -89,12 +99,15 @@
*/
public static void inform(Subscriber subscriber, EventObject event)
throws NoSuchMethodException, IllegalAccessException,
- InvocationTargetException {
- if (subscriber == null) {
+ InvocationTargetException
+ {
+ if (subscriber == null)
+ {
throw new IllegalArgumentException("subscriber arg can't be null");
}
- if (event == null) {
+ if (event == null)
+ {
throw new IllegalArgumentException("event arg cannot be null");
}
@@ -116,7 +129,8 @@
public static Method getSpecificInformMethod(
Subscriber subscr,
EventObject event)
- throws NoSuchMethodException {
+ throws NoSuchMethodException
+ {
Method method = null;
/*
@@ -132,7 +146,8 @@
String key = signature.toString();
- if (methods.containsKey(key)) {
+ if (methods.containsKey(key))
+ {
return (Method) methods.get(key);
}
@@ -145,21 +160,27 @@
list.add(0, event.getClass());
// there may be two EventObject class references in the list
- while (list.contains(EventObject.class)) {
+ while (list.contains(EventObject.class))
+ {
list.remove(EventObject.class);
}
Method[] all = subscr.getClass().getMethods();
- for (int ii = 0; ii < all.length; ii++) {
+ for (int ii = 0; ii < all.length; ii++)
+ {
method = all[ii];
- if (method.getName().equals("inform")) {
+ if (method.getName().equals("inform"))
+ {
Class[] paramTypes = method.getParameterTypes();
- if (paramTypes.length == 1) {
- for (int jj = 0; jj < list.size(); jj++) {
- if (paramTypes[0] == list.get(jj)) {
+ if (paramTypes.length == 1)
+ {
+ for (int jj = 0; jj < list.size(); jj++)
+ {
+ if (paramTypes[0] == list.get(jj))
+ {
methods.put(key, method);
return method;
}
@@ -182,15 +203,18 @@
* @return the <code>List</code> of superclasses in order going up from
* this one <code>null</code> if null input
*/
- public static List getAllSuperclasses(Class cls) {
- if (cls == null) {
+ public static List getAllSuperclasses(Class cls)
+ {
+ if (cls == null)
+ {
return null;
}
List classes = new ArrayList();
Class superclass = cls.getSuperclass();
- while (superclass != null) {
+ while (superclass != null)
+ {
classes.add(superclass);
superclass = superclass.getSuperclass();
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AddProtocolEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AddProtocolEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AddProtocolEvent.java
Sat Oct 30 18:49:56 2004
@@ -26,14 +26,16 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class AddProtocolEvent extends ProtocolEvent {
+public class AddProtocolEvent extends ProtocolEvent
+{
/**
* Creates a protocol addition event denoting the addition of a new
* protocol.
*
* @param proto the newly added protocol
*/
- public AddProtocolEvent(ProtocolProvider proto) {
+ public AddProtocolEvent(ProtocolProvider proto)
+ {
super(proto);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ClientEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ClientEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ClientEvent.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class ClientEvent extends EventObject {
+public abstract class ClientEvent extends EventObject
+{
/** the unique client identifier */
private final ClientKey clientKey;
@@ -39,7 +40,8 @@
* @param source the source that generated this event
* @param clientKey the client's read client key
*/
- public ClientEvent(Object source, ClientKey clientKey) {
+ public ClientEvent(Object source, ClientKey clientKey)
+ {
super(source);
this.clientKey = clientKey;
}
@@ -49,7 +51,8 @@
*
* @return the client's unique key
*/
- public final ClientKey getClientKey() {
+ public final ClientKey getClientKey()
+ {
return clientKey;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectEvent.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ConnectEvent extends ClientEvent {
+public class ConnectEvent extends ClientEvent
+{
/**
* Creates a connect event which represents a client socket connection
* being established.
@@ -34,7 +35,8 @@
* @param source the source that creates this event
* @param clientKey the unique client key
*/
- public ConnectEvent(Object source, ClientKey clientKey) {
+ public ConnectEvent(Object source, ClientKey clientKey)
+ {
super(source, clientKey);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ConnectSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ConnectSubscriber extends Subscriber {
+public interface ConnectSubscriber extends Subscriber
+{
/**
* ConnectionEvent specific inform handler.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultEventRouter implements EventRouter {
+public class DefaultEventRouter implements EventRouter
+{
/** a list of applied routing advice */
private List adviceList = new ArrayList(2);
@@ -43,7 +44,8 @@
* @see org.apache.seda.event.EventRouter#subscribe(java.lang.Class,
* org.apache.seda.event.Subscriber)
*/
- public void subscribe(Class type, Subscriber subscriber) {
+ public void subscribe(Class type, Subscriber subscriber)
+ {
subscribe(type, null, subscriber);
}
@@ -51,8 +53,10 @@
* @see org.apache.seda.event.EventRouter#subscribe(java.lang.Class,
* org.apache.seda.event.Filter, org.apache.eve.event.Subscriber)
*/
- public void subscribe(Class type, Filter filter, Subscriber subscriber) {
- if (!EventObject.class.isAssignableFrom(type)) {
+ public void subscribe(Class type, Filter filter, Subscriber subscriber)
+ {
+ if (!EventObject.class.isAssignableFrom(type))
+ {
throw new IllegalArgumentException("Invalid event class: "
+ type.getName());
}
@@ -60,8 +64,10 @@
Subscription l_subscription =
new Subscription(type, filter, subscriber);
- if (!subscriptions.contains(l_subscription)) {
- synchronized (subscriptions) {
+ if (!subscriptions.contains(l_subscription))
+ {
+ synchronized (subscriptions)
+ {
subscriptions.add(l_subscription);
}
@@ -73,14 +79,18 @@
* @see org.apache.seda.event.EventRouter#unsubscribe(
* org.apache.seda.event.Subscriber)
*/
- public void unsubscribe(Subscriber subscriber) {
+ public void unsubscribe(Subscriber subscriber)
+ {
Iterator l_list = subscriptions.iterator();
- synchronized (subscriptions) {
- while (l_list.hasNext()) {
+ synchronized (subscriptions)
+ {
+ while (l_list.hasNext())
+ {
Subscription l_subscription = (Subscription) l_list.next();
- if (subscriber == l_subscription.getSubscriber()) {
+ if (subscriber == l_subscription.getSubscriber())
+ {
l_list.remove();
monitor.removedSubscription(l_subscription);
}
@@ -93,16 +103,20 @@
* @see org.apache.seda.event.EventRouter#unsubscribe(java.lang.Class,
* org.apache.seda.event.Subscriber)
*/
- public void unsubscribe(Class type, Subscriber subscriber) {
+ public void unsubscribe(Class type, Subscriber subscriber)
+ {
Iterator l_list = subscriptions.iterator();
- synchronized (subscriptions) {
- while (l_list.hasNext()) {
+ synchronized (subscriptions)
+ {
+ while (l_list.hasNext())
+ {
Subscription l_subscription = (Subscription) l_list.next();
if (
(subscriber == l_subscription.getSubscriber())
- && type.equals(l_subscription.getType())) {
+ && type.equals(l_subscription.getType()))
+ {
l_list.remove();
monitor.removedSubscription(l_subscription);
}
@@ -115,8 +129,10 @@
* @see org.apache.seda.event.EventRouter#unsubscribe(java.lang.Class,
* org.apache.seda.event.Subscriber)
*/
- public void unsubscribe(Class type, Filter filter, Subscriber subscriber) {
- if (!EventObject.class.isAssignableFrom(type)) {
+ public void unsubscribe(Class type, Filter filter, Subscriber subscriber)
+ {
+ if (!EventObject.class.isAssignableFrom(type))
+ {
throw new IllegalArgumentException("Invalid event class: "
+ type.getName());
}
@@ -124,7 +140,8 @@
final Subscription l_subscription =
new Subscription(type, filter, subscriber);
- synchronized (subscriptions) {
+ synchronized (subscriptions)
+ {
subscriptions.remove(l_subscription);
}
}
@@ -133,17 +150,21 @@
* (non-Javadoc)
* @see org.apache.seda.event.EventRouter#publish(java.util.EventObject)
*/
- public void publish(EventObject event) {
+ public void publish(EventObject event)
+ {
final ArrayList applicableAdvice = new ArrayList();
// --------------------------------------------------------------------
// Try and see what advice we can apply
// --------------------------------------------------------------------
- synchronized (adviceList) {
- for (int ii = 0; ii < adviceList.size(); ii++) {
+ synchronized (adviceList)
+ {
+ for (int ii = 0; ii < adviceList.size(); ii++)
+ {
RoutingAdvice advice = (RoutingAdvice) adviceList.get(ii);
- if (advice.isApplicable(event)) {
+ if (advice.isApplicable(event))
+ {
applicableAdvice.add(advice);
}
}
@@ -151,18 +172,21 @@
Subscription[] subscrArray;
- synchronized (subscriptions) {
+ synchronized (subscriptions)
+ {
subscrArray =
(Subscription[]) subscriptions.toArray(new
Subscription[subscriptions
.size()]);
}
- if (applicableAdvice.isEmpty()) {
+ if (applicableAdvice.isEmpty())
+ {
publish(event, subscrArray);
return;
}
- if (applicableAdvice.size() == 1) {
+ if (applicableAdvice.size() == 1)
+ {
RoutingAdvice advice = (RoutingAdvice) adviceList.get(0);
publish(
advice.getEvent(event),
@@ -176,30 +200,36 @@
* you know I'm still not sure what sematics are best here whether to
* keep resubsituting events and the subscriptions or what.
*
- EventObject newEvent = null;
- for ( int ii = 0; ii < applicableAdvice.size(); ii++ )
- {
- RoutingAdvice advice = ( RoutingAdvice ) adviceList.get( ii ) ;
- if ( ii >= applicableAdvice.size() - 1 )
- {
- newEvent = advice.getEvent( event );
- }
- }
+ EventObject newEvent = null;
+ for ( int ii = 0; ii < applicableAdvice.size(); ii++ )
+ {
+ RoutingAdvice advice = ( RoutingAdvice ) adviceList.get( ii )
;
+ if ( ii >= applicableAdvice.size() - 1 )
+ {
+ newEvent = advice.getEvent( event );
+ }
+ }
*/
}
- private void publish(EventObject ev, Subscription[] subscriptions) {
- for (int ii = 0; ii < subscriptions.length; ii++) {
+ private void publish(EventObject ev, Subscription[] subscriptions)
+ {
+ for (int ii = 0; ii < subscriptions.length; ii++)
+ {
boolean isAssignable =
subscriptions[ii].getType().isAssignableFrom(ev.getClass());
- if (!isAssignable) {
+ if (!isAssignable)
+ {
continue;
}
- if (subscriptions[ii].getFilter() == null) {
+ if (subscriptions[ii].getFilter() == null)
+ {
subscriptions[ii].getSubscriber().inform(ev);
- } else if (subscriptions[ii].getFilter().accept(ev)) {
+ }
+ else if (subscriptions[ii].getFilter().accept(ev))
+ {
subscriptions[ii].getSubscriber().inform(ev);
}
}
@@ -210,7 +240,8 @@
*
* @param advice the advice to apply
*/
- public void apply(RoutingAdvice advice) {
+ public void apply(RoutingAdvice advice)
+ {
adviceList.add(advice);
}
@@ -219,7 +250,8 @@
*
* @param monitor the monitor
*/
- public void setMonitor(EventRouterMonitor monitor) {
+ public void setMonitor(EventRouterMonitor monitor)
+ {
this.monitor = monitor;
}
@@ -228,7 +260,8 @@
*
* @return the monitor
*/
- public EventRouterMonitor getMonitor() {
+ public EventRouterMonitor getMonitor()
+ {
return monitor;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectEvent.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DisconnectEvent extends ClientEvent {
+public class DisconnectEvent extends ClientEvent
+{
/**
* Creates a new disconnect event using the client key associated with the
* client socket connection that was lost or dropped.
@@ -36,7 +37,8 @@
* disconnections
* @param clientKey the client socket connection
*/
- public DisconnectEvent(Object source, ClientKey clientKey) {
+ public DisconnectEvent(Object source, ClientKey clientKey)
+ {
super(source, clientKey);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DisconnectSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface DisconnectSubscriber extends Subscriber {
+public interface DisconnectSubscriber extends Subscriber
+{
/**
* DisconnectEvent handler for this Subscriber type.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface EventRouter {
+public interface EventRouter
+{
/**
* Subscribes an event subscriber.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface EventRouterMonitor {
+public interface EventRouterMonitor
+{
/**
* Monitors events that are published.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -27,25 +27,29 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class EventRouterMonitorAdapter implements EventRouterMonitor {
+public class EventRouterMonitorAdapter implements EventRouterMonitor
+{
/* (non-Javadoc)
* @see org.apache.stage.event.EventRouterMonitor#eventPublished(
* java.util.EventObject)
*/
- public void eventPublished(EventObject event) {
+ public void eventPublished(EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.stage.event.EventRouterMonitor#addedSubscription(
* org.apache.stage.event.Subscription)
*/
- public void addedSubscription(Subscription subscription) {
+ public void addedSubscription(Subscription subscription)
+ {
}
/* (non-Javadoc)
* @see org.apache.stage.event.EventRouterMonitor#removedSubscription(
* org.apache.stage.event.Subscription)
*/
- public void removedSubscription(Subscription subscription) {
+ public void removedSubscription(Subscription subscription)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Filter {
+public interface Filter
+{
/**
* Determines whether or not to inform a subscriber of an event.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputEvent.java
Sat Oct 30 18:49:56 2004
@@ -35,7 +35,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class InputEvent extends ClientEvent {
+public abstract class InputEvent extends ClientEvent
+{
/** the buffer used to store the read input */
private final ByteBuffer buffer;
@@ -46,7 +47,8 @@
* @param client the key of the client
* @param buffer the buffer containing the input chunk
*/
- public InputEvent(Object source, ClientKey client, ByteBuffer buffer) {
+ public InputEvent(Object source, ClientKey client, ByteBuffer buffer)
+ {
super(source, client);
this.buffer = buffer;
}
@@ -74,7 +76,8 @@
*
* @return the underlying byte buffer
*/
- protected ByteBuffer getBuffer() {
+ protected ByteBuffer getBuffer()
+ {
return buffer;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/InputSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface InputSubscriber extends Subscriber {
+public interface InputSubscriber extends Subscriber
+{
/**
* InputEvent handler for this Subscriber type.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputEvent.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class OutputEvent extends ClientEvent {
+public class OutputEvent extends ClientEvent
+{
/** the data chunk to send */
private final ByteBuffer buf;
@@ -41,7 +42,8 @@
* @param clientKey the key of the client
* @param buf the buffer containing the chunk to output
*/
- public OutputEvent(Object source, ClientKey clientKey, ByteBuffer buf) {
+ public OutputEvent(Object source, ClientKey clientKey, ByteBuffer buf)
+ {
super(source, clientKey);
this.buf = buf;
}
@@ -51,7 +53,8 @@
*
* @return the chunk to flush back to the client
*/
- public ByteBuffer getBuffer() {
+ public ByteBuffer getBuffer()
+ {
return buf;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/OutputSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface OutputSubscriber extends Subscriber {
+public interface OutputSubscriber extends Subscriber
+{
/**
* Informs a Subscriber of an OutputEvent denoting the need to send a
* chunk of response data back to a client.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolEvent.java
Sat Oct 30 18:49:56 2004
@@ -28,13 +28,15 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ProtocolEvent extends EventObject {
+public class ProtocolEvent extends EventObject
+{
/**
* Creates a protocol event with the protocol provider as the source.
*
* @param proto the protocol provider associated with this event
*/
- public ProtocolEvent(ProtocolProvider proto) {
+ public ProtocolEvent(ProtocolProvider proto)
+ {
super(proto);
}
@@ -43,7 +45,8 @@
*
* @return the protocol provider that caused this event
*/
- public ProtocolProvider getProtocolProvider() {
+ public ProtocolProvider getProtocolProvider()
+ {
return (ProtocolProvider) getSource();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ProtocolSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ProtocolSubscriber extends Subscriber {
+public interface ProtocolSubscriber extends Subscriber
+{
/**
* Informs this subscriber of a protocol event.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestEvent.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class RequestEvent extends ClientEvent {
+public class RequestEvent extends ClientEvent
+{
/** the request message */
private final Object request;
@@ -37,7 +38,8 @@
* @param clientKey the key of the client associated with this event
* @param request the request message
*/
- public RequestEvent(Object source, ClientKey clientKey, Object request) {
+ public RequestEvent(Object source, ClientKey clientKey, Object request)
+ {
super(source, clientKey);
this.request = request;
}
@@ -47,7 +49,8 @@
*
* @return the request message associated with this event
*/
- public Object getRequest() {
+ public Object getRequest()
+ {
return request;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RequestSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface RequestSubscriber extends Subscriber {
+public interface RequestSubscriber extends Subscriber
+{
/**
* RequestEvent handler for this Subscriber type.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseEvent.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ResponseEvent extends ClientEvent {
+public class ResponseEvent extends ClientEvent
+{
/** the response message */
private final Object response;
@@ -40,7 +41,8 @@
* @param clientKey the key of the client associated with this event
* @param response the response message
*/
- public ResponseEvent(Object source, ClientKey clientKey, Object response) {
+ public ResponseEvent(Object source, ClientKey clientKey, Object response)
+ {
super(source, clientKey);
this.response = response;
}
@@ -50,7 +52,8 @@
*
* @return the response message associated with this event
*/
- public Object getResponse() {
+ public Object getResponse()
+ {
return response;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/ResponseSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface ResponseSubscriber extends Subscriber {
+public interface ResponseSubscriber extends Subscriber
+{
/**
* ResponseEvent handler for this Subscriber type.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RoutingAdvice.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RoutingAdvice.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/RoutingAdvice.java
Sat Oct 30 18:49:56 2004
@@ -33,7 +33,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface RoutingAdvice {
+public interface RoutingAdvice
+{
/**
* Returns an alternative list of Subscriptions which may or may not be
* the same as those already registered with the router service.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationEvent.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class SessionCreationEvent extends ClientEvent {
+public class SessionCreationEvent extends ClientEvent
+{
/** the newly created client session */
private final ClientSession session;
@@ -40,7 +41,8 @@
* @param source the source that created this event
* @param session the newly created client session
*/
- public SessionCreationEvent(Object source, ClientSession session) {
+ public SessionCreationEvent(Object source, ClientSession session)
+ {
super(source, session.getClientKey());
this.session = session;
}
@@ -50,7 +52,8 @@
*
* @return the newly created session object
*/
- public ClientSession getClientSession() {
+ public ClientSession getClientSession()
+ {
return this.session;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationSubscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationSubscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationSubscriber.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface SessionCreationSubscriber extends Subscriber {
+public interface SessionCreationSubscriber extends Subscriber
+{
/**
* Informs the Subscriber interested in SessionCreationEvents.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionEvent.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class SessionDestructionEvent extends ClientEvent {
+public class SessionDestructionEvent extends ClientEvent
+{
/** the newly created client session */
private final ClientSession session;
@@ -40,7 +41,8 @@
* @param source the source that created this event
* @param session the newly created client session
*/
- public SessionDestructionEvent(Object source, ClientSession session) {
+ public SessionDestructionEvent(Object source, ClientSession session)
+ {
super(source, session.getClientKey());
this.session = session;
}
@@ -50,7 +52,8 @@
*
* @return the destroyed session object
*/
- public ClientSession getClientSession() {
+ public ClientSession getClientSession()
+ {
return this.session;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionListener.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionListener.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionListener.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface SessionDestructionListener {
+public interface SessionDestructionListener
+{
/**
* Informs this Subscriber of session destruction events.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Subscriber extends EventListener {
+public interface Subscriber extends EventListener
+{
/**
* Informs this Subscriber of an event.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface SubscriberMonitor {
+public interface SubscriberMonitor
+{
/**
* Monitors failures occuring while handling events.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscription.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscription.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscription.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class Subscription {
+public class Subscription
+{
/** the filter if any used to filter out events */
private final Filter filter;
@@ -42,7 +43,8 @@
* @param filter the Filter to use weed out unwanted events
* @param subscriber the subscriber to deliever the event to
*/
- public Subscription(Class type, Filter filter, Subscriber subscriber) {
+ public Subscription(Class type, Filter filter, Subscriber subscriber)
+ {
this.type = type;
this.filter = filter;
this.subscriber = subscriber;
@@ -53,7 +55,8 @@
*
* @return the event class/type
*/
- public Class getType() {
+ public Class getType()
+ {
return type;
}
@@ -62,7 +65,8 @@
*
* @return The filter
*/
- public Filter getFilter() {
+ public Filter getFilter()
+ {
return filter;
}
@@ -71,7 +75,8 @@
*
* @return the subscriber
*/
- public Subscriber getSubscriber() {
+ public Subscriber getSubscriber()
+ {
return subscriber;
}
@@ -81,32 +86,40 @@
* @param obj the object to compare this Subscription to
* @return <code>true</code> if the two Subscription objects are the same
*/
- public boolean equals(Object obj) {
- if (this == obj) {
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
return true;
}
- if (!(obj instanceof Subscription)) {
+ if (!(obj instanceof Subscription))
+ {
return false;
}
final Subscription l_subscription = (Subscription) obj;
- if (!type.equals(l_subscription.getType())) {
+ if (!type.equals(l_subscription.getType()))
+ {
return false;
}
- if (filter != null) {
- if (l_subscription.getFilter() == null) {
+ if (filter != null)
+ {
+ if (l_subscription.getFilter() == null)
+ {
return false;
}
- if (!filter.equals(l_subscription.getFilter())) {
+ if (!filter.equals(l_subscription.getFilter()))
+ {
return false;
}
}
- if (!subscriber.equals(l_subscription.getSubscriber())) {
+ if (!subscriber.equals(l_subscription.getSubscriber()))
+ {
return false;
}
@@ -123,12 +136,12 @@
*
* @return the hashCode value
*/
- public int hashCode() {
+ public int hashCode()
+ {
int l_result = 17;
l_result = (37 * l_result) + type.hashCode();
- l_result = (37 * l_result) + (
- (filter != null) ? filter.hashCode() : 0
- );
+ l_result =
+ (37 * l_result) + ((filter != null) ? filter.hashCode() : 0);
l_result = (37 * l_result) + subscriber.hashCode();
return l_result;
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/Enum.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/Enum.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/Enum.java
Sat Oct 30 18:49:56 2004
@@ -234,7 +234,8 @@
* @since 1.0
* @version $Id$
*/
-public abstract class Enum implements Comparable, Serializable {
+public abstract class Enum implements Comparable, Serializable
+{
/** Lang version 1.0.1 serial compatibility */
private static final long serialVersionUID = -487045951170455942L;
@@ -278,7 +279,8 @@
* @throws IllegalArgumentException if the getEnumClass() method returns
* a null or invalid Class
*/
- protected Enum(String name) {
+ protected Enum(String name)
+ {
super();
init(name);
iName = name;
@@ -294,14 +296,17 @@
* @throws IllegalArgumentException if the name is null or empty or
duplicate
* @throws IllegalArgumentException if the enumClass is null or invalid
*/
- private void init(String name) {
- if ((name == null) || name.equals("")) {
+ private void init(String name)
+ {
+ if ((name == null) || name.equals(""))
+ {
throw new IllegalArgumentException("The Enum name must not be
empty or null");
}
Class enumClass = getEnumClass();
- if (enumClass == null) {
+ if (enumClass == null)
+ {
throw new IllegalArgumentException("getEnumClass() must not be
null");
}
@@ -310,8 +315,10 @@
while (
(cls != null) && (cls != Enum.class)
- && (cls != ValuedEnum.class)) {
- if (cls == enumClass) {
+ && (cls != ValuedEnum.class))
+ {
+ if (cls == enumClass)
+ {
ok = true;
break;
}
@@ -319,19 +326,22 @@
cls = cls.getSuperclass();
}
- if (ok == false) {
+ if (ok == false)
+ {
throw new IllegalArgumentException("getEnumClass() must return a
superclass of this class");
}
// create entry
Entry entry = (Entry) cEnumClasses.get(enumClass);
- if (entry == null) {
+ if (entry == null)
+ {
entry = createEntry(enumClass);
cEnumClasses.put(enumClass, entry);
}
- if (entry.map.containsKey(name)) {
+ if (entry.map.containsKey(name))
+ {
throw new IllegalArgumentException("The Enum name must be unique,
'"
+ name
+ "' has already been added");
@@ -347,10 +357,12 @@
*
* @return the resolved object
*/
- protected Object readResolve() {
+ protected Object readResolve()
+ {
Entry entry = (Entry) cEnumClasses.get(getEnumClass());
- if (entry == null) {
+ if (entry == null)
+ {
return null;
}
@@ -370,10 +382,12 @@
* @throws IllegalArgumentException if the enum class
* is <code>null</code>
*/
- protected static Enum getEnum(Class enumClass, String name) {
+ protected static Enum getEnum(Class enumClass, String name)
+ {
Entry entry = getEntry(enumClass);
- if (entry == null) {
+ if (entry == null)
+ {
return null;
}
@@ -393,10 +407,12 @@
* @throws IllegalArgumentException if the enum class is <code>null</code>
* @throws IllegalArgumentException if the enum class is not a subclass of
Enum
*/
- protected static Map getEnumMap(Class enumClass) {
+ protected static Map getEnumMap(Class enumClass)
+ {
Entry entry = getEntry(enumClass);
- if (entry == null) {
+ if (entry == null)
+ {
return EMPTY_MAP;
}
@@ -417,10 +433,12 @@
* @throws IllegalArgumentException if the enum class is <code>null</code>
* @throws IllegalArgumentException if the enum class is not a subclass of
Enum
*/
- protected static List getEnumList(Class enumClass) {
+ protected static List getEnumList(Class enumClass)
+ {
Entry entry = getEntry(enumClass);
- if (entry == null) {
+ if (entry == null)
+ {
return Collections.EMPTY_LIST;
}
@@ -441,7 +459,8 @@
* @throws IllegalArgumentException if the enum class is <code>null</code>
* @throws IllegalArgumentException if the enum class is not a subclass of
Enum
*/
- protected static Iterator iterator(Class enumClass) {
+ protected static Iterator iterator(Class enumClass)
+ {
return Enum.getEnumList(enumClass).iterator();
}
@@ -453,12 +472,15 @@
* @param enumClass the class of the <code>Enum</code> to get
* @return the enum entry
*/
- private static Entry getEntry(Class enumClass) {
- if (enumClass == null) {
+ private static Entry getEntry(Class enumClass)
+ {
+ if (enumClass == null)
+ {
throw new IllegalArgumentException("The Enum Class must not be
null");
}
- if (Enum.class.isAssignableFrom(enumClass) == false) {
+ if (Enum.class.isAssignableFrom(enumClass) == false)
+ {
throw new IllegalArgumentException("The Class must be a subclass
of Enum");
}
@@ -474,16 +496,19 @@
* @param enumClass the class of the <code>Enum</code> to get
* @return the enum entry
*/
- private static Entry createEntry(Class enumClass) {
+ private static Entry createEntry(Class enumClass)
+ {
Entry entry = new Entry();
Class cls = enumClass.getSuperclass();
while (
(cls != null) && (cls != Enum.class)
- && (cls != ValuedEnum.class)) {
+ && (cls != ValuedEnum.class))
+ {
Entry loopEntry = (Entry) cEnumClasses.get(cls);
- if (loopEntry != null) {
+ if (loopEntry != null)
+ {
entry.list.addAll(loopEntry.list);
entry.map.putAll(loopEntry.map);
break; // stop here, as this will already have had
superclasses added
@@ -502,7 +527,8 @@
*
* @return the <code>String</code> name of this Enum item
*/
- public final String getName() {
+ public final String getName()
+ {
return iName;
}
@@ -516,7 +542,8 @@
* @return the <code>Class</code> of the enum
* @since 2.0
*/
- public Class getEnumClass() {
+ public Class getEnumClass()
+ {
return getClass();
}
@@ -533,27 +560,42 @@
* @param other the other object to compare for equality
* @return <code>true</code> if the Enums are equal
*/
- public final boolean equals(Object other) {
- if (other == this) {
+ public final boolean equals(Object other)
+ {
+ if (other == this)
+ {
return true;
- } else if (other == null) {
+ }
+ else if (other == null)
+ {
return false;
- } else if (other.getClass() == this.getClass()) {
+ }
+ else if (other.getClass() == this.getClass())
+ {
// Ok to do a class cast to Enum here since the test above
// guarantee both
// classes are in the same class loader.
return iName.equals(((Enum) other).iName);
- } else {
+ }
+ else
+ {
// This and other are in different class loaders, we must use
reflection.
- try {
+ try
+ {
Method mth = other.getClass().getMethod("getName", null);
String name = (String) mth.invoke(other, null);
return iName.equals(name);
- } catch (NoSuchMethodException e) {
+ }
+ catch (NoSuchMethodException e)
+ {
// ignore - should never happen
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e)
+ {
// ignore - should never happen
- } catch (InvocationTargetException e) {
+ }
+ catch (InvocationTargetException e)
+ {
// ignore - should never happen
}
@@ -566,7 +608,8 @@
*
* @return a hashcode based on the name
*/
- public final int hashCode() {
+ public final int hashCode()
+ {
return iHashCode;
}
@@ -583,8 +626,10 @@
* @throws ClassCastException if other is not an Enum
* @throws NullPointerException if other is <code>null</code>
*/
- public int compareTo(Object other) {
- if (other == this) {
+ public int compareTo(Object other)
+ {
+ if (other == this)
+ {
return 0;
}
@@ -598,21 +643,30 @@
* <code>Color[Red]</code>. Note that the package name is stripped from
* the type name.
*/
- public String toString() {
- if (iToString == null) {
+ public String toString()
+ {
+ if (iToString == null)
+ {
String shortName = null;
- if (getEnumClass() == null) {
+ if (getEnumClass() == null)
+ {
shortName = "";
- } else {
+ }
+ else
+ {
char[] chars =
getEnumClass().getClass().getName().toCharArray();
int lastDot = 0;
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '.') {
+ for (int i = 0; i < chars.length; i++)
+ {
+ if (chars[i] == '.')
+ {
lastDot = i + 1;
- } else if (chars[i] == '$') { // handle inner classes
+ }
+ else if (chars[i] == '$')
+ { // handle inner classes
chars[i] = '.';
}
}
@@ -629,7 +683,8 @@
/**
* <p>Enable the iterator to retain the source code order.</p>
*/
- private static class Entry {
+ private static class Entry
+ {
/**
* Map of Enum name to Enum.
*/
@@ -653,7 +708,8 @@
/**
* <p>Restrictive constructor.</p>
*/
- private Entry() {
+ private Entry()
+ {
}
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/EnumUtils.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/EnumUtils.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/EnumUtils.java
Sat Oct 30 18:49:56 2004
@@ -33,12 +33,14 @@
* @since 1.0
* @version $Id$
*/
-public class EnumUtils {
+public class EnumUtils
+{
/**
* Public constructor. This class should not normally be instantiated.
* @since 2.0
*/
- public EnumUtils() {
+ public EnumUtils()
+ {
}
/**
@@ -49,7 +51,8 @@
* @return the enum object
* @throws IllegalArgumentException if the enum class is <code>null</code>
*/
- public static Enum getEnum(Class enumClass, String name) {
+ public static Enum getEnum(Class enumClass, String name)
+ {
return Enum.getEnum(enumClass, name);
}
@@ -61,7 +64,8 @@
* @return the enum object, or null if the enum does not exist
* @throws IllegalArgumentException if the enum class is <code>null</code>
*/
- public static ValuedEnum getEnum(Class enumClass, int value) {
+ public static ValuedEnum getEnum(Class enumClass, int value)
+ {
return (ValuedEnum) ValuedEnum.getEnum(enumClass, value);
}
@@ -78,7 +82,8 @@
* @throws IllegalArgumentException if the enum class is not a subclass
* of <code>Enum</code>
*/
- public static Map getEnumMap(Class enumClass) {
+ public static Map getEnumMap(Class enumClass)
+ {
return Enum.getEnumMap(enumClass);
}
@@ -98,7 +103,8 @@
* @throws IllegalArgumentException if the enum class is not a subclass
* of <code>Enum</code>
*/
- public static List getEnumList(Class enumClass) {
+ public static List getEnumList(Class enumClass)
+ {
return Enum.getEnumList(enumClass);
}
@@ -118,7 +124,8 @@
* @throws IllegalArgumentException if the enum class is <code>null</code>
* @throws IllegalArgumentException if the enum class is not a subclass of
<code>Enum</code>
*/
- public static Iterator iterator(Class enumClass) {
+ public static Iterator iterator(Class enumClass)
+ {
return Enum.getEnumList(enumClass).iterator();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/ValuedEnum.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/ValuedEnum.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/ValuedEnum.java
Sat Oct 30 18:49:56 2004
@@ -99,7 +99,8 @@
* @since 1.0
* @version $Id$
*/
-public abstract class ValuedEnum extends Enum {
+public abstract class ValuedEnum extends Enum
+{
/** Lang version 1.0.1 serial compatibility */
private static final long serialVersionUID = -7129650521543789085L;
@@ -114,7 +115,8 @@
* @param name the name of enum item
* @param value the value of enum item
*/
- protected ValuedEnum(String name, int value) {
+ protected ValuedEnum(String name, int value)
+ {
super(name);
iValue = value;
}
@@ -131,17 +133,21 @@
* @return the enum object, or null if the enum does not exist
* @throws IllegalArgumentException if the enum class is <code>null</code>
*/
- protected static Enum getEnum(Class enumClass, int value) {
- if (enumClass == null) {
+ protected static Enum getEnum(Class enumClass, int value)
+ {
+ if (enumClass == null)
+ {
throw new IllegalArgumentException("The Enum Class must not be
null");
}
List list = Enum.getEnumList(enumClass);
- for (Iterator it = list.iterator(); it.hasNext();) {
+ for (Iterator it = list.iterator(); it.hasNext();)
+ {
ValuedEnum enum = (ValuedEnum) it.next();
- if (enum.getValue() == value) {
+ if (enum.getValue() == value)
+ {
return enum;
}
}
@@ -154,7 +160,8 @@
*
* @return the enum item's value.
*/
- public final int getValue() {
+ public final int getValue()
+ {
return iValue;
}
@@ -171,7 +178,8 @@
* @throws ClassCastException if other is not an <code>Enum</code>
* @throws NullPointerException if other is <code>null</code>
*/
- public int compareTo(Object other) {
+ public int compareTo(Object other)
+ {
return iValue - ((ValuedEnum) other).iValue;
}
@@ -182,21 +190,30 @@
* <code>JavaVersion[Java 1.0=100]</code>. Note that the package name is
* stripped from the type name.
*/
- public String toString() {
- if (iToString == null) {
+ public String toString()
+ {
+ if (iToString == null)
+ {
String shortName = null;
- if (getEnumClass() == null) {
+ if (getEnumClass() == null)
+ {
shortName = "";
- } else {
+ }
+ else
+ {
char[] chars =
getEnumClass().getClass().getName().toCharArray();
int lastDot = 0;
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '.') {
+ for (int i = 0; i < chars.length; i++)
+ {
+ if (chars[i] == '.')
+ {
lastDot = i + 1;
- } else if (chars[i] == '$') { // handle inner classes
+ }
+ else if (chars[i] == '$')
+ { // handle inner classes
chars[i] = '.';
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManager.java
Sat Oct 30 18:49:56 2004
@@ -25,5 +25,6 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface InputManager {
+public interface InputManager
+{
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitor.java
Sat Oct 30 18:49:56 2004
@@ -36,7 +36,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface InputManagerMonitor {
+public interface InputManagerMonitor
+{
/**
* Monitors client disconnections.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/input/InputManagerMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -36,12 +36,14 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class InputManagerMonitorAdapter implements InputManagerMonitor {
+public class InputManagerMonitorAdapter implements InputManagerMonitor
+{
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#
* disconnectedClient(org.apache.seda.listener.ClientKey)
*/
- public void disconnectedClient(ClientKey key) {
+ public void disconnectedClient(ClientKey key)
+ {
}
/* (non-Javadoc)
@@ -49,28 +51,32 @@
* registeredChannel(org.apache.seda.listener.ClientKey,
* java.nio.channels.Selector)
*/
- public void registeredChannel(ClientKey key, Selector selector) {
+ public void registeredChannel(ClientKey key, Selector selector)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#
* selectorReturned(java.nio.channels.Selector)
*/
- public void selectorReturned(Selector selector) {
+ public void selectorReturned(Selector selector)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#
* inputRecieved(org.apache.seda.listener.ClientKey)
*/
- public void inputRecieved(ClientKey key) {
+ public void inputRecieved(ClientKey key)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#
* selectFailure(java.nio.channels.Selector, java.io.IOException)
*/
- public void selectFailure(Selector selector, IOException fault) {
+ public void selectFailure(Selector selector, IOException fault)
+ {
dump(fault);
}
@@ -79,7 +85,8 @@
* org.apache.seda.listener.ClientKey,
* org.apache.seda.listener.KeyExpiryException)
*/
- public void keyExpiryFailure(ClientKey key, KeyExpiryException fault) {
+ public void keyExpiryFailure(ClientKey key, KeyExpiryException fault)
+ {
dump(fault);
}
@@ -87,7 +94,8 @@
* @see org.apache.seda.input.InputManagerMonitor#
* readFailed(org.apache.seda.listener.ClientKey, java.io.IOException)
*/
- public void readFailed(ClientKey key, IOException fault) {
+ public void readFailed(ClientKey key, IOException fault)
+ {
dump(fault);
}
@@ -96,7 +104,8 @@
* bufferUnavailable(org.apache.seda.buffer.BufferPool,
* org.apache.seda.ResourceException)
*/
- public void bufferUnavailable(BufferPool bp, ResourceException fault) {
+ public void bufferUnavailable(BufferPool bp, ResourceException fault)
+ {
dump(fault);
}
@@ -108,7 +117,8 @@
public void channelRegistrationFailure(
Selector selector,
SocketChannel channel, int key,
- IOException fault) {
+ IOException fault)
+ {
dump(fault);
}
@@ -116,7 +126,8 @@
* @see org.apache.seda.input.InputManagerMonitor#
* channelCloseFailure(java.nio.channels.SocketChannel,
java.io.IOException)
*/
- public void channelCloseFailure(SocketChannel channel, IOException fault) {
+ public void channelCloseFailure(SocketChannel channel, IOException fault)
+ {
dump(fault);
}
@@ -124,28 +135,32 @@
* @see org.apache.seda.input.InputManagerMonitor#enteringSelect(
* java.nio.channels.Selector)
*/
- public void enteringSelect(Selector selector) {
+ public void enteringSelect(Selector selector)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#selectTimedOut(
* java.nio.channels.Selector)
*/
- public void selectTimedOut(Selector selector) {
+ public void selectTimedOut(Selector selector)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#inputRecieved(
* java.nio.ByteBuffer, org.apache.seda.listener.ClientKey)
*/
- public void inputRecieved(ByteBuffer buffer, ClientKey key) {
+ public void inputRecieved(ByteBuffer buffer, ClientKey key)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.input.InputManagerMonitor#cleanedStaleKey(
* java.nio.channels.SelectionKey)
*/
- public void cleanedStaleKey(SelectionKey key) {
+ public void cleanedStaleKey(SelectionKey key)
+ {
}
/**
@@ -153,8 +168,10 @@
*
* @param t the throwables stack to dump to stderr
*/
- private void dump(Throwable t) {
- if (t != null) {
+ private void dump(Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/input/TCPInputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/input/TCPInputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/input/TCPInputManager.java
Sat Oct 30 18:49:56 2004
@@ -50,7 +50,8 @@
public class TCPInputManager extends AbstractSubscriber implements
InputManager,
ConnectSubscriber,
DisconnectSubscriber,
- Runnable {
+ Runnable
+{
/** the thread driving this Runnable */
private Thread thread = null;
@@ -86,7 +87,8 @@
* @param bp a buffer pool service
*/
public TCPInputManager(EventRouter router, BufferPool bp)
- throws IOException {
+ throws IOException
+ {
this.bp = bp;
hasStarted = new Boolean(false);
selector = Selector.open();
@@ -103,7 +105,8 @@
/**
* Runnable run method implementation.
*/
- public void run() {
+ public void run()
+ {
/*
* Loop here solves a bug where some lingering phantom clients (that
are
* long gone) have sockets and channels that appear valid and
connected.
@@ -115,8 +118,10 @@
*
* http://nagoya.apache.org/jira/secure/ViewIssue.jspa?key=DIR-18
*/
- while (hasStarted.booleanValue()) {
- try {
+ while (hasStarted.booleanValue())
+ {
+ try
+ {
/*
* Register newly arrived connections and unregister thosed
* that were dropped while we were blocked on the select call
@@ -134,10 +139,12 @@
* connections lingering around. We remove them since they
* are prematurely triggering selection to return w/o input.
*/
- if (0 == selector.select()) {
+ if (0 == selector.select())
+ {
Iterator l_list = selector.selectedKeys().iterator();
- while (l_list.hasNext()) {
+ while (l_list.hasNext())
+ {
SelectionKey l_key = (SelectionKey) l_list.next();
l_key.channel().close();
l_key.cancel();
@@ -149,7 +156,9 @@
monitor.selectTimedOut(selector);
continue;
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.selectFailure(selector, e);
continue;
}
@@ -165,9 +174,12 @@
/**
* Starts up this module.
*/
- public void start() {
- synchronized (hasStarted) {
- if (hasStarted.booleanValue()) {
+ public void start()
+ {
+ synchronized (hasStarted)
+ {
+ if (hasStarted.booleanValue())
+ {
throw new IllegalStateException("Already started!");
}
@@ -180,12 +192,15 @@
/**
* Blocks calling thread until this module gracefully stops.
*/
- public void stop() throws InterruptedException {
- synchronized (hasStarted) {
+ public void stop() throws InterruptedException
+ {
+ synchronized (hasStarted)
+ {
hasStarted = new Boolean(false);
selector.wakeup();
- while (thread.isAlive()) {
+ while (thread.isAlive())
+ {
Thread.sleep(100);
}
}
@@ -198,8 +213,10 @@
/**
* @see
org.apache.seda.event.ConnectSubscriber#inform(org.apache.seda.event.ConnectEvent)
*/
- public void inform(ConnectEvent an_event) {
- synchronized (connectEvents) {
+ public void inform(ConnectEvent an_event)
+ {
+ synchronized (connectEvents)
+ {
connectEvents.add(an_event);
}
@@ -209,8 +226,10 @@
/**
* @see
org.apache.seda.event.DisconnectSubscriber#inform(org.apache.seda.event.DisconnectEvent)
*/
- public void inform(DisconnectEvent an_event) {
- synchronized (disconnectEvents) {
+ public void inform(DisconnectEvent an_event)
+ {
+ synchronized (disconnectEvents)
+ {
disconnectEvents.add(an_event);
}
@@ -224,36 +243,45 @@
/**
* Register new connections that have arrived since the last select call.
*/
- private void registerNewConnections() {
+ private void registerNewConnections()
+ {
// copy of newly arrived events batched in the list of ConnectEvents
ConnectEvent[] l_events = null;
- synchronized (connectEvents) {
+ synchronized (connectEvents)
+ {
l_events = new ConnectEvent[connectEvents.size()];
l_events = (ConnectEvent[]) connectEvents.toArray(l_events);
connectEvents.clear();
}
// cycle through connections and register them with the selector
- for (int ii = 0; ii < l_events.length; ii++) {
+ for (int ii = 0; ii < l_events.length; ii++)
+ {
TCPClientKey l_key = null;
SocketChannel l_channel = null;
- try {
+ try
+ {
l_key = (TCPClientKey) l_events[ii].getClientKey();
l_channel = l_key.getSocket().getChannel();
// hands-off blocking sockets!
- if (null == l_channel) {
+ if (null == l_channel)
+ {
continue;
}
l_channel.configureBlocking(false);
l_channel.register(selector, SelectionKey.OP_READ, l_key);
monitor.registeredChannel(l_key, selector);
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpiryFailure(l_key, e);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.channelRegistrationFailure(
selector, l_channel,
SelectionKey.OP_READ, e);
@@ -266,37 +294,46 @@
*
* @see <a
href="http://nagoya.apache.org/jira/secure/ViewIssue.jspa?id=13574">JIRA
Issue</a>
*/
- private void unregisterDroppedConnections() {
+ private void unregisterDroppedConnections()
+ {
SelectionKey l_key = null;
DisconnectEvent[] l_events = null;
// synchronized copy all events into a separate list first and clear
- synchronized (disconnectEvents) {
+ synchronized (disconnectEvents)
+ {
l_events = new DisconnectEvent[disconnectEvents.size()];
l_events = (DisconnectEvent[]) disconnectEvents.toArray(l_events);
disconnectEvents.clear();
}
// cancel selection key for the disconnect event's client
- for (int ii = 0; ii < l_events.length; ii++) {
+ for (int ii = 0; ii < l_events.length; ii++)
+ {
Iterator l_keys = selector.keys().iterator();
ClientKey l_clientKey = l_events[ii].getClientKey();
- while (l_keys.hasNext()) {
+ while (l_keys.hasNext())
+ {
l_key = (SelectionKey) l_keys.next();
- if (l_key.attachment().equals(l_clientKey)) {
+ if (l_key.attachment().equals(l_clientKey))
+ {
break;
}
}
- if (null == l_key) {
+ if (null == l_key)
+ {
return;
}
- try {
+ try
+ {
l_key.channel().close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.channelCloseFailure(
(SocketChannel) l_key.channel(),
e);
}
@@ -309,7 +346,8 @@
/**
* Processes input on channels of the read ready selected keys.
*/
- private void processInput() {
+ private void processInput()
+ {
/*
* Process the selectors that are ready. For each selector that
* is ready we read some data into a buffer we claim from a buffer
@@ -318,11 +356,13 @@
*/
Iterator l_list = selector.selectedKeys().iterator();
- while (l_list.hasNext()) {
+ while (l_list.hasNext())
+ {
SelectionKey l_key = (SelectionKey) l_list.next();
ClientKey l_client = (ClientKey) l_key.attachment();
- if (l_key.isReadable()) {
+ if (l_key.isReadable())
+ {
ByteBuffer l_buf = null;
SocketChannel l_channel = (SocketChannel) l_key.channel();
@@ -330,10 +370,12 @@
* claim a buffer, read from channel into it and remove
* the current selection key from selected set
*/
- try {
+ try
+ {
l_buf = bp.getBuffer(this);
- if (l_channel.read(l_buf) == -1) {
+ if (l_channel.read(l_buf) == -1)
+ {
l_channel.socket().close();
l_channel.close();
l_key.cancel();
@@ -343,10 +385,14 @@
l_buf.flip();
monitor.inputRecieved(l_buf.asReadOnlyBuffer(), l_client);
l_list.remove();
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
monitor.bufferUnavailable(bp, e);
continue;
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.readFailed(l_client, e);
bp.releaseClaim(l_buf, this);
continue;
@@ -374,7 +420,8 @@
*
* @return returns the monitor
*/
- public InputManagerMonitor getMonitor() {
+ public InputManagerMonitor getMonitor()
+ {
return monitor;
}
@@ -383,7 +430,8 @@
*
* @param monitor the monitor to set
*/
- public void setMonitor(InputManagerMonitor monitor) {
+ public void setMonitor(InputManagerMonitor monitor)
+ {
this.monitor = monitor;
}
@@ -395,17 +443,21 @@
* @author $Author$
* @version $Revision$
*/
- class ConcreteInputEvent extends InputEvent {
- ConcreteInputEvent(ClientKey key, ByteBuffer buffer) {
+ class ConcreteInputEvent extends InputEvent
+ {
+ ConcreteInputEvent(ClientKey key, ByteBuffer buffer)
+ {
super(TCPInputManager.this, key, buffer);
}
- public ByteBuffer claimInterest(Object party) {
+ public ByteBuffer claimInterest(Object party)
+ {
bp.claimInterest(getBuffer(), party);
return getBuffer().asReadOnlyBuffer();
}
- public void releaseInterest(Object party) {
+ public void releaseInterest(Object party)
+ {
bp.releaseClaim(getBuffer(), party);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java
Sat Oct 30 18:49:56 2004
@@ -34,7 +34,8 @@
* @version $Rev$
* @see <a href="http://www.iana.org/assignments/port-numbers">IANA.org</a>
*/
-public class AvailablePortFinder {
+public class AvailablePortFinder
+{
/**
* The minimum number of server port number.
*/
@@ -48,7 +49,8 @@
/**
* Creates a new instance.
*/
- public AvailablePortFinder() {
+ public AvailablePortFinder()
+ {
}
/**
@@ -58,7 +60,8 @@
*
* WARNING: this can take a very long time.
*/
- public Set getAvailablePorts() {
+ public Set getAvailablePorts()
+ {
return getAvailablePorts(MIN_PORT_NUMBER, MAX_PORT_NUMBER);
}
@@ -67,7 +70,8 @@
*
* @throws NoSuchElementException if there are no ports available
*/
- public static int getNextAvailable() {
+ public static int getNextAvailable()
+ {
return getNextAvailable(MIN_PORT_NUMBER);
}
@@ -77,24 +81,36 @@
* @param fromPort the port to scan for availability
* @throws NoSuchElementException if there are no ports available
*/
- public static int getNextAvailable(int fromPort) {
- if ((fromPort < MIN_PORT_NUMBER) || (fromPort > MAX_PORT_NUMBER)) {
+ public static int getNextAvailable(int fromPort)
+ {
+ if ((fromPort < MIN_PORT_NUMBER) || (fromPort > MAX_PORT_NUMBER))
+ {
throw new IllegalArgumentException("Invalid start port: "
+ fromPort);
}
- for (int i = fromPort; i <= MAX_PORT_NUMBER; i++) {
+ for (int i = fromPort; i <= MAX_PORT_NUMBER; i++)
+ {
ServerSocket s = null;
- try {
+ try
+ {
s = new ServerSocket(i);
return i;
- } catch (IOException e) {
- } finally {
- if (s != null) {
- try {
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (s != null)
+ {
+ try
+ {
s.close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
/* should not be thrown */
}
}
@@ -113,28 +129,40 @@
* [EMAIL PROTECTED] #MIN_PORT_NUMBER} and [EMAIL PROTECTED]
#MAX_PORT_NUMBER} or
* <code>fromPort</code> if greater than <code>toPort</code>.
*/
- public Set getAvailablePorts(int fromPort, int toPort) {
+ public Set getAvailablePorts(int fromPort, int toPort)
+ {
if (
(fromPort < MIN_PORT_NUMBER) || (toPort > MAX_PORT_NUMBER)
- || (fromPort > toPort)) {
+ || (fromPort > toPort))
+ {
throw new IllegalArgumentException("Invalid port range: "
+ fromPort + " ~ " + toPort);
}
Set result = new TreeSet();
- for (int i = fromPort; i <= toPort; i++) {
+ for (int i = fromPort; i <= toPort; i++)
+ {
ServerSocket s = null;
- try {
+ try
+ {
s = new ServerSocket(i);
result.add(new Integer(i));
- } catch (IOException e) {
- } finally {
- if (s != null) {
- try {
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ if (s != null)
+ {
+ try
+ {
s.close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
/* should not be thrown */
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
Sat Oct 30 18:49:56 2004
@@ -41,7 +41,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class ClientKey {
+public abstract class ClientKey
+{
// ----------------------------------------------
// Private members.
// ----------------------------------------------
@@ -72,7 +73,8 @@
*
* @param clientId the id of this client key
*/
- ClientKey(String clientId) {
+ ClientKey(String clientId)
+ {
this.clientId = clientId;
}
@@ -89,7 +91,8 @@
* than depending on developers to maintain a convention of checking for
* key expiration before use in other modules.
*/
- public final String getClientId() throws KeyExpiryException {
+ public final String getClientId() throws KeyExpiryException
+ {
checkExpiry();
return clientId;
}
@@ -122,7 +125,8 @@
* @return ouput lock object.
* @throws KeyExpiryException to force the handling of expired keys
*/
- public final Object getOutputLock() throws KeyExpiryException {
+ public final Object getOutputLock() throws KeyExpiryException
+ {
checkExpiry();
return outputLock;
}
@@ -133,7 +137,8 @@
* @return input lock object.
* @throws KeyExpiryException to force the handling of expired keys
*/
- public final Object getInputLock() throws KeyExpiryException {
+ public final Object getInputLock() throws KeyExpiryException
+ {
checkExpiry();
return inputLock;
}
@@ -183,7 +188,8 @@
*
* @return the client id string.
*/
- public final String toString() {
+ public final String toString()
+ {
return clientId;
}
@@ -193,7 +199,8 @@
*
* @return the clientId hashCode value.
*/
- public final int hashCode() {
+ public final int hashCode()
+ {
return clientId.hashCode();
}
@@ -207,14 +214,22 @@
*
* @return true if an_obj equals this ClientKey, false otherwise.
*/
- public final boolean equals(Object an_obj) {
- if (this == an_obj) {
+ public final boolean equals(Object an_obj)
+ {
+ if (this == an_obj)
+ {
return true;
- } else if (an_obj instanceof String) {
+ }
+ else if (an_obj instanceof String)
+ {
return clientId.equals(an_obj);
- } else if (an_obj instanceof ClientKey) {
+ }
+ else if (an_obj instanceof ClientKey)
+ {
return ((ClientKey) an_obj).clientId.equals(clientId);
- } else {
+ }
+ else
+ {
return clientId.equals(an_obj.toString());
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/KeyExpiryException.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class KeyExpiryException extends IOException {
+public class KeyExpiryException extends IOException
+{
/** the key that caused this exception by being accessed after expiring */
private final ClientKey key;
@@ -36,7 +37,8 @@
*
* @param key the unique key for the client which expired.
*/
- public KeyExpiryException(ClientKey key) {
+ public KeyExpiryException(ClientKey key)
+ {
super();
this.key = key;
}
@@ -47,7 +49,8 @@
* @param key the unique key for the client which expired.
* @param message The message associated with the exception.
*/
- public KeyExpiryException(ClientKey key, String message) {
+ public KeyExpiryException(ClientKey key, String message)
+ {
super(message);
this.key = key;
}
@@ -57,7 +60,8 @@
*
* @return the expired ClientKey.
*/
- public ClientKey getClientKey() {
+ public ClientKey getClientKey()
+ {
return key;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerConfig.java
Sat Oct 30 18:49:56 2004
@@ -24,11 +24,13 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class ListenerConfig {
+public abstract class ListenerConfig
+{
/**
* Empty default constructor.
*/
- protected ListenerConfig() {
+ protected ListenerConfig()
+ {
}
/**
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManager.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author $Author$
* @version $Rev$
*/
-public interface ListenerManager {
+public interface ListenerManager
+{
/**
* Binds and registers a server listener.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitor.java
Sat Oct 30 18:49:56 2004
@@ -33,7 +33,8 @@
* @author $Author$
* @version $Rev$
*/
-public interface ListenerManagerMonitor {
+public interface ListenerManagerMonitor
+{
/**
* Monitors when the ListnenerManager starts.
*/
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ListenerManagerMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -29,61 +29,80 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ListenerManagerMonitorAdapter implements ListenerManagerMonitor {
- public void started() {
+public class ListenerManagerMonitorAdapter implements ListenerManagerMonitor
+{
+ public void started()
+ {
}
- public void stopped() {
+ public void stopped()
+ {
}
- public void bindOccured(ListenerConfig listenerConfig) {
+ public void bindOccured(ListenerConfig listenerConfig)
+ {
}
- public void unbindOccured(ListenerConfig listenerConfig) {
+ public void unbindOccured(ListenerConfig listenerConfig)
+ {
}
- public void acceptOccured(SelectionKey key) {
+ public void acceptOccured(SelectionKey key)
+ {
}
- public void selectOccured(Selector selector) {
+ public void selectOccured(Selector selector)
+ {
}
- public void selectTimedOut(Selector selector) {
+ public void selectTimedOut(Selector selector)
+ {
}
public void failedToBind(
- ListenerConfig listenerConfig, IOException
failure) {
- if (failure != null) {
+ ListenerConfig listenerConfig, IOException
failure)
+ {
+ if (failure != null)
+ {
failure.printStackTrace();
}
}
public void failedToUnbind(
ListenerConfig listenerConfig,
- IOException failure) {
- if (failure != null) {
+ IOException failure)
+ {
+ if (failure != null)
+ {
failure.printStackTrace();
}
}
- public void failedToExpire(ClientKey key, IOException failure) {
- if (failure != null) {
+ public void failedToExpire(ClientKey key, IOException failure)
+ {
+ if (failure != null)
+ {
failure.printStackTrace();
}
}
- public void failedToAccept(SelectionKey key, IOException failure) {
- if (failure != null) {
+ public void failedToAccept(SelectionKey key, IOException failure)
+ {
+ if (failure != null)
+ {
failure.printStackTrace();
}
}
- public void failedToSelect(Selector selector, IOException failure) {
- if (failure != null) {
+ public void failedToSelect(Selector selector, IOException failure)
+ {
+ if (failure != null)
+ {
failure.printStackTrace();
}
}
- public void enteringSelect(Selector selector) {
+ public void enteringSelect(Selector selector)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/SocketListenerConfig.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory Project</a>
* @version $Rev$
*/
-public class SocketListenerConfig extends ListenerConfig {
+public class SocketListenerConfig extends ListenerConfig
+{
/** the InetAddress associated with this server socket configuration */
private final InetAddress inetAddress;
@@ -44,7 +45,8 @@
*/
public SocketListenerConfig(
InetAddress inetAddress,
- InetServiceEntry servEnt) {
+ InetServiceEntry servEnt)
+ {
this.servEnt = servEnt;
this.inetAddress = inetAddress;
}
@@ -54,7 +56,8 @@
*
* @return the address for the server socket associated with this config
*/
- public InetAddress getInetAddress() {
+ public InetAddress getInetAddress()
+ {
return inetAddress;
}
@@ -64,11 +67,13 @@
*
* @return the service entry in the inet service database
*/
- public InetServiceEntry getInetServiceEntry() {
+ public InetServiceEntry getInetServiceEntry()
+ {
return servEnt;
}
- public String getURI() {
+ public String getURI()
+ {
StringBuffer l_buf = new StringBuffer();
l_buf.append(servEnt.getName());
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
Sat Oct 30 18:49:56 2004
@@ -42,7 +42,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public final class TCPClientKey extends ClientKey {
+public final class TCPClientKey extends ClientKey
+{
// ----------------------------------------------
// Private members.
// ----------------------------------------------
@@ -71,12 +72,14 @@
* @param a_socket newly established client socket connection to the
* server.
*/
- TCPClientKey(final Socket a_socket) {
+ TCPClientKey(final Socket a_socket)
+ {
super(getClientId(a_socket));
socket = a_socket;
}
- private static String getClientId(Socket a_socket) {
+ private static String getClientId(Socket a_socket)
+ {
// build the key ...
StringBuffer l_buf = new StringBuffer();
l_buf.append(a_socket.getLocalAddress().getHostAddress());
@@ -97,19 +100,22 @@
*
* @return the client's socket connection
*/
- public Socket getSocket() throws KeyExpiryException {
+ public Socket getSocket() throws KeyExpiryException
+ {
checkExpiry();
return socket;
}
- public InetSocketAddress getLocalAddress() throws KeyExpiryException {
+ public InetSocketAddress getLocalAddress() throws KeyExpiryException
+ {
checkExpiry();
return new InetSocketAddress(
socket.getLocalAddress(),
socket.getLocalPort());
}
- public InetSocketAddress getRemoteAddress() throws KeyExpiryException {
+ public InetSocketAddress getRemoteAddress() throws KeyExpiryException
+ {
checkExpiry();
return new InetSocketAddress(
socket.getInetAddress(),
socket.getPort());
@@ -127,7 +133,8 @@
* @return true if the client is no longer connected to the server, false
* if the client is connected.
*/
- public boolean hasExpired() {
+ public boolean hasExpired()
+ {
return hasExpired;
}
@@ -137,10 +144,12 @@
* only allow access by the ClientModule. Tries to close socket if it is
* still open.
*/
- protected void expire() throws IOException {
+ protected void expire() throws IOException
+ {
hasExpired = true;
- if (null != socket) {
+ if (null != socket)
+ {
socket.close();
}
}
@@ -157,8 +166,10 @@
* than depending on developers to maintain a convention of checking for
* key expiration before use in other modules.
*/
- protected void checkExpiry() throws KeyExpiryException {
- if (hasExpired) {
+ protected void checkExpiry() throws KeyExpiryException
+ {
+ if (hasExpired)
+ {
throw new KeyExpiryException(this);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerConfig.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author $LastChangedBy$
* @version $LastChangedRevision$
*/
-public class TCPListenerConfig extends SocketListenerConfig {
+public class TCPListenerConfig extends SocketListenerConfig
+{
/** the connection backlog */
private int backlog;
@@ -41,21 +42,24 @@
* provides
*/
public TCPListenerConfig(
- InetAddress inetAddress, InetServiceEntry
servEnt) {
+ InetAddress inetAddress, InetServiceEntry servEnt)
+ {
super(inetAddress, servEnt);
}
/* (non-Javadoc)
* @see org.apache.seda.listener.ServerListener#getBacklog()
*/
- public int getBacklog() {
+ public int getBacklog()
+ {
return this.backlog;
}
/**
* @param a_backlog The backlog to set.
*/
- protected void setBacklog(int a_backlog) {
+ protected void setBacklog(int a_backlog)
+ {
this.backlog = a_backlog;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
Sat Oct 30 18:49:56 2004
@@ -51,7 +51,8 @@
*/
public class TCPListenerManager implements DisconnectSubscriber,
ProtocolSubscriber, ListenerManager,
- Runnable {
+ Runnable
+{
/** event manager used to decouple source to sink relationships */
private final EventRouter router;
@@ -89,7 +90,8 @@
* @throws IOException
*/
public TCPListenerManager(EventRouter router)
- throws IOException {
+ throws IOException
+ {
this.router = router;
this.clients = new HashSet();
this.selector = Selector.open();
@@ -108,7 +110,8 @@
*
* @return Returns the monitor.
*/
- public ListenerManagerMonitor getMonitor() {
+ public ListenerManagerMonitor getMonitor()
+ {
return monitor;
}
@@ -117,17 +120,20 @@
*
* @param monitor The monitor to set.
*/
- public void setMonitor(ListenerManagerMonitor monitor) {
+ public void setMonitor(ListenerManagerMonitor monitor)
+ {
this.monitor = monitor;
}
/**
* @see org.apache.seda.listener.ListenerManager#bind(ListenerConfig)
*/
- public void bind(ListenerConfig listener) throws IOException {
+ public void bind(ListenerConfig listener) throws IOException
+ {
ensureListenerConfigType(listener);
- synchronized (bindListeners) {
+ synchronized (bindListeners)
+ {
bindListeners.add(listener);
}
@@ -137,22 +143,27 @@
/**
* @see org.apache.seda.listener.ListenerManager#unbind(ListenerConfig)
*/
- public void unbind(ListenerConfig listener) throws IOException {
+ public void unbind(ListenerConfig listener) throws IOException
+ {
ensureListenerConfigType(listener);
- synchronized (unbindListeners) {
+ synchronized (unbindListeners)
+ {
unbindListeners.add(listener);
}
selector.wakeup();
}
- private void ensureListenerConfigType(ListenerConfig listener) {
- if (listener == null) {
+ private void ensureListenerConfigType(ListenerConfig listener)
+ {
+ if (listener == null)
+ {
throw new NullPointerException();
}
- if (!(listener instanceof TCPListenerConfig)) {
+ if (!(listener instanceof TCPListenerConfig))
+ {
throw new IllegalArgumentException();
}
}
@@ -162,14 +173,18 @@
* This is not fail fast - meaning it will try all the connections in the
* ready to bind set even if one fails.
*/
- private void bind() {
- synchronized (bindListeners) {
+ private void bind()
+ {
+ synchronized (bindListeners)
+ {
Iterator list = bindListeners.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
TCPListenerConfig listener = (TCPListenerConfig) list.next();
- try {
+ try
+ {
ServerSocketChannel channel = ServerSocketChannel.open();
InetSocketAddress address =
new InetSocketAddress(
@@ -181,12 +196,15 @@
channel.register(
selector, SelectionKey.OP_ACCEPT,
listener);
- synchronized (listeners) {
+ synchronized (listeners)
+ {
listeners.add(listener);
}
bindListeners.remove(listener);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToBind(listener, e);
}
@@ -200,27 +218,35 @@
* This is not fail fast - meaning it will try all the connections in the
* ready to unbind set even if one fails.
*/
- private void unbind() {
+ private void unbind()
+ {
SelectionKey key = null;
- synchronized (unbindListeners) {
+ synchronized (unbindListeners)
+ {
Iterator keys = selector.keys().iterator();
- while (keys.hasNext()) {
+ while (keys.hasNext())
+ {
key = (SelectionKey) keys.next();
ListenerConfig listener = (ListenerConfig) key.attachment();
- if (unbindListeners.contains(listener)) {
- try {
+ if (unbindListeners.contains(listener))
+ {
+ try
+ {
key.channel().close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToUnbind(listener, e);
}
key.cancel();
- synchronized (listeners) {
+ synchronized (listeners)
+ {
listeners.remove(listener);
}
@@ -240,12 +266,16 @@
*
* @param event the disconnect event
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
clients.remove(event.getClientKey());
- try {
+ try
+ {
event.getClientKey().expire();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToExpire(event.getClientKey(), e);
}
}
@@ -254,7 +284,8 @@
* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
+ public void inform(EventObject event)
+ {
inform((DisconnectEvent) event);
}
@@ -263,7 +294,8 @@
*
* @param event the protocol event to inform of
*/
- public void inform(ProtocolEvent event) {
+ public void inform(ProtocolEvent event)
+ {
}
// ------------------------------------------------------------------------
@@ -273,38 +305,49 @@
/**
* @see java.lang.Runnable#run()
*/
- public void run() {
- while (hasStarted.booleanValue()) {
- try {
+ public void run()
+ {
+ while (hasStarted.booleanValue())
+ {
+ try
+ {
monitor.enteringSelect(selector);
bind();
unbind();
- if (0 == selector.select()) {
+ if (0 == selector.select())
+ {
monitor.selectTimedOut(selector);
continue;
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToSelect(selector, e);
continue;
}
Iterator list = selector.selectedKeys().iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
SelectionKey key = (SelectionKey) list.next();
- if (key.isAcceptable()) {
+ if (key.isAcceptable())
+ {
SocketChannel channel = null;
ServerSocketChannel server =
(ServerSocketChannel) key.channel();
- try {
+ try
+ {
channel = server.accept();
list.remove();
monitor.acceptOccured(key);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToAccept(key, e);
continue;
}
@@ -322,8 +365,10 @@
*
* @throws IllegalStateException if this service has already started
*/
- public void start() {
- if (hasStarted.booleanValue()) {
+ public void start()
+ {
+ if (hasStarted.booleanValue())
+ {
throw new IllegalStateException("Already started!");
}
@@ -339,7 +384,8 @@
*
* @throws InterruptedException if this service's driver thread cannot
start
*/
- public void stop() throws InterruptedException {
+ public void stop() throws InterruptedException
+ {
hasStarted = new Boolean(false);
selector.wakeup();
@@ -349,19 +395,24 @@
* to make the thread for this component do the work to prevent locking
* issues with the selector.
*/
- if (!listeners.isEmpty()) {
+ if (!listeners.isEmpty())
+ {
Iterator list = listeners.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
ListenerConfig listener = (ListenerConfig) list.next();
- try {
+ try
+ {
/*
* put the listening in the set ready to be unbound by
* the runnable's thread of execution
*/
unbind(listener);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// monitor.doSomthing( e );
e.printStackTrace();
}
@@ -375,18 +426,24 @@
* going to do that so we just do it abruptly for the time being. This
* will need to be changed in the future.
*/
- if (!clients.isEmpty()) {
- synchronized (clients) {
+ if (!clients.isEmpty())
+ {
+ synchronized (clients)
+ {
Iterator list = clients.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
TCPClientKey key = (TCPClientKey) list.next();
- try {
+ try
+ {
Socket socket = key.getSocket();
socket.close();
list.remove();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// monitor.doSomthing( e );
e.printStackTrace();
}
@@ -397,7 +454,8 @@
/*
* now wait until the thread of execution for this runnable dies
*/
- if (this.thread.isAlive()) {
+ if (this.thread.isAlive())
+ {
Thread.sleep(100);
selector.wakeup();
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
Sat Oct 30 18:49:56 2004
@@ -42,7 +42,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public final class UDPClientKey extends ClientKey {
+public final class UDPClientKey extends ClientKey
+{
// ----------------------------------------------
// Private members.
// ----------------------------------------------
@@ -76,7 +77,8 @@
*/
UDPClientKey(
final DatagramSocket a_socket,
- final InetSocketAddress clientAddress) {
+ final InetSocketAddress clientAddress)
+ {
super(getClientId(a_socket, clientAddress));
socket = a_socket;
@@ -85,7 +87,8 @@
private static String getClientId(
DatagramSocket a_socket,
- InetSocketAddress clientAddress) {
+ InetSocketAddress clientAddress)
+ {
// build the key ...
StringBuffer l_buf = new StringBuffer();
l_buf.append(a_socket.getLocalAddress().getHostAddress());
@@ -100,19 +103,22 @@
// ----------------------------------------------
// Accessors of conn. parameters to client id
// ----------------------------------------------
- public DatagramSocket getSocket() throws KeyExpiryException {
+ public DatagramSocket getSocket() throws KeyExpiryException
+ {
checkExpiry();
return socket;
}
- public InetSocketAddress getLocalAddress() throws KeyExpiryException {
+ public InetSocketAddress getLocalAddress() throws KeyExpiryException
+ {
checkExpiry();
return new InetSocketAddress(
socket.getLocalAddress(),
socket.getLocalPort());
}
- public InetSocketAddress getRemoteAddress() throws KeyExpiryException {
+ public InetSocketAddress getRemoteAddress() throws KeyExpiryException
+ {
checkExpiry();
return clientAddress;
}
@@ -129,7 +135,8 @@
* @return true if the client is no longer connected to the server, false
* if the client is connected.
*/
- public boolean hasExpired() {
+ public boolean hasExpired()
+ {
return hasExpired;
}
@@ -139,10 +146,12 @@
* only allow access by the ClientModule. Tries to close socket if it is
* still open.
*/
- protected void expire() throws IOException {
+ protected void expire() throws IOException
+ {
hasExpired = true;
- if (null != socket) {
+ if (null != socket)
+ {
socket.close();
}
}
@@ -159,8 +168,10 @@
* than depending on developers to maintain a convention of checking for
* key expiration before use in other modules.
*/
- protected void checkExpiry() throws KeyExpiryException {
- if (hasExpired) {
+ protected void checkExpiry() throws KeyExpiryException
+ {
+ if (hasExpired)
+ {
throw new KeyExpiryException(this);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerConfig.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author $LastChangedBy$
* @version $LastChangedRevision$
*/
-public class UDPListenerConfig extends SocketListenerConfig {
+public class UDPListenerConfig extends SocketListenerConfig
+{
/**
* Creates a default listener with all the supplied properties.
*
@@ -37,7 +38,8 @@
* @param servEnt the inet service entry for the service this listner
* provides
*/
- public UDPListenerConfig(InetAddress a_address, InetServiceEntry servEnt) {
+ public UDPListenerConfig(InetAddress a_address, InetServiceEntry servEnt)
+ {
super(a_address, servEnt);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPListenerManager.java
Sat Oct 30 18:49:56 2004
@@ -53,7 +53,8 @@
*/
public class UDPListenerManager implements DisconnectSubscriber,
ProtocolSubscriber, ListenerManager,
- Runnable {
+ Runnable
+{
/** event manager used to decouple source to sink relationships */
private final EventRouter router;
@@ -94,7 +95,8 @@
* @throws IOException
*/
public UDPListenerManager(EventRouter router, BufferPool bp)
- throws IOException {
+ throws IOException
+ {
this.router = router;
this.clients = new HashSet();
this.selector = Selector.open();
@@ -114,7 +116,8 @@
*
* @return Returns the monitor.
*/
- public ListenerManagerMonitor getMonitor() {
+ public ListenerManagerMonitor getMonitor()
+ {
return monitor;
}
@@ -123,17 +126,20 @@
*
* @param monitor The monitor to set.
*/
- public void setMonitor(ListenerManagerMonitor monitor) {
+ public void setMonitor(ListenerManagerMonitor monitor)
+ {
this.monitor = monitor;
}
/**
* @see org.apache.seda.listener.ListenerManager#bind(ListenerConfig)
*/
- public void bind(ListenerConfig listener) throws IOException {
+ public void bind(ListenerConfig listener) throws IOException
+ {
ensureListenerConfigType(listener);
- synchronized (bindListeners) {
+ synchronized (bindListeners)
+ {
bindListeners.add(listener);
}
@@ -143,22 +149,27 @@
/**
* @see org.apache.seda.listener.ListenerManager#unbind(ListenerConfig)
*/
- public void unbind(ListenerConfig listener) throws IOException {
+ public void unbind(ListenerConfig listener) throws IOException
+ {
ensureListenerConfigType(listener);
- synchronized (unbindListeners) {
+ synchronized (unbindListeners)
+ {
unbindListeners.add(listener);
}
selector.wakeup();
}
- private void ensureListenerConfigType(ListenerConfig listener) {
- if (listener == null) {
+ private void ensureListenerConfigType(ListenerConfig listener)
+ {
+ if (listener == null)
+ {
throw new NullPointerException();
}
- if (!(listener instanceof UDPListenerConfig)) {
+ if (!(listener instanceof UDPListenerConfig))
+ {
throw new IllegalArgumentException();
}
}
@@ -168,14 +179,18 @@
* This is not fail fast - meaning it will try all the connections in the
* ready to bind set even if one fails.
*/
- private void bind() {
- synchronized (bindListeners) {
+ private void bind()
+ {
+ synchronized (bindListeners)
+ {
Iterator list = bindListeners.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
UDPListenerConfig listener = (UDPListenerConfig) list.next();
- try {
+ try
+ {
DatagramChannel channel = DatagramChannel.open();
InetSocketAddress address =
new InetSocketAddress(
@@ -186,12 +201,15 @@
channel.configureBlocking(false);
channel.register(selector, SelectionKey.OP_READ, listener);
- synchronized (listeners) {
+ synchronized (listeners)
+ {
listeners.add(listener);
}
bindListeners.remove(listener);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToBind(listener, e);
}
@@ -205,27 +223,35 @@
* This is not fail fast - meaning it will try all the connections in the
* ready to unbind set even if one fails.
*/
- private void unbind() {
+ private void unbind()
+ {
SelectionKey key = null;
- synchronized (unbindListeners) {
+ synchronized (unbindListeners)
+ {
Iterator keys = selector.keys().iterator();
- while (keys.hasNext()) {
+ while (keys.hasNext())
+ {
key = (SelectionKey) keys.next();
ListenerConfig listener = (ListenerConfig) key.attachment();
- if (unbindListeners.contains(listener)) {
- try {
+ if (unbindListeners.contains(listener))
+ {
+ try
+ {
key.channel().close();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToUnbind(listener, e);
}
key.cancel();
- synchronized (listeners) {
+ synchronized (listeners)
+ {
listeners.remove(listener);
}
@@ -245,12 +271,16 @@
*
* @param event the disconnect event
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
clients.remove(event.getClientKey());
- try {
+ try
+ {
event.getClientKey().expire();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToExpire(event.getClientKey(), e);
}
}
@@ -259,7 +289,8 @@
* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
+ public void inform(EventObject event)
+ {
inform((DisconnectEvent) event);
}
@@ -268,7 +299,8 @@
*
* @param event the protocol event to inform of
*/
- public void inform(ProtocolEvent event) {
+ public void inform(ProtocolEvent event)
+ {
}
// ------------------------------------------------------------------------
@@ -278,59 +310,77 @@
/**
* @see java.lang.Runnable#run()
*/
- public void run() {
- while (hasStarted.booleanValue()) {
- try {
+ public void run()
+ {
+ while (hasStarted.booleanValue())
+ {
+ try
+ {
monitor.enteringSelect(selector);
bind();
unbind();
- if (0 == selector.select()) {
+ if (0 == selector.select())
+ {
monitor.selectTimedOut(selector);
continue;
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedToSelect(selector, e);
continue;
}
Iterator list = selector.selectedKeys().iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
SelectionKey key = (SelectionKey) list.next();
list.remove();
- if (key.isReadable()) {
+ if (key.isReadable())
+ {
DatagramChannel channel = (DatagramChannel) key.channel();
ByteBuffer buf = null;
InetSocketAddress clientAddress;
boolean read = false;
- try {
+ try
+ {
buf = bp.getBuffer(this);
clientAddress =
(InetSocketAddress) channel.receive(buf);
- if (clientAddress != null) {
+ if (clientAddress != null)
+ {
read = true;
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// FIXME InputManagerMonitor.failedToRead?
monitor.failedToAccept(key, e);
continue;
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
// FIXME InputManagerMonitor.bufferUnavailable?
//monitor.bufferUnavailable( bp, e );
continue;
- } finally {
- if (!read && (buf != null)) {
+ }
+ finally
+ {
+ if (!read && (buf != null))
+ {
bp.releaseClaim(buf, this);
}
}
- if (read) {
+ if (read)
+ {
ClientKey clientKey =
new UDPClientKey(channel.socket(), clientAddress);
InputEvent event =
@@ -347,8 +397,10 @@
*
* @throws IllegalStateException if this service has already started
*/
- public void start() {
- if (hasStarted.booleanValue()) {
+ public void start()
+ {
+ if (hasStarted.booleanValue())
+ {
throw new IllegalStateException("Already started!");
}
@@ -364,7 +416,8 @@
*
* @throws InterruptedException if this service's driver thread cannot
start
*/
- public void stop() throws InterruptedException {
+ public void stop() throws InterruptedException
+ {
hasStarted = new Boolean(false);
selector.wakeup();
@@ -374,19 +427,24 @@
* to make the thread for this component do the work to prevent locking
* issues with the selector.
*/
- if (!listeners.isEmpty()) {
+ if (!listeners.isEmpty())
+ {
Iterator list = listeners.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
ListenerConfig listener = (ListenerConfig) list.next();
- try {
+ try
+ {
/*
* put the listening in the set ready to be unbound by
* the runnable's thread of execution
*/
unbind(listener);
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// monitor.doSomthing( e );
e.printStackTrace();
}
@@ -400,18 +458,24 @@
* going to do that so we just do it abruptly for the time being. This
* will need to be changed in the future.
*/
- if (!clients.isEmpty()) {
- synchronized (clients) {
+ if (!clients.isEmpty())
+ {
+ synchronized (clients)
+ {
Iterator list = clients.iterator();
- while (list.hasNext()) {
+ while (list.hasNext())
+ {
UDPClientKey key = (UDPClientKey) list.next();
- try {
+ try
+ {
DatagramSocket socket = key.getSocket();
socket.close();
list.remove();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// monitor.doSomthing( e );
e.printStackTrace();
}
@@ -422,7 +486,8 @@
/*
* now wait until the thread of execution for this runnable dies
*/
- if (this.thread.isAlive()) {
+ if (this.thread.isAlive())
+ {
Thread.sleep(100);
selector.wakeup();
}
@@ -438,17 +503,21 @@
* @author $Author$
* @version $Revision$
*/
- class ConcreteInputEvent extends InputEvent {
- ConcreteInputEvent(ClientKey key, ByteBuffer buffer) {
+ class ConcreteInputEvent extends InputEvent
+ {
+ ConcreteInputEvent(ClientKey key, ByteBuffer buffer)
+ {
super(UDPListenerManager.this, key, buffer);
}
- public ByteBuffer claimInterest(Object party) {
+ public ByteBuffer claimInterest(Object party)
+ {
bp.claimInterest(getBuffer(), party);
return getBuffer().asReadOnlyBuffer();
}
- public void releaseInterest(Object party) {
+ public void releaseInterest(Object party)
+ {
bp.releaseClaim(getBuffer(), party);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/LoggingOutputMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/LoggingOutputMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/LoggingOutputMonitor.java
Sat Oct 30 18:49:56 2004
@@ -33,7 +33,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class LoggingOutputMonitor implements OutputMonitor {
+public class LoggingOutputMonitor implements OutputMonitor
+{
private final Log log = LogFactory.getLog("OutputManager");
/* (non-Javadoc)
@@ -42,8 +43,10 @@
* java.lang.Throwable)
*/
public void failedOnWrite(
- OutputManager manager, ClientKey key, Throwable
t) {
- if (log.isErrorEnabled()) {
+ OutputManager manager, ClientKey key, Throwable
t)
+ {
+ if (log.isErrorEnabled())
+ {
log.error(
manager + " failed while trying to write to client "
+ key, t);
@@ -54,8 +57,10 @@
* @see org.apache.seda.output.OutputMonitor#writeOccurred(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void writeOccurred(OutputManager manager, ClientKey key) {
- if (log.isDebugEnabled()) {
+ public void writeOccurred(OutputManager manager, ClientKey key)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(manager + " wrote to client " + key);
}
}
@@ -64,8 +69,10 @@
* @see org.apache.seda.output.OutputMonitor#writeLockAcquired(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void writeLockAcquired(OutputManager manager, ClientKey key) {
- if (log.isTraceEnabled()) {
+ public void writeLockAcquired(OutputManager manager, ClientKey key)
+ {
+ if (log.isTraceEnabled())
+ {
log.trace(manager + " locked channel for client " + key);
}
}
@@ -74,8 +81,10 @@
* @see org.apache.seda.output.OutputMonitor#channelMissing(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void channelMissing(OutputManager manager, ClientKey key) {
- if (log.isWarnEnabled()) {
+ public void channelMissing(OutputManager manager, ClientKey key)
+ {
+ if (log.isWarnEnabled())
+ {
log.warn(manager + " could not find channel for client " + key);
}
}
@@ -87,8 +96,10 @@
*/
public void keyExpired(
OutputManager manager, ClientKey key,
- KeyExpiryException e) {
- if (log.isWarnEnabled()) {
+ KeyExpiryException e)
+ {
+ if (log.isWarnEnabled())
+ {
log.warn(manager + " can't use expired key for client " + key, e);
}
}
@@ -100,8 +111,10 @@
*/
public void failedOnInform(
OutputManager manager, EventObject event,
- Throwable fault) {
- if (log.isErrorEnabled()) {
+ Throwable fault)
+ {
+ if (log.isErrorEnabled())
+ {
log.error(manager + " failed to be informed of " + event);
}
}
@@ -110,8 +123,10 @@
* @see org.apache.seda.output.OutputMonitor#addedClient(
* org.apache.seda.output.OutputManager,
org.apache.seda.event.ConnectEvent)
*/
- public void addedClient(OutputManager manager, ConnectEvent event) {
- if (log.isDebugEnabled()) {
+ public void addedClient(OutputManager manager, ConnectEvent event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(manager + " added client " + event.getClientKey());
}
}
@@ -121,8 +136,10 @@
* org.apache.seda.output.OutputManager,
* org.apache.seda.event.DisconnectEvent)
*/
- public void removedClient(OutputManager manager, DisconnectEvent event) {
- if (log.isDebugEnabled()) {
+ public void removedClient(OutputManager manager, DisconnectEvent event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(manager + " removed client " + event.getClientKey());
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputManager.java
Sat Oct 30 18:49:56 2004
@@ -30,7 +30,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface OutputManager {
+public interface OutputManager
+{
/**
* Writes or rather sends a peice of PDU data to a client.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitor.java
Sat Oct 30 18:49:56 2004
@@ -32,7 +32,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface OutputMonitor {
+public interface OutputMonitor
+{
/**
* Monitors failed send events to a client.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/OutputMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -32,14 +32,16 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class OutputMonitorAdapter implements OutputMonitor {
+public class OutputMonitorAdapter implements OutputMonitor
+{
/* (non-Javadoc)
* @see org.apache.seda.output.OutputMonitor#
* failedOnWrite(org.apache.seda.output.OutputManager,
* org.apache.seda.listener.ClientKey, java.lang.Throwable)
*/
public void failedOnWrite(
- OutputManager manager, ClientKey key, Throwable
t) {
+ OutputManager manager, ClientKey key, Throwable
t)
+ {
dump(t);
}
@@ -47,21 +49,24 @@
* @see org.apache.seda.output.OutputMonitor#writeOccurred(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void writeOccurred(OutputManager manager, ClientKey key) {
+ public void writeOccurred(OutputManager manager, ClientKey key)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.output.OutputMonitor#writeLockAcquired(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void writeLockAcquired(OutputManager manager, ClientKey key) {
+ public void writeLockAcquired(OutputManager manager, ClientKey key)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.output.OutputMonitor#channelMissing(
* org.apache.seda.output.OutputManager,
org.apache.seda.listener.ClientKey)
*/
- public void channelMissing(OutputManager manager, ClientKey key) {
+ public void channelMissing(OutputManager manager, ClientKey key)
+ {
}
/* (non-Javadoc)
@@ -71,7 +76,8 @@
*/
public void keyExpired(
OutputManager manager, ClientKey key,
- KeyExpiryException e) {
+ KeyExpiryException e)
+ {
dump(e);
}
@@ -82,7 +88,8 @@
*/
public void failedOnInform(
OutputManager manager, EventObject event,
- Throwable fault) {
+ Throwable fault)
+ {
dump(fault);
}
@@ -90,7 +97,8 @@
* @see org.apache.seda.output.OutputMonitor#addedClient(
* org.apache.seda.output.OutputManager,
org.apache.seda.event.ConnectEvent)
*/
- public void addedClient(OutputManager manager, ConnectEvent event) {
+ public void addedClient(OutputManager manager, ConnectEvent event)
+ {
}
/* (non-Javadoc)
@@ -98,7 +106,8 @@
* org.apache.seda.output.OutputManager,
* org.apache.seda.event.DisconnectEvent)
*/
- public void removedClient(OutputManager manager, DisconnectEvent event) {
+ public void removedClient(OutputManager manager, DisconnectEvent event)
+ {
}
/**
@@ -106,8 +115,10 @@
*
* @param t the throwables stack to dump to stderr
*/
- private void dump(Throwable t) {
- if (t != null) {
+ private void dump(Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/TCPOutputManager.java
Sat Oct 30 18:49:56 2004
@@ -52,7 +52,8 @@
public class TCPOutputManager extends DefaultStage implements OutputManager,
OutputSubscriber,
ConnectSubscriber,
-
DisconnectSubscriber {
+
DisconnectSubscriber
+{
/** the router we subscribe for OutputEvents on */
private final EventRouter router;
@@ -72,7 +73,8 @@
* @param router the router we subscribe for OutputEvents on
* @param config the configuration for this Stage
*/
- public TCPOutputManager(EventRouter router, DefaultStageConfig config) {
+ public TCPOutputManager(EventRouter router, DefaultStageConfig config)
+ {
super(config);
this.router = router;
this.router.subscribe(OutputEvent.class, this);
@@ -90,10 +92,14 @@
/*
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.failedOnInform(this, event, t);
}
}
@@ -102,7 +108,8 @@
* @see org.apache.seda.event.OutputSubscriber#inform(
* org.apache.seda.event.OutputEvent)
*/
- public void inform(OutputEvent event) {
+ public void inform(OutputEvent event)
+ {
enqueue(event);
}
@@ -110,12 +117,16 @@
* @see org.apache.seda.event.ConnectSubscriber#inform(
* org.apache.seda.event.ConnectEvent)
*/
- public void inform(ConnectEvent event) {
+ public void inform(ConnectEvent event)
+ {
TCPClientKey key = (TCPClientKey) event.getClientKey();
- try {
+ try
+ {
channels.put(key, key.getSocket().getChannel());
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpired(this, key, e);
}
@@ -126,7 +137,8 @@
* @see org.apache.seda.event.DisconnectSubscriber#inform(
* org.apache.seda.event.DisconnectEvent)
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
channels.remove(event.getClientKey());
monitor.removedClient(this, event);
}
@@ -141,25 +153,31 @@
* org.apache.seda.listener.ClientKey, java.nio.ByteBuffer)
*/
public void write(ClientKey key, ByteBuffer buf)
- throws IOException {
+ throws IOException
+ {
Object lock = null;
SocketChannel channel = (SocketChannel) channels.get(key);
- if (null == channel) {
+ if (null == channel)
+ {
monitor.channelMissing(this, key);
return;
}
// Obtain output lock for write to client.
- try {
+ try
+ {
lock = key.getOutputLock();
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpired(this, key, e);
return;
}
// synchronize on client output stream lock object.
- synchronized (lock) {
+ synchronized (lock)
+ {
monitor.writeLockAcquired(this, key);
channel.write(buf);
lock.notifyAll();
@@ -173,21 +191,28 @@
*
* @param monitor the monitor used by this output manager
*/
- public void setOutputMonitor(OutputMonitor monitor) {
+ public void setOutputMonitor(OutputMonitor monitor)
+ {
this.monitor = monitor;
}
/**
* EventHandler designed for processing output events.
*/
- class OutputStageHandler implements StageHandler {
- public void handleEvent(EventObject generic) {
- if (generic instanceof OutputEvent) {
+ class OutputStageHandler implements StageHandler
+ {
+ public void handleEvent(EventObject generic)
+ {
+ if (generic instanceof OutputEvent)
+ {
OutputEvent event = (OutputEvent) generic;
- try {
+ try
+ {
write(event.getClientKey(), event.getBuffer());
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedOnWrite(
TCPOutputManager.this,
event.getClientKey(), e);
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
Sat Oct 30 18:49:56 2004
@@ -52,7 +52,8 @@
public class UDPOutputManager extends DefaultStage implements OutputManager,
OutputSubscriber,
ConnectSubscriber,
-
DisconnectSubscriber {
+
DisconnectSubscriber
+{
/** the router we subscribe for OutputEvents on */
private final EventRouter router;
@@ -72,7 +73,8 @@
* @param router the router we subscribe for OutputEvents on
* @param config the configuration for this Stage
*/
- public UDPOutputManager(EventRouter router, DefaultStageConfig config) {
+ public UDPOutputManager(EventRouter router, DefaultStageConfig config)
+ {
super(config);
this.router = router;
this.router.subscribe(OutputEvent.class, this);
@@ -90,10 +92,14 @@
/*
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.failedOnInform(this, event, t);
}
}
@@ -102,7 +108,8 @@
* @see org.apache.seda.event.OutputSubscriber#inform(
* org.apache.seda.event.OutputEvent)
*/
- public void inform(OutputEvent event) {
+ public void inform(OutputEvent event)
+ {
enqueue(event);
}
@@ -110,12 +117,16 @@
* @see org.apache.seda.event.ConnectSubscriber#inform(
* org.apache.seda.event.ConnectEvent)
*/
- public void inform(ConnectEvent event) {
+ public void inform(ConnectEvent event)
+ {
UDPClientKey key = (UDPClientKey) event.getClientKey();
- try {
+ try
+ {
channels.put(key, key.getSocket().getChannel());
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpired(this, key, e);
}
@@ -126,7 +137,8 @@
* @see org.apache.seda.event.DisconnectSubscriber#inform(
* org.apache.seda.event.DisconnectEvent)
*/
- public void inform(DisconnectEvent event) {
+ public void inform(DisconnectEvent event)
+ {
channels.remove(event.getClientKey());
monitor.removedClient(this, event);
}
@@ -141,25 +153,31 @@
* org.apache.seda.listener.ClientKey, java.nio.ByteBuffer)
*/
public void write(ClientKey key, ByteBuffer buf)
- throws IOException {
+ throws IOException
+ {
Object lock = null;
DatagramChannel channel = (DatagramChannel) channels.get(key);
- if (null == channel) {
+ if (null == channel)
+ {
monitor.channelMissing(this, key);
return;
}
// Obtain output lock for write to client.
- try {
+ try
+ {
lock = key.getOutputLock();
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpired(this, key, e);
return;
}
// synchronize on client output stream lock object.
- synchronized (lock) {
+ synchronized (lock)
+ {
monitor.writeLockAcquired(this, key);
channel.send(buf, key.getRemoteAddress());
lock.notifyAll();
@@ -173,21 +191,28 @@
*
* @param monitor the monitor used by this output manager
*/
- public void setOutputMonitor(OutputMonitor monitor) {
+ public void setOutputMonitor(OutputMonitor monitor)
+ {
this.monitor = monitor;
}
/**
* EventHandler designed for processing output events.
*/
- class OutputStageHandler implements StageHandler {
- public void handleEvent(EventObject generic) {
- if (generic instanceof OutputEvent) {
+ class OutputStageHandler implements StageHandler
+ {
+ public void handleEvent(EventObject generic)
+ {
+ if (generic instanceof OutputEvent)
+ {
OutputEvent event = (OutputEvent) generic;
- try {
+ try
+ {
write(event.getClientKey(), event.getBuffer());
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
monitor.failedOnWrite(
UDPOutputManager.this,
event.getClientKey(), e);
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultInetServicesDatabase.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultInetServicesDatabase.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultInetServicesDatabase.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultInetServicesDatabase implements InetServicesDatabase {
+public class DefaultInetServicesDatabase implements InetServicesDatabase
+{
/** maintains a list of entries mapped by the authoritative name */
private final Map entriesByName = new HashMap();
@@ -36,12 +37,15 @@
/** maps a port number to the authoritative service protocol name */
private final Map protoByPort = new HashMap();
- public DefaultInetServicesDatabase(InetServiceEntry[] entries) {
- for (int ii = 0; ii < entries.length; ii++) {
+ public DefaultInetServicesDatabase(InetServiceEntry[] entries)
+ {
+ for (int ii = 0; ii < entries.length; ii++)
+ {
// first add entry to entriesByName map
List list = (List) entriesByName.get(entries[ii].getName());
- if (list == null) {
+ if (list == null)
+ {
list = new ArrayList(2);
entriesByName.put(entries[ii].getName(), list);
}
@@ -52,7 +56,8 @@
Integer iport = new Integer(entries[ii].getPort());
list = (List) entriesByPort.get(iport);
- if (list == null) {
+ if (list == null)
+ {
list = new ArrayList(2);
entriesByPort.put(iport, list);
}
@@ -70,10 +75,12 @@
*
* @param entry the entry to add
*/
- public void addEntry(InetServiceEntry entry) {
+ public void addEntry(InetServiceEntry entry)
+ {
Integer iport = new Integer(entry.getPort());
- if (protoByPort.containsKey(iport)) {
+ if (protoByPort.containsKey(iport))
+ {
protoByPort.remove(iport);
}
@@ -81,41 +88,51 @@
ArrayList list = null;
- if (entriesByPort.containsKey(iport)) {
+ if (entriesByPort.containsKey(iport))
+ {
list = (ArrayList) entriesByPort.get(iport);
- for (int ii = 0; ii < list.size(); ii++) {
+ for (int ii = 0; ii < list.size(); ii++)
+ {
InetServiceEntry ise = (InetServiceEntry) list.get(ii);
if (
(ise != null)
- && (ise.getProtocol() == entry.getProtocol())) {
+ && (ise.getProtocol() == entry.getProtocol()))
+ {
list.remove(ise);
}
}
list.add(entry);
- } else {
+ }
+ else
+ {
list = new ArrayList(2);
list.add(entry);
entriesByPort.put(iport, list);
}
- if (entriesByName.containsKey(entry.getName())) {
+ if (entriesByName.containsKey(entry.getName()))
+ {
list = (ArrayList) entriesByName.get(entry.getName());
- for (int ii = 0; ii < list.size(); ii++) {
+ for (int ii = 0; ii < list.size(); ii++)
+ {
InetServiceEntry ise = (InetServiceEntry) list.get(ii);
if (
(ise != null)
- && (ise.getProtocol() == entry.getProtocol())) {
+ && (ise.getProtocol() == entry.getProtocol()))
+ {
list.remove(ise);
}
}
list.add(entry);
- } else {
+ }
+ else
+ {
list = new ArrayList(2);
list.add(entry);
entriesByName.put(entry.getName(), list);
@@ -129,10 +146,12 @@
* @param name the authoritative name of the service
* @return an Iterator over InetServiceEntry objects
*/
- public Iterator getByName(String name) {
+ public Iterator getByName(String name)
+ {
List list = (List) entriesByName.get(name);
- if (list == null) {
+ if (list == null)
+ {
list = Collections.EMPTY_LIST;
}
@@ -147,10 +166,12 @@
* @param port the port one which the service resides
* @return an Iterator over InetServiceEntry objects
*/
- public Iterator getByPort(int port) {
+ public Iterator getByPort(int port)
+ {
List list = (List) entriesByPort.get(new Integer(port));
- if (list == null) {
+ if (list == null)
+ {
list = Collections.EMPTY_LIST;
}
@@ -162,7 +183,8 @@
*
* @param port the port one which the service resides
*/
- public String getProtoByPort(int port) {
+ public String getProtoByPort(int port)
+ {
return (String) protoByPort.get(new Integer(port));
}
@@ -174,7 +196,8 @@
* @param proto the transport protocol used for the service
* @return the internet service entry
*/
- public InetServiceEntry getByName(String name, String proto) {
+ public InetServiceEntry getByName(String name, String proto)
+ {
throw new UnsupportedOperationException("not needed yet");
}
@@ -185,7 +208,8 @@
* @param proto the transport protocol used for the service
* @return the internet service entry
*/
- public InetServiceEntry getByPort(String port, String proto) {
+ public InetServiceEntry getByPort(String port, String proto)
+ {
throw new UnsupportedOperationException("not needed yet");
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultRequestProcessor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultRequestProcessor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/DefaultRequestProcessor.java
Sat Oct 30 18:49:56 2004
@@ -35,7 +35,8 @@
* @version $Rev$
*/
public class DefaultRequestProcessor extends DefaultStage
- implements RequestProcessor, RequestSubscriber, ProtocolSubscriber {
+ implements RequestProcessor, RequestSubscriber, ProtocolSubscriber
+{
private final Map protocols;
private final EventRouter router;
private final InetServicesDatabase inetDb;
@@ -49,7 +50,8 @@
*/
public DefaultRequestProcessor(
EventRouter router, StageConfig config,
- InetServicesDatabase inetDb) {
+ InetServicesDatabase inetDb)
+ {
super(config);
DefaultStageConfig defaultConfig = (DefaultStageConfig) config;
@@ -68,17 +70,22 @@
* @see org.apache.seda.event.RequestSubscriber#inform(
* org.apache.seda.event.RequestEvent)
*/
- public void inform(RequestEvent event) {
+ public void inform(RequestEvent event)
+ {
enqueue(event);
}
/* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.failedOnInform(this, event, t);
}
}
@@ -88,17 +95,22 @@
*
* @param event the protocol event to inform of
*/
- public void inform(ProtocolEvent event) {
+ public void inform(ProtocolEvent event)
+ {
ProtocolProvider proto = event.getProtocolProvider();
protocols.put(proto.getName(), proto);
}
- private RequestHandler getProtocolHandler(ClientKey key, Object request) {
+ private RequestHandler getProtocolHandler(ClientKey key, Object request)
+ {
String name = null;
- try {
+ try
+ {
name = inetDb.getProtoByPort(key.getLocalAddress().getPort());
- } catch (KeyExpiryException e) {
+ }
+ catch (KeyExpiryException e)
+ {
monitor.keyExpired(key, request, e);
throw new IllegalStateException("key expired can't service req");
}
@@ -114,14 +126,18 @@
* @param request the request responded to
*/
private void reply(
- ManyReplyHandler handler, Object request, ClientKey
key) {
+ ManyReplyHandler handler, Object request, ClientKey key)
+ {
Object response = null;
- try {
+ try
+ {
Iterator list = handler.handle(request);
- if (handler.isSequential()) {
- while (list.hasNext()) {
+ if (handler.isSequential())
+ {
+ while (list.hasNext())
+ {
response = list.next();
// @todo: need to force serialized response processing
@@ -129,14 +145,18 @@
// response sequence number for multi-part responses
throw new UnsupportedOperationException("need response
serialization");
}
- } else {
- while (list.hasNext()) {
+ }
+ else
+ {
+ while (list.hasNext())
+ {
response = list.next();
router.publish(new ResponseEvent(this, key, response));
}
}
}
- catch (Throwable t) {
+ catch (Throwable t)
+ {
monitor.failedOnSingleReply(key, request, t);
}
}
@@ -149,16 +169,20 @@
*/
private void reply(
SingleReplyHandler handler, Object request,
- ClientKey key) {
+ ClientKey key)
+ {
Object response = null;
- try {
+ try
+ {
response = handler.handle(request);
}
+
// If the individual handlers do not do a global catch and report this
// will sheild the server from complete failure on a request reporting
// at a minimum the stack trace that cause the request to fail.
- catch (Throwable t) {
+ catch (Throwable t)
+ {
monitor.failedOnSingleReply(key, request, t);
return;
}
@@ -166,20 +190,23 @@
router.publish(new ResponseEvent(this, key, response));
}
- class ProcessorStageHandler implements StageHandler {
+ class ProcessorStageHandler implements StageHandler
+ {
/**
* Event handler method for processing RequestEvents.
*
* @param nonspecific the RequestEvent to process.
*/
- public void handleEvent(EventObject nonspecific) {
+ public void handleEvent(EventObject nonspecific)
+ {
RequestEvent event = (RequestEvent) nonspecific;
ClientKey key = event.getClientKey();
RequestHandler handler =
getProtocolHandler(event.getClientKey(), event.getRequest());
- switch (handler.getHandlerType().getValue()) {
+ switch (handler.getHandlerType().getValue())
+ {
case (HandlerTypeEnum.NOREPLY_VAL):
NoReplyHandler noreply = (NoReplyHandler) handler;
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class HandlerTypeEnum extends ValuedEnum {
+public class HandlerTypeEnum extends ValuedEnum
+{
/** Value for noreply enumeration type */
public static final int NOREPLY_VAL = 0;
@@ -56,7 +57,8 @@
* @param name the name of the enum
* @param value the value of the enum
*/
- private HandlerTypeEnum(String name, int value) {
+ private HandlerTypeEnum(String name, int value)
+ {
super(name, value);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServiceEntry.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServiceEntry.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServiceEntry.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class InetServiceEntry {
+public class InetServiceEntry
+{
/** an empty string array for no aliases */
private static final String[] EMPTY_ALIASES = new String[0];
@@ -47,7 +48,8 @@
* @param name the authoritative name of the service
* @param port the port the service runs on
*/
- public InetServiceEntry(String name, int port) {
+ public InetServiceEntry(String name, int port)
+ {
this(name, port, TransportTypeEnum.TCP, null);
}
@@ -58,7 +60,8 @@
* @param port the port the service runs on
* @param proto the transport protocol used by the service
*/
- public InetServiceEntry(String name, int port, TransportTypeEnum proto) {
+ public InetServiceEntry(String name, int port, TransportTypeEnum proto)
+ {
this(name, port, proto, null);
}
@@ -72,8 +75,10 @@
*/
public InetServiceEntry(
String name, int port, TransportTypeEnum proto,
- String[] aliases) {
- if (name == null) {
+ String[] aliases)
+ {
+ if (name == null)
+ {
throw new NullPointerException("service name can't be null");
}
@@ -81,13 +86,17 @@
this.port = port;
this.proto = proto;
- if (proto == null) {
+ if (proto == null)
+ {
throw new NullPointerException("transport can't be null");
}
- if (aliases == null) {
+ if (aliases == null)
+ {
this.aliases = EMPTY_ALIASES;
- } else {
+ }
+ else
+ {
this.aliases = aliases;
}
}
@@ -97,7 +106,8 @@
*
* @return the authoritative name of the service
*/
- public String getName() {
+ public String getName()
+ {
return name;
}
@@ -106,7 +116,8 @@
*
* @return the port this entry's service runs on
*/
- public int getPort() {
+ public int getPort()
+ {
return port;
}
@@ -115,7 +126,8 @@
*
* @return the alternative names for this entry's service
*/
- public String[] getAliases() {
+ public String[] getAliases()
+ {
return aliases;
}
@@ -124,7 +136,8 @@
*
* @return the transport protocol used for this service
*/
- public TransportTypeEnum getProtocol() {
+ public TransportTypeEnum getProtocol()
+ {
return proto;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServicesDatabase.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServicesDatabase.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/InetServicesDatabase.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface InetServicesDatabase {
+public interface InetServicesDatabase
+{
/**
* Gets an iteration over all the entries for a service by the name of the
* service.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ManyReplyHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ManyReplyHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ManyReplyHandler.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ManyReplyHandler extends RequestHandler {
+public interface ManyReplyHandler extends RequestHandler
+{
/**
* A handler for a request that can create multiple responses of
* heterogenous messages.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/NoReplyHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/NoReplyHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/NoReplyHandler.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface NoReplyHandler extends RequestHandler {
+public interface NoReplyHandler extends RequestHandler
+{
/**
* Handles requests that do not reply to the requesting client with a
* response.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ProtocolProvider.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ProtocolProvider.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/ProtocolProvider.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory Project</a>
* @version $Rev$
*/
-public interface ProtocolProvider {
+public interface ProtocolProvider
+{
/**
* Gets the authoritative name for the service of this provider.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestHandler.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface RequestHandler {
+public interface RequestHandler
+{
/**
* Gets the handler type.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessor.java
Sat Oct 30 18:49:56 2004
@@ -25,5 +25,6 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface RequestProcessor {
+public interface RequestProcessor
+{
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
Sat Oct 30 18:49:56 2004
@@ -31,7 +31,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface RequestProcessorMonitor {
+public interface RequestProcessorMonitor
+{
/**
* Monitors failures while processing inform methods if any.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -31,15 +31,18 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class RequestProcessorMonitorAdapter implements RequestProcessorMonitor
{
+public class RequestProcessorMonitorAdapter implements RequestProcessorMonitor
+{
/* @see org.apache.seda.protocol.RequestProcessorMonitor#failedOnInform(
* org.apache.seda.event.Subscriber, java.util.EventObject,
* java.lang.Throwable)
*/
public void failedOnInform(
Subscriber subscriber, EventObject event,
- Throwable t) {
- if (t != null) {
+ Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
@@ -50,14 +53,18 @@
* org.apache.ldap.common.message.Request, java.lang.Throwable)
*/
public void failedOnSingleReply(
- ClientKey key, Object request, Throwable
t) {
- if (t != null) {
+ ClientKey key, Object request, Throwable t)
+ {
+ if (t != null)
+ {
t.printStackTrace();
}
}
- public void keyExpired(ClientKey key, Object req, KeyExpiryException e) {
- if (e != null) {
+ public void keyExpired(ClientKey key, Object req, KeyExpiryException e)
+ {
+ if (e != null)
+ {
e.printStackTrace();
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/SingleReplyHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/SingleReplyHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/SingleReplyHandler.java
Sat Oct 30 18:49:56 2004
@@ -25,7 +25,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface SingleReplyHandler extends RequestHandler {
+public interface SingleReplyHandler extends RequestHandler
+{
/**
* Handles a request that generates a sole response by returning the
* response object back to the caller.
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/TransportTypeEnum.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/TransportTypeEnum.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/TransportTypeEnum.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class TransportTypeEnum extends ValuedEnum {
+public class TransportTypeEnum extends ValuedEnum
+{
/** Value for TCP transport enumeration type */
public static final int TCP_VAL = 0;
@@ -54,7 +55,8 @@
* @param name the name of the enum
* @param value the value of the enum
*/
- private TransportTypeEnum(String name, int value) {
+ private TransportTypeEnum(String name, int value)
+ {
super(name, value);
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/session/ClientSession.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/session/ClientSession.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/session/ClientSession.java
Sat Oct 30 18:49:56 2004
@@ -31,7 +31,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ClientSession {
+public interface ClientSession
+{
/**
* Gets the unique client key associated with this session.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultStage implements Stage {
+public class DefaultStage implements Stage
+{
/**
* time to sleep in milliseconds waiting for this stage to stop
* @todo migth want add this to config and use this as the default value
@@ -63,7 +64,8 @@
*
* @param config the configuration bean
*/
- public DefaultStage(StageConfig config) {
+ public DefaultStage(StageConfig config)
+ {
this.config = config;
hasStarted = new Boolean(false);
}
@@ -77,7 +79,8 @@
* org.apache.seda.stage.EnqueuePredicate)
* addPredicate(org.apache.seda.seda.EnqueuePredicate)
*/
- public void addPredicate(EnqueuePredicate predicate) {
+ public void addPredicate(EnqueuePredicate predicate)
+ {
config.getPredicates().add(predicate);
monitor.predicateAdded(this, predicate);
}
@@ -85,7 +88,8 @@
/**
* @see org.apache.seda.stage.Stage#getConfig()
*/
- public StageConfig getConfig() {
+ public StageConfig getConfig()
+ {
return config;
}
@@ -96,30 +100,37 @@
*
* @see org.apache.seda.stage.Stage#enqueue(java.util.EventObject)
*/
- public void enqueue(final EventObject event) {
+ public void enqueue(final EventObject event)
+ {
boolean isAccepted = true;
- if (!hasStarted.booleanValue()) {
+ if (!hasStarted.booleanValue())
+ {
monitor.enqueueRejected(this, event);
return;
}
for (int ii = 0; (ii < config.getPredicates().size()) && isAccepted;
- ii++) {
+ ii++)
+ {
EnqueuePredicate test =
(EnqueuePredicate) config.getPredicates().get(ii);
isAccepted &= test.accept(event);
}
- if (isAccepted) {
- synchronized (queue) {
+ if (isAccepted)
+ {
+ synchronized (queue)
+ {
monitor.lockedQueue(this, event);
queue.addFirst(event);
queue.notifyAll();
}
monitor.enqueueOccurred(this, event);
- } else {
+ }
+ else
+ {
monitor.enqueueRejected(this, event);
}
}
@@ -131,8 +142,10 @@
/**
* Starts up this Stage's driver.
*/
- public void start() {
- if (hasStarted.booleanValue()) {
+ public void start()
+ {
+ if (hasStarted.booleanValue())
+ {
throw new IllegalStateException("Already started!");
}
@@ -147,15 +160,18 @@
* Blocks calling thread until this Stage gracefully stops its driver and
* all its worker threads.
*/
- public void stop() throws InterruptedException {
+ public void stop() throws InterruptedException
+ {
hasStarted = new Boolean(false);
monitor.stopping(this);
- while (thread.isAlive() || !activeWorkers.isEmpty()) {
+ while (thread.isAlive() || !activeWorkers.isEmpty())
+ {
monitor.stopping(this, STOP_WAIT);
Thread.sleep(STOP_WAIT);
- synchronized (queue) {
+ synchronized (queue)
+ {
queue.notifyAll();
}
}
@@ -168,7 +184,8 @@
*
* @return true if this stage has started, false otherwise
*/
- public boolean hasStarted() {
+ public boolean hasStarted()
+ {
return hasStarted.booleanValue();
}
@@ -177,7 +194,8 @@
*
* @return the monitor for this Stage
*/
- public StageMonitor getStageMonitor() {
+ public StageMonitor getStageMonitor()
+ {
return monitor;
}
@@ -186,7 +204,8 @@
*
* @param monitor the monitor to set for this Stage
*/
- public void setMonitor(StageMonitor monitor) {
+ public void setMonitor(StageMonitor monitor)
+ {
this.monitor = monitor;
}
@@ -201,8 +220,10 @@
* @author $Author$
* @version $Revision$
*/
- class StageDriver implements Runnable {
- public final void run() {
+ class StageDriver implements Runnable
+ {
+ public final void run()
+ {
monitor.startedDriver(DefaultStage.this);
/*
@@ -210,24 +231,36 @@
* and there are no queue events left. Before without the queue
* term events would be left unprocessed on the queue on stop calls
*/
- while (hasStarted.booleanValue() || !queue.isEmpty()) {
- synchronized (queue) {
+ while (hasStarted.booleanValue() || !queue.isEmpty())
+ {
+ synchronized (queue)
+ {
monitor.lockedQueue(DefaultStage.this);
- if (queue.isEmpty()) {
- try {
+ if (queue.isEmpty())
+ {
+ try
+ {
monitor.waiting(DefaultStage.this);
queue.wait();
monitor.notified(DefaultStage.this);
- } catch (InterruptedException e) {
- try {
+ }
+ catch (InterruptedException e)
+ {
+ try
+ {
stop();
- } catch (Exception e2) { /*NOT THROWN*/
+ }
+ catch (Exception e2)
+ {
+ /*NOT THROWN*/
}
monitor.driverFailed(DefaultStage.this, e);
}
- } else {
+ }
+ else
+ {
EventObject event = (EventObject) queue.removeLast();
monitor.eventDequeued(DefaultStage.this, event);
@@ -247,25 +280,36 @@
* @author $Author$
* @version $Revision$
*/
- class ExecutableHandler implements Runnable {
+ class ExecutableHandler implements Runnable
+ {
final EventObject m_event;
- public ExecutableHandler(EventObject event) {
+ public ExecutableHandler(EventObject event)
+ {
m_event = event;
}
- public void run() {
+ public void run()
+ {
activeWorkers.add(Thread.currentThread());
- try {
- if (config.getHandler() == null) {
+ try
+ {
+ if (config.getHandler() == null)
+ {
monitor.handlerMissing(DefaultStage.this);
- } else {
+ }
+ else
+ {
config.getHandler().handleEvent(m_event);
}
- } catch (Throwable t) {
+ }
+ catch (Throwable t)
+ {
monitor.handlerFailed(DefaultStage.this, m_event, t);
- } finally {
+ }
+ finally
+ {
activeWorkers.remove(Thread.currentThread());
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
Sat Oct 30 18:49:56 2004
@@ -29,7 +29,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultStageConfig implements StageConfig {
+public class DefaultStageConfig implements StageConfig
+{
/** the name of this Stage */
private final String name;
@@ -52,14 +53,18 @@
*/
public DefaultStageConfig(
String name, StageHandler handler,
- List predicates, ThreadPool tp) {
+ List predicates, ThreadPool tp)
+ {
this.tp = tp;
this.name = name;
this.handler = handler;
- if (predicates == null) {
+ if (predicates == null)
+ {
this.predicates = new ArrayList();
- } else {
+ }
+ else
+ {
this.predicates = predicates;
}
}
@@ -71,7 +76,8 @@
* @param predicates the enqueue predicates for this Stage
* @param tp the thread pool used for this Stages workers
*/
- public DefaultStageConfig(String name, List predicates, ThreadPool tp) {
+ public DefaultStageConfig(String name, List predicates, ThreadPool tp)
+ {
this(name, null, predicates, tp);
}
@@ -81,39 +87,45 @@
* @param name the name of this Stage
* @param tp the thread pool used for this Stage's workers
*/
- public DefaultStageConfig(String name, ThreadPool tp) {
+ public DefaultStageConfig(String name, ThreadPool tp)
+ {
this(name, null, null, tp);
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageConfig#getName()
*/
- public String getName() {
+ public String getName()
+ {
return name;
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageConfig#getHandler()
*/
- public StageHandler getHandler() {
+ public StageHandler getHandler()
+ {
return handler;
}
- public void setHandler(StageHandler handler) {
+ public void setHandler(StageHandler handler)
+ {
this.handler = handler;
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageConfig#getPredicates()
*/
- public List getPredicates() {
+ public List getPredicates()
+ {
return predicates;
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageConfig#getThreadPool()
*/
- public ThreadPool getThreadPool() {
+ public ThreadPool getThreadPool()
+ {
return tp;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
Sat Oct 30 18:49:56 2004
@@ -26,7 +26,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface EnqueuePredicate {
+public interface EnqueuePredicate
+{
/**
* Determines whether or not an event gets enqueued onto a Stage queue.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
Sat Oct 30 18:49:56 2004
@@ -31,14 +31,16 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class LoggingStageMonitor implements StageMonitor {
+public class LoggingStageMonitor implements StageMonitor
+{
/** the commons-logging log to log to */
private final Log log;
/**
* Presumes the logged class is the DefaultStage.
*/
- public LoggingStageMonitor() {
+ public LoggingStageMonitor()
+ {
log = LogFactory.getLog(DefaultStage.class);
}
@@ -48,7 +50,8 @@
* @param clazz the class of the stage
* @throws IllegalArgumentException if clazz does not implement Stage
*/
- public LoggingStageMonitor(Class clazz) {
+ public LoggingStageMonitor(Class clazz)
+ {
log = LogFactory.getLog(clazz);
}
@@ -56,8 +59,10 @@
* @see org.apache.seda.seda.StageMonitor#
* handlerMissing(org.apache.seda.seda.Stage)
*/
- public void handlerMissing(Stage stage) {
- if (log.isErrorEnabled()) {
+ public void handlerMissing(Stage stage)
+ {
+ if (log.isErrorEnabled())
+ {
log.error("Stage " + stage.getConfig().getName()
+ " does not have a handler assigned");
}
@@ -66,8 +71,10 @@
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#started(org.apache.eve.seda.Stage)
*/
- public void started(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void started(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName() + " has started!");
}
}
@@ -75,8 +82,10 @@
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#stopped(org.apache.eve.seda.Stage)
*/
- public void stopped(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void stopped(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName() + " has stopped!");
}
}
@@ -85,8 +94,10 @@
* @see org.apache.seda.seda.StageMonitor#startedDriver(
* org.apache.seda.seda.Stage)
*/
- public void startedDriver(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void startedDriver(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName()
+ "'s driver started execution!");
}
@@ -96,8 +107,10 @@
* @see org.apache.seda.seda.StageMonitor#enqueueOccurred(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void enqueueOccurred(Stage stage, EventObject event) {
- if (log.isDebugEnabled()) {
+ public void enqueueOccurred(Stage stage, EventObject event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName() + " had event "
+ getDesc(event) + " enqueued!");
}
@@ -107,8 +120,10 @@
* @see org.apache.seda.seda.StageMonitor#enqueueRejected(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void enqueueRejected(Stage stage, EventObject event) {
- if (log.isWarnEnabled()) {
+ public void enqueueRejected(Stage stage, EventObject event)
+ {
+ if (log.isWarnEnabled())
+ {
log.warn(stage.getConfig().getName() + " had event "
+ getDesc(event) + " enqueue REJECTED!");
}
@@ -118,8 +133,10 @@
* @see org.apache.seda.seda.StageMonitor#lockedQueue(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void lockedQueue(Stage stage, EventObject event) {
- if (log.isDebugEnabled()) {
+ public void lockedQueue(Stage stage, EventObject event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName()
+ "'s queue locked for processing " + getDesc(event));
}
@@ -129,8 +146,10 @@
* @see org.apache.seda.seda.StageMonitor#lockedQueue(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void lockedQueue(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void lockedQueue(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName()
+ "'s queue locked by awoken stage driver thread");
}
@@ -139,8 +158,10 @@
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#notified(org.apache.eve.seda.Stage)
*/
- public void notified(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void notified(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName()
+ "'s driver thread notified out of waiting");
}
@@ -149,8 +170,10 @@
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#stopping(org.apache.eve.seda.Stage)
*/
- public void stopping(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void stopping(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug("Graceful shutdown of stage "
+ stage.getConfig().getName() + " was requested");
}
@@ -160,8 +183,10 @@
* @see
org.apache.seda.seda.StageMonitor#stopping(org.apache.eve.seda.Stage,
* long)
*/
- public void stopping(Stage stage, long millis) {
- if (log.isDebugEnabled()) {
+ public void stopping(Stage stage, long millis)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug("Waiting " + millis + " for graceful shutdown of stage "
+ stage.getConfig().getName());
}
@@ -171,8 +196,10 @@
* @see org.apache.seda.seda.StageMonitor#lockedQueue(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void waiting(Stage stage) {
- if (log.isDebugEnabled()) {
+ public void waiting(Stage stage)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName()
+ "'s stage queue is empty, driver thread is waiting");
}
@@ -182,8 +209,10 @@
* @see org.apache.seda.seda.StageMonitor#eventDequeued(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void eventDequeued(Stage stage, EventObject event) {
- if (log.isDebugEnabled()) {
+ public void eventDequeued(Stage stage, EventObject event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName() + " had event "
+ getDesc(event) + " dequeued!");
}
@@ -193,8 +222,10 @@
* @see org.apache.seda.seda.StageMonitor#eventHandled(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void eventHandled(Stage stage, EventObject event) {
- if (log.isDebugEnabled()) {
+ public void eventHandled(Stage stage, EventObject event)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug(stage.getConfig().getName() + " handled "
+ getDesc(event));
}
@@ -204,8 +235,10 @@
* @see org.apache.seda.seda.StageMonitor#driverFailed(
* org.apache.seda.seda.Stage, java.lang.InterruptedException)
*/
- public void driverFailed(Stage stage, InterruptedException fault) {
- if (log.isErrorEnabled()) {
+ public void driverFailed(Stage stage, InterruptedException fault)
+ {
+ if (log.isErrorEnabled())
+ {
log.error(stage.getConfig().getName() + "'s driver failed", fault);
}
}
@@ -214,8 +247,10 @@
* @see org.apache.seda.seda.StageMonitor#handlerFailed(
* org.apache.seda.seda.Stage, java.util.EventObject, java.lang.Throwable)
*/
- public void handlerFailed(Stage stage, EventObject event, Throwable fault)
{
- if (log.isErrorEnabled()) {
+ public void handlerFailed(Stage stage, EventObject event, Throwable fault)
+ {
+ if (log.isErrorEnabled())
+ {
log.error(
stage.getConfig().getName() + "'s handler failed",
fault);
}
@@ -227,8 +262,10 @@
* @param stage the default stage the predicate is added to
* @param predicate the enqueue predicate added to the stage
*/
- public void predicateAdded(Stage stage, EnqueuePredicate predicate) {
- if (log.isDebugEnabled()) {
+ public void predicateAdded(Stage stage, EnqueuePredicate predicate)
+ {
+ if (log.isDebugEnabled())
+ {
log.debug("predicate added to stage "
+ stage.getConfig().getName());
}
@@ -240,7 +277,8 @@
* @param event the event to create a description string for
* @return the description string for the event
*/
- private String getDesc(EventObject event) {
+ private String getDesc(EventObject event)
+ {
return getShortClassName(event.getClass().getName());
}
@@ -252,22 +290,29 @@
* @return the class name of the class without the package name or an
* empty string
*/
- public static String getShortClassName(String className) {
- if (className == null) {
+ public static String getShortClassName(String className)
+ {
+ if (className == null)
+ {
return "";
}
- if (className.length() == 0) {
+ if (className.length() == 0)
+ {
return "";
}
char[] chars = className.toCharArray();
int lastDot = 0;
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '.') {
+ for (int i = 0; i < chars.length; i++)
+ {
+ if (chars[i] == '.')
+ {
lastDot = i + 1;
- } else if (chars[i] == '$') {
+ }
+ else if (chars[i] == '$')
+ {
chars[i] = '.';
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Stage {
+public interface Stage
+{
/**
* Gets the configuration for this Stage.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java
Sat Oct 30 18:49:56 2004
@@ -28,7 +28,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface StageConfig {
+public interface StageConfig
+{
/**
* Gets the name of the Stage.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface StageHandler extends EventListener {
+public interface StageHandler extends EventListener
+{
/**
* Handles an event for the Stage.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java
Sat Oct 30 18:49:56 2004
@@ -27,7 +27,8 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public interface StageMonitor {
+public interface StageMonitor
+{
/**
* Reports when the Stage is missing its handler.
*
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
Sat Oct 30 18:49:56 2004
@@ -29,106 +29,123 @@
* Apache Directory Project</a>
* @version $Rev$
*/
-public class StageMonitorAdapter implements StageMonitor {
+public class StageMonitorAdapter implements StageMonitor
+{
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#handlerMissing(
* org.apache.seda.seda.Stage)
*/
- public void handlerMissing(Stage stage) {
+ public void handlerMissing(Stage stage)
+ {
}
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#stopping(org.apache.eve.seda.Stage)
*/
- public void stopping(Stage stage) {
+ public void stopping(Stage stage)
+ {
}
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#stopping(org.apache.eve.seda.Stage,
* long)
*/
- public void stopping(Stage stage, long millis) {
+ public void stopping(Stage stage, long millis)
+ {
}
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#notified(org.apache.eve.seda.Stage)
*/
- public void notified(Stage stage) {
+ public void notified(Stage stage)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#waiting( Stage )
*/
- public void waiting(Stage stage) {
+ public void waiting(Stage stage)
+ {
}
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#started(org.apache.eve.seda.Stage)
*/
- public void started(Stage stage) {
+ public void started(Stage stage)
+ {
}
/* (non-Javadoc)
* @see
org.apache.seda.seda.StageMonitor#stopped(org.apache.eve.seda.Stage)
*/
- public void stopped(Stage stage) {
+ public void stopped(Stage stage)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#startedDriver(
* org.apache.seda.seda.Stage)
*/
- public void startedDriver(Stage stage) {
+ public void startedDriver(Stage stage)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#enqueueOccurred(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void enqueueOccurred(Stage stage, EventObject event) {
+ public void enqueueOccurred(Stage stage, EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#enqueueRejected(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void enqueueRejected(Stage stage, EventObject event) {
+ public void enqueueRejected(Stage stage, EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#lockedQueue(
* org.apache.seda.seda.Stage)
*/
- public void lockedQueue(Stage stage) {
+ public void lockedQueue(Stage stage)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#lockedQueue(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void lockedQueue(Stage stage, EventObject event) {
+ public void lockedQueue(Stage stage, EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#eventDequeued(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void eventDequeued(Stage stage, EventObject event) {
+ public void eventDequeued(Stage stage, EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#eventHandled(
* org.apache.seda.seda.Stage, java.util.EventObject)
*/
- public void eventHandled(Stage stage, EventObject event) {
+ public void eventHandled(Stage stage, EventObject event)
+ {
}
/* (non-Javadoc)
* @see org.apache.seda.seda.StageMonitor#driverFailed(
* org.apache.seda.seda.Stage, java.lang.InterruptedException)
*/
- public void driverFailed(Stage stage, InterruptedException fault) {
- if (fault != null) {
+ public void driverFailed(Stage stage, InterruptedException fault)
+ {
+ if (fault != null)
+ {
fault.printStackTrace();
}
}
@@ -137,8 +154,10 @@
* @see org.apache.seda.seda.StageMonitor#handlerFailed(
* org.apache.seda.seda.Stage, java.util.EventObject, java.lang.Throwable)
*/
- public void handlerFailed(Stage stage, EventObject event, Throwable fault)
{
- if (fault != null) {
+ public void handlerFailed(Stage stage, EventObject event, Throwable fault)
+ {
+ if (fault != null)
+ {
fault.printStackTrace();
}
}
@@ -149,6 +168,7 @@
* @param stage the default stage the predicate is added to
* @param predicate the enqueue predicate added to the stage
*/
- public void predicateAdded(Stage stage, EnqueuePredicate predicate) {
+ public void predicateAdded(Stage stage, EnqueuePredicate predicate)
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/thread/ThreadPool.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/thread/ThreadPool.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/thread/ThreadPool.java
Sat Oct 30 18:49:56 2004
@@ -24,7 +24,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ThreadPool {
+public interface ThreadPool
+{
/**
* Allocates Thread from pool to execute a runnable and releases it on
* completion.
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
Sat Oct 30 18:49:56 2004
@@ -38,7 +38,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultFrontendFactoryTest extends TestCase {
+public class DefaultFrontendFactoryTest extends TestCase
+{
/** the frontend used to test the protocol */
protected DefaultFrontend fe = null;
@@ -47,7 +48,8 @@
*
* @throws Exception due to super call and stop method
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
fe.stop();
fe = null;
@@ -58,7 +60,8 @@
*
* @throws Exception due to super call and create()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
fe = (DefaultFrontend) new DefaultFrontendFactory().create();
}
@@ -66,7 +69,8 @@
/**
* Tests to make sure setup of the apparatus works.
*/
- public void testSetup() {
+ public void testSetup()
+ {
assertNotNull(fe);
assertNotNull(fe.getBufferPool());
assertNotNull(fe.getDecoderManager());
@@ -84,7 +88,8 @@
*
* @throws IOException
*/
- public void testBind() throws IOException {
+ public void testBind() throws IOException
+ {
int port = AvailablePortFinder.getNextAvailable();
ListenerConfig config = null;
config =
@@ -95,7 +100,8 @@
fe.getListenerManager().unbind(config);
}
- public void testEcho() throws IOException {
+ public void testEcho() throws IOException
+ {
InetServiceEntry srvEntry =
new InetServiceEntry(
"echo",
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
Sat Oct 30 18:49:56 2004
@@ -36,7 +36,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class ProtocolTestCase extends TestCase {
+public class ProtocolTestCase extends TestCase
+{
/** the frontend used to test the protocol */
protected DefaultFrontend fe = null;
@@ -46,7 +47,8 @@
/** the listener configuration for the protocol */
protected ListenerConfig config = null;
- public ProtocolTestCase(ProtocolProvider proto) {
+ public ProtocolTestCase(ProtocolProvider proto)
+ {
this.proto = proto;
}
@@ -55,7 +57,8 @@
*
* @throws Exception due to super call and stop method
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
fe.getListenerManager().unbind(config);
fe.stop();
@@ -67,7 +70,8 @@
*
* @throws Exception due to super call and create()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
fe = (DefaultFrontend) new DefaultFrontendFactory().create();
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/buffer/DefaultBufferPoolTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/buffer/DefaultBufferPoolTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/buffer/DefaultBufferPoolTest.java
Sat Oct 30 18:49:56 2004
@@ -30,25 +30,29 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultBufferPoolTest extends TestCase {
+public class DefaultBufferPoolTest extends TestCase
+{
DefaultBufferPool m_bp = null;
/**
* Constructor for DefaultBufferPoolTest.
* @param arg0
*/
- public DefaultBufferPoolTest(String arg0) {
+ public DefaultBufferPoolTest(String arg0)
+ {
super(arg0);
}
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
junit.textui.TestRunner.run(DefaultBufferPoolTest.class);
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
- public void setUp() throws Exception {
+ public void setUp() throws Exception
+ {
super.setUp();
DefaultBufferPoolConfig l_config =
@@ -60,40 +64,49 @@
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
m_bp = null;
super.tearDown();
}
- public void testGetConfig() throws Exception {
+ public void testGetConfig() throws Exception
+ {
BufferPoolConfig l_config = m_bp.getConfig();
assertNotNull("Configuration was null", l_config);
}
- public void testGetBuffer() throws Exception {
+ public void testGetBuffer() throws Exception
+ {
final int l_max = m_bp.getConfig().getMaximumSize();
ByteBuffer[] l_buffers = new ByteBuffer[l_max];
- for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++) {
+ for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++)
+ {
l_buffers[ii] = m_bp.getBuffer(this);
assertNotNull("Got null ByteBuffer", l_buffers[ii]);
}
ByteBuffer l_buf = null;
- try {
+ try
+ {
l_buf = m_bp.getBuffer(this);
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
assertNull(l_buf);
assertNotNull(e);
}
}
- public void testGetFreeCount() throws Exception {
+ public void testGetFreeCount() throws Exception
+ {
final int l_max = m_bp.getConfig().getMaximumSize();
ByteBuffer[] l_buffers = new ByteBuffer[l_max];
- for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++) {
+ for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++)
+ {
l_buffers[ii] = m_bp.getBuffer(this);
assertNotNull("Got null ByteBuffer", l_buffers[ii]);
assertEquals(
@@ -103,19 +116,24 @@
ByteBuffer l_buf = null;
- try {
+ try
+ {
l_buf = m_bp.getBuffer(this);
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
assertNull(l_buf);
assertNotNull(e);
}
}
- public void testGetInUseCount() throws Exception {
+ public void testGetInUseCount() throws Exception
+ {
final int l_max = m_bp.getConfig().getMaximumSize();
ByteBuffer[] l_buffers = new ByteBuffer[l_max];
- for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++) {
+ for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++)
+ {
l_buffers[ii] = m_bp.getBuffer(this);
assertNotNull("Got null ByteBuffer", l_buffers[ii]);
assertEquals("In use count was off", ii + 1, m_bp.getInUseCount());
@@ -123,19 +141,24 @@
ByteBuffer l_buf = null;
- try {
+ try
+ {
l_buf = m_bp.getBuffer(this);
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
assertNull(l_buf);
assertNotNull(e);
}
}
- public void testGetInterestedCount() throws Exception {
+ public void testGetInterestedCount() throws Exception
+ {
final int l_max = m_bp.getConfig().getMaximumSize();
ByteBuffer[] l_buffers = new ByteBuffer[l_max];
- for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++) {
+ for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++)
+ {
l_buffers[ii] = m_bp.getBuffer(this);
assertNotNull("Got null ByteBuffer", l_buffers[ii]);
assertEquals("In use count was off", ii + 1, m_bp.getInUseCount());
@@ -146,41 +169,57 @@
ByteBuffer l_buf = null;
- try {
+ try
+ {
l_buf = m_bp.getBuffer(this);
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
assertNull(l_buf);
assertNotNull(e);
}
}
- public void testReleaseClaim() throws Exception {
+ public void testReleaseClaim() throws Exception
+ {
}
- public void testSize() throws Exception {
+ public void testSize() throws Exception
+ {
final int l_max = m_bp.getConfig().getMaximumSize();
ByteBuffer[] l_buffers = new ByteBuffer[l_max];
- for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++) {
+ for (int ii = 0; ii < m_bp.getConfig().getMaximumSize(); ii++)
+ {
l_buffers[ii] = m_bp.getBuffer(this);
assertNotNull("Got null ByteBuffer", l_buffers[ii]);
- if (ii < 2) {
+ if (ii < 2)
+ {
assertEquals("size was off", 2, m_bp.size());
- } else if ((ii >= 2) && (ii < 6)) {
+ }
+ else if ((ii >= 2) && (ii < 6))
+ {
assertEquals("size was off", 6, m_bp.size());
- } else if ((ii >= 6) && (ii < 10)) {
+ }
+ else if ((ii >= 6) && (ii < 10))
+ {
assertEquals("size was off", 10, m_bp.size());
- } else {
+ }
+ else
+ {
throw new IllegalStateException("should never get here!");
}
}
ByteBuffer l_buf = null;
- try {
+ try
+ {
l_buf = m_bp.getBuffer(this);
- } catch (ResourceException e) {
+ }
+ catch (ResourceException e)
+ {
assertNull(l_buf);
assertNotNull(e);
}
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
Sat Oct 30 18:49:56 2004
@@ -44,7 +44,8 @@
* @version $Rev$
*/
public class DefaultDecoderManagerTest extends TestCase
- implements RequestSubscriber {
+ implements RequestSubscriber
+{
private ThreadPool tpool = null;
private EventRouter router = null;
private BufferPoolConfig bpConfig = null;
@@ -57,18 +58,21 @@
* Constructor for DefaultDecoderManagerTest.
* @param arg0
*/
- public DefaultDecoderManagerTest(String arg0) {
+ public DefaultDecoderManagerTest(String arg0)
+ {
super(arg0);
}
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
junit.textui.TestRunner.run(DefaultDecoderManagerTest.class);
}
/*
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
bpConfig = new DefaultBufferPoolConfig("default", 10, 100, 10, 1024);
@@ -76,11 +80,13 @@
router = new DefaultEventRouter();
router.subscribe(RequestEvent.class, this);
tpool =
- new ThreadPool() {
+ new ThreadPool()
+ {
/* (non-Javadoc)
* @see
org.apache.seda.thread.ThreadPool#execute(java.lang.Runnable)
*/
- public void execute(Runnable runnable) {
+ public void execute(Runnable runnable)
+ {
// fake it out
runnable.run();
}
@@ -90,26 +96,32 @@
decodeMan =
new DefaultDecoderManager(
router, config,
- new InetServicesDatabase() {
- public Iterator getByName(String name) {
+ new InetServicesDatabase()
+ {
+ public Iterator getByName(String name)
+ {
return null;
}
- public Iterator getByPort(int port) {
+ public Iterator getByPort(int port)
+ {
return null;
}
- public String getProtoByPort(int port) {
+ public String getProtoByPort(int port)
+ {
return null;
}
public InetServiceEntry getByName(
- String name, String
proto) {
+ String name, String
proto)
+ {
return null;
}
public InetServiceEntry getByPort(
- String port, String
proto) {
+ String port, String
proto)
+ {
return null;
}
});
@@ -120,7 +132,8 @@
/*
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
tpool = null;
@@ -133,7 +146,8 @@
event = null;
}
- public void inform(RequestEvent event) {
+ public void inform(RequestEvent event)
+ {
System.out.println("\n\nRequestEvent Set!!!\n\n");
this.event = event;
}
@@ -141,10 +155,14 @@
/* (non-Javadoc)
* @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
*/
- public void inform(EventObject event) {
- try {
+ public void inform(EventObject event)
+ {
+ try
+ {
AbstractSubscriber.inform(this, event);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
fail("we should be able to inform just fine");
}
}
@@ -152,57 +170,70 @@
/*
* Class to test for void inform(EventObject)
*/
- public void testInformEventObject() {
+ public void testInformEventObject()
+ {
}
/*
* Class to test for void inform(InputEvent)
*/
- public void testInformInputEvent() {
+ public void testInformInputEvent()
+ {
}
/*
* Class to test for void inform(DisconnectEvent)
*/
- public void testInformDisconnectEvent() {
+ public void testInformDisconnectEvent()
+ {
}
/*
* Class to test for void inform(ConnectEvent)
*/
- public void testInformConnectEvent() {
+ public void testInformConnectEvent()
+ {
}
- public void testDecodeOccurred() {
+ public void testDecodeOccurred()
+ {
}
- public void testSetCallback() {
+ public void testSetCallback()
+ {
}
- public void testSetDecoderMonitor() {
+ public void testSetDecoderMonitor()
+ {
}
- public void testDisable() {
+ public void testDisable()
+ {
}
/*
* Class to test for void decode(ClientKey, ByteBuffer)
*/
- public void testDecodeClientKeyByteBuffer() {
+ public void testDecodeClientKeyByteBuffer()
+ {
}
/*
* Class to test for Object decode(ByteBuffer)
*/
- public void testDecodeByteBuffer() {
+ public void testDecodeByteBuffer()
+ {
}
- public void testGetMonitor() {
+ public void testGetMonitor()
+ {
}
- public void testSetMonitor() {
+ public void testSetMonitor()
+ {
}
- public void testGetDecoder() {
+ public void testGetDecoder()
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/event/AbstractSubscriberTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/event/AbstractSubscriberTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/event/AbstractSubscriberTest.java
Sat Oct 30 18:49:56 2004
@@ -32,13 +32,15 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class AbstractSubscriberTest extends TestCase {
+public class AbstractSubscriberTest extends TestCase
+{
TestSubscriber subscriber = null;
/*
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
subscriber = new TestSubscriber();
}
@@ -46,7 +48,8 @@
/*
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
subscriber = null;
}
@@ -54,19 +57,22 @@
/*
* Class to test for void AbstractSubscriber()
*/
- public void testAbstractSubscriber() {
+ public void testAbstractSubscriber()
+ {
}
/*
* Class to test for void AbstractSubscriber(SubscriberMonitor)
*/
- public void testAbstractSubscriberSubscriberMonitor() {
+ public void testAbstractSubscriberSubscriberMonitor()
+ {
}
/*
* Class to test for void inform(EventObject)
*/
- public void testInformEventObject() {
+ public void testInformEventObject()
+ {
EventObject e = new EventSubclass(null, null);
subscriber.inform(e);
subscriber.assertDelivery();
@@ -77,37 +83,45 @@
/*
* Class to test for void inform(Subscriber, EventObject,
SubscriberMonitor)
*/
- public void testInformSubscriberEventObjectSubscriberMonitor() {
+ public void testInformSubscriberEventObjectSubscriberMonitor()
+ {
}
- class EventSubclass extends InputEvent {
- public EventSubclass(ClientKey key, ByteBuffer buf) {
+ class EventSubclass extends InputEvent
+ {
+ public EventSubclass(ClientKey key, ByteBuffer buf)
+ {
super(AbstractSubscriberTest.this, key, buf);
}
/* (non-Javadoc)
* @see
org.apache.seda.event.InputEvent#claimInterest(java.lang.Object)
*/
- public ByteBuffer claimInterest(Object party) {
+ public ByteBuffer claimInterest(Object party)
+ {
return null;
}
/* (non-Javadoc)
* @see
org.apache.seda.event.InputEvent#releaseInterest(java.lang.Object)
*/
- public void releaseInterest(Object party) {
+ public void releaseInterest(Object party)
+ {
}
}
- class TestSubscriber extends AbstractSubscriber {
+ class TestSubscriber extends AbstractSubscriber
+ {
InputEvent e = null;
- public void assertDelivery() {
+ public void assertDelivery()
+ {
assertNotNull(e);
e = null;
}
- public void inform(InputEvent event) {
+ public void inform(InputEvent event)
+ {
assertNotNull(event);
e = event;
}
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
Sat Oct 30 18:49:56 2004
@@ -32,7 +32,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class DefaultStageTest extends TestCase {
+public class DefaultStageTest extends TestCase
+{
DefaultStage stage = null;
ThreadPool pool = null;
DefaultStageConfig config = null;
@@ -42,7 +43,8 @@
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
// @todo Auto-generated method stub
super.tearDown();
@@ -57,15 +59,18 @@
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
pool =
- new ThreadPool() {
+ new ThreadPool()
+ {
/* (non-Javadoc)
* @see
org.apache.seda.thread.ThreadPool#execute(java.lang.Runnable)
*/
- public void execute(Runnable runnable) {
+ public void execute(Runnable runnable)
+ {
runnable.run();
}
};
@@ -73,8 +78,10 @@
events = new ArrayList();
handler =
- new StageHandler() {
- public void handleEvent(EventObject event) {
+ new StageHandler()
+ {
+ public void handleEvent(EventObject event)
+ {
events.add(event);
}
};
@@ -86,9 +93,12 @@
stage.start();
}
- public void testAddPredicateAccept() throws Exception {
- stage.addPredicate(new EnqueuePredicate() {
- public boolean accept(EventObject event) {
+ public void testAddPredicateAccept() throws Exception
+ {
+ stage.addPredicate(new EnqueuePredicate()
+ {
+ public boolean accept(EventObject event)
+ {
return true;
}
});
@@ -98,9 +108,12 @@
assertEquals(1, events.size());
}
- public void testAddPredicateDeny() throws Exception {
- stage.addPredicate(new EnqueuePredicate() {
- public boolean accept(EventObject event) {
+ public void testAddPredicateDeny() throws Exception
+ {
+ stage.addPredicate(new EnqueuePredicate()
+ {
+ public boolean accept(EventObject event)
+ {
return false;
}
});
@@ -110,13 +123,16 @@
assertEquals(0, events.size());
}
- public void testGetConfig() {
+ public void testGetConfig()
+ {
assertEquals(config, stage.getConfig());
}
- public void testEnqueue() {
+ public void testEnqueue()
+ {
}
- public void testSetMonitor() {
+ public void testSetMonitor()
+ {
}
}
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/examples/DiscardProtocolProviderTest.java
Sat Oct 30 18:49:56 2004
@@ -17,6 +17,9 @@
package org.apache.seda.examples;
+import java.net.InetAddress;
+
+import org.apache.commons.net.DiscardTCPClient;
import org.apache.seda.ProtocolTestCase;
@@ -27,12 +30,15 @@
* Project</a>
* @version $Rev$
*/
-public class DiscardProtocolProviderTest extends ProtocolTestCase {
- public DiscardProtocolProviderTest() {
+public class DiscardProtocolProviderTest extends ProtocolTestCase
+{
+ public DiscardProtocolProviderTest()
+ {
super(new DiscardProtocolProvider());
}
- public void testDiscardProtocol() {
- //DiscardTCPClient client = new DiscardTCPClient();
+ public void testDiscardProtocol()
+ {
+ DiscardTCPClient client = new DiscardTCPClient();
}
}
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/AvailablePortFinderTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/AvailablePortFinderTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/AvailablePortFinderTest.java
Sat Oct 30 18:49:56 2004
@@ -27,8 +27,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class AvailablePortFinderTest extends TestCase {
- public void testDefault() {
+public class AvailablePortFinderTest extends TestCase
+{
+ public void testDefault()
+ {
AvailablePortFinder finder = new AvailablePortFinder();
// this just scan just takes too much time
@@ -37,33 +39,44 @@
finder.getAvailablePorts(1024, 1048);
}
- public void testExceptions() {
+ public void testExceptions()
+ {
AvailablePortFinder finder = new AvailablePortFinder();
- try {
+ try
+ {
finder.getAvailablePorts(
AvailablePortFinder.MIN_PORT_NUMBER - 1,
10);
Assert.fail("IllegalArgumentException must be thrown.");
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e)
+ {
}
- try {
+ try
+ {
finder.getAvailablePorts(
AvailablePortFinder.MAX_PORT_NUMBER - 1,
AvailablePortFinder.MAX_PORT_NUMBER + 1);
Assert.fail("IllegalArgumentException must be thrown.");
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e)
+ {
}
- try {
+ try
+ {
finder.getAvailablePorts(10, 5);
Assert.fail("IllegalArgumentException must be thrown.");
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e)
+ {
}
}
- public void testNextAvailable() {
+ public void testNextAvailable()
+ {
int port =
AvailablePortFinder.getNextAvailable(AvailablePortFinder.MIN_PORT_NUMBER);
assertTrue(port >= AvailablePortFinder.MIN_PORT_NUMBER);
Modified:
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
==============================================================================
---
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
(original)
+++
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
Sat Oct 30 18:49:56 2004
@@ -32,7 +32,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public class TCPListenerManagerTest extends TestCase {
+public class TCPListenerManagerTest extends TestCase
+{
/** An event router to use for testing */
private EventRouter router = null;
@@ -43,14 +44,16 @@
* Constructor for DefaultListenerManagerTest.
* @param arg0
*/
- public TCPListenerManagerTest(String arg0) {
+ public TCPListenerManagerTest(String arg0)
+ {
super(arg0);
}
/*
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
router = new DefaultEventRouter();
@@ -61,7 +64,8 @@
/*
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
router = null;
@@ -69,7 +73,8 @@
listener = null;
}
- public void testBind() throws Exception {
+ public void testBind() throws Exception
+ {
int port = AvailablePortFinder.getNextAvailable();
ListenerConfig config =
new TCPListenerConfig(
@@ -79,7 +84,8 @@
listener.unbind(config);
}
- public void testUnbind() throws Exception {
+ public void testUnbind() throws Exception
+ {
int port = AvailablePortFinder.getNextAvailable();
ListenerConfig config =
new TCPListenerConfig(