[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Handling contexts in error
adrian@jboss.org
do-not-reply at jboss.com
Wed Feb 20 12:24:28 EST 2008
The MC can do all this, except the failure part.
The reason it can't do the failure part is because it follows what is an accepted
generally good programming practice (e.g. ejbs do the same)
that if the container invokes a bean and it throws an error then you discard
that bean. You can't know that the bean is still in a good state because
you don't know why it threw the error.
PROPOSAL
I've had a seperate thought which is probably more acceptable to both
you and to me, ;-)
What you really want to do is manage the state of the failed beans.
i.e. you want to takeover the management of the context in error from the MC
and fix it manually.
So my solution would be to allow something like:
xml pseudo code as always ;-)
| <bean ... error-handling="manual"/>
|
If for example the bean threw an error in start() then we no longer just discard
this bean. Instead we would effectively change its controller mode to "manual"
(if it isn't already) and just then revert it to the previous state. i.e. Created in this case
or back to Instantiated if the property configuration failed.
You can then pick up the management of the bean from there.
When you decide to move the bean, we would just clear the error in the
controller context and try again (reverting back to automatic if the bean
was previously in that mode).
We would never try to move a context in such a state without an
explicit request on the controller to do so.
I don't think this would require a major change in the Controller,
most of the work would be in the IncompleteDeploymentException
where we would now have to check all contexts at all states
to see whether it has an error set (previously we just retrieved those
in the **ERROR** state).
We may want to only allow this for checked exceptions. i.e. if start throws
a RuntimeException or Error, we would still discard the bean
or perhaps make it configurable?
This semantic would deal with my objections above and give you the
ability to manage the failing beans/contexts without having to re-install them.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4130872#4130872
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4130872
More information about the jboss-dev-forums
mailing list