-
1. Re: Cannot resolve dependency against unstarted bundle
thomas.diesler Sep 1, 2009 11:41 AM (in response to thomas.diesler)If Bundle.RESOLVED maps to ControllerState.CLASSLOADER
and Bundle.ACTIVE maps to ControllerState.INSTALLED
we need to somehow resolve PackageRequirements against context's in state CLASSLOADER. -
2. Re: Cannot resolve dependency against unstarted bundle
alesj Sep 1, 2009 11:43 AM (in response to thomas.diesler)"thomas.diesler@jboss.com" wrote:
So it seems that RequirementDependencyItems can only resolve againt INSTALLED contexts.
Yes.
But what's the issue?
Should it be resolved against deployments that are past CLASSLOADER?
In my demos, to automagically pick up DESCRIBED deployments,
I hacked around with this idea:
- http://anonsvn.jboss.org/repos/jbossas/projects/demos/microcontainer/trunk/igloo/src/main/java/org/jboss/demos/bootstrap/igloo/deployers/BundleResolver.java
New "Reset" state, after Installed. -
3. Re: Cannot resolve dependency against unstarted bundle
alesj Sep 1, 2009 11:48 AM (in response to thomas.diesler)"alesj" wrote:
But what's the issue?
Should it be resolved against deployments that are past CLASSLOADER?"thomas.diesler@jboss.com" wrote:
we need to somehow resolve PackageRequirements against context's in state CLASSLOADER.
Yeah, I don't see why we need fully installed deployment to resolve against.
I assumed there is some reason to it, hence hacked around it. -
4. Re: Cannot resolve dependency against unstarted bundle
adrian.brock Sep 14, 2009 1:00 PM (in response to thomas.diesler)I think you're missing the point?
What is actually required is like "on-demand" processing for pojos
but done for deployments.
i.e. the bundle/deployment should sit at status DESCRIBED or CLASSLOADER
(if somebody manually resolved it) until somebody wants to import from it.
When somebody does that, it should try to move the deployment to INSTALLED
If you look at the AbstractDependencyItem.resolve() there is this codeif (context == null) { resolved = false; ControllerContext unresolvedContext = controller.getContext(iDependOn, null); if (unresolvedContext != null && ControllerMode.ON_DEMAND.equals(unresolvedContext.getMode())) { try { controller.enableOnDemand(unresolvedContext); } catch (Throwable ignored) { if (log.isTraceEnabled()) log.trace("Unexpected error", ignored); } } }
but RequirementDependencyItem overrides that method so there is no
on-demand processing.
But making deployments have a controller mode of "on-demand" probably isn't
the correct solution? For normal usage they need to be "manual" so that deployments
are fully under the control of the MainDeployer.
But you could add some similar code to the RequirementDependencyItem, e.g.
(completely untested/compiled etc.)// Resolved against a context in the dependent state Object iDependOn = module.getContextName(); ControllerContext context = controller.getContext(iDependOn, getDependentState()); if (context != null) { setIDependOn(context.getName()); addDependsOnMe(controller, context); setResolved(true); if (module.getClassLoadingSpace() == null) log.warn(getModule() + " resolved " + getRequirement() + " to " + module + " which has import-all=true. Cannot check its consistency."); return isResolved(); } + else + { + // The dependent module is not fully installed + // if its not currently being processed (required state == state) then try to fully install it + context = controller.getContext(iDependOn, null); + if (context != null && context.getRequiredState().equals(context.getState())) + { + try + { + controller.change(context, ControllerState.INSTALLED); + // It worked so we are now resolved + if (ControllerState.INSTALLED.equals(context.getState())) + { + <Same code as above when it was already in the correct state/> + } + } + catch (Throwable t) + { + log.trace("Error trying to fully install a dependent module: " + module, t); + } + } + }
You almost certainly need to do something for circular dependencies in this code. :-) -
5. Re: Cannot resolve dependency against unstarted bundle
alesj Sep 15, 2009 7:17 AM (in response to thomas.diesler)"adrian@jboss.org" wrote:
But making deployments have a controller mode of "on-demand" probably isn't
the correct solution? For normal usage they need to be "manual" so that deployments
are fully under the control of the MainDeployer.
We will need some "on-demand" notion for (OSGi) deployments anyway,
if we wanna handle lazy activation of bundles on first class loading hit from this bundle. -
6. Re: Cannot resolve dependency against unstarted bundle
thomas.diesler Sep 16, 2009 10:03 AM (in response to thomas.diesler)There is also a consideration where the first possible match for a capability/requirement combination is not the one we want in the context of all available modules.
Details
https://jira.jboss.org/jira/browse/JBKERNEL-54
https://jira.jboss.org/jira/browse/JBKERNEL-55