# HG changeset patch # User Jaroslav Tulach # Date 1280418299 -7200 # Node ID 6507a9474b6dae4d3eaf5d3d7b4772898fa495c2 # Parent 2b670a8a31aeaefacedf52acc7667acf41674a0e Exposing code snippets, removing useless headers diff -r 2b670a8a31ae -r 6507a9474b6d samples/livedb/src/org/apidesign/livedb/LiveDB.java --- a/samples/livedb/src/org/apidesign/livedb/LiveDB.java Fri Jul 16 23:36:14 2010 +0200 +++ b/samples/livedb/src/org/apidesign/livedb/LiveDB.java Thu Jul 29 17:44:59 2010 +0200 @@ -9,6 +9,7 @@ * * @author Jaroslav Tulach */ +// BEGIN: livedb.connection.annotation @Target(ElementType.PACKAGE) @Retention(RetentionPolicy.SOURCE) public @interface LiveDB { @@ -18,3 +19,4 @@ String query(); String classname(); } +// END: livedb.connection.annotation diff -r 2b670a8a31ae -r 6507a9474b6d samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java --- a/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Fri Jul 16 23:36:14 2010 +0200 +++ b/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Thu Jul 29 17:44:59 2010 +0200 @@ -1,8 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package org.apidesign.livedb.impl; import java.io.IOException; @@ -10,16 +5,12 @@ import java.sql.CallableStatement; import java.sql.Connection; import java.sql.Driver; -import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; -import java.util.Enumeration; import java.util.Properties; import java.util.ServiceLoader; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Processor; import javax.annotation.processing.RoundEnvironment; @@ -37,10 +28,11 @@ * * @author Jaroslav Tulach */ +// BEGIN: livedb.processor @SupportedAnnotationTypes("org.apidesign.livedb.LiveDB") @SupportedSourceVersion(SourceVersion.RELEASE_6) @ServiceProvider(service=Processor.class) -public class LiveDBProcessor extends AbstractProcessor { +public final class LiveDBProcessor extends AbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { for (Element e : roundEnv.getElementsAnnotatedWith(LiveDB.class)) { @@ -106,7 +98,7 @@ } return true; } - +// FINISH: livedb.processor private static Connection getConnection(String url, String user, String password) throws SQLException { final ClassLoader cl = LiveDBProcessor.class.getClassLoader(); diff -r 2b670a8a31ae -r 6507a9474b6d samples/livedb/test/org/apidesign/livedb/example/LiveDBTest.java --- a/samples/livedb/test/org/apidesign/livedb/example/LiveDBTest.java Fri Jul 16 23:36:14 2010 +0200 +++ b/samples/livedb/test/org/apidesign/livedb/example/LiveDBTest.java Thu Jul 29 17:44:59 2010 +0200 @@ -1,8 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package org.apidesign.livedb.example; import java.sql.SQLException; @@ -19,6 +14,7 @@ super(testName); } + // BEGIN: livedb.test public void testSomeMethod() throws SQLException { List ages = Age.query(); assertEquals("One record", 1, ages.size()); @@ -26,5 +22,6 @@ assertEquals("name is apidesign", "apidesign", age.NAME); assertEquals("it is three years old", 3, age.AGE.intValue()); } + // END: livedb.test } diff -r 2b670a8a31ae -r 6507a9474b6d samples/livedb/test/org/apidesign/livedb/example/package-info.java --- a/samples/livedb/test/org/apidesign/livedb/example/package-info.java Fri Jul 16 23:36:14 2010 +0200 +++ b/samples/livedb/test/org/apidesign/livedb/example/package-info.java Thu Jul 29 17:44:59 2010 +0200 @@ -1,10 +1,11 @@ - +// BEGIN: livedb.connect @LiveDB( classname="Age", password="j1", user="j1", query="select * from APP.AGE", url="jdbc:derby:classpath:db" ) package org.apidesign.livedb.example; +// END: livedb.connect import org.apidesign.livedb.LiveDB;