dev@grizzly.java.net

Re: SSL client code review

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 03 Jul 2007 21:33:29 +0300

Hello,

> Wonder if it might be worthy to revisit some of the discussion(s) we
> about exception handling and logging in the past at one or more of
> Project Grizzly meetings?
+1 for discussing this question on meeting.
BTW, if we started to discuss logging, probably it makes sense to
mention internationalization? Think in WSIT we had quite good solution
with resource files and Localization classes generator (I can put some
details if it makes sense).

I've fixed logging and configuration stuff.

Thanks for comments!

WBR,
Alexey.

PS:
Also see inline
>>> + public void connect(SocketAddress remoteAddress, SocketAddress
>>> localAddress) throws IOException {
>>> + if (isConnected) {
>>> + throw new AlreadyConnectedException();
>>> + }
>>> + + if (controller == null) {
>>> + isStandalone = true;
>>> + controller = new Controller();
>>> + controller.setSelectorHandler(new
>>> TCPSelectorHandler(true));
>>> + DefaultPipeline pipeline = new DefaultPipeline();
>>> + pipeline.initPipeline();
>>> + pipeline.startPipeline();
>>> + controller.setPipeline(pipeline);
>>> + + callbackHandler = new SSLCallbackHandler<Context>() {
>>> + + public void onConnect(IOEvent<Context> ioEvent) {
>>> + SelectionKey key =
>>> ioEvent.attachment().getSelectionKey();
>>> + socketChannel = (SocketChannel) key.channel();
>>> + finishConnect(key);
>>> + getController().registerKey(key,
>>> SelectionKey.OP_WRITE, Protocol.TCP);
>>> + }
>>> + + public void onRead(IOEvent<Context> ioEvent) {
>>> + }
>>> + + public void onWrite(IOEvent<Context> ioEvent) {
>>> + }
>>> + + public void onHandshake(IOEvent<Context> ioEvent) {
>>> + }
>>> + };
>>> + + final CountDownLatch latch = new CountDownLatch(1);
>>> + try {
>>> + pipeline.execute(new Context() {
>>> + @Override
>>> + public Object call() throws Exception {
>>> + latch.countDown();
>>> + controller.start();
>>> + return null;
>>> + }
>>> + });
>>> + } catch (PipelineFullException ex) {
>>> + throw new IOException(ex.getMessage());
>>> + }
>>> + + try {
>>> + latch.await();
>>> + Thread.sleep(1000);
>>
>> Just to make sure, can you make that variable configurable in case
>> some platform gives us surprise?
After revisiting code, I don't see the reason to leave that
Thread.sleep(1000) at all... May be I didn't notice something?