AEM 6.3:创建使用OSGi R6注释

问题描述:

我已经使用OSGi R6注释写的调度,但它似乎并没有运行调度:AEM 6.3:创建使用OSGi R6注释

package com.aem.sites.interfaces; 

import org.osgi.service.metatype.annotations.AttributeDefinition; 
import org.osgi.service.metatype.annotations.AttributeType; 
import org.osgi.service.metatype.annotations.ObjectClassDefinition; 

@ObjectClassDefinition(name = "Scheduler Configuration for Weather", description = "Configuration file for Scheduler") 
public @interface SchedulerConfiguration { 

    @AttributeDefinition(
      name = "sample parameter", 
      description="Sample String parameter", 
      type = AttributeType.STRING 
      ) 
    public String parameter() default "scheduler"; 

    @AttributeDefinition(
      name = "Concurrent", 
      description = "Schedule task concurrently", 
      type = AttributeType.BOOLEAN 
     ) 
     boolean scheduler_concurrent() default true; 

     @AttributeDefinition(
      name = "Expression", 
      description = "Cron-job expression. Default: run every minute.", 
      type = AttributeType.STRING 
     ) 
     String scheduler_expression() default "0 * * * * ?"; 

} 

package com.aem.sites.schedulers; 

import org.osgi.service.component.annotations.Component; 
import org.osgi.service.component.annotations.Activate; 
import org.osgi.service.metatype.annotations.Designate; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

import com.aem.sites.interfaces.SchedulerConfiguration; 

@Component(immediate = true, 
     configurationPid = "com.aem.sites.schedulers.WeatherServiceScheduler") 
@Designate(ocd=SchedulerConfiguration.class) 
public class WeatherServiceScheduler implements Runnable { 

    private final Logger logger = LoggerFactory.getLogger(this.getClass()); 

    private String myParameter; 

    @Override 
    public void run() { 
     logger.info("*******************************************Sample OSGi Scheduler is now running", myParameter); 

    } 
    @Activate 
    public void activate(SchedulerConfiguration config) { 
     logger.info("*******************************************weather service scheduler"+ myParameter); 
     myParameter = config.parameter(); 
    } 

} 

我下面这个https://github.com/nateyolles/aem-osgi-annotation-demo/blob/master/core/src/main/java/com/nateyolles/aem/osgiannotationdemo/core/schedulers/SampleOsgiScheduledTask.java但看起来我在这里做错了什么。不知道是什么。

在此先感谢