Package railo.runtime.db

Examples of railo.runtime.db.DataSource


     */
   
    ORMConfiguration ormConf = data.getORMConfiguration();
   
    // dialect
    DataSource ds = dc.getDatasource();
    String dialect=null;
    try  {
      if (Class.forName(ormConf.getDialect()) != null) {
        dialect = ormConf.getDialect();
      }
    }
    catch (Exception e) {
      // MZ: The dialect value could not be bound to a classname or instantiation causes an exception - ignore and use the default dialect entries
    }
    if (dialect == null) {
      dialect = Dialect.getDialect(ormConf.getDialect());
      if(Util.isEmpty(dialect)) dialect=Dialect.getDialect(ds);
    }
    if(Util.isEmpty(dialect))
      throw ExceptionUtil.createException(data,null,"A valid dialect definition inside the "+Constants.APP_CFC+"/"+Constants.CFAPP_NAME+" is missing. The dialect cannot be determinated automatically",null);
   
    // Cache Provider
    String cacheProvider = ormConf.getCacheProvider();
    Class<? extends RegionFactory> regionFactory=null;
   
    if(Util.isEmpty(cacheProvider) || "EHCache".equalsIgnoreCase(cacheProvider)) {
      regionFactory=net.sf.ehcache.hibernate.EhCacheRegionFactory.class;
      cacheProvider=regionFactory.getName();//"org.hibernate.cache.EhCacheProvider";
         
    }
    else if("JBossCache".equalsIgnoreCase(cacheProvider))   cacheProvider="org.hibernate.cache.TreeCacheProvider";
    else if("HashTable".equalsIgnoreCase(cacheProvider))   cacheProvider="org.hibernate.cache.HashtableCacheProvider";
    else if("SwarmCache".equalsIgnoreCase(cacheProvider))   cacheProvider="org.hibernate.cache.SwarmCacheProvider";
    else if("OSCache".equalsIgnoreCase(cacheProvider))     cacheProvider="org.hibernate.cache.OSCacheProvider";
 
    Resource cacheConfig = ormConf.getCacheConfig();
    Configuration configuration = new Configuration();
   
    // ormConfig
    Resource conf = ormConf.getOrmConfig();
    if(conf!=null){
      try {
        Document doc = CommonUtil.toDocument(conf);
        configuration.configure(doc);
      }
      catch (Throwable t) {
        ORMUtil.printError(t);
       
      }
    }
   
    try{
      configuration.addXML(mappings);
    }
    catch(MappingException me){
      throw ExceptionUtil.createException(data,null, me);
    }
   
    configuration
       
        // Database connection settings
        .setProperty("hibernate.connection.driver_class", ds.getClazz().getName())
      .setProperty("hibernate.connection.url", ds.getDsnTranslated())
      .setProperty("hibernate.connection.username", ds.getUsername())
      .setProperty("hibernate.connection.password", ds.getPassword())
      //.setProperty("hibernate.connection.release_mode", "after_transaction")
      .setProperty("hibernate.transaction.flush_before_completion", "false")
      .setProperty("hibernate.transaction.auto_close_session", "false")
     
      // JDBC connection pool (use the built-in)
View Full Code Here


  @Override
  public ORMSession createSession(PageContext pc) throws PageException {
    ApplicationContextPro appContext = (ApplicationContextPro) pc.getApplicationContext();
    Object o=appContext.getORMDataSource();
   
    DataSource ds=o instanceof DataSource?
        (DataSource)o:
        CommonUtil.getDataSource(pc,CommonUtil.toString(o));
   
       
    DatasourceConnection dc = CommonUtil.getDatasourceConnection(pc,ds);
View Full Code Here

    if(!appContext.isORMEnabled())
      throw ExceptionUtil.createException((ORMSession)null,null,"ORM is not enabled","");
   
   
    // datasource
    DataSource ds = ORMUtil.getDataSource(pc);
    ORMConfiguration ormConf=appContext.getORMConfiguration();
    String key = hash(ormConf,ds);
    SessionFactoryData data = factories.get(key);
    if(initType==INIT_ALL && data!=null) {
      data.reset();
View Full Code Here

  }

  private static Object hash(PageContext pc) throws PageException {
    ApplicationContextPro appContext=(ApplicationContextPro) pc.getApplicationContext();
    Object o=appContext.getORMDataSource();
    DataSource ds;
    if(o instanceof DataSource) ds=(DataSource) o;
    else ds=CommonUtil.getDataSource(pc,CommonUtil.toString(o));
    return hash(appContext.getORMConfiguration(),ds);
  }
View Full Code Here

      // aliases
      if("ram".equals(storage)) return "memory";
      if("registry".equals(storage)) return "file";
     
      // datasource
      DataSource  ds = config.getDataSource(storage,null);
      if(ds!=null) {
        if(ds.isStorage())return storage;
        throw new ApplicationException("datasource ["+storage+"] is not enabled to be used as session/client storage");
      }
   
      // cache
      CacheConnection cc = Util.getCacheConnection(config, storage,null);
View Full Code Here

        Array sqlparts = ListUtil.listToArrayRemoveEmpty(
            SQLUtil.removeLiterals(sql.getSQLString())
            ," \t"+System.getProperty("line.separator"));

        //print.ln(List.toStringArray(sqlparts));
        DataSource ds = dc.getDatasource();
        if(!ds.hasAllow(DataSource.ALLOW_ALTER))    checkSQLRestriction(dc,"alter",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_CREATE))   checkSQLRestriction(dc,"create",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_DELETE))   checkSQLRestriction(dc,"delete",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_DROP))     checkSQLRestriction(dc,"drop",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_GRANT))    checkSQLRestriction(dc,"grant",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_INSERT))   checkSQLRestriction(dc,"insert",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_REVOKE))   checkSQLRestriction(dc,"revoke",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_SELECT))   checkSQLRestriction(dc,"select",sqlparts,sql);
        if(!ds.hasAllow(DataSource.ALLOW_UPDATE))   checkSQLRestriction(dc,"update",sqlparts,sql);
    }
View Full Code Here

    ConfigImpl ci = (ConfigImpl)config;
    DatasourceConnectionPool pool = ci.getDatasourceConnectionPool();
    Log log=((ConfigImpl)config).getScopeLogger();
    try {
      PageContext pc = ThreadLocalPageContext.get();// FUTURE change method interface
      DataSource ds;
      if(pc!=null) ds=((PageContextImpl)pc).getDataSource(datasourceName);
      else ds=config.getDataSource(datasourceName);
      dc=pool.getDatasourceConnection(null,ds,null,null);
      SQLExecutor executor=SQLExecutionFactory.getInstance(dc);
      executor.update(config, cfid,appName, dc, getType(), sct,getTimeSpan(),log);
View Full Code Here

   
    DatasourceConnectionPool pool = ci.getDatasourceConnectionPool();
    Log log=((ConfigImpl)config).getScopeLogger();
    try {
      PageContext pc = ThreadLocalPageContext.get();// FUTURE change method interface
      DataSource ds;
      if(pc!=null) ds=((PageContextImpl)pc).getDataSource(datasourceName);
      else ds=config.getDataSource(datasourceName);
      dc=pool.getDatasourceConnection(null,ds,null,null);
      SQLExecutor executor=SQLExecutionFactory.getInstance(dc);
      executor.delete(config, cfid,appName, dc, getType(),log);
View Full Code Here

    return scope(name, null);
  }
 
// FUTURE add to PageContext
  public DataSource getDataSource(String datasource) throws PageException {
    DataSource ds = ((ApplicationContextPro)getApplicationContext()).getDataSource(datasource,null);
    if(ds!=null) return ds;
    ds=getConfig().getDataSource(datasource,null);
    if(ds!=null) return ds;
   
    throw DatabaseException.notFoundException(this, datasource);
View Full Code Here

    throw DatabaseException.notFoundException(this, datasource);
  }
   
// FUTURE add to PageContext
  public DataSource getDataSource(String datasource, DataSource defaultValue) {
    DataSource ds = ((ApplicationContextPro)getApplicationContext()).getDataSource(datasource,null);
    if(ds==null) ds=getConfig().getDataSource(datasource,defaultValue);
    return ds;
  }
View Full Code Here

TOP

Related Classes of railo.runtime.db.DataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.