You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2007/03/08 00:00:15 UTC
svn commit: r515827 -
/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java
Author: cschoett
Date: Wed Mar 7 15:00:14 2007
New Revision: 515827
URL: http://svn.apache.org/viewvc?view=rev&rev=515827
Log:
Fixed a problem which caused the JDBC system control to not be able to re-establish a JDBC connection after deserialization.
Modified:
beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java
Modified: beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java?view=diff&rev=515827&r1=515826&r2=515827
==============================================================================
--- beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java (original)
+++ beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java Wed Mar 7 15:00:14 2007
@@ -103,25 +103,6 @@
public JdbcControlImpl() { }
/**
- * Invoked when this implementation is created.
- */
- @EventHandler(field = "_context", eventSet = ControlBeanContext.LifeCycle.class, eventName = "onCreate")
- public void onCreate() {
-
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Enter: onCreate()");
- }
-
- _connectionDataSource = _context.getControlPropertySet(ConnectionDataSource.class);
- _connectionDriver = _context.getControlPropertySet(ConnectionDriver.class);
- ConnectionOptions connectionOptions = _context.getControlPropertySet(ConnectionOptions.class);
- _externalConnection = connectionOptions.useExternalConnection();
-
- _connectionAnnotations = (_connectionDataSource != null && _connectionDataSource.jndiName() != null)
- || (_connectionDriver != null && _connectionDriver.databaseDriverClass() != null);
- }
-
- /**
* Invoked by the controls runtime when a new instance of this class is aquired by the runtime.
* The default behavior of this method is to acquire a new connection to the database using the
* information from the ConnectionDataSource or ConnectionDriver annotation. If neither of these
@@ -135,6 +116,8 @@
LOGGER.debug("Enter: onAquire()");
}
+ loadConnectionAnnotationValues();
+
// if the connection annotations are not present or using an external connection just return
if (!_connectionAnnotations || _externalConnection) {
return;
@@ -275,7 +258,7 @@
protected Object execPreparedStatement(Method method, Object[] args)
throws Throwable {
- final SQL methodSQL = (SQL) _context.getMethodPropertySet(method, SQL.class);
+ final SQL methodSQL = _context.getMethodPropertySet(method, SQL.class);
if (methodSQL == null || methodSQL.statement() == null) {
throw new ControlException("Method " + method.getName() + " is missing @SQL annotation");
}
@@ -437,6 +420,20 @@
_connection = null;
_externalConnection = false;
+ }
+
+ /**
+ * Load the connection anntotations' values into private members.
+ */
+ private void loadConnectionAnnotationValues() {
+
+ _connectionDataSource = _context.getControlPropertySet(ConnectionDataSource.class);
+ _connectionDriver = _context.getControlPropertySet(ConnectionDriver.class);
+ ConnectionOptions connectionOptions = _context.getControlPropertySet(ConnectionOptions.class);
+ _externalConnection = connectionOptions.useExternalConnection();
+
+ _connectionAnnotations = (_connectionDataSource != null && _connectionDataSource.jndiName() != null)
+ || (_connectionDriver != null && _connectionDriver.databaseDriverClass() != null);
}
/**