X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcomponents%2FDatabaseComponent.java;h=fc941724e9a2b215edd45313ba435f4032c3a79b;hb=cb91054f35281c6fc5619f93ff71df46bf4686b9;hp=afcc581aba29c2a328ab35962cf8c180ea3ab15d;hpb=194e49725ed5ac15346c5f5a1fc874876132bca5;p=utils diff --git a/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java b/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java index afcc581a..fc941724 100644 --- a/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java +++ b/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,48 +17,60 @@ package org.wamblee.system.components; import java.util.Properties; -import org.wamblee.support.persistence.Database; -import org.wamblee.support.persistence.DerbyDatabase; import org.wamblee.system.components.ORMappingConfig.DatabaseType; import org.wamblee.system.core.AbstractComponent; import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.Scope; +import org.wamblee.test.persistence.Database; +import org.wamblee.test.persistence.DerbyDatabase; +/** + * + * @author $author$ + * @version $Revision$ + */ public class DatabaseComponent extends AbstractComponent { - - private static ProvidedInterface DB_PROPS = new DefaultProvidedInterface("dbProps", Properties.class); - - private Database _database; - - public DatabaseComponent(String aName, Database aDatabase) { - super(aName); - _database = aDatabase; + private static ProvidedInterface DB_PROPS = new DefaultProvidedInterface( + "dbProps", Properties.class); + + private Database database; + + /** + * Creates a new DatabaseComponent object. + * + */ + public DatabaseComponent(String aName, Database aDatabase) { + super(aName); + database = aDatabase; addProvidedInterface(DB_PROPS); } @Override protected Database doStart(Scope aScope) { - _database.start(); - + database.start(); + Properties props = new Properties(); - if ( _database instanceof DerbyDatabase ) { + + if (database instanceof DerbyDatabase) { props.put("database.type", DatabaseType.DERBY.toString()); - } else { - throw new IllegalArgumentException("Unknown database type " + _database); + } else { + throw new IllegalArgumentException("Unknown database type " + + database); } - //props.put("database.driver", _database.getDriverClassName()); - props.put("database.url", _database.getJdbcUrl()); - props.put("database.username", _database.getUsername()); - props.put("database.password", _database.getPassword()); + + // props.put("database.driver", database.getDriverClassName()); + props.put("database.url", database.getJdbcUrl()); + props.put("database.username", database.getUsername()); + props.put("database.password", database.getPassword()); addInterface(DB_PROPS, props, aScope); - return _database; + + return database; } @Override protected void doStop(Database aRuntime) { - _database.stop(); + database.stop(); } - }