I coded a bundle that uses Apache Felix Dependency management. It's Activator extends
DependencyActivatorBase. But Plugin my plugin activator extends AbstractUIPlugin. How can I get services from the felix dependency manager from within the eclipse plugin?
DependencyManager has a getDepenencyManagers method but it is a list, not sure how I would know the right manager in the list.
Yes you can use Dependency Manager in any OSGi framework, including Equinox (on which Eclipse is based).
Why does your bundle activator need to extend AbstractUIPlugin?? Are you actually using AbstractUIPlugin, or was this just generated for you because you used Eclipse PDE to generate the initial code? The project templates in PDE are basically junk, most bundles do not need activators at all, and very very few really need to extend AbstractUIPlugin.
So, just change your activator to extend DependencyActivatorBase instead of AbstractUIPlugin.
The DependencyActivatorBase class is just a base class that is there for your convenience. If, for some reason, you cannot use it (like, arguably, in your case), you can always instantiate an instance of DependencyManager yourself from your own class. All it needs is a reference to the BundleContext (which you can get from the start() method of BundleActivator, assuming you do implement that yourself). Then just do something like this:
DependencyManager dm = new DependencyManager(bundleContext);
dm.add(dm.createComponent()
.setImplementation(YourComponent.class)
.add(dm.createServiceDependency()
.setService(LogService.class)
)
);
Related
I try to build a native container with Quarkus (with -Pnative flag), I use -H:+PrintClassInitialization to generate the class initializer reports. I see a initilizer_dependencies_yyyymmdd_hhmmss.dot file is generated; in this file, I see some classes marked with [fillcover=red], could you tell me what this means? and what action is needed?
Thanks
it seems to me those classes are the ones that will be called but not in reflection configuration. I add them in reflection or initialize to solve it.
Hello I have many many projects in many solutions and all use Ninject as IoC container. Common libraries have Ninject modules, the applications (like console application) usually have modules too and combine the modules in one StandardKernel. Now I have to change all common libraries to Autofac.
Let's say I make modifications and use Autofac (by defining Autofac modules) in a project named A (common library). A is referenced in project B (a console application) which still uses Ninject. Let's assume that for now I do not want to modify project B too much and I want to leave Ninject there.
It is possible to use Autofac modules from project A when in the end I use Ninject's StandardKernel in the "final" project B?
To the best of my knowledge there is no adapter that just "converts" one IoC format to the other. I don't think Ninject supports Microsoft.Extensions.DependencyInjection format registrations, either, so trying to use the IServiceCollection from there as a bridge also won't work.
Unfortunately, I think you're stuck. You'll have to do it all at once. Sorry.
I have a scenario where I need to use a plugin as well as a static library into my xcode project. The plugin will be dynamically loaded into the system. Now, the static library is also getting used in creation of the plugin.
While executing my project I am getting a warning saying :
Class A is getting referenced from /staticLibraryPath and plugin. One of them will be used.
Please let me know, how to resolve the warning or a better way of implementing the scenario.
The issue is a name class of the two ClassA types found in both plugin and library
I assume you have control over the source of either plugin / library.
.. rename Class A in one instance to make the names not clash -- I don't think there is another way to get rid of the warning/error
I am currently experiencing a problem in my RCP application and wanted to ask, if someone stumbled over the same problem and can give me some valuable hints:
My RCP application allows plugins to provide implementations of a specific abstract class of my model (singleton) to extend my model during runtime via the update manager. I instantiate these classes via
extensionPointImplementation.createExecutableExtension(..)
after parsing the Eclipse registry. I can serialize the created instances using the default Java serialization API.
Now to the problem: The plugin trying to deserialize the objects cannot find the class implementations of the model extensions due to the fact, that there is no plugin dependency between the plugins. Nevertheless, it is not possible for me to create such a dependency which would make the idea of extending the model during runtime obsolete.
Is it possible to solve this problem by using the default Java serialization API or do I have to implement my own serialization (which parses the Eclipse registry and creates the instances via the line shown above if all necessary plugins are available, otherwise throw an exception) which might be based on the default Java serialization API (if possible I do not want to create the serialization completely by myself)?
Thanks.
You need to define a so called buddy policy.
In the bundle trying to instantiate the class add
Eclipse-BuddyPolicy: registered
to the manifest.mf.
In the bundle providing the class add
Eclipse-RegisterBuddy: <symbolic name of the bundle instantiating the class>
to the manifest.mf.
I am using Rhino to script an Eclipse (RCP) application. The problem is that from Javascript I only have access to classes available to the plugin that provides Rhino, and not to all the classes available to the plugin that runs the scripts.
The obvious answer would be to put Rhino in the scripting plugin, but this doesn't work because it's already provided by one of the application's own plugins (which also provides things I need to script) and Eclipse always uses this version instead of the version closer to hand.
Is there a way to change the classloader used by Rhino
or is it possible to ensure that Eclipse loads the Rhino classes from one plugin rather than another?
Thanks to Thilo's answer I used this:
import net.weissmann.tom.rhino.Activator; // Plugin activator class
import org.mozilla.javascript.tools.shell.Main;
public class JSServer extends Thread {
//[...]
public void run() {
// recent versions of the Main class kindly export
// the context factory
Main.shellContextFactory.initApplicationClassLoader(
Activator.class.getClassLoader()
) ;
//[...]
}
Is there a way to change the classloader used by Rhino
Rhino should be using the current Thread's ContextClassLoader. Try Thread.setContextClassLoader (don't forget to restore it).
If that does not work, maybe you can create your own Rhino ContextFactory:
public final void initApplicationClassLoader(java.lang.ClassLoader loader)
Set explicit class loader to use when searching for Java classes.
I don't know Rhino specifics, but you could consider using Eclipse "buddy classloading" with the "registered" policy.
Rhino's plug-in (net.weissmann.tom.rhino, say) would declare itself "open to extension" by specifying Eclipse-BuddyPolicy: registered in its MANIFEST.MF. Plug-ins with classes that Rhino should be able to see would specify Eclipse-RegisterBuddy: net.weissmann.tom.rhino and would need a bundle-level dependency on net.weissmann.tom.rhino.
http://www.eclipsezone.com/articles/eclipse-vms/
http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements#Technical_Solution