Package de.mhus.lib.config

Examples of de.mhus.lib.config.IConfig


      // return initializeConnection((CaoConnection) getActivator().getClazz(CdbConnection.class.getCanonicalName()).getConstructor(DbDriver.class,DbConfiguration.class).newInstance(this,form));
      // return initializeConnection(new DbCaoConnection(this,form));

      // MActivator acti = getActivator();
      MActivator acti = new MActivator(getClass().getClassLoader());
      IConfig cClassPath = config.getConfig("classpath");
      if (cClassPath != null) {
        DynamicClassLoader classLoader = new DynamicClassLoader(getName(),getClass().getClassLoader());
        classLoader.doSetupFromConfig(cClassPath);
        acti = new MActivator(classLoader);
      }
View Full Code Here


  private LinkedList<FormAction> actions = new LinkedList<FormAction>();
  private HashMap<String, FormAction> map = new HashMap<String, FormAction>();
 
  protected void doBuildChildren() throws Exception {
    // load actions
    IConfig cActions = config.getConfig("actions");
    if (cActions == null) return;
    for (IConfig action : cActions.getConfigBundle()) {
      FormAction a = new FormAction(this,action);
      actions.add(a);
      map.put(action.getName(),  a);
    }
  }
View Full Code Here

 
  @Override
  public NavigationNode getParent() {
   
    if (config != null) {
      IConfig cur = config.getParent();
      if (cur != null) {
        return new ConfigNavigationNode(cur);
      }
    }
    return null;
View Full Code Here

   * @throws Exception
   */
  public void createTable(DbConnection con) throws Exception {
   
      HashConfig cstr = new HashConfig();
      IConfig ctable = cstr.createConfig("table");
      ctable.setProperty("name", tableNameOrg);
     
      LinkedList<String> pk = new LinkedList<String>();
     
      for (Field f : fList) {
        IConfig cfield = ctable.createConfig("field");
        cfield.setProperty(Dialect.K_NAME, f.createName);
        cfield.setProperty(Dialect.K_TYPE, f.retDbType);
        cfield.setProperty(Dialect.K_SIZE, String.valueOf(f.size));
        cfield.setProperty(Dialect.K_DEFAULT, f.defValue);
          cfield.setProperty(Dialect.K_NOT_NULL, f.nullable ? "no" : "yes");
          LinkedList<String> cat = new LinkedList<String>();
          if (!f.isPersistent()) cat.add(Dialect.C_VIRTUAL);
          if (f.isPrimary) cat.add(Dialect.C_PRIMARY_KEY);
          if (f.ret.isEnum()) cat.add(Dialect.C_ENUMERATION);
          cfield.setProperty(Dialect.K_CATEGORIES, MString.join(cat.iterator(), ",") )// add primary key
        if (f.isPrimary && f.isPersistent()) pk.add(f.createName);
      }
     
      if (pk.size() > 0) {
        String pkNames = MString.join(pk.iterator(), ",");
        ctable.setProperty(Dialect.K_PRIMARY_KEY, pkNames);
      }
     
      // create index entries
      for (Entry<String, LinkedList<Field>> item : iIdx.entrySet()) {
        IConfig cindex = cstr.createConfig("index");
        String n = item.getKey();
        if (n.startsWith(DbIndex.UNIQUE)) {
          cindex.setString(Dialect.I_TYPE, Dialect.I_UNIQUE);
        }
        cindex.setString(Dialect.I_NAME, "idx_" + n);
        cindex.setString(Dialect.I_TABLE, tableNameOrg);
        StringBuffer fields = new StringBuffer();
        for (Field field : item.getValue()) {
          if (fields.length() > 0) fields.append(",");
          fields.append(field.createName);
        }
        cindex.setString(Dialect.I_FIELDS, fields.toString());
      }
     
      manager.getPool().getDialect().createStructure(cstr, con, manager.getCaoMetadata());
     
  }
View Full Code Here

   * @param form
   * @return
   * @throws CaoException
   */
  public CaoConnection createConnection(CaoForm form) throws CaoException {
    IConfig c = form.getConfig();
    if (c == null) c = getConfig();
    return createConnection(form.toUrl(true),c);
  }
View Full Code Here

   */
  protected abstract void initDefaultApplications();
 
  public synchronized IConfig getConfig() {
    if (config == null) {
      IConfig c = MSingleton.instance().getConfig().getConfig(DEFAULT_CONFIG);
      if (c != null) {
        log.t(getName(),"loaded default config",config);
        config = c.getConfig(getName());
      }
    }
    return config;
  }
View Full Code Here

   * Create all applications for the connection with help of the factories.
   *
   * @param con
   */
  private void createApplications(CaoConnection con) {
    IConfig c = con.getConfig();
    if (c!=null) {
      IConfig[] bundle = c.getConfigBundle("load_application");
      if (bundle.length == 0) {
        for (Entry<String, CaoApplicationFactory> factory : this.applications.entrySet()) {
          log.t(getName(),"Load Application",factory.getKey());
          CaoApplication app = factory.getValue().create(con);
          if (app != null) {
View Full Code Here

        MLog.w(clazz,t);
      }
    }
   
    // start the http server if configured
    IConfig cserver = config.getConfig("server");
    if (cserver != null) {
      if (cserver.getBoolean("enabled", false))
          manager.openServer(cserver);
        else
          manager.closeServer();
    }
  }
View Full Code Here

   *
   * @param con
   * @return
   */
  public CaoApplication create(CaoConnection con) {
    IConfig c = config;
    if ( c == null) {
      c = con.getDriver().getConfig();
    }
    if (c != null) {
      // IConfig driverConfig = c.getConfig(con.getDriver().getName());
      // if (driverConfig != null) {
        IConfig appConfig = c.getConfig(getName());
        if (appConfig != null) {
          try {
            return create(con, appConfig);
          } catch (CaoException e) {
            log.e(con.getDriver().getName(),getName(),e);
View Full Code Here

  public JmxConsole() throws IOException {
    super();
    width = 80;
    height = 40;
    IConfig config = MSingleton.instance().getConfig(this, null);
    if (config != null) {
      width = config.getInt("width",width);
      height = config.getInt("height", height);
    }
    reset();
    jmxProxy = new JmxConsoleProxy(this);
  }
View Full Code Here

TOP

Related Classes of de.mhus.lib.config.IConfig

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.