Codota Logo
SingletonLaContainer.getComponent
Code IndexAdd Codota to your IDE (free)

How to use
getComponent
method
in
org.lastaflute.di.core.SingletonLaContainer

Best Java code snippets using org.lastaflute.di.core.SingletonLaContainer.getComponent (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: org.dbflute.utflute/utflute-lastaflute

/** {@inheritDoc} */
protected boolean hasComponent(Class<?> type) { // user method
  try {
    SingletonLaContainer.getComponent(type);
    return true;
  } catch (ComponentNotFoundException ignored) {
    return false;
  }
}
origin: org.dbflute.utflute/utflute-lastaflute

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
protected <COMPONENT> COMPONENT getComponent(String name) { // user method
  return (COMPONENT) SingletonLaContainer.getComponent(name);
}
origin: org.dbflute.utflute/utflute-lasta-di

/** {@inheritDoc} */
protected boolean hasComponent(Class<?> type) { // user method
  try {
    SingletonLaContainer.getComponent(type);
    return true;
  } catch (ComponentNotFoundException ignored) {
    return false;
  }
}
origin: lastaflute/lastaflute

/**
 * @param componentName The component name to find. (NotNull)
 * @return The found component. (NotNull)
 * @throws ComponentNotFoundException When the component is not found by the type.
 * @throws TooManyRegistrationComponentException When the component key is related to plural components.
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
public static <COMPONENT> COMPONENT pickupComponentByName(String componentName) {
  final COMPONENT component = SingletonLaContainer.getComponent(componentName); // variable for generic
  return component;
}
origin: org.dbflute.utflute/utflute-lasta-di

/** {@inheritDoc} */
protected <COMPONENT> COMPONENT getComponent(Class<COMPONENT> type) { // user method
  return SingletonLaContainer.getComponent(type);
}
origin: org.lastaflute/lastaflute

/**
 * @param componentType The component type to find. (NotNull)
 * @return The found component. (NotNull)
 * @throws ComponentNotFoundException When the component is not found by the type.
 * @throws TooManyRegistrationComponentException When the component key is related to plural components.
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
public static <COMPONENT> COMPONENT getComponent(Class<COMPONENT> componentType) { // most frequently used
  return (COMPONENT) SingletonLaContainer.getComponent(componentType);
}
origin: org.lastaflute/lastaflute

/**
 * @param componentName The component name to find. (NotNull)
 * @return The found component. (NotNull)
 * @throws ComponentNotFoundException When the component is not found by the type.
 * @throws TooManyRegistrationComponentException When the component key is related to plural components.
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
public static <COMPONENT> COMPONENT pickupComponentByName(String componentName) {
  final COMPONENT component = SingletonLaContainer.getComponent(componentName); // variable for generic
  return component;
}
origin: org.dbflute.utflute/utflute-lasta-di

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
protected <COMPONENT> COMPONENT getComponent(String name) { // user method
  return (COMPONENT) SingletonLaContainer.getComponent(name);
}
origin: org.dbflute.utflute/utflute-lasta-di

/** {@inheritDoc} */
protected boolean hasComponent(String name) { // user method
  try {
    SingletonLaContainer.getComponent(name);
    return true;
  } catch (ComponentNotFoundException ignored) {
    return false;
  }
}
origin: org.dbflute.utflute/utflute-lastaflute

/** {@inheritDoc} */
protected boolean hasComponent(String name) { // user method
  try {
    SingletonLaContainer.getComponent(name);
    return true;
  } catch (ComponentNotFoundException ignored) {
    return false;
  }
}
origin: lastaflute/lastaflute

/**
 * @param componentType The component type to find. (NotNull)
 * @return The found component. (NotNull)
 * @throws ComponentNotFoundException When the component is not found by the type.
 * @throws TooManyRegistrationComponentException When the component key is related to plural components.
 * @throws CyclicReferenceComponentException When the components refers each other.
 */
public static <COMPONENT> COMPONENT getComponent(Class<COMPONENT> componentType) { // most frequently used
  return (COMPONENT) SingletonLaContainer.getComponent(componentType);
}
origin: org.dbflute.utflute/utflute-lastaflute

/** {@inheritDoc} */
protected <COMPONENT> COMPONENT getComponent(Class<COMPONENT> type) { // user method
  return SingletonLaContainer.getComponent(type);
}
origin: codelibs/elasticsearch-river-web

@PostConstruct
public void init() {
  esClient = SingletonLaContainer.getComponent(EsClient.class);
  riverConfigManager = SingletonLaContainer.getComponent(RiverConfigManager.class);
}
origin: codelibs/elasticsearch-river-web

private Object executeScript(final String lang, final String script, final String scriptTypeValue, final Map<String, Object> vars) {
  ScriptType scriptType;
  if (ScriptType.FILE.toString().equalsIgnoreCase(scriptTypeValue)) {
    scriptType = ScriptType.FILE;
  } else if (ScriptType.INDEXED.toString().equalsIgnoreCase(scriptTypeValue)) {
    scriptType = ScriptType.INDEXED;
  } else {
    scriptType = ScriptType.INLINE;
  }
  vars.put("logger", logger);
  final ScriptService scriptService = SingletonLaContainer.getComponent(ScriptService.class);
  return scriptService.execute(lang, script, scriptType, vars);
}
origin: codelibs/elasticsearch-river-web

protected String loadCharset(final InputStream inputStream, final int preloadSize) {
  BufferedInputStream bis = null;
  String encoding = null;
  try {
    bis = new BufferedInputStream(inputStream);
    final byte[] buffer = new byte[preloadSize];
    final int size = bis.read(buffer);
    if (size != -1) {
      final String content = new String(buffer, 0, size);
      encoding = parseCharset(content);
    }
  } catch (final IOException e) {
    throw new CrawlingAccessException("Could not load a content.", e);
  }
  try {
    final EncodingHelper encodingHelper = SingletonLaContainer.getComponent(EncodingHelper.class);
    encoding = encodingHelper.normalize(encoding);
  } catch (final Exception e) {
    // NOP
  }
  return encoding;
}
origin: codelibs/elasticsearch-river-web

public static Object execute(final Map<String, Object> scriptSettings, final String target, final Consumer<Map<String, Object>> vars) {
  final String script = SettingsUtils.get(scriptSettings, target);
  final String lang = SettingsUtils.get(scriptSettings, "lang", WebRiverConstants.DEFAULT_SCRIPT_LANG);
  final String scriptTypeValue = SettingsUtils.get(scriptSettings, "script_type", "inline");
  ScriptType scriptType;
  if (ScriptType.FILE.toString().equalsIgnoreCase(scriptTypeValue)) {
    scriptType = ScriptType.FILE;
  } else if (ScriptType.INDEXED.toString().equalsIgnoreCase(scriptTypeValue)) {
    scriptType = ScriptType.INDEXED;
  } else {
    scriptType = ScriptType.INLINE;
  }
  if (StringUtil.isNotBlank(script)) {
    final Map<String, Object> localVars = new HashMap<String, Object>();
    vars.accept(localVars);
    try {
      final ScriptService scriptService = SingletonLaContainer.getComponent(ScriptService.class);
      final Object result = scriptService.execute(lang, script, scriptType, localVars);
      if (logger.isDebugEnabled()) {
        logger.debug("[{}] \"{}\" => {}", target, script, result);
      }
      return result;
    } catch (final Exception e) {
      logger.warn("Failed to execute script: " + script, e);
    }
  }
  return null;
}
origin: codelibs/elasticsearch-river-web

public static void main(final String[] args) {
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      synchronized (this) {
        SingletonLaContainerFactory.destroy();
      }
    }
  });
  SingletonLaContainerFactory.init();
  final RiverWeb riverWeb = SingletonLaContainer.getComponent(RiverWeb.class);
  final CmdLineParser parser = new CmdLineParser(riverWeb, ParserProperties.defaults().withUsageWidth(80));
  try {
    parser.parseArgument(args);
  } catch (final Exception e) {
    parser.printUsage(System.out);
    exitMethod.accept(1);
    return;
  }
  try {
    exitMethod.accept(riverWeb.execute());
  } catch (final Exception e) {
    riverWeb.print(e.getMessage());
    exitMethod.accept(1);
    logger.error("Failed to process your request.", e);
  } finally {
    SingletonLaContainerFactory.destroy();
  }
}
origin: codelibs/elasticsearch-river-web

  return crawl(SingletonLaContainer.getComponent(Crawler.class), configId, sessionId);
} else {
  final String configIndex = config.getConfigIndex();
                print("Config %s is started with Session %s.", configId, sessionId);
                try {
                  crawl(SingletonLaContainer.getComponent(Crawler.class), configId.toString(), sessionId);
                } finally {
                  print("Config %s is finished.", configId);
origin: codelibs/elasticsearch-river-web

  @Override
  protected boolean isContentUpdated(final CrawlerClient client, final UrlQueue<?> urlQueue) {
    final RiverConfigManager riverConfigManager = SingletonLaContainer.getComponent(RiverConfigManager.class);
    final RiverConfig riverConfig = riverConfigManager.get(crawlerContext.getSessionId());
    if (riverConfig.isIncremental()) {
      final EsClient esClient = SingletonLaContainer.getComponent(EsClient.class);
      try {
        final SearchResponse response = esClient.prepareSearch(riverConfig.getIndex()).setTypes(riverConfig.getType())
            .setQuery(QueryBuilders.termQuery("url", urlQueue.getUrl())).addField("lastModified")
            .addSort("lastModified", SortOrder.DESC).execute().actionGet();
        final SearchHits hits = response.getHits();
        if (hits.getTotalHits() > 0) {
          final SearchHitField lastModifiedField = hits.getAt(0).getFields().get("lastModified");
          if (lastModifiedField != null) {
            final Date lastModified = ConversionUtil.convert(lastModifiedField.getValue(), Date.class);
            if (lastModified != null) {
              urlQueue.setLastModified(lastModified.getTime());
            }
          }
        }
      } catch (final Exception e) {
        logger.debug("Failed to retrieve lastModified.", e);
      }
    }
    return super.isContentUpdated(client, urlQueue);
  }
}
origin: codelibs/elasticsearch-river-web

final List<String> wdUrlList = (List<String>) crawlSettings.get("web_driver_urls");
if (wdUrlList != null) {
  CrawlerClient client = SingletonLaContainer.getComponent("webDriverClient");
  wdUrlList.stream().forEach(regex -> clientFactory.addClient(regex, client, 0));
  final EsUrlFilterService urlFilterService = SingletonLaContainer.getComponent(EsUrlFilterService.class);
  final EsUrlQueueService urlQueueService = SingletonLaContainer.getComponent(EsUrlQueueService.class);
  final EsDataService dataService = SingletonLaContainer.getComponent(EsDataService.class);
org.lastaflute.di.coreSingletonLaContainergetComponent

Popular methods of SingletonLaContainer

    Popular in Java

    • Making http post requests using okhttp
    • addToBackStack (FragmentTransaction)
    • runOnUiThread (Activity)
    • onCreateOptionsMenu (Activity)
    • BorderLayout (java.awt)
      A border layout lays out a container, arranging and resizing its components to fit in five regions:
    • ByteBuffer (java.nio)
      A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
    • ImageIO (javax.imageio)
    • Filter (javax.servlet)
      A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
    • JTextField (javax.swing)
    • IsNull (org.hamcrest.core)
      Is the value null?
    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