Adding back ability to configure the data directory and datasource.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@389528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-03-28 16:03:28 +00:00
parent d1a18f5787
commit 5a392bee0a
2 changed files with 61 additions and 2 deletions

View File

@ -18,13 +18,18 @@ package org.apache.activemq.gbean;
import java.net.URI; import java.net.URI;
import javax.sql.DataSource;
import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.store.DefaultPersistenceAdapterFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle; import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.system.serverinfo.ServerInfo;
/** /**
* Default implementation of the ActiveMQ Message Server * Default implementation of the ActiveMQ Message Server
@ -38,6 +43,9 @@ public class BrokerServiceGBeanImpl implements GBeanLifecycle, BrokerServiceGBea
private String brokerName; private String brokerName;
private String brokerUri; private String brokerUri;
private BrokerService brokerService; private BrokerService brokerService;
private ServerInfo serverInfo;
private String dataDirectory;
private DataSourceReference dataSource;
public BrokerServiceGBeanImpl() { public BrokerServiceGBeanImpl() {
} }
@ -52,8 +60,11 @@ public class BrokerServiceGBeanImpl implements GBeanLifecycle, BrokerServiceGBea
try { try {
if (brokerService == null) { if (brokerService == null) {
brokerService = createContainer(); brokerService = createContainer();
brokerService.start();
} }
DefaultPersistenceAdapterFactory persistenceFactory = brokerService.getPersistenceFactory();
persistenceFactory.setDataDirectory(serverInfo.resolve(dataDirectory));
persistenceFactory.setDataSource((DataSource) dataSource.$getResource());
brokerService.start();
} finally { } finally {
Thread.currentThread().setContextClassLoader(old); Thread.currentThread().setContextClassLoader(old);
} }
@ -95,8 +106,11 @@ public class BrokerServiceGBeanImpl implements GBeanLifecycle, BrokerServiceGBea
static { static {
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker", BrokerServiceGBeanImpl.class, "JMSServer"); GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker", BrokerServiceGBeanImpl.class, "JMSServer");
infoFactory.addReference("serverInfo", ServerInfo.class);
infoFactory.addAttribute("brokerName", String.class, true); infoFactory.addAttribute("brokerName", String.class, true);
infoFactory.addAttribute("brokerUri", String.class, true); infoFactory.addAttribute("brokerUri", String.class, true);
infoFactory.addAttribute("dataDirectory", String.class, true);
infoFactory.addReference("dataSource", DataSourceReference.class);
infoFactory.addInterface(BrokerServiceGBean.class); infoFactory.addInterface(BrokerServiceGBean.class);
// infoFactory.setConstructor(new String[]{"brokerName, brokerUri"}); // infoFactory.setConstructor(new String[]{"brokerName, brokerUri"});
GBEAN_INFO = infoFactory.getBeanInfo(); GBEAN_INFO = infoFactory.getBeanInfo();
@ -125,5 +139,29 @@ public class BrokerServiceGBeanImpl implements GBeanLifecycle, BrokerServiceGBea
this.brokerUri = brokerUri; this.brokerUri = brokerUri;
} }
public ServerInfo getServerInfo() {
return serverInfo;
}
public void setServerInfo(ServerInfo serverInfo) {
this.serverInfo = serverInfo;
}
public String getDataDirectory() {
return dataDirectory;
}
public void setDataDirectory(String dataDir) {
this.dataDirectory = dataDir;
}
public DataSourceReference getDataSource() {
return dataSource;
}
public void setDataSource(DataSourceReference dataSource) {
this.dataSource = dataSource;
}
} }

View File

@ -0,0 +1,21 @@
/**
*
* Copyright 2005-2006 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.activemq.gbean;
public interface DataSourceReference {
public Object $getResource();
}