Community

Wildcard support in Dynamic-imports

reply from Adrian Brock in JBoss Microcontainer Development - View the full discussion

Looks kind of ok. But...

 

1) You should use the delegate you just created NOT the module.

The operations on the module don't respect export restrictions, they can see private stuff.

Like I said before, you shouldn't be using those module operations. They are for debug purposes on the management console.

i.e. the request starts from that module which is not the case here.

 

You want the operation to go through the delegate to the other policy with whatever export/import restrictions apply.

 

   protected DelegateLoader resolve(String pckg)
   {
      Requirement requirement = new PackageRequirement(pckg, range);
      // TODO -- add this DI to module? new DI impl to remove delegate from policy when resolved module goes away?
      RequirementDependencyItem item = new RequirementDependencyItem(module, requirement, module.getClassLoaderState(), ControllerState.INSTALLED);
      if (item.resolve(controller))
      {
         ClassLoaderPolicy policy = getPolicy();
         // TODO -- add delegate to policy
         return delegate;
      }
      return null;
   }

 

2) I think you should return null for failures, I didn't check but I remember trying to write the internal handling of "not found" to not throw

ClassNotFoundExceptions all over the place. Throwing the RuntimeException would likely mean it doesn't go onto the next delegate?

 

3) You don't show how you are handling the undeploy of the dynamically resolved module when it is not shutdownPolicy=GarbageCollection.

It will move your ClassLoaderPolicy back to DESCRIBED since one of the dependencies has been removed. But I think you should also

remove the dynamic wildcard dependency items you will be adding in the first TODO shown above.

For shutdownPolicy=GarbageCollection you still need to do something in the Module to make the refreshPackages() stuff work properly.

For the GC policy used by OSGi, the dependsOnMe are tracked inside the Module rather than the DependencyInfo.

Reply to this message by going to Community

Start a new discussion in JBoss Microcontainer Development at Community