private static String resolve(ServiceProfile<?> profile, String key, String value) { assert profile != null; assert key != null; assert value != null; try { return profile.getContext().getContextParameters().replace(value, true); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(MessageFormat.format( "Failed to resolve {0} ({1})", key, value), e); } }
/** * Creates a new context with system variables as context parameters. * @param classLoader current class loader * @return the created context object * @throws IllegalArgumentException if some parameters were {@code null} */ public static ProfileContext system(ClassLoader classLoader) { return new ProfileContext(classLoader, new VariableResolver(System.getenv())); }
/** * Returns the class loader which loaded this service class. * @return the class loader * @deprecated use {@link #getContext()} instead */ @Deprecated public ClassLoader getClassLoader() { return getContext().getClassLoader(); }
/** * Loads a YAESS profile from the specified properties. * @param properties source properties * @param classLoader the class loader to load the service class * @return the loaded profile * @throws IllegalArgumentException if the target profile is invalid, or parameters contain {@code null} * @deprecated use {@link #load(Properties, ProfileContext)} instead */ @Deprecated public static YaessProfile load(Properties properties, ClassLoader classLoader) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$ } if (classLoader == null) { throw new IllegalArgumentException("classLoader must not be null"); //$NON-NLS-1$ } return load(properties, ProfileContext.system(classLoader)); }
throw new IllegalArgumentException("classLoader must not be null"); //$NON-NLS-1$ return load(properties, prefix, serviceBaseClass, ProfileContext.system(classLoader));
private List<String> extractCommand(ServiceProfile<?> profile, String prefix) throws IOException { try { return ProcessUtil.extractCommandLineTokens( prefix, profile.getConfiguration(), profile.getContext().getContextParameters()); } catch (IllegalArgumentException e) { throw new IOException(MessageFormat.format( "Failed to resolve command line tokens ({0})", profile.getPrefix() + '.' + prefix + '*'), e); } }
env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context);
loaded = context.getClassLoader().loadClass(targetClassName); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(MessageFormat.format(
private List<String> extractCommand( ServiceProfile<?> profile, String prefix) throws IOException { try { return ProcessUtil.extractCommandLineTokens( prefix, profile.getConfiguration(), profile.getContext().getContextParameters()); } catch (IllegalArgumentException e) { throw new IOException(MessageFormat.format( "Failed to resolve command line tokens ({0})", profile.getPrefix() + '.' + prefix + '*'), e); } }
@Override protected void doConfigure(ServiceProfile<?> profile) throws InterruptedException, IOException { try { this.executor = ParallelJobExecutor.extract( profile.getPrefix(), profile.getConfiguration(), profile.getContext().getContextParameters()); } catch (IllegalArgumentException e) { throw new IOException(MessageFormat.format( "Failed to configure job scheduler: {0}", profile.getPrefix()), e); } }
@Override protected void configureExtension(ServiceProfile<?> profile) throws InterruptedException, IOException { try { this.executor = JschProcessExecutor.extract( profile.getPrefix(), profile.getConfiguration(), profile.getContext().getContextParameters()); } catch (IllegalArgumentException e) { throw new IOException(MessageFormat.format( "Failed to configure SSH: {0}", profile.getPrefix()), e); } catch (JSchException e) { throw new IOException(MessageFormat.format( "Failed to configure SSH: {0}", profile.getPrefix()), e); } }
@Override protected void configureExtension(ServiceProfile<?> profile) throws InterruptedException, IOException { try { this.executor = JschProcessExecutor.extract( profile.getPrefix(), profile.getConfiguration(), profile.getContext().getContextParameters()); } catch (IllegalArgumentException e) { throw new IOException(MessageFormat.format( "Failed to configure SSH: {0}", profile.getPrefix()), e); } catch (JSchException e) { throw new IOException(MessageFormat.format( "Failed to configure SSH: {0}", profile.getPrefix()), e); } }
if (resolve) { try { string = getContext().getContextParameters().replace(string, true); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(MessageFormat.format(
String unresolved = entry.getValue(); try { String value = profile.getContext().getContextParameters().replace(unresolved, true); resolved.put(key, value); } catch (IllegalArgumentException e) {
String unresolved = entry.getValue(); try { String value = profile.getContext().getContextParameters().replace(unresolved, true); resolved.put(key, value); } catch (IllegalArgumentException e) {