mirror of https://github.com/apache/activemq.git
added a helper method on the broker for its default administration connection context to avoid various parts of the code spoofing one and to provide a single place we can register any particular security details for startup or runtime MBean based administration
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@426132 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4bd8a8bf85
commit
8abb655e82
|
@ -238,4 +238,14 @@ public interface Broker extends Region, Service {
|
||||||
* @return true if fault tolerant
|
* @return true if fault tolerant
|
||||||
*/
|
*/
|
||||||
public boolean isFaultTolerantConfiguration();
|
public boolean isFaultTolerantConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the connection context used to make administration operations on startup or via JMX MBeans
|
||||||
|
*/
|
||||||
|
public abstract ConnectionContext getAdminConnectionContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the default administration connection context used when configuring the broker on startup or via JMX
|
||||||
|
*/
|
||||||
|
public abstract void setAdminConnectionContext(ConnectionContext adminConnectionContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,9 +213,16 @@ public class BrokerFilter implements Broker {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isFaultTolerantConfiguration(){
|
public boolean isFaultTolerantConfiguration(){
|
||||||
return next.isFaultTolerantConfiguration();
|
return next.isFaultTolerantConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectionContext getAdminConnectionContext() {
|
||||||
|
return next.getAdminConnectionContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||||
|
next.setAdminConnectionContext(adminConnectionContext);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1202,16 +1202,41 @@ public class BrokerService implements Service, Serializable {
|
||||||
*/
|
*/
|
||||||
protected void startDestinations() throws Exception {
|
protected void startDestinations() throws Exception {
|
||||||
if (destinations != null) {
|
if (destinations != null) {
|
||||||
ConnectionContext context = new ConnectionContext();
|
ConnectionContext adminConnectionContext = getAdminConnectionContext();
|
||||||
context.setBroker(getBroker());
|
|
||||||
|
|
||||||
for (int i = 0; i < destinations.length; i++) {
|
for (int i = 0; i < destinations.length; i++) {
|
||||||
ActiveMQDestination destination = destinations[i];
|
ActiveMQDestination destination = destinations[i];
|
||||||
getBroker().addDestination(context, destination);
|
getBroker().addDestination(adminConnectionContext, destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the broker's administration connection context used for configuring the broker
|
||||||
|
* at startup
|
||||||
|
*/
|
||||||
|
public ConnectionContext getAdminConnectionContext() throws Exception {
|
||||||
|
ConnectionContext adminConnectionContext = getBroker().getAdminConnectionContext();
|
||||||
|
if (adminConnectionContext == null) {
|
||||||
|
adminConnectionContext = createAdminConnectionContext();
|
||||||
|
getBroker().setAdminConnectionContext(adminConnectionContext);
|
||||||
|
}
|
||||||
|
return adminConnectionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to create the new administration connection context object.
|
||||||
|
* Note this method is here rather than inside a default broker implementation to
|
||||||
|
* ensure that the broker reference inside it is the outer most interceptor
|
||||||
|
*/
|
||||||
|
protected ConnectionContext createAdminConnectionContext() throws Exception {
|
||||||
|
ConnectionContext context = new ConnectionContext();
|
||||||
|
context.setBroker(getBroker());
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start all transport and network connections, proxies and bridges
|
* Start all transport and network connections, proxies and bridges
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
|
@ -182,6 +182,7 @@ public class EmptyBroker implements Broker{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifiy the Broker that a dispatch has happened
|
* Notifiy the Broker that a dispatch has happened
|
||||||
|
*
|
||||||
* @param messageDispatch
|
* @param messageDispatch
|
||||||
*/
|
*/
|
||||||
public void processDispatch(MessageDispatch messageDispatch) {
|
public void processDispatch(MessageDispatch messageDispatch) {
|
||||||
|
@ -214,5 +215,11 @@ public class EmptyBroker implements Broker{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectionContext getAdminConnectionContext() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,8 @@ import org.apache.activemq.command.SessionInfo;
|
||||||
import org.apache.activemq.command.TransactionId;
|
import org.apache.activemq.command.TransactionId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the broker where all it's methods throw an BrokerStoppedException.
|
* Implementation of the broker where all it's methods throw an
|
||||||
|
* BrokerStoppedException.
|
||||||
*
|
*
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
@ -204,17 +205,22 @@ public class ErrorBroker implements Broker {
|
||||||
|
|
||||||
public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||||
throw new BrokerStoppedException(this.message);
|
throw new BrokerStoppedException(this.message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||||
throw new BrokerStoppedException(this.message);
|
throw new BrokerStoppedException(this.message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFaultTolerantConfiguration() {
|
public boolean isFaultTolerantConfiguration() {
|
||||||
throw new BrokerStoppedException(this.message);
|
throw new BrokerStoppedException(this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectionContext getAdminConnectionContext() {
|
||||||
|
throw new BrokerStoppedException(this.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||||
|
throw new BrokerStoppedException(this.message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,4 +229,12 @@ public class MutableBrokerFilter implements Broker {
|
||||||
return getNext().isFaultTolerantConfiguration();
|
return getNext().isFaultTolerantConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectionContext getAdminConnectionContext() {
|
||||||
|
return getNext().getAdminConnectionContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||||
|
getNext().setAdminConnectionContext(adminConnectionContext);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,9 +180,7 @@ public class BrokerView implements BrokerViewMBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ConnectionContext getConnectionContext(Broker broker) {
|
static public ConnectionContext getConnectionContext(Broker broker) {
|
||||||
ConnectionContext context = new ConnectionContext();
|
return broker.getAdminConnectionContext();
|
||||||
context.setBroker(broker);
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class RegionBroker implements Broker {
|
||||||
private Map clientIdSet = new HashMap(); // we will synchronize access
|
private Map clientIdSet = new HashMap(); // we will synchronize access
|
||||||
protected PersistenceAdapter adaptor;
|
protected PersistenceAdapter adaptor;
|
||||||
private final DestinationInterceptor destinationInterceptor;
|
private final DestinationInterceptor destinationInterceptor;
|
||||||
|
private ConnectionContext adminConnectionContext;
|
||||||
|
|
||||||
public RegionBroker(BrokerService brokerService,TaskRunnerFactory taskRunnerFactory, UsageManager memoryManager, PersistenceAdapter adapter, DestinationInterceptor destinationInterceptor) throws IOException {
|
public RegionBroker(BrokerService brokerService,TaskRunnerFactory taskRunnerFactory, UsageManager memoryManager, PersistenceAdapter adapter, DestinationInterceptor destinationInterceptor) throws IOException {
|
||||||
this.brokerService = brokerService;
|
this.brokerService = brokerService;
|
||||||
|
@ -533,5 +534,11 @@ public class RegionBroker implements Broker {
|
||||||
return destinationInterceptor;
|
return destinationInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectionContext getAdminConnectionContext() {
|
||||||
|
return adminConnectionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||||
|
this.adminConnectionContext = adminConnectionContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue