public synchronized Configuration createFactoryConfiguration(
      String factoryPid, String location, boolean checkLocation) throws IOException {
    if (checkLocation) {
      ConfigurationDictionary dictionary = configurationDictionaryManager.loadOne(factoryPid);

      String locationFactoryPidIsBoundTo = null;
      if (dictionary != null && dictionary.size() > 0) {
        locationFactoryPidIsBoundTo = dictionary.getLocation();
      }
      if (locationFactoryPidIsBoundTo != null && !location.equals(locationFactoryPidIsBoundTo)) {
        throw new SecurityException("Not owner of the factoryPid");
      }
    }
    // TODO should check and ensure availability
    String pid = factoryPid + "-" + UUID.randomUUID(8);
    return new ConfigurationImpl(this, location, factoryPid, pid);
  }
Ejemplo n.º 2
0
 /**
  * Constructor for repeating times
  *
  * @param info Information about the timer
  * @param delay Delay until first execution
  * @param fixedDelay Whether fixed delay mode should be used
  * @param period Period between execution
  * @param listener Listener that will get timeout events.
  */
 public ServletTimerImpl(
     Serializable info,
     long delay,
     boolean fixedDelay,
     long period,
     TimerListener listener,
     ApplicationSessionImpl appSession) {
   this.id = UUID.randomUUID(UUID_LENGTH);
   this.info = info;
   this.delay = delay;
   this.scheduledExecutionTime = delay + System.currentTimeMillis();
   this.fixedDelay = fixedDelay;
   this.period = period;
   this.listener = listener;
   this.appSession = appSession;
   this.numInvocations = 0;
   this.firstExecution = 0;
   this.repeatingTimer = (period > 0);
   this.timerTask = new RunnableTimerTask(this);
 }