From 9b5972c1ecc750c7801fc9641b51dbc2179e250c Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 22 Jul 2006 02:07:46 +0000 Subject: [PATCH] Work around Java's goddamned decision to make allocation and initialization happen at the same time. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1879 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/SimpleRepository.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/jdbc/SimpleRepository.java b/src/java/com/samskivert/jdbc/SimpleRepository.java index a101b0b3..38931157 100644 --- a/src/java/com/samskivert/jdbc/SimpleRepository.java +++ b/src/java/com/samskivert/jdbc/SimpleRepository.java @@ -59,12 +59,28 @@ public class SimpleRepository extends Repository * * @param provider the connection provider which will be used to * obtain our database connection. - * @param dbident the identifier of the database that will be accessed - * by this repository. + * @param dbident the identifier of the database that will be accessed by + * this repository or null if the derived class will call {@link + * #configureDatabaseIdent} by hand later. */ public SimpleRepository (ConnectionProvider provider, String dbident) { super(provider); + + if (dbident != null) { + configureDatabaseIdent(dbident); + } + } + + /** + * This is called automatically if a dbident is provided at construct time, + * but a derived class can pass null to its constructor and then call this + * method itself later if it wishes to obtain its database identifier from + * an overridable method which could not otherwise be called at construct + * time. + */ + protected void configureDatabaseIdent (String dbident) + { _dbident = dbident; // give the repository a chance to do any schema migration before