@Override
  public boolean isTaskEnabled() throws DeviceMgtTaskException {

    return DeviceConfigurationManager.getInstance()
        .getDeviceManagementConfig()
        .getDeviceManagementConfigRepository()
        .getTaskConfiguration()
        .isEnabled();
  }
  @Override
  public int getTaskFrequency() throws DeviceMgtTaskException {

    return DeviceConfigurationManager.getInstance()
        .getDeviceManagementConfig()
        .getDeviceManagementConfigRepository()
        .getTaskConfiguration()
        .getFrequency();
  }
  @Override
  public String getTaskImplementedClazz() throws DeviceMgtTaskException {

    return DeviceConfigurationManager.getInstance()
        .getDeviceManagementConfig()
        .getDeviceManagementConfigRepository()
        .getTaskConfiguration()
        .getTaskClazz();
  }
  @Override
  public List<TaskOperation> getOperationList() throws DeviceMgtTaskException {

    TaskConfiguration taskConfiguration =
        DeviceConfigurationManager.getInstance()
            .getDeviceManagementConfig()
            .getDeviceManagementConfigRepository()
            .getTaskConfiguration();

    List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
    List<TaskOperation> taskOperations = new ArrayList<>();

    for (TaskConfiguration.Operation op : ops) {
      TaskOperation taskOperation = new TaskOperation();
      taskOperation.setTaskName(op.getOperationName());
      taskOperation.setRecurrentTimes(op.getRecurrency());
      taskOperations.add(taskOperation);
    }
    return taskOperations;
  }
  @SuppressWarnings("unused")
  protected void activate(ComponentContext componentContext) {
    try {
      if (log.isDebugEnabled()) {
        log.debug("Initializing device management core bundle");
      }
      /* Initializing Device Management Configuration */
      DeviceConfigurationManager.getInstance().initConfig();
      DeviceManagementConfig config =
          DeviceConfigurationManager.getInstance().getDeviceManagementConfig();

      DataSourceConfig dsConfig =
          config.getDeviceManagementConfigRepository().getDataSourceConfig();

      APIManagerConfiguration apiManagerConfiguration = new APIManagerConfiguration();
      apiManagerConfiguration.load(APIM_CONFIGURATION_PATH);
      DeviceManagementDataHolder.getInstance().setApiManagerConfiguration(apiManagerConfiguration);

      DeviceManagementDAOFactory.init(dsConfig);
      GroupManagementDAOFactory.init(dsConfig);
      NotificationManagementDAOFactory.init(dsConfig);
      OperationManagementDAOFactory.init(dsConfig);

      String apiManagerDataSource = apiManagerConfiguration.getFirstProperty(DATA_SOURCE_NAME);
      ScopeManagementDAOFactory.init(apiManagerDataSource);

      /* Initialize Operation Manager */
      this.initOperationsManager();

      PushNotificationProviderRepository pushNotificationRepo =
          new PushNotificationProviderRepository();
      List<String> pushNotificationProviders = config.getPushNotificationProviders();
      if (pushNotificationProviders != null) {
        for (String pushNoteProvider : pushNotificationProviders) {
          pushNotificationRepo.addProvider(pushNoteProvider);
        }
      }
      DeviceManagementDataHolder.getInstance()
          .setPushNotificationProviderRepository(pushNotificationRepo);

      /* If -Dsetup option enabled then create device management database schema */
      String setupOption = System.getProperty(DeviceManagementConstants.Common.SETUP_PROPERTY);
      if (setupOption != null) {
        if (log.isDebugEnabled()) {
          log.debug(
              "-Dsetup is enabled. Device management repository schema initialization is about to "
                  + "begin");
        }
        this.setupDeviceManagementSchema(dsConfig);
      }

      /* Registering declarative service instances exposed by DeviceManagementServiceComponent */
      this.registerServices(componentContext);

      /* This is a workaround to initialize all Device Management Service Providers after the initialization
       * of Device Management Service component in order to avoid bundle start up order related complications */
      notifyStartupListeners();
      if (log.isDebugEnabled()) {
        log.debug("Device management core bundle has been successfully initialized");
      }
    } catch (Throwable e) {
      log.error("Error occurred while initializing device management core bundle", e);
    }
  }