This content has been marked as final.
Show 5 replies
-
1. Re: Uninstall OnDemand context if there are no more dependen
alesj Jul 15, 2009 5:13 AM (in response to kabirkhan)"kabir.khan@jboss.com" wrote:
int requiredIndex = states.indexOf(item.getWhenRequired()); int actualIndex = states.indexOf(dependsContext.getState()); if (requiredIndex <= actualIndex)
Such code should not exist, as it depends on the impl details (== List) of the states model.
You should do this state checks against ControllerStateModel.
e.g. for tree states the model will change, but the rest of the code won't have to be fixed/modified ;-)
(at least not in a hard to detect/find it way) -
2. Re: Uninstall OnDemand context if there are no more dependen
kabirkhan Jul 15, 2009 5:32 AM (in response to kabirkhan)Sure, I can change it. There are several other examples of this though, or are they subtly different?
protected void change(ControllerContext context, ControllerState state, boolean trace) throws Throwable { int currentIndex = states.indexOf(fromState); int requiredIndex = states.indexOf(state); ... while (currentIndex > requiredIndex) { uninstallContext(context, trace); currentIndex = states.indexOf(context.getState()); } } protected void uninstallContext(ControllerContext context, ControllerState toState, boolean trace) { int targetState = states.indexOf(toState); if (targetState == -1) log.error("INTERNAL ERROR: unknown state " + toState + " states=" + states, new Exception("STACKTRACE")); while (true) { ... if (targetState > currentState) return; else uninstallContext(context, trace); } }
-
3. Re: Uninstall OnDemand context if there are no more dependen
alesj Jul 15, 2009 6:07 AM (in response to kabirkhan)"kabir.khan@jboss.com" wrote:
Sure, I can change it. There are several other examples of this though, or are they subtly different?
Ah, you can call those my laziness :-),
as I seem to miss them when I was porting states checking to CSM.
You can fix that, or I will eventually. -
4. Re: Uninstall OnDemand context if there are no more dependen
kabirkhan Jul 22, 2009 5:27 PM (in response to kabirkhan)"alesj" wrote:
Such code should not exist, as it depends on the impl details (== List) of the states model.
I am leaving this as is for the moment until JBKERNEL-4 and JBKERNEL-25 are complete. JIRA to use ControllerStateModel https://jira.jboss.org/jira/browse/JBKERNEL-48 -
5. Re: Uninstall OnDemand context if there are no more dependen
kabirkhan Jan 28, 2010 2:19 PM (in response to kabirkhan)Looking at http://community.jboss.org/message/522801#522801 I discovered that the uninstall is checking the wrong thing.
When iterating over dependsOnMe instead of calling getContext() which checks the current controller and the parent for the reverse dependency, we should be calling getContexts(Object name, Set<ControllerContext) which checks the current controller and children, since the reverse dependencies can not come from a parent.