Author: jboynes
Date: Fri Oct 1 12:55:52 2004
New Revision: 51751
Added:
geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java
geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystem.java
Modified:
geronimo/trunk/modules/assembly/project.xml
geronimo/trunk/modules/assembly/src/plan/system-database-plan.xml
geronimo/trunk/modules/derby/derby.iml
geronimo/trunk/modules/derby/project.xml
geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
Log:
Add basic network support for Derby
Modified: geronimo/trunk/modules/assembly/project.xml
==============================================================================
--- geronimo/trunk/modules/assembly/project.xml (original)
+++ geronimo/trunk/modules/assembly/project.xml Fri Oct 1 12:55:52 2004
@@ -338,6 +338,15 @@
</dependency>
<dependency>
+ <groupId>derby</groupId>
+ <artifactId>derbynet</artifactId>
+ <version>&derby-version;</version>
+ <properties>
+ <repository>true</repository>
+ </properties>
+ </dependency>
+
+ <dependency>
<groupId>castor</groupId>
<artifactId>castor</artifactId>
<version>&castor-version;</version>
Modified: geronimo/trunk/modules/assembly/src/plan/system-database-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/system-database-plan.xml (original)
+++ geronimo/trunk/modules/assembly/src/plan/system-database-plan.xml Fri Oct 1 12:55:52
2004
@@ -27,6 +27,9 @@
<uri>derby/jars/derby-${derby_version}.jar</uri>
</dependency>
<dependency>
+ <uri>derby/jars/derbynet-${derby_version}.jar</uri>
+ </dependency>
+ <dependency>
<uri>geronimo/jars/geronimo-derby-${geronimo_version}.jar</uri>
</dependency>
@@ -55,11 +58,17 @@
</outbound-resourceadapter>
</resourceadapter>
- <gbean name="geronimo.server:type=DerbyDatabase,role=SystemDatabase" class="org.apache.geronimo.derby.DerbySystemGBean">
+ <gbean name="geronimo.server:role=DerbySystem" class="org.apache.geronimo.derby.DerbySystemGBean">
<reference name="serverInfo">geronimo.system:role=ServerInfo</reference>
<attribute name="derbySystemHome" type="java.lang.String">var/derby</attribute>
</gbean>
-<!--
+ <gbean name="geronimo.server:role=DerbyNetwork" class="org.apache.geronimo.derby.DerbyNetworkGBean">
+ <reference name="derbySystem">geronimo.server:role=DerbySystem</reference>
+ <attribute name="host" type="java.lang.String">127.0.0.1</attribute>
+ <attribute name="port" type="int">1527</attribute>
+ </gbean>
+
+ <!--
<gbean name="geronimo.server:type=ThreadPooledTimer,name=JDBCTransactionalThreadPooledTimer"
class="org.apache.geronimo.timer.jdbc.JDBCStoreThreadPooledTransactionalTimer">
<attribute name="repeatCount" type="int">5</attribute>
<reference name="TransactionContextManager">geronimo.server:type=TransactionContextManager</reference>
Modified: geronimo/trunk/modules/derby/derby.iml
==============================================================================
--- geronimo/trunk/modules/derby/derby.iml (original)
+++ geronimo/trunk/modules/derby/derby.iml Fri Oct 1 12:55:52 2004
@@ -16,6 +16,7 @@
<orderEntry type="library" name="derby" level="application" />
<orderEntry type="library" name="junit-3.8.1" level="application" />
<orderEntry type="module" module-name="system" />
+ <orderEntry type="library" name="commons-logging-1.0.3" level="application" />
<orderEntryProperties />
</component>
</module>
Modified: geronimo/trunk/modules/derby/project.xml
==============================================================================
--- geronimo/trunk/modules/derby/project.xml (original)
+++ geronimo/trunk/modules/derby/project.xml Fri Oct 1 12:55:52 2004
@@ -68,6 +68,13 @@
<artifactId>derbynet</artifactId>
<version>&derby-version;</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>&commons-logging-version;</version>
+ <url>http://jakarta.apache.org/commons/logging/</url>
+ </dependency>
</dependencies>
Added: geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbyNetworkGBean.java
Fri Oct 1 12:55:52 2004
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.derby;
+
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.WaitingException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.net.InetAddress;
+
+/**
+ * A GBean that manages remote network access to the embedded Derby server.
+ *
+ * todo need to figure out how to configure this without using system properties
+ * @version $Rev: 47413 $ $Date: 2004-09-28 11:46:39 -0700 (Tue, 28 Sep 2004) $
+ */
+public class DerbyNetworkGBean implements GBeanLifecycle {
+ private static final Log log = LogFactory.getLog("DerbyNetwork");
+
+ private NetworkServerControl network;
+ private String host = "localhost";
+ private int port = 1527;
+
+ public DerbyNetworkGBean(DerbySystem system) {
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public void doStart() throws WaitingException, Exception {
+ InetAddress address = InetAddress.getByName(host);
+ network = new NetworkServerControl(address, port);
+ network.start(null); // todo work out how to add this to our log stream
+ log.info("Started on host " + host + ':' + port);
+ }
+
+ public void doStop() throws WaitingException, Exception {
+ if (network != null) {
+ try {
+ network.shutdown();
+ } finally {
+ network = null;
+ }
+ }
+ log.info("Stopped");
+ }
+
+ public void doFail() {
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
+ static {
+ GBeanInfoFactory infoFactory = new GBeanInfoFactory(DerbyNetworkGBean.class);
+ infoFactory.addAttribute("host", String.class, true);
+ infoFactory.addAttribute("port", Integer.TYPE, true);
+ infoFactory.addReference("derbySystem", DerbySystem.class);
+ infoFactory.setConstructor(new String[]{"derbySystem"});
+ GBEAN_INFO = infoFactory.getBeanInfo();
+ }
+}
Added: geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystem.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystem.java Fri Oct
1 12:55:52 2004
@@ -0,0 +1,11 @@
+package org.apache.geronimo.derby;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: jboynes
+ * Date: Oct 1, 2004
+ * Time: 11:25:52 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface DerbySystem {
+}
Modified: geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
==============================================================================
--- geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
(original)
+++ geronimo/trunk/modules/derby/src/java/org/apache/geronimo/derby/DerbySystemGBean.java
Fri Oct 1 12:55:52 2004
@@ -22,6 +22,8 @@
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.sql.DriverManager;
@@ -33,7 +35,8 @@
*
* @version $Rev: 47413 $ $Date: 2004-09-28 11:46:39 -0700 (Tue, 28 Sep 2004) $
*/
-public class DerbySystemGBean implements GBeanLifecycle {
+public class DerbySystemGBean implements DerbySystem, GBeanLifecycle {
+ private static final Log log = LogFactory.getLog("DerbySystem");
private static final String SYSTEM_HOME = "derby.system.home";
private static final String SHUTDOWN_ALL = "jdbc:derby:;shutdown=true";
@@ -54,10 +57,16 @@
System.setProperty(SYSTEM_HOME, actualHome);
// load the Embedded driver to initialize the home
new org.apache.derby.jdbc.EmbeddedDriver();
+ log.info("Started in " + actualHome);
}
public void doStop() throws WaitingException, Exception {
- doFail();
+ try {
+ DriverManager.getConnection(SHUTDOWN_ALL, null, null);
+ } catch (SQLException e) {
+ // SQLException gets thrown on successful shutdown so ignore
+ }
+ log.info("Stopped");
}
public void doFail() {
@@ -66,6 +75,7 @@
} catch (SQLException e) {
// SQLException gets thrown on successful shutdown so ignore
}
+ log.info("Failed");
}
public static final GBeanInfo GBEAN_INFO;
|