org.jpos.ee.DB.open()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中org.jpos.ee.DB.open()方法的一些代码示例,展示了DB.open()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DB.open()方法的具体详情如下:
包路径:org.jpos.ee.DB
类名称:DB
方法名:open

DB.open介绍

[英]open a new HibernateSession if none exists
[中]如果不存在HibernateSession,请打开新的HibernateSession

代码示例

代码示例来源:origin: jpos/jPOS-EE

/**
 * Open underlying Hibernate session.
 * @throws HibernateException
 */
public synchronized Session open () throws HibernateException {
  return db.open();
}
/**

代码示例来源:origin: jpos/jPOS-EE

public static <T> T exec(String configModifier, DBAction<T> action) throws Exception {
  try (DB db = new DB(configModifier)) {
    db.open();
    return action.exec(db);
  }
}

代码示例来源:origin: jpos/jPOS-EE

public static <T> T exec(DBAction<T> action) throws Exception {
  try (DB db = new DB()) {
    db.open();
    return action.exec(db);
  }
}

代码示例来源:origin: jpos/jPOS-EE

private void ensureOpen() {
  if (db == null) {
    db = new DB();
    db.open();
    mgr = new SysConfigManager(db);
  }
}
private void close() {

代码示例来源:origin: jpos/jPOS-EE

private synchronized void touch (String id, String detail) {
  int sp = detail.indexOf (" ");
  String state = Status.OFF;
  if (sp > 0 && detail.length() > sp) {
    state = detail.substring (0, sp);
    detail = detail.substring (++sp);
  }
  try {
    db.open ();
    mgr.touch (id, state, detail);
  } catch (Throwable t) {
    getLog().error (t);
  } finally {
    close();
  }
}
private synchronized String getNextCommand (String id) {

代码示例来源:origin: jpos/jPOS-EE

@Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    String filename = "-";  // defaults to stdout     '
    String configModifier = null;
    boolean create = false;
    if (args.length > 1)
      filename = args[1];
    if (args.length > 2)
      create = "yes".equalsIgnoreCase(args[2]) || "true".equalsIgnoreCase(args[2]);
    if (args.length > 3)
      configModifier = args[3];

    try (DB db = new DB(configModifier)) {
      db.open();
      db.beginTransaction();
      db.createSchema(filename, create);
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

private void create (String id) {
    try (DB db = new DB()) {
      db.open();
      db.beginTransaction();
      SeqNo seq = new SeqNo(id);
      db.session().save(seq);
      db.commit();
    } catch (Exception ignored) { }
  }
}

代码示例来源:origin: jpos/jPOS-EE

private synchronized void setResponse (String id, String response) {
  try {
    db.open ();
    mgr.setResponse (id, response);
  } catch (Throwable t) {
    getLog().error (t);
  } finally {
    close();
  }
}
public class MonitorTimerTask extends TimerTask {

代码示例来源:origin: jpos/jPOS-EE

public static <T> T execWithTransaction(DBAction<T> action) throws Exception {
  try (DB db = new DB()) {
    db.open();
    db.beginTransaction();
    T obj = action.exec(db);
    db.commit();
    return obj;
  }
}

代码示例来源:origin: jpos/jPOS-EE

private synchronized String getNextCommand (String id) {
  try {
    db.open ();
    return mgr.getNextCommand (id);
  } catch (Throwable t) {
    getLog().error (t);
  } finally {
    close();
  }
  return null;
}
private synchronized void setResponse (String id, String response) {

代码示例来源:origin: jpos/jPOS-EE

public static <T> T execWithTransaction(String configModifier, DBAction<T> action) throws Exception {
  try (DB db = new DB(configModifier)) {
    db.open();
    db.beginTransaction();
    T obj = action.exec(db);
    db.commit();
    return obj;
  }
}

代码示例来源:origin: jpos/jPOS-EE

private void createSchema () throws HibernateException, DocumentException {
  DB db = new DB();
  db.open();
  db.beginTransaction();
  db.createSchema(null, true);
  db.commit();
  db.close();
}

代码示例来源:origin: jpos/jPOS-EE

@Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    try (DB db = new DB()) {
      db.open();
      RoleManager rm = new RoleManager(db);
      for (Role r : rm.getAll()) {
        cli.println (r.getName() + " " + r.getPermissions());
      }
    } catch (Exception e) {
      cli.println (e.getMessage());
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

@Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    try (DB db = new DB()) {
      db.open();
      SysConfigManager mgr = new SysConfigManager(db);

      if (cli.getUserData().containsKey(SYSCONFIG.PREFIX))
        mgr.setPrefix((String) cli.getUserData().get(SYSCONFIG.PREFIX));
      else if (args.length > 1)
        mgr.setPrefix(args[1]);
      String format = "%" + mgr.getMaxIdLength() + "s: %s";
      for (SysConfig sc : mgr.getAll()) {
        cli.println (String.format (format, sc.getId(), sc.getValue()));
      }
    } catch (Exception e) {
      cli.println (e.getMessage());
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

public void run() {
  long start = System.currentTimeMillis();
  for (int i=1; running(); i++) {
    try {
      db.open ();
      if (cfg.getBoolean ("check", true))
        mgr.check ();
      mgr.touch (statusId, Status.OK, getDetail (start, i));
      Thread.sleep (interval);
    } catch (Throwable t) {
      getLog().error (t);
      ISOUtil.sleep (1000);
    } finally {
      close();
    }
  }
}
private void close() {

代码示例来源:origin: jpos/jPOS-EE

public void testAddExportUser() throws Exception {     
  Session sess = new DB().open();
  try {
    GLUser user = getUser(sess,System.getProperty("user.name"));
  } catch (IllegalArgumentException e) {
    Transaction txn = sess.beginTransaction();
    GLUser user = new GLUser();
    user.setName(System.getProperty ("user.name"));
    user.setNick(System.getProperty ("user.name"));
    List<String> perms = Arrays.asList("read","write","grant");
    perms.forEach(p -> {sess.save (new GLPermission (p)); user.grant (new GLPermission (p));});
    sess.save (user);
    txn.commit();
  }
  sess.close ();
}

代码示例来源:origin: jpos/jPOS-EE

@Before
public void setUp() throws Exception {
  db = new DB();
  db.createSchema("schema.sql", true);
  db.open();
}

代码示例来源:origin: jpos/jPOS-EE

public int prepare (long id, Serializable o) {
  int rc = ABORTED;
  Context ctx = (Context) o;
  try {
    DB db = getDB (ctx);
    db.open ();
    ctx.put (TX, db.beginTransaction(timeout));
    checkPoint (ctx);
    rc = PREPARED;
  } catch (Throwable t) {
    error (t);
    ctx.remove (DB); // "Close" participant checks 
             // for DB in Context
  }
  return rc | NO_JOIN | READONLY;
}
public void commit (long id, Serializable o) { }

代码示例来源:origin: jpos/jPOS-EE

private void reset() {
    try (DB db = new DB()) {
      SeqNoManager mgr = new SeqNoManager(db);
      db.open();
      db.beginTransaction();
      mgr.reset("sync", 0L);
      db.commit();
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

private long next(long delay) {
  try (DB db = new DB()) {
    SeqNoManager mgr = new SeqNoManager(db);
    db.open();
    db.beginTransaction();
    long l = mgr.next("sync", 999999L);
    ISOUtil.sleep(delay);
    db.commit();
    return l;
  }
}

相关文章