ClosedInterceptor design approach
timfox Apr 4, 2005 5:28 PMHi All-
I've been looking at implementing the ClosedInterceptor functionality for the JMS Facade, and wanted to run my design approach by you to make sure I'm on the right track.
I've had a look at how this was implemented in JBoss 4 messaging, and I believe there is a fair amount in the actually ClosedInterceptor logic that could be re-used :) (In particular the valve logic itself.)
However, I believe the code that maintains the tree of "containers" (JBoss 4 messaging terminology ??), so that close and closing() can be cascaded down the nodes of the tree (i.e. close on a connection causes a session to close that causes a producer to close...), needs to be done somewhat differently.
In JBoss 4, the hierarchy is held in the InvocationHandler classes (Container class) and the parent child relation-ship is set-up when the Container class is constructed). This is fine since in JBoss 4 the client side interceptor stack is created on the client side.
In the new JBoss messaging, the client side interceptor stack is created on the server side and sent back to the client so the approach of maintaining the hierarchy on the server side won't seem to work (and also is more stuff to shift across the network), since each call to createSessionDelegate would end up with it's own copy of it's parent JMSInvocationHandler being sent back.
A solution to this seems to be to maintain the hierarchy on the client side. This can be done by intercepting calls to createSessionDelegate(), createProducer() etc. and adding the child to the parent's invocation handler, so each invocation handler maintains a set of it's child invocation handlers.
Assuming this sounds the right thing to do, then the question arises of which interceptor to use to actually maintain the hierarchy. Choices seem to be:
1. Just use the ClosedInterceptor itself.
2. Create a new client side interceptor
3. FactoryInterceptor?
So far I've assumed 1. but not sure if that's the right approach.
I'd much like to hear what you think here.
Another question I have involves the MessageProducer and MessageConsumer close() method.
Is there any need to do anything on the server side for this method. I.e. is there any server side clean-up to do?
I notice currently the ProducerDelegate does not have a close() method, but not sure if this will be implemented in the future.
If there is nothing to do, this could simplify the ClosedInterceptor since you'd just be traversing from Connection to Session.
So, basically I have, so far, implemented everything as mentioned above, and have knocked some tests together and everything seems to be working ok, so if the approach seems reasonable I should be able to get this finished by tomorrow hopefully.
Sorry for boring you with the long mail ;)
-Tim
Almost forgot... A couple of misc. questions:
Do people at JBoss maintain copyright over their code? If so, I believe I would need to ask permission of the authors if I were to re-use any code from R4.0? I'm not really sure of the procedure here.
Eclipse coding template. Is there an eclipse coding template (or something like that) available for the JBoss coding style?