diff options
Diffstat (limited to 'archiva-database/src/main')
-rw-r--r-- | archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java index 4a3938f1d..b02cf1106 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java @@ -31,10 +31,9 @@ import org.codehaus.plexus.jdo.JdoFactory; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.jpox.PMFConfiguration; import org.jpox.SchemaTool; -import sun.security.action.GetLongAction; - import java.io.File; import java.io.PrintStream; import java.net.URL; @@ -79,23 +78,37 @@ public class JdoAccess throws InitializationException { pmf = jdoFactory.getPersistenceManagerFactory(); - + + /* Primitive (and failed) attempt at creating the schema on startup. + Just to prevent the multiple stack trace warnings on auto-gen of schema. + // Create the schema (if needed) URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; File propsFile = null; // intentional boolean verbose = true; - + try { + String connectionFactoryName = pmf.getConnectionFactoryName(); + if ( StringUtils.isNotBlank( connectionFactoryName ) && connectionFactoryName.startsWith( "java:comp" ) ) + { + // We have a JNDI datasource! + String jndiDatasource = connectionFactoryName; + System.setProperty( PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, jndiDatasource ); + } + + // TODO: figure out how to get the jdbc driver details from JNDI to pass into SchemaTool. + SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); } catch ( Exception e ) { getLogger().error( "Unable to create schema: " + e.getMessage(), e ); } - + pmf.getPersistenceManager(); + */ // Add the lifecycle listener. pmf.addInstanceLifecycleListener( this, null ); @@ -352,7 +365,7 @@ public class JdoAccess + "> declared parameters, yet there are <" + constraint.getParameters().length + "> parameter objects to use. This should be equal." ); } - + query.declareParameters( StringUtils.join( constraint.getDeclaredParameters(), ", " ) ); return processParameterizedQuery( query, constraint.getParameters() ); |