Ticket #740 (closed Defect: fixed)

Opened 10 years ago

Last modified 10 years ago

dm4-core: ConsumesService class does not exist anymore

Reported by: Malte Owned by: jri
Priority: Major Milestone:
Component: DeepaMehta Standard Distribution Version: 4.4
Keywords: Cc:
Complexity: 3 Area:
Module:

Description

It looks like the ConsumesService? AnnotationType? has vanished in 4.4, I can not find it the service.annotation package in the deepamehta repo anymore.

When, why? I cant find any info about that not being supported anymore.

Plugins want to react upon serviceArrive and serviceGone, e.g. use the fileService to create some folder structure as soon as the service has arrived.

Should we use the init hook and can we assume that the services are there, then?

If this is all true, please update the ReleaseNotes page accordingly. Thanks.

Change History

comment:1 Changed 10 years ago by jri

Since DM 4.4 we have "Service Injection".
In most cases getting hold of services is much more easy this way.
We have a new @Inject annotation.
See #695.

Note: the serviceArrived() and serviceGone() hooks are still there but are needed only when you want perform any work just in the moment when a service becomes available or goes away. You still need the @Inject annotation in this case as it controls the plugin's service tracking.

Last edited 10 years ago by jri (previous) (diff)

comment:2 follow-up: ↓ 3 Changed 10 years ago by Malte

  • Status changed from new to closed
  • Resolution set to fixed

I just found out what I need:
To implement listeners for the serviceGone and serviceArrived-Hooks in 4.4 one can just drop the @ConsumesService?-Annotation along with the explicit specification of Service-classes.

comment:3 in reply to: ↑ 2 Changed 10 years ago by jri

Replying to Malte:

I just found out what I need:
To implement listeners for the serviceGone and serviceArrived-Hooks in 4.4 one can just drop the @ConsumesService?-Annotation along with the explicit specification of Service-classes.

You still need the @Inject annotation. That's how DM knows what service you're interested in.
The serviceArrived() and serviceGone() hooks are needed only when you want perform any work just in the moment when a service becomes available or goes away.
#695 contains a thorough explanation.

comment:4 Changed 10 years ago by jri

When you're just intereseted in consuming a service but not explicitly in in the moment when it becomes available or goes away you don't need the serviceArrived() and serviceGone() hooks at all.

comment:5 Changed 10 years ago by Malte

Thanks for your hints about the injection service but I am very well aware of all content in #695. There I could just not find any info on the (through the @Injection mechanism) changed annotation style (none) for serviceGone and serviceArrived. The new usage is simply:

    @Override
    public void serviceArrived(PluginService service) {
        if (service instanceof FilesService) {
            // ... do stuff here 
        }
    }

But how should one know?

Thanks again, but I use the @Injection mechanism since its intrduced, its straight forward and simple, but here

e.g. use the fileService to create some folder structure as soon as the service has arrived.

I was explcitly interested in performing actions when certain services do arrive.
Greetings.

comment:6 Changed 10 years ago by jri

That's the correct way you do it.
Good you found out!
Cheers!

comment:7 in reply to: ↑ description Changed 10 years ago by jri

Replying to Malte:

Should we use the init hook and can we assume that the services are there, then?

Yes, at init() time the services the plugin consumes are available already.

Note: See TracTickets for help on using tickets.