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
|
||||
*/
|
||||
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(){
|
||||
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 {
|
||||
if (destinations != null) {
|
||||
ConnectionContext context = new ConnectionContext();
|
||||
context.setBroker(getBroker());
|
||||
ConnectionContext adminConnectionContext = getAdminConnectionContext();
|
||||
|
||||
for (int i = 0; i < destinations.length; 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
|
||||
* @throws Exception
|
||||
|
|
|
@ -182,6 +182,7 @@ public class EmptyBroker implements Broker{
|
|||
|
||||
/**
|
||||
* Notifiy the Broker that a dispatch has happened
|
||||
*
|
||||
* @param messageDispatch
|
||||
*/
|
||||
public void processDispatch(MessageDispatch messageDispatch) {
|
||||
|
@ -214,5 +215,11 @@ public class EmptyBroker implements Broker{
|
|||
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;
|
||||
|
||||
/**
|
||||
* 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$
|
||||
*/
|
||||
|
@ -204,17 +205,22 @@ public class ErrorBroker implements Broker {
|
|||
|
||||
public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||
throw new BrokerStoppedException(this.message);
|
||||
|
||||
}
|
||||
|
||||
public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||
throw new BrokerStoppedException(this.message);
|
||||
|
||||
}
|
||||
|
||||
public boolean isFaultTolerantConfiguration() {
|
||||
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();
|
||||
}
|
||||
|
||||
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) {
|
||||
ConnectionContext context = new ConnectionContext();
|
||||
context.setBroker(broker);
|
||||
return context;
|
||||
return broker.getAdminConnectionContext();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ public class RegionBroker implements Broker {
|
|||
private Map clientIdSet = new HashMap(); // we will synchronize access
|
||||
protected PersistenceAdapter adaptor;
|
||||
private final DestinationInterceptor destinationInterceptor;
|
||||
private ConnectionContext adminConnectionContext;
|
||||
|
||||
public RegionBroker(BrokerService brokerService,TaskRunnerFactory taskRunnerFactory, UsageManager memoryManager, PersistenceAdapter adapter, DestinationInterceptor destinationInterceptor) throws IOException {
|
||||
this.brokerService = brokerService;
|
||||
|
@ -533,5 +534,11 @@ public class RegionBroker implements Broker {
|
|||
return destinationInterceptor;
|
||||
}
|
||||
|
||||
|
||||
public ConnectionContext getAdminConnectionContext() {
|
||||
return adminConnectionContext;
|
||||
}
|
||||
|
||||
public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
|
||||
this.adminConnectionContext = adminConnectionContext;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue