<property name="dist.src" value="${app.name}.jar"/>
<property name="dist.war" value="${app.name}.war"/>
<property name="javadoc.home" value="${deploy.home}/javadoc"/>
- <property name="build.compiler" value="jikes"/>
<!-- The "prepare" target is used to construct the deployment home
<copy todir="${deploy.home}/WEB-INF/classes">
<fileset dir="source" includes="**/*.properties"/>
</copy>
+ <copy todir="${deploy.home}/WEB-INF/classes">
+ <fileset dir="source" includes="**/*.xml"/>
+ </copy>
<copy todir="${deploy.home}">
<fileset dir="source" includes="**/content-types.properties"/>
- <fileset dir="source" includes="**/server.xml"/>
</copy>
</target>
try {
if (usersModule == null) usersModule = new ModuleUsers(DatabaseUsers.getInstance());
return usersModule.getUserForLogin(user, password);
+ } catch(Exception e) {
+ theLog.printDebugInfo(e.toString());
+ e.printStackTrace();
+ return null;
}
- catch(Exception e) { theLog.printDebugInfo(e.toString()); return null; }
}
// Redirect-methods
import java.util.*;
import java.lang.*;
import com.javaexchange.dbConnectionBroker.*;
-import mir.storage.StorageObjectException;
+import mir.storage.StorageObjectException;
+import com.codestudio.util.*;
/**
* Title: Mir
return (String)configHash.get("Home") +
(String)configHash.get(propName);
}
-
+
public static void addBroker(String driver, String URL) throws StorageObjectException {
String username,passwd,min,max,log,reset;
log=getProp("Home") + configHash.get("Database.PoolLog");
reset=getProp("Database.poolResetTime");
+ System.err.println("-- making Broker for -"
+ +driver+" - " +URL
+ + " log " + log + " user "
+ + username + " pass: " + passwd);
+
+ JDBCPoolMetaData meta = new JDBCPoolMetaData();
+ meta.setDbname("mir");
+ meta.setDriver(driver);
+ meta.setURL(URL);
+ meta.setUserName(username);
+ meta.setPassword(passwd);
+ meta.setJNDIName("mir");
+ meta.setMaximumSize(Integer.parseInt(max));
+ meta.setMinimumSize(Integer.parseInt(min));
+
+ JDBCPool pool = SQLManager.getInstance().createPool(meta);
+ SQLManager.getInstance().addPool("mir",pool);
+
+ if (pool!=null){
+ instances++;
+ brokerHash.put("Pool.broker",pool);
+ }
+
+ } // end if
+ }
+
+ public static void addBroker2(String driver, String URL) throws StorageObjectException {
+
+ String username,passwd,min,max,log,reset;
+
+ if(!brokerHash.containsKey("Pool.broker")){
+ username=getProp("Database.Username");
+ passwd=getProp("Database.Password");
+ min=getProp("Database.poolMin");
+ max=getProp("Database.poolMax");
+ log=getProp("Home") + configHash.get("Database.PoolLog");
+ reset=getProp("Database.poolResetTime");
+
try{
System.err.println("-- making Broker for -"
+driver+" - " +URL
} catch(IOException e){
System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace();
throw new StorageObjectException(e.toString());
- }
+ }
} // end if
}
/**
- * Liefert DBConnectionBroker einer Configuration zurueck
- * @param confFilename
- * @return DBConnectionBroker
- */
- public static DbConnectionBroker getBroker() {
- DbConnectionBroker broker=null;
- broker=(DbConnectionBroker)brokerHash.get("Pool.broker");
- if (broker==null) {
- System.err.println("Konnte kein ConnectionPoolBroker initialisiert werden");
- }
- return broker;
- }
-
- /**
- * Liefert Anzahl der Instantiierten DBConnectionBroker zurueck
- * @return
- */
- public static int getBrokerInstances() {
- return instances;
- }
-
- public static DbConnectionBroker getBrokerInfo(){
- return (DbConnectionBroker)brokerHash.get("Pool.broker");
- }
-
- /**
* Finalize method
*/
public void finalize(){
getSimpleInfo(res.getWriter(),getConfs());
PrintWriter out = res.getWriter();
out.println(getInstancesInfo());
- out.println(getInstancesConfInfo());
}
catch (Exception e) {
public String getInstancesInfo(){
return "<table><tr><td>Momentan instanzierte EntityObjekte = </td><td>" + getInstances()+"</td></tr></table>\n";
}
- public String getInstancesConfInfo(){
- return "<table><tr><td>Momentan instanzierte BrokerObjekte = </td><td>" + getConfBrokerCnt()+"</td></tr></table>\n";
- }
-
protected HashMap getConfs(){
return Configuration.getConfs();
}
protected int getBrokerUseCnt(DbConnectionBroker broker){
return broker.getUseCount();
}
- protected int getConfBrokerCnt(){
- return MirConfig.getBrokerInstances();
- }
+
protected int getBrokerSize(DbConnectionBroker broker){
return broker.getSize();
}
String key;
DbConnectionBroker broker = null;
out.write(getInstancesInfo());
- out.write(getInstancesConfInfo());
Set set = confs.keySet();
Iterator it = set.iterator();
for (int i=0;i<set.size();i++){
key=(String)it.next();
out.write("<table><tr><td>Konfiguration : </td><td>" + confs.get(key)+ "</td></tr>\n" );
- broker=MirConfig.getBrokerInfo();
//broker=(DbConnectionBroker) ((HashMap)confs.get(key)).get("Pool.broker");
if(broker!=null) out.write(getBrokerInfo(broker));
else
import mir.storage.StorageObject;
import mir.entity.*;
import mir.misc.*;
+import com.codestudio.sql.*;
+import com.codestudio.sql.*;
+import com.codestudio.util.*;
/**
database_url=theAdaptor.getURL(database_username,database_password,database_host);
theLog.printDebugInfo("adding Broker with: " +database_driver+":"+database_url );
MirConfig.addBroker(database_driver,database_url);
- myBroker=MirConfig.getBroker();
+ //myBroker=MirConfig.getBroker();
}
catch (Exception e){
theLog.printError("Bei Konstruktion von Database() with " + theAdaptorName + " -- " +e.toString());
throwSQLException(sqe, "disconnectPool");
}
}
+
+ public Connection getPooledCon() throws StorageObjectException {
+ try{
+ Class.forName("com.codestudio.sql.PoolMan").newInstance();
+ } catch (Exception e){
+ e.printStackTrace();
+ throw new StorageObjectException("Could not find the PoolMan Driver"+e.toString());
+ }
+ Connection con = null;
+ try{
+ con = SQLManager.getInstance().requestConnection();
+ } catch(SQLException e){
+ e.printStackTrace();
+ throw new StorageObjectException("No connection to the database");
+ }
+ return con;
+ }
/**
* Returns Connection-Object out of the PoolBroker.
*
* @return Connection Object.
*/
- public Connection getPooledCon () throws StorageObjectException {
+ public Connection getPooledCon2() throws StorageObjectException {
if (myBroker != null) {
Connection con = myBroker.getConnection();
if (con != null)
* @param con Connection zur Datenbank
* @param stmt Statement-Objekt
*/
- public void freeConnection (Connection con, Statement stmt)
+ public void freeConnection2 (Connection con, Statement stmt)
throws StorageObjectException {
try {
if (stmt != null)
throw new StorageObjectException("Con was null!");
}
}
+
+ public void freeConnection (Connection con, Statement stmt)
+ throws StorageObjectException {
+ SQLManager.getInstance().closeStatement(stmt);
+ SQLManager.getInstance().returnConnection(con);
+ }
/**
* Wertet SQLException aus und wirft dannach eine StorageObjectException