Skip to main content



      Home
Home » Eclipse Projects » Equinox » registering a protocol
registering a protocol [message #39143] Wed, 31 March 2004 11:49 Go to next message
Eclipse UserFriend
Originally posted by: a.java.dcs.shef.ac.uk

Hi All,

I am new to eclipse and am in the process of developing a plugin that
invokes an application in a JAR file. The application that I need to use
requires that it registers a URLHandler for the protocol myprotocol:// and
i do this using thestandard Java mechanism (ie System.setProperty). This
works fine in stand alone but not when i use it in the plugin. I realize
from an
earlier documentation that this mechanism would not work due to the fact
that eclipse uses PlatformURLHandler to register protocols and hence I
would need to use an extention point in the plugin.xml file
(org.eclipse.runtime.urlhandlers) and define the handler that implements
a URLStreamHandler. I did this and still got a malformed URL exception....

Then I came across the bug report
https://bugs.eclipse.org/bugs/show_bug.cgi?id=43400#c1
that says that this was used in eclipse 2.0 and now in eclipse 3.0 i
need to use org.osgi.service.url.URLStreamHandlerService

but i am not quite clear on how to do this? and I could not find any APIs
so I am also unsure about the methods...

By now, I am quite confused with this and would really be extremely
grateful if you could please help me in this regard....

Thanks a lot
Akshay Java
Re: registering a protocol [message #39205 is a reply to message #39143] Wed, 31 March 2004 19:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pascal.ibm.canada

In eclipse 3.0 you want to register your url programmatically.
Instead of describing the code here, please take a look at
PlatformActivator.installPlatformURLSupport().
Note that your handler must extends AbstractURLStreamHandlerService.

PaScaL


Akshay Java wrote:
> Hi All,
>
> I am new to eclipse and am in the process of developing a plugin that
> invokes an application in a JAR file. The application that I need to use
> requires that it registers a URLHandler for the protocol myprotocol:// and
> i do this using thestandard Java mechanism (ie System.setProperty). This
> works fine in stand alone but not when i use it in the plugin. I realize
> from an
> earlier documentation that this mechanism would not work due to the fact
> that eclipse uses PlatformURLHandler to register protocols and hence I
> would need to use an extention point in the plugin.xml file
> (org.eclipse.runtime.urlhandlers) and define the handler that implements
> a URLStreamHandler. I did this and still got a malformed URL exception....
>
> Then I came across the bug report
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=43400#c1
> that says that this was used in eclipse 2.0 and now in eclipse 3.0 i
> need to use org.osgi.service.url.URLStreamHandlerService
>
> but i am not quite clear on how to do this? and I could not find any APIs
> so I am also unsure about the methods...
>
> By now, I am quite confused with this and would really be extremely
> grateful if you could please help me in this regard....
>
> Thanks a lot
> Akshay Java
>
>
Re: registering a protocol [message #39327 is a reply to message #39205] Thu, 01 April 2004 08:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hi Pascal,

What i have now is ProtocolHandler that implements
org.osgi.service.url.AbstractStreamHandler. From the code for
PlatformActivator it seems to me like i may need a
class ProtocolActivator implementing a BundleActivator with its start
method being used to register my ProtocolHandler. Would that be the
right way to do this? or am I mistaken in this regard?

Also.. when is the start method invoked ? is it when the plugin gets
loaded or when eclipse workbench starts?
Thanks for your time and help,
Akshay
Re: registering a protocol [message #39358 is a reply to message #39327] Thu, 01 April 2004 22:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pascal.ibm.canada

You are on the right track.

A bundleActivator is somewhat equivalent to the plugin class with the
difference that the instance is not available from a registry (compared
to the plugin object in eclipse). An activator is responsible for
startup and shutdown, and most of the time it is the place where you
register services.

In eclipse 3.0, when you don't have a prerequisite on compatibility, the
plugin class plays the role of the activator. To facilitate the work,
org.eclipse.core.runtime.Plugin implements BundleActivator.

Therefore you should do the registration of your url handler in the
start method.

PaScaL

user@domain.invalid wrote:
> Hi Pascal,
>
> What i have now is ProtocolHandler that implements
> org.osgi.service.url.AbstractStreamHandler. From the code for
> PlatformActivator it seems to me like i may need a
> class ProtocolActivator implementing a BundleActivator with its start
> method being used to register my ProtocolHandler. Would that be the
> right way to do this? or am I mistaken in this regard?
>
> Also.. when is the start method invoked ? is it when the plugin gets
> loaded or when eclipse workbench starts?
> Thanks for your time and help,
> Akshay
Re: registering a protocol [message #39388 is a reply to message #39358] Fri, 02 April 2004 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.java.dcs.shef.ac.uk

Hey Pascal,
Thanx for all your help and guidance!! It was gr8 fun! i managed to get it
done! For the benefit of anyone else looking for info on a similar problem
here is how i did it

1. Write your own handler that extends AbstractURLStreamHandlerService
(org.osgi.service.url.AbstractURLStreamHandlerService)

2. Your Plugin class (which extends AbstractUIPlugin) implements
BundleActivator (org.osgi.framework.*)

3. Provide a start method similar to this
public void start(BundleContext context) {
Hashtable properties = new Hashtable();
properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] {
ProtocolHandler.PROTOCOL });
context.registerService(URLStreamHandlerService.class.getNam e(), new
ProtocolHandler(), properties);

}

4 Thats it!!!

thanx again
Akshay

Pascal Rapicault wrote:

> You are on the right track.

> A bundleActivator is somewhat equivalent to the plugin class with the
> difference that the instance is not available from a registry (compared
> to the plugin object in eclipse). An activator is responsible for
> startup and shutdown, and most of the time it is the place where you
> register services.

> In eclipse 3.0, when you don't have a prerequisite on compatibility, the
> plugin class plays the role of the activator. To facilitate the work,
> org.eclipse.core.runtime.Plugin implements BundleActivator.

> Therefore you should do the registration of your url handler in the
> start method.

> PaScaL

> user@domain.invalid wrote:
> > Hi Pascal,
> >
> > What i have now is ProtocolHandler that implements
> > org.osgi.service.url.AbstractStreamHandler. From the code for
> > PlatformActivator it seems to me like i may need a
> > class ProtocolActivator implementing a BundleActivator with its start
> > method being used to register my ProtocolHandler. Would that be the
> > right way to do this? or am I mistaken in this regard?
> >
> > Also.. when is the start method invoked ? is it when the plugin gets
> > loaded or when eclipse workbench starts?
> > Thanks for your time and help,
> > Akshay
Re: registering a protocol [message #39481 is a reply to message #39388] Sat, 03 April 2004 00:40 Go to previous message
Eclipse UserFriend
Originally posted by: pascal.ibm.canada

Only correction on that, you can also inherits from
org.eclipse.core.runtime.Plugin which avoids you an unecessary
dependency on the UI.
You also want to call super.start() first.

PaScaL

Akshay Java wrote:
> Hey Pascal,
> Thanx for all your help and guidance!! It was gr8 fun! i managed to get it
> done! For the benefit of anyone else looking for info on a similar problem
> here is how i did it
>
> 1. Write your own handler that extends AbstractURLStreamHandlerService
> (org.osgi.service.url.AbstractURLStreamHandlerService)
>
> 2. Your Plugin class (which extends AbstractUIPlugin) implements
> BundleActivator (org.osgi.framework.*)
>
> 3. Provide a start method similar to this
> public void start(BundleContext context) {
> Hashtable properties = new Hashtable();
> properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] {
> ProtocolHandler.PROTOCOL });
> context.registerService(URLStreamHandlerService.class.getNam e(), new
> ProtocolHandler(), properties);
>
> }
>
> 4 Thats it!!!
>
> thanx again
> Akshay
>
> Pascal Rapicault wrote:
>
>
>>You are on the right track.
>
>
>>A bundleActivator is somewhat equivalent to the plugin class with the
>>difference that the instance is not available from a registry (compared
>>to the plugin object in eclipse). An activator is responsible for
>>startup and shutdown, and most of the time it is the place where you
>>register services.
>
>
>>In eclipse 3.0, when you don't have a prerequisite on compatibility, the
>>plugin class plays the role of the activator. To facilitate the work,
>>org.eclipse.core.runtime.Plugin implements BundleActivator.
>
>
>>Therefore you should do the registration of your url handler in the
>>start method.
>
>
>>PaScaL
>
>
>>user@domain.invalid wrote:
>>
>>>Hi Pascal,
>>>
>>>What i have now is ProtocolHandler that implements
>>>org.osgi.service.url.AbstractStreamHandler. From the code for
>>>PlatformActivator it seems to me like i may need a
>>>class ProtocolActivator implementing a BundleActivator with its start
>>>method being used to register my ProtocolHandler. Would that be the
>>>right way to do this? or am I mistaken in this regard?
>>>
>>>Also.. when is the start method invoked ? is it when the plugin gets
>>>loaded or when eclipse workbench starts?
>>>Thanks for your time and help,
>>>Akshay
>
>
>
Previous Topic:Bundle access without activation (M8)
Next Topic:dynamically load classes in plugins
Goto Forum:
  


Current Time: Tue Jul 22 15:45:53 EDT 2025

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

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

Back to the top