Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.AbstractScheduledService$CustomScheduler$Schedule


  private final List<IWVWObjective> content = new CopyOnWriteArrayList<IWVWObjective>();

  private Service service;

  public MapObjectivesTableModel() {
    this.service = new AbstractScheduledService() {
      @Override
      protected void runOneIteration() throws Exception {
        int row = 0;
        for (IWVWObjective content : MapObjectivesTableModel.this.content) {
          if (content.getRemainingBuffDuration(TimeUnit.SECONDS) > 0) {
View Full Code Here


  @Inject
  public APIStatusTableModel(IGW2StatsService gw2statsService) {
    this.gw2statsService = checkNotNull(gw2statsService);
    // TODO refactor this to an event based system -> wrap it
    final AbstractScheduledService service = new AbstractScheduledService() {
      @Override
      protected Scheduler scheduler() {
        return AbstractScheduledService.Scheduler.newFixedDelaySchedule(0, 5000, TimeUnit.MILLISECONDS);
      }

      @Override
      protected void runOneIteration() throws Exception {
        APIStatusTableModel.this.states = APIStatusTableModel.this.gw2statsService.retrieveAPIStates();
        APIStatusTableModel.this.fireTableDataChanged();
      }
    };
    service.start();
  }
View Full Code Here

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();
View Full Code Here

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();
View Full Code Here

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();
View Full Code Here

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();
View Full Code Here

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();
View Full Code Here

        int pollFrequency = scheduledListener.getPollFrequencySeconds();
        int pollLatency = getPollLatencySeconds(scheduledListener);

        if(scheduleIdRef != null) {
            listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_ID_REF, scheduleIdRef);
            final Schedule schedule = model.getSchedule(scheduleIdRef) ;
            if (schedule.isSetStartDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_START_DATE, Long.toString(schedule.getStartDate().getTimeInMillis())) ;
            }
            if (schedule.isSetEndDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_END_DATE, Long.toString(schedule.getEndDate().getTimeInMillis())) ;
            }
            if (schedule instanceof SimpleSchedule) {
                final SimpleSchedule simpleSchedule = (SimpleSchedule)schedule ;
                final long simpleFrequency = simpleSchedule.getFrequency() ;
                final FrequencyUnit.Enum unit = simpleSchedule.getFrequencyUnits() ;
                final String frequencyVal ;
                if (unit.equals(FrequencyUnit.SECONDS)) {
                    frequencyVal = Long.toString(simpleFrequency * 1000) ;
                } else {
                    frequencyVal = Long.toString(simpleFrequency) ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_FREQUENCY, frequencyVal) ;
                if (simpleSchedule.isSetExecCount()) {
                    listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_EXEC, Integer.toString(simpleSchedule.getExecCount())) ;
                }
            } else if (schedule instanceof CronSchedule) {
                final String cronExpression = ((CronSchedule)schedule).getCronExpression() ;
                if (cronExpression == null) {
                    throw new ConfigurationException("Missing cron expression from configuration") ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_CRON_EXPRESSION, cronExpression) ;
            } else {
                throw new ConfigurationException("Unknown schedule type specified in configuration: " + schedule.getClass().getName()) ;
            }
           
            if(domElement.hasAttribute("poll-frequency-seconds") || domElement.hasAttribute("schedule-frequency") ) {
                logger.warn("Schedule Listener '" + listenerConfig.getTagName() + "' defines both 'scheduleidref' and frequency attributes.  Using the 'scheduleidref'.");
            }
View Full Code Here

        int pollFrequency = scheduledListener.getPollFrequencySeconds();
        int pollLatency = getPollLatencySeconds(scheduledListener);

        if(scheduleIdRef != null) {
            listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_ID_REF, scheduleIdRef);
            final Schedule schedule = model.getSchedule(scheduleIdRef) ;
            if (schedule.isSetStartDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_START_DATE, Long.toString(schedule.getStartDate().getTimeInMillis())) ;
            }
            if (schedule.isSetEndDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_END_DATE, Long.toString(schedule.getEndDate().getTimeInMillis())) ;
            }
            if (schedule instanceof SimpleSchedule) {
                final SimpleSchedule simpleSchedule = (SimpleSchedule)schedule ;
                final long simpleFrequency = simpleSchedule.getFrequency() ;
                final FrequencyUnit.Enum unit = simpleSchedule.getFrequencyUnits() ;
                final String frequencyVal ;
                if (unit.equals(FrequencyUnit.SECONDS)) {
                    frequencyVal = Long.toString(simpleFrequency * 1000) ;
                } else {
                    frequencyVal = Long.toString(simpleFrequency) ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_FREQUENCY, frequencyVal) ;
                if (simpleSchedule.isSetExecCount()) {
                    listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_EXEC, Integer.toString(simpleSchedule.getExecCount())) ;
                }
            } else if (schedule instanceof CronSchedule) {
                final String cronExpression = ((CronSchedule)schedule).getCronExpression() ;
                if (cronExpression == null) {
                    throw new ConfigurationException("Missing cron expression from configuration") ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_CRON_EXPRESSION, cronExpression) ;
            } else {
                throw new ConfigurationException("Unknown schedule type specified in configuration: " + schedule.getClass().getName()) ;
            }
           
            if(domElement.hasAttribute("poll-frequency-seconds") || domElement.hasAttribute("schedule-frequency") ) {
                logger.warn("Schedule Listener '" + listenerConfig.getTagName() + "' defines both 'scheduleidref' and frequency attributes.  Using the 'scheduleidref'.");
            }
View Full Code Here

        int pollFrequency = scheduledListener.getPollFrequencySeconds();
        int pollLatency = getPollLatencySeconds(scheduledListener);

        if(scheduleIdRef != null) {
            listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_ID_REF, scheduleIdRef);
            final Schedule schedule = model.getSchedule(scheduleIdRef) ;
            if (schedule.isSetStartDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_START_DATE, Long.toString(schedule.getStartDate().getTimeInMillis())) ;
            }
            if (schedule.isSetEndDate()) {
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_END_DATE, Long.toString(schedule.getEndDate().getTimeInMillis())) ;
            }
            if (schedule instanceof SimpleSchedule) {
                final SimpleSchedule simpleSchedule = (SimpleSchedule)schedule ;
                final long simpleFrequency = simpleSchedule.getFrequency() ;
                final FrequencyUnit.Enum unit = simpleSchedule.getFrequencyUnits() ;
                final String frequencyVal ;
                if (unit.equals(FrequencyUnit.SECONDS)) {
                    frequencyVal = Long.toString(simpleFrequency * 1000) ;
                } else {
                    frequencyVal = Long.toString(simpleFrequency) ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_FREQUENCY, frequencyVal) ;
                if (simpleSchedule.isSetExecCount()) {
                    listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_SIMPLE_EXEC, Integer.toString(simpleSchedule.getExecCount())) ;
                }
            } else if (schedule instanceof CronSchedule) {
                final String cronExpression = ((CronSchedule)schedule).getCronExpression() ;
                if (cronExpression == null) {
                    throw new ConfigurationException("Missing cron expression from configuration") ;
                }
                listenerConfig.setAttribute(ListenerTagNames.SCHEDULE_CRON_EXPRESSION, cronExpression) ;
            } else {
                throw new ConfigurationException("Unknown schedule type specified in configuration: " + schedule.getClass().getName()) ;
            }

            if(domElement.hasAttribute("poll-frequency-seconds") || domElement.hasAttribute("schedule-frequency") ) {
                logger.warn("Schedule Listener '" + listenerConfig.getTagName() + "' defines both 'scheduleidref' and frequency attributes.  Using the 'scheduleidref'.");
            }
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.AbstractScheduledService$CustomScheduler$Schedule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.