@Test public void createSourceForSource() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(JdbcProcess.TABLE.key(), "PAIR"); conf.put(JdbcProcess.COLUMNS.key(), "KEY,VALUE"); conf.put(JdbcProcess.CONDITION.key(), "KEY > 2"); conf.put(JdbcProcess.JDBC_SUPPORT.key(), PairSupport.class.getName()); ProcessScript<Pair> process = process(new DriverScript("jdbc", conf), dummy()); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (1, 'Hello1, world!')"); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (2, 'Hello2, world!')"); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (3, 'Hello3, world!')"); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (4, 'Hello4, world!')"); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (5, 'Hello5, world!')"); JdbcResourceManipulator manipulator = new JdbcResourceManipulator(profile(), new ParameterList()); try (SourceDriver<Pair> driver = manipulator.createSourceForSource(process)) { driver.prepare(); test(driver, "Hello3, world!", "Hello4, world!", "Hello5, world!"); } }
@Override public <T> SourceDriver<T> createSourceForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.SOURCE); T object = ProcessUtil.newDataModel(profile.getResourceName(), script); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcSourceDriver<T> result = new JdbcSourceDriver<>(profile, jdbc, conn, object); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> SourceDriver<T> createSourceForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.SOURCE); T object = ProcessUtil.newDataModel(profile.getResourceName(), script); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcSourceDriver<T> result = new JdbcSourceDriver<>(profile, jdbc, conn, object); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> SourceDriver<T> createSourceForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.SOURCE); T object = ProcessUtil.newDataModel(profile.getResourceName(), script); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcSourceDriver<T> result = new JdbcSourceDriver<>(profile, jdbc, conn, object); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> SourceDriver<T> createSourceForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.SOURCE); T object = ProcessUtil.newDataModel(profile.getResourceName(), script); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcSourceDriver<T> result = new JdbcSourceDriver<>(profile, jdbc, conn, object); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script); }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> SourceDriver<T> createSourceForSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.SOURCE); T object = ProcessUtil.newDataModel(profile.getResourceName(), script); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcSourceDriver<T> result = new JdbcSourceDriver<>(profile, jdbc, conn, object); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script);  }