activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r426132 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker: ./ jmx/ region/
Date Thu, 27 Jul 2006 16:39:10 GMT
Author: jstrachan
Date: Thu Jul 27 09:39:09 2006
New Revision: 426132

URL: http://svn.apache.org/viewvc?rev=426132&view=rev
Log:
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

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Broker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Broker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Broker.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Broker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Broker.java
Thu Jul 27 09:39:09 2006
@@ -238,4 +238,14 @@
      * @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);
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerFilter.java
Thu Jul 27 09:39:09 2006
@@ -213,9 +213,16 @@
         
     }
 
-
     public boolean isFaultTolerantConfiguration(){
         return next.isFaultTolerantConfiguration();
     }
 
+    public ConnectionContext getAdminConnectionContext() {
+        return next.getAdminConnectionContext();
+    }
+
+    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
+        next.setAdminConnectionContext(adminConnectionContext);
+    }
+    
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Thu Jul 27 09:39:09 2006
@@ -1202,16 +1202,41 @@
      */
     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

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/EmptyBroker.java
Thu Jul 27 09:39:09 2006
@@ -42,18 +42,18 @@
  * 
  * @version $Revision$
  */
-public class EmptyBroker implements Broker{
+public class EmptyBroker implements Broker {
 
-    public BrokerId getBrokerId(){
+    public BrokerId getBrokerId() {
         return null;
     }
 
-    public String getBrokerName(){
+    public String getBrokerName() {
         return null;
     }
-    
-    public Broker getAdaptor(Class type){
-        if (type.isInstance(this)){
+
+    public Broker getAdaptor(Class type) {
+        if (type.isInstance(this)) {
             return this;
         }
         return null;
@@ -67,152 +67,159 @@
         return Collections.EMPTY_SET;
     }
 
-    public void addConnection(ConnectionContext context,ConnectionInfo info) throws Exception{
+    public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception
{
 
     }
 
-    public void removeConnection(ConnectionContext context,ConnectionInfo info,Throwable
error) throws Exception{
+    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable
error) throws Exception {
 
     }
 
-    public void addSession(ConnectionContext context,SessionInfo info) throws Exception{
+    public void addSession(ConnectionContext context, SessionInfo info) throws Exception
{
 
     }
 
-    public void removeSession(ConnectionContext context,SessionInfo info) throws Exception{
+    public void removeSession(ConnectionContext context, SessionInfo info) throws Exception
{
 
     }
 
-    public void addProducer(ConnectionContext context,ProducerInfo info) throws Exception{
+    public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
 
     }
 
-    public void removeProducer(ConnectionContext context,ProducerInfo info) throws Exception{
+    public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
{
 
     }
 
-    public Connection[] getClients() throws Exception{
+    public Connection[] getClients() throws Exception {
 
         return null;
     }
 
-    public ActiveMQDestination[] getDestinations() throws Exception{
+    public ActiveMQDestination[] getDestinations() throws Exception {
 
         return null;
     }
 
-    public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception{
+    public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception
{
 
         return null;
     }
 
-    public void beginTransaction(ConnectionContext context,TransactionId xid) throws Exception{
+    public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception
{
 
     }
 
-    public int prepareTransaction(ConnectionContext context,TransactionId xid) throws Exception{
+    public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception
{
 
         return 0;
     }
 
-    public void rollbackTransaction(ConnectionContext context,TransactionId xid) throws Exception{
+    public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws
Exception {
 
     }
 
-    public void commitTransaction(ConnectionContext context,TransactionId xid,boolean onePhase)
throws Exception{
+    public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase)
throws Exception {
 
     }
 
-    public void forgetTransaction(ConnectionContext context,TransactionId transactionId)
throws Exception{
+    public void forgetTransaction(ConnectionContext context, TransactionId transactionId)
throws Exception {
 
     }
 
-    public Destination addDestination(ConnectionContext context,ActiveMQDestination destination)
throws Exception{
+    public Destination addDestination(ConnectionContext context, ActiveMQDestination destination)
throws Exception {
 
         return null;
     }
 
-    public void removeDestination(ConnectionContext context,ActiveMQDestination destination,long
timeout) throws Exception{
+    public void removeDestination(ConnectionContext context, ActiveMQDestination destination,
long timeout) throws Exception {
 
     }
 
-    public Subscription addConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
+    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws
Exception {
         return null;
     }
 
-    public void removeConsumer(ConnectionContext context,ConsumerInfo info) throws Exception{
+    public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
{
 
     }
 
-    public void removeSubscription(ConnectionContext context,RemoveSubscriptionInfo info)
throws Exception{
+    public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info)
throws Exception {
 
     }
 
-    public void send(ConnectionContext context,Message message) throws Exception{
+    public void send(ConnectionContext context, Message message) throws Exception {
 
     }
 
-    public void acknowledge(ConnectionContext context,MessageAck ack) throws Exception{
+    public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
 
     }
 
-    public void gc(){
+    public void gc() {
 
     }
 
-    public void start() throws Exception{
+    public void start() throws Exception {
 
     }
 
-    public void stop() throws Exception{
+    public void stop() throws Exception {
 
     }
 
-    public void addBroker(Connection connection,BrokerInfo info){
-        
+    public void addBroker(Connection connection, BrokerInfo info) {
+
     }
-    
-    public void removeBroker(Connection connection,BrokerInfo info){
-       
+
+    public void removeBroker(Connection connection, BrokerInfo info) {
+
     }
 
-    public BrokerInfo[] getPeerBrokerInfos(){
+    public BrokerInfo[] getPeerBrokerInfos() {
         return null;
     }
-    
+
     /**
      * Notifiy the Broker that a dispatch has happened
+     * 
      * @param messageDispatch
      */
-    public void processDispatch(MessageDispatch messageDispatch){
-        
+    public void processDispatch(MessageDispatch messageDispatch) {
+
     }
-    
-    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception{
-        
+
+    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception {
+
     }
-    
-    public boolean isSlaveBroker(){
+
+    public boolean isSlaveBroker() {
         return false;
     }
-    
-    public boolean isStopped(){
+
+    public boolean isStopped() {
         return false;
     }
-    
-    public Set getDurableDestinations(){
+
+    public Set getDurableDestinations() {
         return null;
     }
 
-    public void addDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
+    public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws
Exception {
     }
 
-    public void removeDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{        
+    public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws
Exception {
     }
 
-    public boolean isFaultTolerantConfiguration(){
+    public boolean isFaultTolerantConfiguration() {
         return false;
     }
-    
-   
+
+    public ConnectionContext getAdminConnectionContext() {
+        return null;
+    }
+
+    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
+    }
+
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ErrorBroker.java
Thu Jul 27 09:39:09 2006
@@ -38,7 +38,8 @@
 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$
  */
@@ -47,9 +48,9 @@
     private final String message;
 
     public ErrorBroker(String message) {
-        this.message=message;
+        this.message = message;
     }
-    
+
     public Map getDestinationMap() {
         return Collections.EMPTY_MAP;
     }
@@ -58,13 +59,13 @@
         return Collections.EMPTY_SET;
     }
 
-    public Broker getAdaptor(Class type){
-        if (type.isInstance(this)){
+    public Broker getAdaptor(Class type) {
+        if (type.isInstance(this)) {
             return this;
         }
         return null;
     }
-    
+
     public BrokerId getBrokerId() {
         throw new BrokerStoppedException(this.message);
     }
@@ -72,7 +73,7 @@
     public String getBrokerName() {
         throw new BrokerStoppedException(this.message);
     }
-	
+
     public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception
{
         throw new BrokerStoppedException(this.message);
     }
@@ -169,52 +170,57 @@
         throw new BrokerStoppedException(this.message);
     }
 
-    public void addBroker(Connection connection,BrokerInfo info){
+    public void addBroker(Connection connection, BrokerInfo info) {
         throw new BrokerStoppedException(this.message);
-        
+
     }
-    
-    public void removeBroker(Connection connection,BrokerInfo info){
+
+    public void removeBroker(Connection connection, BrokerInfo info) {
         throw new BrokerStoppedException(this.message);
     }
 
-    public BrokerInfo[] getPeerBrokerInfos(){
+    public BrokerInfo[] getPeerBrokerInfos() {
         throw new BrokerStoppedException(this.message);
     }
-    
-    public void processDispatch(MessageDispatch messageDispatch){
+
+    public void processDispatch(MessageDispatch messageDispatch) {
         throw new BrokerStoppedException(this.message);
     }
-    
-    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception{
+
+    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
throws Exception {
         throw new BrokerStoppedException(this.message);
     }
-    
-    public boolean isSlaveBroker(){
+
+    public boolean isSlaveBroker() {
         throw new BrokerStoppedException(this.message);
     }
-    
-    public boolean isStopped(){
+
+    public boolean isStopped() {
         return true;
     }
-    
-    public Set getDurableDestinations(){
+
+    public Set getDurableDestinations() {
+        throw new BrokerStoppedException(this.message);
+    }
+
+    public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws
Exception {
         throw new BrokerStoppedException(this.message);
     }
 
-    public void addDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
+    public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws
Exception {
         throw new BrokerStoppedException(this.message);
-        
     }
 
-    public void removeDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
+    public boolean isFaultTolerantConfiguration() {
         throw new BrokerStoppedException(this.message);
-        
     }
 
-    public boolean isFaultTolerantConfiguration(){
+    public ConnectionContext getAdminConnectionContext() {
         throw new BrokerStoppedException(this.message);
     }
-    
-   
+
+    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
+        throw new BrokerStoppedException(this.message);
+    }
+
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
Thu Jul 27 09:39:09 2006
@@ -229,4 +229,12 @@
        return getNext().isFaultTolerantConfiguration();
     }
 
+    public ConnectionContext getAdminConnectionContext() {
+        return getNext().getAdminConnectionContext();
+    }
+
+    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
+        getNext().setAdminConnectionContext(adminConnectionContext);
+    }
+
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Thu Jul 27 09:39:09 2006
@@ -180,9 +180,7 @@
     }
     
     static public ConnectionContext getConnectionContext(Broker broker) {
-        ConnectionContext context = new ConnectionContext();
-        context.setBroker(broker);
-        return context;
+        return broker.getAdminConnectionContext();
     }
 
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?rev=426132&r1=426131&r2=426132&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Thu Jul 27 09:39:09 2006
@@ -85,6 +85,7 @@
     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 @@
         return destinationInterceptor;
     }
 
-
+    public ConnectionContext getAdminConnectionContext() {
+        return adminConnectionContext;
+    }
+ 
+    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
+        this.adminConnectionContext = adminConnectionContext;
+    }
 }



Mime
View raw message