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

How to use
Configuration
in
org.javalite.activejdbc

Best Java code snippets using org.javalite.activejdbc.Configuration (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: javalite/activejdbc

Registry() {
  statisticsQueue = configuration.collectStatistics()
      ? new StatisticsQueue(configuration.collectStatisticsOnHold())
      : null;
}
origin: javalite/activejdbc

QueryCache() {
  String cacheManagerClass = Registry.instance().getConfiguration().getCacheManager();
  if(cacheManagerClass != null){
    try{
      Class cmc = Class.forName(cacheManagerClass);
      cacheManager = (CacheManager)cmc.newInstance();
      enabled = true;
    }catch(InitException e){
      throw e;
    }catch(Exception e){
      throw new InitException("Failed to initialize a CacheManager. Please, ensure that the property " +
          "'cache.manager' points to correct class which extends '" + CacheManager.class.getName()
          + "' and provides a default constructor.", e);
    }
  }else{
    cacheManager = new NopeCacheManager();
  }
}
origin: javalite/activejdbc

public static void log(Logger logger, LogLevel logLevel, String log, Object param1, Object param2) {
  if(Configuration.hasActiveLogger()) {
    Configuration.getActiveLogger().log(logger, logLevel, log, param1, param2);
  }else {
    if (matches(logger, logLevel, log)) {
      switch (logLevel){
        case DEBUG:
          logger.debug(log, param1, param2);
          break;
        case INFO:
          logger.info(log, param1, param2);
          break;
        case WARNING:
          logger.warn(log, param1, param2);
          break;
        case ERROR:
          logger.error(log, param1, param2);
          break;
        default:
      }
    }
  }
}
origin: javalite/activejdbc

/**
 * Finds a connection {@link ConnectionSpec} that corresponds to system properties,
 * environment variables of <code>database.properties</code> configuration, whichever is found first.
 * Configuration of system properties overrides environment variables, which overrides
 * <code>database.properties</code>.
 *
 * @return {@link ConnectionSpec} used by {@link DB#open()} to open a "default" connection, as well as {@link Base#open()} methods.
 */
public  ConnectionSpec getCurrentConnectionSpec(){
  return getConnectionSpec(getEnvironment());
}
origin: org.javalite/activejdbc

public Dialect getDialect(MetaModel mm){
  return getDialect(mm.getDbType());
}
origin: javalite/activejdbc

private static void collectStatistics(String query, long time, boolean cacheHit) {
  if (Registry.instance().getConfiguration().collectStatistics() && !cacheHit) {
    Registry.instance().getStatisticsQueue().enqueue(new QueryExecutionEvent(query, time));
  }
}
origin: javalite/activejdbc

/**
 * This method will open a connection defined in the file 'database.properties' located at
 * root of classpath. The connection picked up from the file is defined by <code>ACTIVE_ENV</code>
 * environment variable or <code>active_env</code> system property.
 * If this variable is not defined, it defaults to 'development' environment.
 *
 * <p></p>
 * If there is JUnit on classpath, this method assumes it is running under test, and defaults to 'test'.
 *
 * @see Configuration#getEnvironment()
 */
public DB open(){
  Configuration config = Registry.instance().getConfiguration();
  ConnectionSpec spec = config.getCurrentConnectionSpec();
  if(spec == null){
    throw new DBException("Could not find configuration in a property file for environment: " + config.getEnvironment() +
        ". Are you sure you have a database.properties file configured?");
  }
  return open(spec);
}
origin: com.github.tchoulihan/activejdbc

protected static void findModels(String dbName) throws IOException, ClassNotFoundException {
  //this is for static instrumentation. In case of dynamic, the  modelClassNames will already be filled.
  List<String> models = Registry.instance().getConfiguration().getModelNames(dbName);
  if (models != null && !models.isEmpty()) {
    for (String model : models) {
      modelFound(model);
    }
  } else {
    throw new InitException("you are trying to work with models, but no models are found. Maybe you have " +
        "no models in project, or you did not instrument the models. It is expected that you have " +
        "a file activejdbc_models.properties on classpath");
  }
}

origin: javalite/activejdbc

/**
 * Provides a list of all connection wrappers corresponding to a current environment.
 *
 * @return  a list of all connection wrappers corresponding to a current environment.
 */
public static List<ConnectionSpecWrapper> getConnectionSpecWrappers() {
  return getConnectionSpecWrappers(Configuration.getEnv());
}
origin: com.github.tchoulihan/activejdbc

public Dialect getDialect() {
  return Registry.instance().getConfiguration().getDialect(this);
}
origin: com.github.tchoulihan/activejdbc

static void logQuery(Logger logger, String query, Object[] params, long queryStartTime){
  long time = System.currentTimeMillis() - queryStartTime;
  if (Registry.instance().getConfiguration().collectStatistics()) {
    Registry.instance().getStatisticsQueue().enqueue(new QueryExecutionEvent(query, time));
  }
  if (logger.isInfoEnabled()) {
    StringBuilder log =  new StringBuilder().append("Query: \"").append(query).append('"');
    if (!empty(params)) {
      log.append(", with parameters: ").append('<');
      join(log, params, ">, <");
      log.append('>');
    }
    log(logger, log.append(", took: ").append(time).append(" milliseconds").toString());
  }
}
origin: org.javalite/activejdbc

/**
 * Finds a connection {@link ConnectionSpec} that corresponds to system properties,
 * environment variables of <code>database.properties</code> configuration, whichever is found first.
 * Configuration of system properties overrides environment variables, which overrides
 * <code>database.properties</code>.
 *
 * @return {@link ConnectionSpec} used by {@link DB#open()} to open a "default" connection, as well as {@link Base#open()} methods.
 */
public  ConnectionSpec getCurrentConnectionSpec(){
  return getConnectionSpec(getEnvironment());
}
origin: org.javalite/activejdbc

/**
 * This method will open a connection defined in the file 'database.properties' located at
 * root of classpath. The connection picked up from the file is defined by <code>ACTIVE_ENV</code>
 * environment variable or <code>active_env</code> system property.
 * If this variable is not defined, it defaults to 'development' environment.
 *
 * <p></p>
 * If there is JUnit on classpath, this method assumes it is running under test, and defaults to 'test'.
 *
 * @see Configuration#getEnvironment()
 */
public DB open(){
  Configuration config = Registry.instance().getConfiguration();
  ConnectionSpec spec = config.getCurrentConnectionSpec();
  if(spec == null){
    throw new DBException("Could not find configuration in a property file for environment: " + config.getEnvironment() +
        ". Are you sure you have a database.properties file configured?");
  }
  return open(spec);
}
origin: org.javalite/activejdbc

protected static void findModels(String dbName) throws IOException, ClassNotFoundException {
  //this is for static instrumentation. In case of dynamic, the  modelClassNames will already be filled.
  List<String> models = Registry.instance().getConfiguration().getModelNames(dbName);
  if (models != null && !models.isEmpty()) {
    for (String model : models) {
      modelFound(model);
    }
  } else {
    throw new InitException("you are trying to work with models, but no models are found. Maybe you have " +
        "no models in project, or you did not instrument the models. It is expected that you have " +
        "a file activejdbc_models.properties on classpath");
  }
}
origin: javalite/activejdbc

public static void clearConnectionWrappers() {
  clearConnectionWrappers(Configuration.getEnv());
}
origin: com.github.tchoulihan/activejdbc

private Registry() {
  statisticsQueue = configuration.collectStatistics()
      ? new StatisticsQueue(configuration.collectStatisticsOnHold())
      : null;
}
origin: org.javalite/activejdbc

public Dialect getDialect() {
  return Registry.instance().getConfiguration().getDialect(this);
}
origin: javalite/activejdbc

public static void log(Logger logger, LogLevel logLevel, String log, Object param) {
  if(Configuration.hasActiveLogger()) {
    Configuration.getActiveLogger().log(logger, logLevel, log, param);
  }else {
    if (matches(logger, logLevel, log)) {
      switch (logLevel){
        case DEBUG:
          logger.debug(log, param);
          break;
        case INFO:
          logger.info(log, param);
          break;
        case WARNING:
          logger.warn(log, param);
          break;
        case ERROR:
          logger.error(log, param);
          break;
        default:
      }
    }
  }
}
origin: org.javalite/activejdbc

private static String getJson(String query, Object[] params, long time) {
  if (Registry.instance().getConfiguration().collectStatistics()) {
    Registry.instance().getStatisticsQueue().enqueue(new QueryExecutionEvent(query, time));
  }
  return  "{\"sql\":\"" + query.replace("\"", "'") + "\",\"params\":[" + getParamsJson(params) + "]" +
      ",\"duration_millis\":" + time + "}";
}
origin: com.github.tchoulihan/activejdbc

private QueryCache() {
  cacheManager = Registry.instance().getConfiguration().getCacheManager();
  System.out.println(Registry.instance().getConfiguration().getCacheManager());
}
org.javalite.activejdbcConfiguration

Most used methods

  • getDialect
  • collectStatistics
  • collectStatisticsOnHold
  • getCacheManager
  • getModelNames
  • getActiveLogger
  • getConnectionSpec
  • getCurrentConnectionSpec
    Finds a connection ConnectionSpec that corresponds to system properties, environment variables of da
  • getEnv
    Returns name of environment, such as "development", "production", etc. This is a value that is usual
  • getEnvironment
  • getEnvironments
  • hasActiveLogger
  • getEnvironments,
  • hasActiveLogger,
  • loadConnectionsSpecs,
  • loadOverridesFromSystemProperties,
  • loadProjectProperties,
  • overrideFromEnvironmentVariables,
  • overrideFromSystemProperties,
  • readPropertyFile

Popular in Java

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • startActivity (Activity)
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • JFrame (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
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