Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » embedding eclipse - osgi
embedding eclipse - osgi [message #48878] Mon, 25 July 2005 15:01 Go to next message
Erik Vanherck is currently offline Erik VanherckFriend
Messages: 23
Registered: July 2009
Junior Member
Hi All,

I see the same questions have been posted several times however with
little or no usefull responses. It seems more people are thinking of what
I want to achieve and hopefully for them I can fill some blanks and maybe
someone can help me along finding what I need.

Question:
I want to embed the eclipse runtime inside a java application, a servlet,
a java api, .. it doesn't really matter. It all boils down on, I want to
run eclipse and use it's functionality from inside a foreign java
environment.

Partial Answer:
As eclipse is based on OSGI it's possible to do this. Each of the OSGI
implementations has some means to retrieve the System bundle context. From
this bundle context you have access to the services provided by bundles in
the framework. Eclipse default osgi adaptor is no different in this
respect and you can basically use the same technique if you want to embed
Oscar or Knopplerfish. There is however a big BUT. The OSGI runtime of
eclipse provides two different adaptors. The default adaptor
(unfortunately a bit poorly documented) and the Eclipse Adaptor. The
EclipseStarter stuff which is used when normally running eclipse is
present in the eclipse adaptor.

The latter unfortunately isn't meant to be run by client code and it
doesn't provide a way to access the System bundlecontext (AFAIK). Now this
kind off sucks because I would like to reuse the eclipse plugins and
configuration directory layout and the default adaptor uses a different
bundlestore layout.

So is there no other solution for me than to program a mix between the
eclipse adaptor and the default adaptor ?

With kind regards,
Erik Vanherck
Re: embedding eclipse - osgi [message #48911 is a reply to message #48878] Wed, 27 July 2005 06:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amottadelli.it.ibm.comnospam

Erik Vanherck wrote:
> Hi All,
> I see the same questions have been posted several times however with
> little or no usefull responses. It seems more people are thinking of
> what I want to achieve and hopefully for them I can fill some blanks and
> maybe someone can help me along finding what I need.
>
> Question:
> I want to embed the eclipse runtime inside a java application, a
> servlet, a java api, .. it doesn't really matter. It all boils down on,
> I want to run eclipse and use it's functionality from inside a foreign
> java environment.
> Partial Answer: As eclipse is based on OSGI it's possible to do this.
> Each of the OSGI implementations has some means to retrieve the System
> bundle context. From this bundle context you have access to the services
> provided by bundles in the framework. Eclipse default osgi adaptor is no
> different in this respect and you can basically use the same technique
> if you want to embed Oscar or Knopplerfish. There is however a big BUT.
> The OSGI runtime of eclipse provides two different adaptors. The default
> adaptor (unfortunately a bit poorly documented) and the Eclipse Adaptor.
> The EclipseStarter stuff which is used when normally running eclipse is
> present in the eclipse adaptor.
> The latter unfortunately isn't meant to be run by client code and it
> doesn't provide a way to access the System bundlecontext (AFAIK). Now
> this kind off sucks because I would like to reuse the eclipse plugins
> and configuration directory layout and the default adaptor uses a
> different bundlestore layout.
> So is there no other solution for me than to program a mix between the
> eclipse adaptor and the default adaptor ?
>
> With kind regards,
> Erik Vanherck
>
I have made some experiment in running Eclipse OSGI runtime inside a
Tomcat servlet. The problem I found is that both Tomcat and Eclipse try
to register their own URLStreamHandlerFactory and ContentHandlerFactory.
As a workaround I "hacked" java.net.URL and java.net.URLConnection to
just print out a message instead of throwing an arror.... the runtime
seems now to be starting just fine.

Regards,
Alessandro Mottadelli
Re: embedding eclipse - osgi [message #48941 is a reply to message #48911] Wed, 27 July 2005 21:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Another way...
You can use Jetty to launch -one- instance of eclipse.
Tomcat calls the offending singleton operation but Jetty doesn't.

--

Either approach should let you launch eclipse in a workable environment
however in order to communicate with a bundle running inside Eclipse you
have a bit more work to do.

An approach that's worked for me is to launch an "application" that does a
call-back to a static method on a class outside of Eclipse (in your
launching environment). There it registers itself as a handle for use in
the communication channel.

By default Eclipse uses "boot" as the parentClassloader. To set up this
communication channel you'll have to set the osgi.parentClassloader=fwk
property. This step is required so that that the application can see the
launching environment's registration point.

(Note: Setting osgi.parentClassloader=fwk might be overkill -- if you can
control the app classpath you might look at Eclipse-BuddyPolicy: app --
considerably tidier)

After registering the channel you can forward messages into your Eclipse
entrypoint via the interface of whatever it was that you registered.

...

You also asked about Adaptors... I would recommend using
EclipseStarter.run(...) unless you simply can't -- and then still I would
leverage it.

Hope this helps.

-Simon
Re: embedding eclipse - osgi [message #49027 is a reply to message #48941] Tue, 02 August 2005 06:16 Go to previous message
Eclipse UserFriend
Originally posted by: amottadelli.it.ibm.comnospam

Thanks...
Enabling the Eclipse (OSGi) component (programming) model on the server
side could be a huge step forward for server side programming.
J2EE definitely needs something like RCP (maybe a RSP?).
Regards,
Alessandro Mottadelli
Previous Topic:Using eclipse OSGi and runtime in stand-alone project
Next Topic:Empty folders in eclipse/configuration/org.eclipse.osgi/bundles
Goto Forum:
  


Current Time: Fri Apr 26 22:53:27 GMT 2024

Powered by FUDForum. Page generated in 0.03163 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top