private static void initConfiguration() { closeConfiguration(); // just incase Filter filter = null; try { filter = context.createFilter(FILTER_PREFIX + PROP_CONFIG_AREA + "))"); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } configTracker = new ServiceTracker(context, filter, new AppPersistence()); configTracker.open(); }
static void start(BundleContext bc) { context = bc; shutdown = false; initConfiguration(); }
private boolean isPersistentlyLocked() { return AppPersistence.isLocked(this); }
static void stop() { shutdown = true; stopTimer(); if (storageManager != null) { storageManager.close(); storageManager = null; } closeConfiguration(); context = null; }
/** * Used by {@link ScheduledApplication} to persistently schedule an application launch * @param descriptor * @param arguments * @param topic * @param eventFilter * @param recurring * @return the scheduled application * @throws InvalidSyntaxException * @throws ApplicationException */ public static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, String scheduleId, Map arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException, ApplicationException { if (!scheduling && !checkSchedulingSupport()) throw new ApplicationException(ApplicationException.APPLICATION_SCHEDULING_FAILED, "Cannot support scheduling without org.osgi.service.event package"); //$NON-NLS-1$ // check the event filter for correct syntax context.createFilter(eventFilter); EclipseScheduledApplication result; synchronized (scheduledApps) { result = new EclipseScheduledApplication(context, getNextScheduledID(scheduleId), descriptor.getApplicationId(), arguments, topic, eventFilter, recurring); addScheduledApp(result); saveData(FILE_APPSCHEDULED); } return result; }
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()); } }
return true; if (FILE_APPLOCKS.equals(fileName)) loadLocks(dataFile); else if (FILE_APPSCHEDULED.equals(fileName)) loadSchedules(dataFile); } catch (IOException e) { return false;
arguments = checkArgs(arguments, true); return AppPersistence.addScheduledApp(this, scheduleId, arguments, topic, eventFilter, recurring);
/** * Used by {@link ScheduledApplication} to persistently schedule an application launch * @param descriptor * @param arguments * @param topic * @param eventFilter * @param recurring * @return the scheduled application * @throws InvalidSyntaxException * @throws ApplicationException */ public static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, String scheduleId, Map arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException, ApplicationException { if (!scheduling && !checkSchedulingSupport()) throw new ApplicationException(ApplicationException.APPLICATION_SCHEDULING_FAILED, "Cannot support scheduling without org.osgi.service.event package"); //$NON-NLS-1$ // check the event filter for correct syntax context.createFilter(eventFilter); EclipseScheduledApplication result; synchronized (scheduledApps) { result = new EclipseScheduledApplication(context, getNextScheduledID(scheduleId), descriptor.getApplicationId(), arguments, topic, eventFilter, recurring); addScheduledApp(result); saveData(FILE_APPSCHEDULED); } return result; }
static void stop() { shutdown = true; stopTimer(); if (storageManager != null) { storageManager.close(); storageManager = null; } closeConfiguration(); context = 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(); } }
return true; if (FILE_APPLOCKS.equals(fileName)) loadLocks(dataFile); else if (FILE_APPSCHEDULED.equals(fileName)) loadSchedules(dataFile); } catch (IOException e) { return false;
arguments = checkArgs(arguments, true); return AppPersistence.addScheduledApp(this, scheduleId, arguments, topic, eventFilter, recurring);
/** * Used by {@link ScheduledApplication} to persistently schedule an application launch * @param descriptor * @param arguments * @param topic * @param eventFilter * @param recurring * @return the scheduled application * @throws InvalidSyntaxException * @throws ApplicationException */ public static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, String scheduleId, Map arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException, ApplicationException { if (!scheduling && !checkSchedulingSupport()) throw new ApplicationException(ApplicationException.APPLICATION_SCHEDULING_FAILED, "Cannot support scheduling without org.osgi.service.event package"); //$NON-NLS-1$ // check the event filter for correct syntax context.createFilter(eventFilter); EclipseScheduledApplication result; synchronized (scheduledApps) { result = new EclipseScheduledApplication(context, getNextScheduledID(scheduleId), descriptor.getApplicationId(), arguments, topic, eventFilter, recurring); addScheduledApp(result); saveData(FILE_APPSCHEDULED); } return result; }
private static void initConfiguration() { closeConfiguration(); // just incase Filter filter = null; try { filter = context.createFilter(FILTER_PREFIX + PROP_CONFIG_AREA + "))"); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } configTracker = new ServiceTracker(context, filter, new AppPersistence()); configTracker.open(); }
static void stop() { shutdown = true; stopTimer(); if (storageManager != null) { storageManager.close(); storageManager = null; } closeConfiguration(); context = 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(); } }
return true; if (FILE_APPLOCKS.equals(fileName)) loadLocks(dataFile); else if (FILE_APPSCHEDULED.equals(fileName)) loadSchedules(dataFile); } catch (IOException e) { return false;