Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

How can i start OSGI framework from a plugin

$
0
0

If i try to start a bundle like this from simple class in the main method everything works fine:

 

FrameworkFactory fFactory =ServiceLoader.load(FrameworkFactory.class).iterator().next(); //line 1Framework framework = fFactory.newFramework(config);
...
context = framework.getBundleContext(); bundle = context.installBundle(myBundle); bundle.start();


But if i do the same thing when the first file is opened, it dosn't work.

import org.osgi.framework.launch.FrameworkFactory;

public class MyEditor implements FileEditor, FileEditorManagerListener {
        private final VirtualFile file;
        private final Project project;

    static {
        FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next(); // line 44
          ......
    }

I get this error:

[  18578]  ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(120,238),absolute(186,238),button=1,modifiers=Button1,clickCount=2] on frame0
java.util.ServiceConfigurationError: org.osgi.framework.launch.FrameworkFactory: Provider org.eclipse.osgi.launch.EquinoxFactory not a subtype
     at java.util.ServiceLoader.fail(ServiceLoader.java:231)
     at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
     at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
     at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
     at myPackage.MyEditor.<clinit>(MyEditor.java:44)


Way is this happening?
How can i start the framework?

( and i also copied
org.eclipse.osgi_3.7.2.v20120110-1415.jar
into ...\IntelliJ IDEA Community Edition 12.1.6\lib
because i was getting:
   java.util.NoSuchElementException
     at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:357)
     at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
     at myPackage.MyEditor.<clinit>(MyEditor.java:44)
)

Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>