registering a protocol [message #39143] |
Wed, 31 March 2004 11:49  |
Eclipse User |
|
|
|
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 #39388 is a reply to message #39358] |
Fri, 02 April 2004 09:45   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04336 seconds