2017-10-21 169 views
1

我已經使用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但看起來我在這裏做錯了什麼。不知道是什麼。

在此先感謝

回答