private static void saveSchedules(File schedulesData) throws IOException { try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(schedulesData))) { out.writeInt(DATA_VERSION); out.writeInt(scheduledApps.size()); for (Iterator apps = scheduledApps.values().iterator(); apps.hasNext();) { EclipseScheduledApplication app = (EclipseScheduledApplication) apps.next(); writeStringOrNull(out, app.getScheduleId()); writeStringOrNull(out, app.getAppPid()); writeStringOrNull(out, app.getTopic()); writeStringOrNull(out, app.getEventFilter()); out.writeBoolean(app.isRecurring()); out.writeObject(app.getArguments()); } } }
@Override public synchronized void handleEvent(Event event) { try { if (removed) return; ApplicationDescriptor desc = getApplicationDescriptor(); if (desc == null) // in this case the application descriptor was removed; // we must return and keep the scheduled app incase the application comes back return; desc.launch(getArguments(event)); } catch (Exception e) { String message = NLS.bind(Messages.scheduled_app_launch_error, sr); Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, e, null)); return; // return here to avoid removing non-recurring apps when an error occurs } if (!isRecurring()) remove(); }
private static void addScheduledApp(EclipseScheduledApplication scheduledApp) { if (ScheduledApplication.TIMER_TOPIC.equals(scheduledApp.getTopic())) { synchronized (timerApps) { timerApps.add(scheduledApp); if (timerThread == null) startTimer(); } } scheduledApps.put(scheduledApp.getScheduleId(), scheduledApp); Hashtable serviceProps = new Hashtable(); if (scheduledApp.getTopic() != null) serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()}); if (scheduledApp.getEventFilter() != null) serviceProps.put(EventConstants.EVENT_FILTER, scheduledApp.getEventFilter()); serviceProps.put(ScheduledApplication.SCHEDULE_ID, scheduledApp.getScheduleId()); serviceProps.put(ScheduledApplication.APPLICATION_PID, scheduledApp.getAppPid()); ServiceRegistration sr = context.registerService(new String[] {ScheduledApplication.class.getName(), EVENT_HANDLER}, scheduledApp, serviceProps); scheduledApp.setServiceRegistration(sr); }
String filterString = apps[i].getEventFilter(); Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString); if (filter == null || filter.match(props)) apps[i].handleEvent(timerEvent); } catch (Throwable t) { String message = NLS.bind(Messages.scheduled_app_launch_error, apps[i].getAppPid()); Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
private static void loadSchedules(File schedulesData) throws IOException { try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(schedulesData))) { int dataVersion = in.readInt(); if (dataVersion != DATA_VERSION) return; int numScheds = in.readInt(); for (int i = 0; i < numScheds; i++) { String id = readString(in, false); String appPid = readString(in, false); String topic = readString(in, false); String eventFilter = readString(in, false); boolean recurring = in.readBoolean(); Map args = (Map) in.readObject(); EclipseScheduledApplication schedApp = new EclipseScheduledApplication(context, id, appPid, args, topic, eventFilter, recurring); addScheduledApp(schedApp); } } catch (InvalidSyntaxException e) { throw new IOException(e.getMessage()); } catch (NoClassDefFoundError e) { throw new IOException(e.getMessage()); } catch (ClassNotFoundException e) { throw new IOException(e.getMessage()); } }
private Map getArguments(Event trigger) { Map result = args == null ? new HashMap() : getArguments(); result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic()))); return result; }
static void removeScheduledApp(EclipseScheduledApplication scheduledApp) { boolean removed; synchronized (scheduledApps) { removed = scheduledApps.remove(scheduledApp.getScheduleId()) != null; if (removed) { saveData(FILE_APPSCHEDULED); } } if (removed) synchronized (timerApps) { timerApps.remove(scheduledApp); } }
private static void addScheduledApp(EclipseScheduledApplication scheduledApp) { if (ScheduledApplication.TIMER_TOPIC.equals(scheduledApp.getTopic())) { synchronized (timerApps) { timerApps.add(scheduledApp); if (timerThread == null) startTimer(); } } scheduledApps.put(scheduledApp.getScheduleId(), scheduledApp); Hashtable serviceProps = new Hashtable(); if (scheduledApp.getTopic() != null) serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()}); if (scheduledApp.getEventFilter() != null) serviceProps.put(EventConstants.EVENT_FILTER, scheduledApp.getEventFilter()); serviceProps.put(ScheduledApplication.SCHEDULE_ID, scheduledApp.getScheduleId()); serviceProps.put(ScheduledApplication.APPLICATION_PID, scheduledApp.getAppPid()); ServiceRegistration sr = context.registerService(new String[] {ScheduledApplication.class.getName(), EVENT_HANDLER}, scheduledApp, serviceProps); scheduledApp.setServiceRegistration(sr); }
String filterString = apps[i].getEventFilter(); Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString); if (filter == null || filter.match(props)) apps[i].handleEvent(timerEvent); } catch (Throwable t) { String message = NLS.bind(Messages.scheduled_app_launch_error, apps[i].getAppPid()); Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
private static void loadSchedules(File schedulesData) throws IOException { ObjectInputStream in = null; try { in = new ObjectInputStream(new FileInputStream(schedulesData)); int dataVersion = in.readInt(); if (dataVersion != DATA_VERSION) return; int numScheds = in.readInt(); for (int i = 0; i < numScheds; i++) { String id = readString(in, false); String appPid = readString(in, false); String topic = readString(in, false); String eventFilter = readString(in, false); boolean recurring = in.readBoolean(); Map args = (Map) in.readObject(); EclipseScheduledApplication schedApp = new EclipseScheduledApplication(context, id, appPid, args, topic, eventFilter, recurring); addScheduledApp(schedApp); } } catch (InvalidSyntaxException e) { throw new IOException(e.getMessage()); } catch (NoClassDefFoundError e) { throw new IOException(e.getMessage()); } catch (ClassNotFoundException e) { throw new IOException(e.getMessage()); } finally { if (in != null) in.close(); } }
private Map getArguments(Event trigger) { Map result = args == null ? new HashMap() : getArguments(); result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic()))); return result; }
static void removeScheduledApp(EclipseScheduledApplication scheduledApp) { boolean removed; synchronized (scheduledApps) { removed = scheduledApps.remove(scheduledApp.getScheduleId()) != null; if (removed) { saveData(FILE_APPSCHEDULED); } } if (removed) synchronized (timerApps) { timerApps.remove(scheduledApp); } }
private static void saveSchedules(File schedulesData) throws IOException { ObjectOutputStream out = null; try { out = new ObjectOutputStream(new FileOutputStream(schedulesData)); out.writeInt(DATA_VERSION); out.writeInt(scheduledApps.size()); for (Iterator apps = scheduledApps.values().iterator(); apps.hasNext();) { EclipseScheduledApplication app = (EclipseScheduledApplication) apps.next(); writeStringOrNull(out, app.getScheduleId()); writeStringOrNull(out, app.getAppPid()); writeStringOrNull(out, app.getTopic()); writeStringOrNull(out, app.getEventFilter()); out.writeBoolean(app.isRecurring()); out.writeObject(app.getArguments()); } } finally { if (out != null) out.close(); } }
private static void addScheduledApp(EclipseScheduledApplication scheduledApp) { if (ScheduledApplication.TIMER_TOPIC.equals(scheduledApp.getTopic())) { synchronized (timerApps) { timerApps.add(scheduledApp); if (timerThread == null) startTimer(); } } scheduledApps.put(scheduledApp.getScheduleId(), scheduledApp); Hashtable serviceProps = new Hashtable(); if (scheduledApp.getTopic() != null) serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()}); if (scheduledApp.getEventFilter() != null) serviceProps.put(EventConstants.EVENT_FILTER, scheduledApp.getEventFilter()); serviceProps.put(ScheduledApplication.SCHEDULE_ID, scheduledApp.getScheduleId()); serviceProps.put(ScheduledApplication.APPLICATION_PID, scheduledApp.getAppPid()); ServiceRegistration sr = context.registerService(new String[] {ScheduledApplication.class.getName(), EVENT_HANDLER}, scheduledApp, serviceProps); scheduledApp.setServiceRegistration(sr); }
public synchronized void handleEvent(Event event) { try { if (removed) return; ApplicationDescriptor desc = getApplicationDescriptor(); if (desc == null) // in this case the application descriptor was removed; // we must return and keep the scheduled app incase the application comes back return; desc.launch(getArguments(event)); } catch (Exception e) { String message = NLS.bind(Messages.scheduled_app_launch_error, sr); Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, e, null)); return; // return here to avoid removing non-recurring apps when an error occurs } if (!isRecurring()) remove(); }
String filterString = apps[i].getEventFilter(); Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString); if (filter == null || filter.match(props)) apps[i].handleEvent(timerEvent); } catch (Throwable t) { String message = NLS.bind(Messages.scheduled_app_launch_error, apps[i].getAppPid()); Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
private static void loadSchedules(File schedulesData) throws IOException { ObjectInputStream in = null; try { in = new ObjectInputStream(new FileInputStream(schedulesData)); int dataVersion = in.readInt(); if (dataVersion != DATA_VERSION) return; int numScheds = in.readInt(); for (int i = 0; i < numScheds; i++) { String id = readString(in, false); String appPid = readString(in, false); String topic = readString(in, false); String eventFilter = readString(in, false); boolean recurring = in.readBoolean(); Map args = (Map) in.readObject(); EclipseScheduledApplication schedApp = new EclipseScheduledApplication(context, id, appPid, args, topic, eventFilter, recurring); addScheduledApp(schedApp); } } catch (InvalidSyntaxException e) { throw new IOException(e.getMessage()); } catch (NoClassDefFoundError e) { throw new IOException(e.getMessage()); } catch (ClassNotFoundException e) { throw new IOException(e.getMessage()); } finally { if (in != null) in.close(); } }
private Map getArguments(Event trigger) { Map result = args == null ? new HashMap() : getArguments(); result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic()))); return result; }
static void removeScheduledApp(EclipseScheduledApplication scheduledApp) { boolean removed; synchronized (scheduledApps) { removed = scheduledApps.remove(scheduledApp.getScheduleId()) != null; if (removed) { saveData(FILE_APPSCHEDULED); } } if (removed) synchronized (timerApps) { timerApps.remove(scheduledApp); } }
private static void saveSchedules(File schedulesData) throws IOException { ObjectOutputStream out = null; try { out = new ObjectOutputStream(new FileOutputStream(schedulesData)); out.writeInt(DATA_VERSION); out.writeInt(scheduledApps.size()); for (Iterator apps = scheduledApps.values().iterator(); apps.hasNext();) { EclipseScheduledApplication app = (EclipseScheduledApplication) apps.next(); writeStringOrNull(out, app.getScheduleId()); writeStringOrNull(out, app.getAppPid()); writeStringOrNull(out, app.getTopic()); writeStringOrNull(out, app.getEventFilter()); out.writeBoolean(app.isRecurring()); out.writeObject(app.getArguments()); } } finally { if (out != null) out.close(); } }