XML : Injection using blueprint on sling

My whole osgi project (i.e. more than 220 bundes) is all based on blueprint xml. Injections are done on the xml and there's no annotations at all.

I'd like to keep it that way, but it's not clear for me if it can be done on sling.

On the following code:

  package com.acme.schedulerconsumerstd;  import org.apache.felix.scr.annotations.Component;  import org.apache.felix.scr.annotations.Property;  import org.apache.felix.scr.annotations.Service;  import org.apache.sling.event.jobs.Job;  import org.apache.sling.event.jobs.consumer.JobConsumer;    @Component  @Service(value = { JobConsumer.class })  @Property(name = JobConsumer.PROPERTY_TOPICS, value = "my/special/jobtopic")  public class SchedulerConsumerStd implements JobConsumer {      public JobResult process(final Job job) {      // process the job and return the result      return JobResult.OK;    }    }    

In the code above there's already 3 different undesirable annotations - Component, Service and Property.

I believe I could setup on blueprint the component and service this way:

  <?xml version="1.0" encoding="UTF-8" standalone="no"?>  <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">        <bean id="schedulerConsumerStd" class="com.acme.schedulerconsumerstd.SchedulerConsumerStd" />      <service ref="schedulerConsumerStd" interface="org.apache.sling.event.jobs.consumer.JobConsumer" />  </blueprint>    

The question is, would that code above on the blueprint xml replace effectively the need to use those annotations? If not, then how? And how can I add the "@Property" annotation on the xml? Is it the same as adding filter="PROPERTY_TOPICS=my/special/jobtopic)" to the service declaration?

No comments:

Post a Comment