/** * create a SysLog object with auto commit on. * (open/begin/commit/close is not required). */ public SysLogManager () { super (new DB(),SysLog.class); autoCommit = true; }
public static <T> T exec(String configModifier, DBAction<T> action) throws Exception { try (DB db = new DB(configModifier)) { db.open(); return action.exec(db); } }
public synchronized DB getDB (Context ctx) { DB db = (DB) ctx.get (DB); if (db == null) { ctx.put (DB, db = new DB ()); } return db; } public void setResultCode (Context ctx, String rc) {
public static <T> T exec(DBAction<T> action) throws Exception { try (DB db = new DB()) { db.open(); return action.exec(db); } }
private void ensureOpen() { if (db == null) { db = new DB(); db.open(); mgr = new SysConfigManager(db); } } private void close() {
@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); } } }
public void initService () { db = new DB(); mgr = new StatusManager (db); timer = new Timer (true); Iterator iter = config.getChildren ("monitor").iterator(); List handlers = new ArrayList(); while (iter.hasNext()) { Element e = (Element) iter.next(); try { registerTask (e); } catch (ConfigurationException ex) { getLog().error (ex); } } } public void destroyService() {
public void initService () throws Exception { db = new DB(); mgr = new StatusManager (db); interval = cfg.getLong ("interval", 60000L); initStatus(); } public void startService() {
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) { } } }
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; } }
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; } }
private void createSchema () throws HibernateException, DocumentException { DB db = new DB(); db.open(); db.beginTransaction(); db.createSchema(null, true); db.commit(); db.close(); }
public void initService() throws Exception { super.initService(); Space sp = SpaceFactory.getSpace("tspace:dbconfig"); String cm = cfg.get("config-modifier", null); String dbprefix = (cm != null ? cm.split(":")[0] + ":" : ""); sp.out(dbprefix + "connection.username", cfg.get("dbuser", "UNKNOWN")); sp.out(dbprefix + "connection.password", cfg.get("dbpass", "UNKNOWN")); new org.jpos.ee.DB(cm); } }
@BeforeClass public static void setUp() throws DocumentException { try (DB db = new DB()) { db.createSchema(null, true); } }
private long nextAsync(long id, long delay) { SeqNoManager mgr = new SeqNoManager(new DB()); long l = mgr.next("sync", id, 60000L, 60000L, 999999L); ISOUtil.sleep(delay); mgr.release("sync", id); return l; } private void reset() {
@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()); } } }
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 (); }
@Before public void setUp() throws Exception { db = new DB(); db.createSchema("schema.sql", true); db.open(); }
private void reset() { try (DB db = new DB()) { SeqNoManager mgr = new SeqNoManager(db); db.open(); db.beginTransaction(); mgr.reset("sync", 0L); db.commit(); } } }
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; } }