Codota Logo
ServiceProfile
Code IndexAdd Codota to your IDE (free)

How to use
ServiceProfile
in
com.asakusafw.yaess.core

Best Java code snippets using com.asakusafw.yaess.core.ServiceProfile (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: asakusafw/asakusafw

@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);
  }
}
origin: asakusafw/asakusafw

private void checkPrefix(ServiceProfile<?> profile, String prefix) {
  assert profile != null;
  assert prefix != null;
  if (profile.getPrefix().equals(prefix) == false) {
    throw new IllegalArgumentException(MessageFormat.format(
        "Profile \"{1}\" is invalid, this must be \"{0}\" ({2})",
        prefix,
        profile.getPrefix(),
        profile.getServiceClass().getName()));
  }
}
origin: asakusafw/asakusafw

/**
 * Creates a new instance.
 * The created service will automatically {@link Service#configure(ServiceProfile) configured}
 * by using this profile.
 * @param variables the variable resolver
 * @return the created instance.
 * @throws InterruptedException if interrupted in configuring the target service
 * @throws IOException if failed to create or configure the service
 * @deprecated use {@link #newInstance()} instead
 */
@Deprecated
public T newInstance(VariableResolver variables) throws InterruptedException, IOException {
  if (variables == null) {
    throw new IllegalArgumentException("variables must not be null"); //$NON-NLS-1$
  }
  return newInstance();
}
origin: asakusafw/asakusafw

private void configureResourceId(ServiceProfile<?> profile) {
  assert profile != null;
  String override = profile.getConfiguration(ExecutionScriptHandler.KEY_RESOURCE, false, true);
  if (override == null) {
    LOG.debug("resourceId is not override in {}",
        profile.getPrefix());
    resourceId = ExecutionScriptHandler.DEFAULT_RESOURCE_ID;
  } else {
    LOG.debug("resourceId is overriden in {}: {}",
        profile.getPrefix(),
        override);
    resourceId = override;
  }
}
origin: asakusafw/asakusafw

/**
 * Returns the target configuration.
 * @param key the configuration key
 * @param mandatory whether the configuration is mandatory
 * @param resolve whether resolves the configuration
 * @return the corresponded configuration, or {@code null} if is not defined/empty
 * @throws IllegalArgumentException if some parameters were {@code null}
 * @since 0.4.0
 */
public String getConfiguration(String key, boolean mandatory, boolean resolve) {
  if (key == null) {
    throw new IllegalArgumentException("key must not be null"); //$NON-NLS-1$
  }
  String value = getConfiguration().get(key);
  return normalize(key, value, mandatory, resolve);
}
origin: asakusafw/asakusafw

private Map<String, ExecutionScriptHandler<T>> getDelegations(
    ServiceProfile<?> profile) throws IOException, InterruptedException {
  assert profile != null;
  Map<String, String> conf = profile.getConfiguration();
  Set<String> keys = PropertiesUtil.getChildKeys(conf, "", ".");
  keys.remove(PREFIX_CONF);
    throw new IOException(MessageFormat.format(
        "Default profile for multidispatch plugin is not defined: {0}.{1}",
        profile.getPrefix(),
        PREFIX_DEFAULT));
    String key = profile.getPrefix() + "." + entry.getKey();
    String value = entry.getValue();
    properties.setProperty(key, value);
    String subPrefix = profile.getPrefix() + "." + key;
    ServiceProfile<? extends ExecutionScriptHandler<T>> subProfile;
    try {
      subProfile = ServiceProfile.load(
          properties,
          subPrefix,
          handlerKind,
          profile.getContext());
    } catch (IllegalArgumentException e) {
      throw new IOException(MessageFormat.format(
    ExecutionScriptHandler<T> subInstance = subProfile.newInstance();
    results.put(key, subInstance);
origin: asakusafw/asakusafw

@Override
public final void configure(ServiceProfile<?> profile) throws InterruptedException, IOException {
  try {
    doConfigure(profile);
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure \"{0}\" ({1})",
        profile.getPrefix(),
        profile.getPrefix()), e);
  }
}
origin: asakusafw/asakusafw

@Override
public void configure(ServiceProfile<?> profile) throws IOException, InterruptedException {
  this.prefix = profile.getPrefix();
  try {
    this.confDirectory = getConfDirectory(profile);
    this.delegations = getDelegations(profile);
    this.forceSetUp = profile.getConfiguration(KEY_SETUP, false, true);
    this.forceCleanUp = profile.getConfiguration(KEY_CLEANUP, false, true);
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure \"{0}\" ({1})",
        profile.getPrefix(),
        profile.getServiceClass().getName()), e);
  }
  if (forceSetUp != null && delegations.containsKey(forceSetUp) == false) {
    throw new IOException(MessageFormat.format(
        "Failed to detect setUp target: \"{2}\" in {0}.{1}",
        profile.getPrefix(),
        KEY_SETUP,
        forceSetUp));
  }
  if (forceCleanUp != null && delegations.containsKey(forceCleanUp) == false) {
    throw new IOException(MessageFormat.format(
        "Failed to detect cleanUp target: \"{2}\" in {0}.{1}",
        profile.getPrefix(),
        KEY_CLEANUP,
        forceCleanUp));
  }
}
origin: asakusafw/asakusafw

    throw new IllegalArgumentException(MessageFormat.format(
        "The profile \"{0}\" must not be defined",
        getPrefix() + '.' + key));
  } else {
    return null;
if (resolve) {
  try {
    string = getContext().getContextParameters().replace(string, true);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(MessageFormat.format(
        "Failed to resolve the profile \"{0}\": {1}",
        getPrefix() + '.' + key,
        string), e);
    throw new IllegalArgumentException(MessageFormat.format(
        "The profile \"{0}\" must not be defined",
        getPrefix() + '.' + key));
  } else {
    return null;
origin: asakusafw/asakusafw

  /**
   * Merges this profile into the specified properties.
   * If properties already contains entries related to this profile,
   * then this method will overwrite them.
   * @param properties target properties
   * @throws IllegalArgumentException if some parameters were {@code null}
   */
  public void storeTo(Properties properties) {
    if (properties == null) {
      throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$
    }
    properties.setProperty(prefix, getServiceClass().getName());
    for (Map.Entry<String, String> entry : getConfiguration().entrySet()) {
      properties.setProperty(prefix + '.' + entry.getKey(), entry.getValue());
    }
  }
}
origin: asakusafw/asakusafw

private static long extractLong(
    ServiceProfile<?> profile,
    Map<String, String> conf,
    String key,
    long defaultValue) {
  assert profile != null;
  assert conf != null;
  assert key != null;
  String value = profile.normalize(key, conf.remove(key), false, true);
  if (value == null) {
    return defaultValue;
  }
  try {
    return Long.parseLong(value);
  } catch (RuntimeException e) {
    throw new IllegalArgumentException(MessageFormat.format(
        "{0}.{1} must be an integer ({2})",
        profile.getPrefix(),
        key,
        value));
  }
}
origin: asakusafw/asakusafw

private void configureVersion(ServiceProfile<?> profile) {
  assert profile != null;
  this.version = profile.getConfiguration(KEY_VERSION, true, false);
}
origin: asakusafw/asakusafw

/**
 * 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();
}
origin: asakusafw/asakusafw

  ServiceProfile.load(properties, PREFIX_CORE, CoreProfile.class, context);
ServiceProfile<ExecutionMonitorProvider> monitors =
  ServiceProfile.load(properties, PREFIX_MONITOR, ExecutionMonitorProvider.class, context);
ServiceProfile<ExecutionLockProvider> locks =
  ServiceProfile.load(properties, PREFIX_LOCK, ExecutionLockProvider.class, context);
ServiceProfile<JobScheduler> scheduler =
  ServiceProfile.load(properties, PREFIX_SCHEDULER, JobScheduler.class, context);
ServiceProfile<HadoopScriptHandler> hadoopHandler =
  ServiceProfile.load(properties, PREFIX_HADOOP, HadoopScriptHandler.class, context);
List<ServiceProfile<CommandScriptHandler>> commandHandlers = new ArrayList<>();
for (String commandHandlerPrefix : PropertiesUtil.getChildKeys(properties, GROUP_PREFIX_COMMAND, ".")) {
  ServiceProfile<CommandScriptHandler> profile =
    ServiceProfile.load(properties, commandHandlerPrefix, CommandScriptHandler.class, context);
  commandHandlers.add(profile);
origin: asakusafw/asakusafw

private void configureStepUnit(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String stepUnitString = profile.getConfiguration(KEY_STEP_UNIT, false, true);
  if (stepUnitString == null) {
    LOG.debug("{} is not defined in {}", KEY_STEP_UNIT, profile.getPrefix());
  } else {
    try {
      stepUnit = Double.parseDouble(stepUnitString);
    } catch (NumberFormatException e) {
      throw new IOException(MessageFormat.format(
          "{0}.{1} must be a number: {2}",
          profile.getPrefix(),
          KEY_STEP_UNIT,
          stepUnitString));
    }
  }
}
origin: asakusafw/asakusafw

@Override
public final void configure(ServiceProfile<?> profile) throws InterruptedException, IOException {
  try {
    doConfigure(profile);
  } catch (IllegalArgumentException e) {
    throw new IOException(MessageFormat.format(
        "Failed to configure \"{0}\" ({1})",
        profile.getPrefix(),
        profile.getPrefix()), e);
  }
}
origin: asakusafw/asakusafw

private File prepareDirectory(ServiceProfile<?> profile) throws IOException {
  assert profile != null;
  String path = profile.getConfiguration(KEY_DIRECTORY, true, true);
  File dir = new File(path);
  if (dir.isDirectory() == false && dir.mkdirs() == false) {
    throw new IOException(MessageFormat.format(
        "Failed to prepare lock directory: {0}",
        dir.getAbsolutePath()));
  }
  return dir;
}
origin: asakusafw/asakusafw

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);
  }
}
origin: asakusafw/asakusafw

  throw new IllegalArgumentException("classLoader must not be null"); //$NON-NLS-1$
return load(properties, prefix, serviceBaseClass, ProfileContext.system(classLoader));
origin: asakusafw/asakusafw

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);
  }
}
com.asakusafw.yaess.coreServiceProfile

Javadoc

A common service profile format for configurable instances.
 
<prefix> = <fully qualified class name which extends T> 
<prefix>.<key1> = <value1> 
<prefix>.<key2> = <value2> 
... 

Most used methods

  • getConfiguration
    Returns the target configuration.
  • getContext
    Returns the current profile context.
  • getPrefix
    Returns the key prefix of this profile.
  • getServiceClass
    Returns the service class.
  • load
    Loads a service profile with the specified key prefix.
  • newInstance
    Creates a new instance. The created service will automatically Service#configure(ServiceProfile)by u
  • normalize
    Normalizes the configuration value.
  • <init>
    Creates a new instance.

Popular in Java

  • Running tasks concurrently on multiple threads
  • findViewById (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now