Question about <applicationService ?/>

Hi,

Can anyone explain how to use the  tag in my
plugin.xml?

It looks like it needs a "serviceInterface" attribute as well as a
"serviceImplementation" attribute. In the example code I'm looking at,
they both point to the same fully-qualified class. If one can just put
the same value in both places, why are both attributes required? What
kinds of values can "serviceInterface" take on? From example code it
looks like I can put the fully-qualified name of an actual class (not
an interface) so it's not really clear what can go there. Can
"serviceImplementation" only point to a fully-qualified name of a class
with an empty public constructor?

Thanks in advance for any help!

-Mike

5 comments
Comment actions Permalink

Hello Mike,

If you have a separate interface and implementation for your service, you
can put the name of the interface in serviceInterface and the name of implementation
in serviceImplementation.

Classes registered as components or services are initialized via dependency
injection, so you can have other components or services as parameters in
your service implementation class constructor.

Can anyone explain how to use the <applicationService .../> tag in my
plugin.xml?

It looks like it needs a "serviceInterface" attribute as well as a
"serviceImplementation" attribute. In the example code I'm looking at,
they both point to the same fully-qualified class. If one can just put
the same value in both places, why are both attributes required? What
kinds of values can "serviceInterface" take on? From example code it
looks like I can put the fully-qualified name of an actual class (not
an interface) so it's not really clear what can go there. Can
"serviceImplementation" only point to a fully-qualified name of a
class with an empty public constructor?

Thanks in advance for any help!


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

You may want to have a look at http://confluence.jetbrains.net/display/IDEADEV/IntelliJ+IDEA+Plugin+Structure where this amongst other things is described.


0
Comment actions Permalink

Thanks Dmitry and Björn!

Is it safe to say that if I have
serviceInterface="foo.bar.MyServiceImplClass" and
serviceImplementation="foo.bar.MyServiceImplClass" then I can get a
reference to it via:

MyServiceImplClass service =
ServiceManager.getService(MyServiceImplClass.class);

but if I have serviceInterface="foo.bar.MyServiceInterface" and
serviceImplementation="foo.bar.MyServiceImplClass"

then I can get a reference to it via:

MyServiceInterface service =
ServiceManager.getService(MyServiceInterface.class)

but if I do:

MyServiceImplClass service =
ServiceManager.getService(MyServiceImplClass.class);

it won't work?


On 2011-09-07 10:13:30 +0000, Dmitry Jemerov said:

Hello Mike,

If you have a separate interface and implementation for your service,
you can put the name of the interface in serviceInterface and the name
of implementation in serviceImplementation.

Classes registered as components or services are initialized via
dependency injection, so you can have other components or services as
parameters in your service implementation class constructor.

>> Can anyone explain how to use the  Thanks in advance for any help!


0
Comment actions Permalink

That's how I understood that page, yes.
It also would fit to the statement on that page that two services of the same level must not have the same interface class.
There is no mentioning of the implementation class.
This is so because via the interface class you get them from the service manager.

0
Comment actions Permalink

Hello Mike,

Yes, this is correct.

Thanks Dmitry and Björn!

Is it safe to say that if I have
serviceInterface="foo.bar.MyServiceImplClass" and
serviceImplementation="foo.bar.MyServiceImplClass" then I can get a
reference to it via:

MyServiceImplClass service =
ServiceManager.getService(MyServiceImplClass.class);

but if I have serviceInterface="foo.bar.MyServiceInterface" and
serviceImplementation="foo.bar.MyServiceImplClass"

then I can get a reference to it via:

MyServiceInterface service =
ServiceManager.getService(MyServiceInterface.class)

but if I do:

MyServiceImplClass service =
ServiceManager.getService(MyServiceImplClass.class);

it won't work?

On 2011-09-07 10:13:30 +0000, Dmitry Jemerov said:

>> Hello Mike,
>>
>> If you have a separate interface and implementation for your service,
>> you can put the name of the interface in serviceInterface and the
>> name of implementation in serviceImplementation.
>>
>> Classes registered as components or services are initialized via
>> dependency injection, so you can have other components or services as
>> parameters in your service implementation class constructor.
>>
>>> Can anyone explain how to use the 

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.