1.1 --- a/samples/livedb/src/org/apidesign/livedb/LiveDB.java Fri Jul 16 23:36:14 2010 +0200
1.2 +++ b/samples/livedb/src/org/apidesign/livedb/LiveDB.java Thu Jul 29 17:44:59 2010 +0200
1.3 @@ -9,6 +9,7 @@
1.4 *
1.5 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.6 */
1.7 +// BEGIN: livedb.connection.annotation
1.8 @Target(ElementType.PACKAGE)
1.9 @Retention(RetentionPolicy.SOURCE)
1.10 public @interface LiveDB {
1.11 @@ -18,3 +19,4 @@
1.12 String query();
1.13 String classname();
1.14 }
1.15 +// END: livedb.connection.annotation
2.1 --- a/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Fri Jul 16 23:36:14 2010 +0200
2.2 +++ b/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Thu Jul 29 17:44:59 2010 +0200
2.3 @@ -1,8 +1,3 @@
2.4 -/*
2.5 - * To change this template, choose Tools | Templates
2.6 - * and open the template in the editor.
2.7 - */
2.8 -
2.9 package org.apidesign.livedb.impl;
2.10
2.11 import java.io.IOException;
2.12 @@ -10,16 +5,12 @@
2.13 import java.sql.CallableStatement;
2.14 import java.sql.Connection;
2.15 import java.sql.Driver;
2.16 -import java.sql.DriverManager;
2.17 import java.sql.ResultSet;
2.18 import java.sql.ResultSetMetaData;
2.19 import java.sql.SQLException;
2.20 -import java.util.Enumeration;
2.21 import java.util.Properties;
2.22 import java.util.ServiceLoader;
2.23 import java.util.Set;
2.24 -import java.util.logging.Level;
2.25 -import java.util.logging.Logger;
2.26 import javax.annotation.processing.AbstractProcessor;
2.27 import javax.annotation.processing.Processor;
2.28 import javax.annotation.processing.RoundEnvironment;
2.29 @@ -37,10 +28,11 @@
2.30 *
2.31 * @author Jaroslav Tulach <jtulach@netbeans.org>
2.32 */
2.33 +// BEGIN: livedb.processor
2.34 @SupportedAnnotationTypes("org.apidesign.livedb.LiveDB")
2.35 @SupportedSourceVersion(SourceVersion.RELEASE_6)
2.36 @ServiceProvider(service=Processor.class)
2.37 -public class LiveDBProcessor extends AbstractProcessor {
2.38 +public final class LiveDBProcessor extends AbstractProcessor {
2.39 @Override
2.40 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
2.41 for (Element e : roundEnv.getElementsAnnotatedWith(LiveDB.class)) {
2.42 @@ -106,7 +98,7 @@
2.43 }
2.44 return true;
2.45 }
2.46 -
2.47 +// FINISH: livedb.processor
2.48 private static Connection getConnection(String url, String user, String password)
2.49 throws SQLException {
2.50 final ClassLoader cl = LiveDBProcessor.class.getClassLoader();
3.1 --- a/samples/livedb/test/org/apidesign/livedb/example/LiveDBTest.java Fri Jul 16 23:36:14 2010 +0200
3.2 +++ b/samples/livedb/test/org/apidesign/livedb/example/LiveDBTest.java Thu Jul 29 17:44:59 2010 +0200
3.3 @@ -1,8 +1,3 @@
3.4 -/*
3.5 - * To change this template, choose Tools | Templates
3.6 - * and open the template in the editor.
3.7 - */
3.8 -
3.9 package org.apidesign.livedb.example;
3.10
3.11 import java.sql.SQLException;
3.12 @@ -19,6 +14,7 @@
3.13 super(testName);
3.14 }
3.15
3.16 + // BEGIN: livedb.test
3.17 public void testSomeMethod() throws SQLException {
3.18 List<Age> ages = Age.query();
3.19 assertEquals("One record", 1, ages.size());
3.20 @@ -26,5 +22,6 @@
3.21 assertEquals("name is apidesign", "apidesign", age.NAME);
3.22 assertEquals("it is three years old", 3, age.AGE.intValue());
3.23 }
3.24 + // END: livedb.test
3.25
3.26 }
4.1 --- a/samples/livedb/test/org/apidesign/livedb/example/package-info.java Fri Jul 16 23:36:14 2010 +0200
4.2 +++ b/samples/livedb/test/org/apidesign/livedb/example/package-info.java Thu Jul 29 17:44:59 2010 +0200
4.3 @@ -1,10 +1,11 @@
4.4
4.5 -
4.6 +// BEGIN: livedb.connect
4.7 @LiveDB(
4.8 classname="Age", password="j1", user="j1",
4.9 query="select * from APP.AGE",
4.10 url="jdbc:derby:classpath:db"
4.11 )
4.12 package org.apidesign.livedb.example;
4.13 +// END: livedb.connect
4.14
4.15 import org.apidesign.livedb.LiveDB;