@Override protected void performInitialize() throws Exception { LimbusProperties properties = new LimbusProperties(filesystem, TaskSchedulerImpl.class, true, false); int threadCount = properties.getInt(PERIODIC_TASKS_THREAD_POOL_SIZE); this.shutdownTimeout = properties.getLong(SHUTDOWN_TIMEOUT); this.shutdownTimeoutUnit = properties.getEnum(SHUTDOWN_TIMEOUT_UNIT, TimeUnit.class); // extra scheduler for cyclical call of commands so that the scheduler can be stopped separately scheduler = Executors.newScheduledThreadPool(threadCount, this); this.tasks = new ConcurrentHashMap<Task, TaskExecution>(); }
/** * The configuration key 'contextClassLoaderFilter' specifies a regexp which is used to filter the thread context * classloaders. Only matching context classloaders are logged on permission request. * * @return Returns the configuration value for key 'contextClassLoaderFilter' */ private String contextClassLoaderFilter() { return properties.getProperty("contextClassLoaderFilter"); }
private void _checkKey(String key) { if (!containsKey(key)) { throw new RuntimeException(String.format("Configuration key '%s' not available.", key)); } }
public float getFloat(String key) { Lang.denyNull("key", key); _checkKey(key); try { return Float.parseFloat(getProperty(key)); } catch (Exception e) { throw new RuntimeException(String.format("Configuration key '%s' cannot be parsed.", key)); } }
/** * Saves the configuration keys that differ from the default configuration to the configuration file in the * filesystem. Note: If the effective properties do not differ from the default values, nothing is written to file. * * @throws Exception * Thrown if the configuration file cannot be written. */ public void storeConfiguration() throws Exception { Properties defaults = getConfigurationDefault(false, forClassName); Properties effectiveDifferences = getEffectiveDifferences(defaults, properties); if (!effectiveDifferences.isEmpty()) { // Only write the effective differences between the default and the effective properties String filePath = getFilePath(forClassName); try (OutputStream output = filesystem.createFile(filePath)) { effectiveDifferences.store(output, String.format("Current configuration of %s.", forClassName)); } catch (Exception e) { throw new Exception(String.format("Cannot write configuration for %s.", filePath), e); } } }
Properties defaultProperties = getConfigurationDefault(failOnNoDefault, forClassName); String filePath = getFilePath(forClassName); if (filesystem.hasFile(filePath)) { URL file = filesystem.getFile(filePath); fileProperties = loadProperties(file, failOnNoFile); } else { if (failOnNoFile) {
private void initialize() throws RuntimeException { try { this.properties = new LimbusProperties(filesystem, PluginClassLoader.class, true, false); } catch (Exception e) { throw new RuntimeException("Cannot get properties for plugin classloader.", e); } // Collect the set of permissions required to access every code source within this classpath for (URL url : urls) { try { Permission permission = url.openConnection() .getPermission(); if (permission != null) { codeSourcePermissions.add(permission); } } catch (IOException e) { throw new RuntimeException( String.format("Cannot request required permissions to connect to the URL %s", url.toString()), e); } } }
private boolean logDeny() { return properties.getBoolean("logDeny"); } }
public boolean getBoolean(String key) { Lang.denyNull("key", key); _checkKey(key); try { return Boolean.parseBoolean(getProperty(key)); } catch (Exception e) { throw new RuntimeException(String.format("Configuration key '%s' cannot be parsed.", key)); } }
public LimbusSecurityManager(LimbusFileService filesystem) { Lang.denyNull("filesystem", filesystem); try { this.properties = new LimbusProperties(filesystem, LimbusSecurityManager.class, true, false); } catch (Exception e) { throw new LimbusSecurityException( "Cannot initialize Limbus Security Manager due to missing default configuration."); } init(); }
private boolean nullOutStaticFields() { return properties.getBoolean("nullOutStaticFields"); }
public double getDouble(String key) { Lang.denyNull("key", key); _checkKey(key); try { return Double.parseDouble(getProperty(key)); } catch (Exception e) { throw new RuntimeException(String.format("Configuration key '%s' cannot be parsed.", key)); } }
@Override protected void performInitialize() throws LimbusException { try { // Create the properties this.properties = new LimbusProperties(filesystem, getClass(), true, false); // Register as a deployment listener container.addDeploymentListener(this); // When created by the container, clean old deployments cleanWorkDirectory(); // Make sure work folder is available getCreateOrFailWorkDirectory(); // Make sure deploy folder is available getCreateOrFailDeployDirectory(); // Start hot deploy listener startFileDeployWatchService(); // Deploy all artifacts from deploy directory. deployAll(); } catch (Exception e) { throw new LimbusException("Cannot initialize Limbus Deploy Service.", e); } }
/** * This is the subfolder for deployed classpath access by the limbus container. Files here are assumed to be readable * exclusively by the container. */ private String workFolder() { checkState(); return this.properties.getProperty("work-folder"); }
private boolean dumpDenyThreadStack() { return properties.getBoolean("dumpDenyThreadStack"); }
public int getInt(String key) { Lang.denyNull("key", key); _checkKey(key); try { return Integer.parseInt(getProperty(key)); } catch (Exception e) { throw new RuntimeException(String.format("Configuration key '%s' cannot be parsed.", key)); } }
/** * Reads the subfolder for hot deploy from the properties. Files here are intended to be added and removed to signal a * (un)deploy via filesystem. */ private String deployFolder() { checkState(); return this.properties.getProperty("deploy-folder"); }
private boolean dumpRequestThreadStack() { return properties.getBoolean("dumpRequestThreadStack"); }
public long getLong(String key) { Lang.denyNull("key", key); _checkKey(key); try { return Long.parseLong(getProperty(key)); } catch (Exception e) { throw new RuntimeException(String.format("Configuration key '%s' cannot be parsed.", key)); } }
private boolean logRequests() { return properties.getBoolean("logRequests"); }