Thanks for the advice. More info below...
> Sounds to me you are not giving a proper example. Probably. > If BundleA only knows of Vehicle, it will only import Vehicle, > and if BundleB is then a SkateboardEditor it will know of Skateboard > and hence import Skateboard. Indeed, BundleA only knows of Vehicle and only imports vehicle. Indeed, that's all I want it to do. I don't want it to need to know about specific types of Vehicles, since those should be able to be "plugged into" the system without the systems' knowing the specific types in advance. And yes, SkateboardEditor knows about Skateboards, so it does indeed know about the Skateboard class (as well as Vehicle, for that matter). > My guess is that you in reality are talking about various > systems that take a descriptor of a class, such as a String > or a marshalled object of some sort, and that generic > system tries to load the class into existence. I am talking > about Hibernate, reading Properties files with classnames > filled out by third-party, and so forth. Nope. Actually, I am simply managing Vehicles and their lifecycle within the system. The whole point of the system is to manage Vehicles, so this is part of my domain model, I guess. To use your example above, some bundle (BundleS) will register a Skateboard as a Vehicle to the system, which is tracked by BundleA. BundleA will then manage the Skateboard just like it would any other Vehicle. BundleS should not need to do anything regarding management other than registering the Skateboard as an OSGi service implementing Vehicle with a property "id=skateboard". BundleA, from its perspective, just receives a Vehicle that it then takes control of as a Vehicle (it doesn't need to know any of the details of a Skateboard). Since BundleS knows the specific type, I was wondering how I can pass on that type to BundleA at runtime so the service is already casted to the specific type. There are many ways to do this in plain old java, but the problem is classloading in OSGi, since Skateboard is not imported. I am trying to avoid forcing a convention like "must be of class com.blah.foo.bar.*" so I can use dynamic imports. I want the choice of class to be free, which means there's no way of using the dynamic-import in the manifest. If it can't be done, it can't be done, but it is a very nice-to-have with regards to what I'm trying to do: // The lifecycle management system from BundleA Service service = getVehicleService(); // Registering Skateboard from BundleS Skateboard skateboard = new Skateboard(); bundleContext.registerService( ... ) //register Skateboard as Vehicle // Use the registered service from BundleB Skateboard skateboard = service.getVehicle( "skateboard" ); Cheers, David _______________________________________________ OSGi Developer Mail List [email protected] http://www2.osgi.org/mailman/listinfo/osgi-dev
