コード例 #1
0
  @Override
  protected void initializeComponents() {
    super.initializeComponents();
    JDBCSecurityServiceConfig config = (JDBCSecurityServiceConfig) configHelper.getConfig();
    if (config.isJndi()) {
      comp =
          new JDBCConnectFormComponent(
              "jdbcConnectFormComponent", Mode.DYNAMIC, config.getJndiName());
    } else {
      comp =
          new JDBCConnectFormComponent(
              "jdbcConnectFormComponent",
              Mode.DYNAMIC,
              config.getDriverClassName(),
              config.getConnectURL(),
              config.getUserName(),
              config.getPassword());
    }
    addOrReplace(comp);

    add(creatingTablesComponent = new CheckBox("config.creatingTables"));
    propertyFileNameDDLComponent = new TextField<String>("config.propertyFileNameDDL");
    add(propertyFileNameDDLComponent);
    propertyFileNameDMLComponent = new TextField<String>("config.propertyFileNameDML");
    add(propertyFileNameDMLComponent);
  };
コード例 #2
0
  @Override
  public void updateModel() {
    super.updateModel();
    comp.updateModel();
    creatingTablesComponent.updateModel();
    propertyFileNameDDLComponent.updateModel();
    propertyFileNameDMLComponent.updateModel();
    JDBCSecurityServiceConfig config = (JDBCSecurityServiceConfig) configHelper.getConfig();
    JDBCConnectConfig c = comp.getModelObject();
    config.setJndiName(null);
    config.setDriverClassName(null);
    config.setConnectURL(null);
    config.setUserName(null);
    config.setPassword(null);

    config.setJndi(c.getType().equals(JDBCConnectConfig.TYPEJNDI));
    if (config.isJndi()) {
      config.setJndiName(c.getJndiName());
    } else {
      config.setDriverClassName(c.getDriverName());
      config.setConnectURL(c.getConnectURL());
      config.setUserName(c.getUsername());
      config.setPassword(c.getPassword());
    }
  }
コード例 #3
0
 /**
  * initialize a {@link DataSource} form a {@link JdbcSecurityServiceConfig} object
  *
  * @param config
  * @throws IOException
  */
 public void initializeDSFromConfig(SecurityNamedServiceConfig namedConfig) throws IOException {
   JDBCSecurityServiceConfig config = (JDBCSecurityServiceConfig) namedConfig;
   if (config.isJndi()) {
     String jndiName = config.getJndiName();
     try {
       Context initialContext = new InitialContext();
       datasource = (DataSource) initialContext.lookup(jndiName);
     } catch (NamingException e) {
       throw new IOException(e);
     }
   } else {
     BasicDataSource bds = new BasicDataSource();
     bds.setDriverClassName(config.getDriverClassName());
     bds.setUrl(config.getConnectURL());
     bds.setUsername(config.getUserName());
     bds.setPassword(config.getPassword());
     bds.setDefaultAutoCommit(false);
     bds.setDefaultTransactionIsolation(DEFAULT_ISOLATION_LEVEL);
     bds.setMaxActive(10);
     datasource = bds;
   }
 }