henning 2003/06/22 15:28:05
Modified: src/java/org/apache/torque/avalon TorqueComponent.java
Log:
- We should (must?) implement the o.a.avalon.framework.component.Component interface
- remove Disposable interface, replaced with startable()
- to make sure that we won't get instantiated and destroyed every time
a TorqueComponent is requested, we implement ThreadSafe. This relies
on the effect (side effect?) that a component marked like this will
be instantiated only one time. The Torque whitepaper talks about " A
Component that implements this interface will generally only have
one instance available in the system, and other Components will use
that one instance." (http://avalon.apache.org/developing/framework.html))
I don't like the "generally", though.
Revision Changes Path
1.3 +26 -6 db-torque/src/java/org/apache/torque/avalon/TorqueComponent.java
Index: TorqueComponent.java
===================================================================
RCS file:
/home/cvs/db-torque/src/java/org/apache/torque/avalon/TorqueComponent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TorqueComponent.java 21 Jun 2003 11:50:13 -0000 1.2
+++ TorqueComponent.java 22 Jun 2003 22:28:05 -0000 1.3
@@ -56,8 +56,9 @@
import java.sql.Connection;
-import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -65,6 +66,7 @@
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.commons.lang.StringUtils;
@@ -83,7 +85,12 @@
*/
public class TorqueComponent
extends AbstractLogEnabled
- implements Configurable, Initializable, Disposable, Contextualizable
+ implements Component,
+ Configurable,
+ Initializable,
+ Contextualizable,
+ Startable,
+ ThreadSafe
{
/** The Avalon Context */
private Context context = null;
@@ -178,13 +185,26 @@
}
/**
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ * This does nothing but must be present so the container does
+ * not defer initialization until the component is requested for
+ * the first time.
+ *
+ * @see org.apache.avalon.framework.activity.Startable#start()
*/
- public void dispose()
+ public void start()
{
- getLogger().debug("dispose()");
+ getLogger().debug("start()");
+ }
+
+ /**
+ * @see org.apache.avalon.framework.activity.Startable#stop()
+ */
+ public void stop()
+ {
+ getLogger().debug("stop()");
getTorque().shutdown();
}
+
/*
* ========================================================================
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]