1.1 --- a/samples/libs/build.xml Wed Jul 14 20:56:33 2010 +0200
1.2 +++ b/samples/libs/build.xml Thu Jul 15 00:40:37 2010 +0200
1.3 @@ -5,6 +5,14 @@
1.4 <param name="library" value="junit-4.4"/>
1.5 <param name="url" value="http://switch.dl.sourceforge.net/sourceforge/junit/junit-4.4.jar"/>
1.6 </antcall>
1.7 + <antcall target="-library">
1.8 + <param name="library" value="derby"/>
1.9 + <param name="url" value="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/derby/derby/10.6.1.0/derby-10.6.1.0.jar"/>
1.10 + </antcall>
1.11 + <antcall target="-library">
1.12 + <param name="library" value="derbyclient"/>
1.13 + <param name="url" value="http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/derby/derbyclient/10.6.1.0/derbyclient-10.6.1.0.jar"/>
1.14 + </antcall>
1.15 <antcall target="-library-from-nbm">
1.16 <param name="library" value="org.openide.util.lookup"/>
1.17 <param name="library.include" value="**/org-openide-util-lookup.jar"/>
2.1 --- a/samples/livedb/nbproject/build-impl.xml Wed Jul 14 20:56:33 2010 +0200
2.2 +++ b/samples/livedb/nbproject/build-impl.xml Thu Jul 15 00:40:37 2010 +0200
2.3 @@ -55,7 +55,14 @@
2.4 </target>
2.5 <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
2.6 <available file="${manifest.file}" property="manifest.available"/>
2.7 - <available file="${application.splash}" property="splashscreen.available"/>
2.8 + <condition property="splashscreen.available">
2.9 + <and>
2.10 + <not>
2.11 + <equals arg1="${application.splash}" arg2="" trim="true"/>
2.12 + </not>
2.13 + <available file="${application.splash}"/>
2.14 + </and>
2.15 + </condition>
2.16 <condition property="main.class.available">
2.17 <and>
2.18 <isset property="main.class"/>
2.19 @@ -231,7 +238,7 @@
2.20 <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
2.21 <compilerarg line="${javac.compilerargs}"/>
2.22 <compilerarg value="-processorpath"/>
2.23 - <compilerarg path="@{processorpath}"/>
2.24 + <compilerarg path="@{processorpath}:${empty.dir}"/>
2.25 <compilerarg line="${ap.processors.internal}"/>
2.26 <compilerarg line="${annotation.processing.processor.options}"/>
2.27 <compilerarg value="-s"/>
2.28 @@ -700,6 +707,14 @@
2.29 <include name="**/*.java"/>
2.30 </fileset>
2.31 </javadoc>
2.32 + <copy todir="${dist.javadoc.dir}">
2.33 + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
2.34 + <filename name="**/doc-files/**"/>
2.35 + </fileset>
2.36 + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
2.37 + <include name="**/doc-files/**"/>
2.38 + </fileset>
2.39 + </copy>
2.40 </target>
2.41 <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
2.42 <nbbrowse file="${dist.javadoc.dir}/index.html"/>
3.1 --- a/samples/livedb/nbproject/genfiles.properties Wed Jul 14 20:56:33 2010 +0200
3.2 +++ b/samples/livedb/nbproject/genfiles.properties Thu Jul 15 00:40:37 2010 +0200
3.3 @@ -1,8 +1,8 @@
3.4 build.xml.data.CRC32=acb473e7
3.5 build.xml.script.CRC32=61ba5a6a
3.6 -build.xml.stylesheet.CRC32=958a1d3e@1.38.0.45
3.7 +build.xml.stylesheet.CRC32=28e38971@1.39.0.45
3.8 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
3.9 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
3.10 nbproject/build-impl.xml.data.CRC32=acb473e7
3.11 -nbproject/build-impl.xml.script.CRC32=c82572ef
3.12 -nbproject/build-impl.xml.stylesheet.CRC32=c75ce636@1.38.0.45
3.13 +nbproject/build-impl.xml.script.CRC32=e442701c
3.14 +nbproject/build-impl.xml.stylesheet.CRC32=78d75bcc@1.39.0.45
4.1 --- a/samples/livedb/nbproject/project.properties Wed Jul 14 20:56:33 2010 +0200
4.2 +++ b/samples/livedb/nbproject/project.properties Thu Jul 15 00:40:37 2010 +0200
4.3 @@ -26,6 +26,7 @@
4.4 dist.javadoc.dir=${dist.dir}/javadoc
4.5 endorsed.classpath=
4.6 excludes=
4.7 +file.reference.derby.jar=../libs/dist/derbyclient.jar
4.8 file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar
4.9 file.reference.org-openide-util-lookup.jar=../libs/dist/org-openide-util-lookup.jar
4.10 includes=**
4.11 @@ -42,6 +43,7 @@
4.12 javac.test.classpath=\
4.13 ${javac.classpath}:\
4.14 ${build.classes.dir}:\
4.15 + ${file.reference.derby.jar}:\
4.16 ${file.reference.junit-4.4.jar}
4.17 javac.test.processorpath=\
4.18 ${javac.test.classpath}
5.1 --- a/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Wed Jul 14 20:56:33 2010 +0200
5.2 +++ b/samples/livedb/src/org/apidesign/livedb/impl/LiveDBProcessor.java Thu Jul 15 00:40:37 2010 +0200
5.3 @@ -15,7 +15,11 @@
5.4 import java.sql.ResultSetMetaData;
5.5 import java.sql.SQLException;
5.6 import java.util.Enumeration;
5.7 +import java.util.Properties;
5.8 +import java.util.ServiceLoader;
5.9 import java.util.Set;
5.10 +import java.util.logging.Level;
5.11 +import java.util.logging.Logger;
5.12 import javax.annotation.processing.AbstractProcessor;
5.13 import javax.annotation.processing.Processor;
5.14 import javax.annotation.processing.RoundEnvironment;
5.15 @@ -46,7 +50,7 @@
5.16 try {
5.17 JavaFileObject src = processingEnv.getFiler().createSourceFile(clsName, pe);
5.18 Writer w = src.openWriter();
5.19 - Connection c = DriverManager.getConnection(db.url(), db.user(), db.password());
5.20 + Connection c = getConnection(db.url(), db.user(), db.password());
5.21 CallableStatement s = c.prepareCall(db.query());
5.22 ResultSet rs = s.executeQuery();
5.23 ResultSetMetaData md = rs.getMetaData();
5.24 @@ -103,12 +107,19 @@
5.25 return true;
5.26 }
5.27
5.28 - static {
5.29 - // init drivers
5.30 - Enumeration<Driver> en;
5.31 - en = DriverManager.getDrivers();
5.32 - while (en.hasMoreElements()) {
5.33 - Driver driver = en.nextElement();
5.34 + private static Connection getConnection(String url, String user, String password)
5.35 + throws SQLException {
5.36 + final ClassLoader cl = LiveDBProcessor.class.getClassLoader();
5.37 + for (Driver d : ServiceLoader.load(Driver.class, cl)) {
5.38 +// System.out.println("looked up: " + d);
5.39 + if (d.acceptsURL(url)) {
5.40 + //System.out.println("accepts: " + d);
5.41 + Properties p = new Properties();
5.42 + p.put("user", user);
5.43 + p.put("password", password);
5.44 + return d.connect(url, p);
5.45 + }
5.46 }
5.47 + throw new SQLException("No driver found for " + url);
5.48 }
5.49 }