geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r736391 [1/2] - in /geronimo/server/trunk: framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/ plugins/activemq/activemq-broker/ plugins/activemq/activemq-broker/src/main/plan/ plugins/activemq/activ...
Date Wed, 21 Jan 2009 19:47:30 GMT
Author: dwoods
Date: Wed Jan 21 11:47:28 2009
New Revision: 736391

URL: http://svn.apache.org/viewvc?rev=736391&view=rev
Log:
GERONIMO-4475 Improve JMS portlet for Borker configuration.  Applied 4 patches from Ivan.

Added:
    geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml   (with props)
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmsmanager/server/edit.jsp   (with props)
    geronimo/server/trunk/plugins/activemq/geronimo-activemq/src/main/java/org/apache/geronimo/activemq/GeronimoPropertyPlaceholderConfigurer.java   (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JMSManager.java
    geronimo/server/trunk/plugins/activemq/activemq-broker/pom.xml
    geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq.xml
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/BaseJMSPortlet.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/JMSBrokerPortlet.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/ListScreenHandler.java
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq.properties
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/activemq_zh.properties
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/portletinfo.properties
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/resources/portletinfo_zh.properties
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmsmanager/server/connector/normal.jsp
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmsmanager/server/normal.jsp
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmsmanager/viewDLQ.jsp
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmsmanager/viewmessages.jsp
    geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/webapp/WEB-INF/view/jmswizard/list.jsp
    geronimo/server/trunk/plugins/activemq/geronimo-activemq/src/main/java/org/apache/geronimo/activemq/BrokerServiceGBeanImpl.java
    geronimo/server/trunk/plugins/activemq/geronimo-activemq/src/main/java/org/apache/geronimo/activemq/management/ActiveMQManagerGBean.java
    geronimo/server/trunk/plugins/monitoring/mconsole-jetty-server/pom.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JMSManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JMSManager.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JMSManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JMSManager.java Wed Jan 21 11:47:28 2009
@@ -17,6 +17,9 @@
 package org.apache.geronimo.management.geronimo;
 
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.KernelException;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
 
 /**
  * Main entry point for managing a particular JMS implementation.  The manager
@@ -44,4 +47,8 @@
      *         started.
      */
     public JMSConnector addConnector(JMSBroker broker, String uniqueName, String protocol, String host, int port);
+    
+    public JMSBroker addBroker(String brokerName, GBeanData gBeanData) throws KernelException, InvalidConfigException;
+    
+    public void removeBroker(AbstractName brokerName) throws KernelException, InvalidConfigException;
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-broker/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-broker/pom.xml?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-broker/pom.xml (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-broker/pom.xml Wed Jan 21 11:47:28 2009
@@ -94,6 +94,7 @@
                     <instance>
                         <plugin-artifact>
                             <copy-file relative-to="server" dest-dir="var/activemq/conf">activemq.xml</copy-file>
+                            <copy-file relative-to="server" dest-dir="var/activemq/template">activemq-template.xml</copy-file>
                             <!--
                             <config-xml-content>
                                 <gbean name="ActiveMQ.tcp.default">

Modified: geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/plan/plan.xml?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/plan/plan.xml Wed Jan 21 11:47:28 2009
@@ -22,9 +22,10 @@
 
     <gbean name="ActiveMQManager" class="org.apache.geronimo.activemq.management.ActiveMQManagerGBean"/>
 
-    <gbean name="ActiveMQ" class="org.apache.geronimo.activemq.BrokerServiceGBeanImpl">
+    <gbean name="DefaultActiveMQBroker" class="org.apache.geronimo.activemq.BrokerServiceGBeanImpl">
+        <attribute name="brokerName">DefaultActiveMQBroker</attribute>
         <attribute name="amqBaseDir">var/activemq/</attribute>
-        <attribute name="amqDataDir">data</attribute>
+        <attribute name="amqDataDir">data/default</attribute>
         <attribute name="amqConfigFile">conf/activemq.xml</attribute>
         <attribute name="useShutdownHook">false</attribute>
         <!--reference name="dataSource">

Added: geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml?rev=736391&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml (added)
+++ geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml Wed Jan 21 11:47:28 2009
@@ -0,0 +1,298 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<!-- 
+    BY DEFAULT, PLEASE DO NOT EDIT OR REMOVE THOSE SYSTEM PROPERTY VALUES LIKE ${activemq.*}, SERVER RUNTIME WILL SET THEM FOR YOU 
+    THE ACTIVEMQ XML CONFIGURATION FILE WILL BE SAVE IN THE FOLDER /VAR/ACTIVEMQ/CONF/${ACTIVEMQ.BROKERNAME}.XML
+    THE DATA FOLDER WILL BE /VAR/ACTIVEMQ/DATA/${ACTIVEMQ.BROKERNAME}/
+-->
+
+
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd   
+  http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+    <!-- Allows us to use system properties as variables in this configuration file-->
+    <bean class="org.apache.geronimo.activemq.GeronimoPropertyPlaceholderConfigurer">
+         <property name="locations">
+            <!--<value>file://${activemq.base}/conf/credentials.properties</value>-->
+            <value>${activemq.geronimo.home.url}/var/config/config-substitutions.properties</value>
+         </property>
+    </bean>
+
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="${activemq.brokerName}">
+
+        <!--
+            Configure per-destination policies on the broker. The policies
+            below limit the memory that any destination can use to 128mb. For 
+            more information, see:
+
+            http://activemq.apache.org/per-destination-policies.html
+        -->
+        <destinationPolicy>
+          <policyMap>
+            <policyEntries>
+              <policyEntry queue=">" memoryLimit="128mb" />
+              <policyEntry topic=">" memoryLimit="128mb" />
+            </policyEntries>
+          </policyMap>
+        </destinationPolicy>
+    
+        <!-- 
+            The managementContext is used to configure how ActiveMQ is exposed in 
+            JMX. By default, ActiveMQ uses the MBean server that is started by 
+            the JVM. For more information, see: 
+
+            http://activemq.apache.org/jmx.html 
+        -->
+        <managementContext>
+            <managementContext createConnector="false"/>
+        </managementContext>
+
+        <!-- 
+            The network connectors are used to create a network of brokers. For 
+            more information, see: 
+            
+            http://activemq.apache.org/networks-of-brokers.html 
+        -->
+        <!--networkConnectors-->
+          <!--
+              This connector automatically discovers the other brokers using
+              IP multicast. Such discovery is possible only because the 
+              openwire transport connector is advertised via the default IP
+              multicast group. For more information on multicast, see: 
+                
+              http://activemq.apache.org/multicast-transport-reference.html
+
+            <networkConnector name="default-nc" uri="multicast://default"/>
+            -->
+
+            <!-- 
+            Example of a static configuration. For more information, see:
+                             
+            http://activemq.apache.org/static-transport-reference.html
+
+            <networkConnector name="host1 and host2" uri="static://(tcp://host1:61616,tcp://host2:61616)"/>
+            -->
+        <!--/networkConnectors-->
+
+        <!-- 
+            Configure message persistence for the broker. The default persistence
+            mechanism is the AMQ store (identified by the amqPersistenceAdapter). 
+            For more information, see: 
+            
+            http://activemq.apache.org/persistence.html 
+        -->
+        <persistenceAdapter>
+            <amqPersistenceAdapter syncOnWrite="false" directory="${activemq.data}" maxFileLength="20 mb"/>
+        </persistenceAdapter>
+
+        <!-- 
+            Configure the following if you wish to use journaled JDBC for message 
+            persistence. 
+
+        <persistenceAdapter>
+            <journaledJDBC dataDirectory="${activemq.base}/data/${activemq.brokerName}" dataSource="#postgres-ds"/>
+        </persistenceAdapter>
+        -->
+
+        <!-- 
+            Configure the following if you wish to use non-journaled JDBC for message 
+            persistence.
+  
+        <persistenceAdapter>
+            <jdbcPersistenceAdapter dataSource="#postgres-ds"/>
+        </persistenceAdapter>
+        -->
+
+        <!-- 
+            The sslContext can be used to configure broker-specific SSL properties.
+            For more information, see: 
+            
+            http://activemq.apache.org/how-do-i-use-ssl.html 
+
+        <sslContext>
+            <sslContext keyStore="file:${activemq.base}/conf/${activemq.brokerName}/broker.ks" 
+                keyStorePassword="password" 
+                trustStore="file:${activemq.base}/conf/${activemq.brokerName}/broker.ts" 
+                trustStorePassword="password"/>
+        </sslContext>
+        -->
+        
+        <!--  
+            The systemUsage controls the maximum amount of space the broker will 
+            use before slowing down producers. 
+
+            In general, these three configuration items are in place to limit the
+            amount of space the broker will use to hold and store messages.  Below
+            is actual breakdown of where they're each used in ActiveMQ 5.1:
+
+            * The memoryUsage is used by JMX, destinations, some cursors, the AMQ
+              store, the journal
+            * The storeUsage is not used anywhere other than JMX
+            * The tempUsage is used by JMX and the FilePendingMessageCursor
+
+            The best recommendation is to set the memoryUsage to a setting that is
+            appropriate for holding all the messages you need to be in memory at
+            any given time. This is used for pending messages, topics with
+            inactive durable subscribers and queues with slow consumers. I've
+            bound it beneficial to utilize the memoryUsage setting in conjunction
+            with a memoryLimit attribute on the policyEntry element for a
+            destination.
+            
+        -->
+        <systemUsage>
+            <systemUsage>
+                <memoryUsage>
+                    <memoryUsage limit="20 mb"/>
+                </memoryUsage>
+                <storeUsage>
+                    <storeUsage limit="1 gb" name="foo"/>
+                </storeUsage>
+                <tempUsage>
+                    <tempUsage limit="100 mb"/>
+                </tempUsage>
+            </systemUsage>
+        </systemUsage>
+
+
+        <!-- 
+            The transport connectors expose ActiveMQ over a given protocol to
+            clients and other brokers. For more information, see: 
+            
+            http://activemq.apache.org/configuring-transports.html 
+        -->
+        <transportConnectors>
+            <!--
+            <transportConnector name="openwire" uri="tcp://localhost:${* + ${PortOffset}}" />            
+            <transportConnector name="openwire2" uri="tcp://localhost:${* + ${PortOffset}}" discoveryUri="multicast://default"/>
+            <transportConnector name="ssl" uri="ssl://localhost:${* + ${PortOffset}}"/>
+            <transportConnector name="stomp" uri="stomp://localhost:${* + ${PortOffset}}"/>            
+            -->
+        </transportConnectors>
+
+    </broker>
+
+    <!--
+       Lets deploy some Enterprise Integration Patterns inside the ActiveMQ Message 
+       Broker. For more details see:
+      
+       http://activemq.apache.org/enterprise-integration-patterns.html
+    
+    <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+     -->
+     <!--</camelContext>-->
+
+        <!-- You can use a <package> element for each root package to search for Java routes 
+        <package>org.foo.bar</package>
+        -->
+
+        <!-- You can use Spring XML syntax to define the routes here using the <route> element 
+        <route>
+            <from uri="activemq:example.A"/>
+            <to uri="activemq:example.B"/>
+        </route>
+    </camelContext>
+    -->
+
+    <!--
+    ** Lets configure some Camel endpoints
+    **
+    ** http://activemq.apache.org/camel/components.html
+    -->
+
+    <!-- 
+        Uncomment to create a command agent to respond to message based admin 
+        commands on the ActiveMQ.Agent topic. For more information, see: 
+        
+        http://activemq.apache.org/command-agent.html
+
+    <commandAgent xmlns="http://activemq.apache.org/schema/core" brokerUrl="vm://localhost" username="${activemq.username}" password="${activemq.password}"/>
+    -->
+
+
+    <!-- 
+        An embedded servlet engine for serving up the Admin console and other demos. 
+
+    <jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
+        <connectors>
+            <nioConnector port="8161"/>
+        </connectors>
+
+        <handlers>
+            <webAppContext contextPath="/admin" resourceBase="${activemq.base}/webapps/admin" logUrlOnStart="true"/>
+            <webAppContext contextPath="/demo" resourceBase="${activemq.base}/webapps/demo" logUrlOnStart="true"/>
+            <webAppContext contextPath="/fileserver" resourceBase="${activemq.base}/webapps/fileserver" logUrlOnStart="true"/>
+        </handlers>
+    </jetty>
+    -->
+
+    <!-- 
+        This xbean configuration file supports all the standard Spring XML 
+        configuration options such as the following bean definitions. 
+    -->
+
+    <!-- Postgres DataSource Sample Setup -->
+    <!--
+    <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
+      <property name="serverName" value="localhost"/>
+      <property name="databaseName" value="activemq"/>
+      <property name="portNumber" value="0"/>
+      <property name="user" value="activemq"/>
+      <property name="password" value="activemq"/>
+      <property name="dataSourceName" value="postgres"/>
+      <property name="initialConnections" value="1"/>
+      <property name="maxConnections" value="10"/>
+    </bean>
+    -->
+
+    <!-- MySql DataSource Sample Setup -->
+    <!--
+    <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+      <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+      <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
+      <property name="username" value="activemq"/>
+      <property name="password" value="activemq"/>
+      <property name="maxActive" value="200"/>
+      <property name="poolPreparedStatements" value="true"/>
+    </bean>
+    -->
+
+    <!-- Oracle DataSource Sample Setup -->
+    <!--
+    <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+      <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
+      <property name="url" value="jdbc:oracle:thin:@localhost:1521:AMQDB"/>
+      <property name="username" value="scott"/>
+      <property name="password" value="tiger"/>
+      <property name="maxActive" value="200"/>
+      <property name="poolPreparedStatements" value="true"/>
+    </bean>
+    -->
+
+    <!-- Embedded Derby DataSource Sample Setup -->
+    <!--
+    <bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
+      <property name="databaseName" value="derbydb"/>
+      <property name="createDatabase" value="create"/>
+    </bean>
+    -->
+
+</beans>

Propchange: geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq-template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq.xml?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq.xml (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-broker/src/main/resources/activemq.xml Wed Jan 21 11:47:28 2009
@@ -14,6 +14,13 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
+
+<!-- 
+    BY DEFAULT, PLEASE DO NOT EDIT OR REMOVE THOSE SYSTEM PROPERTY VALUES LIKE ${activemq.*}, SERVER RUNTIME WILL SET THEM FOR YOU 
+    THE ACTIVEMQ XML CONFIGURATION FILE WILL BE SAVE IN THE FOLDER /VAR/ACTIVEMQ/CONF/${ACTIVEMQ.BROKERNAME}.XML
+    THE DATA FOLDER WILL BE /VAR/ACTIVEMQ/DATA/${ACTIVEMQ.BROKERNAME}/
+-->
+
 <beans
   xmlns="http://www.springframework.org/schema/beans"
   xmlns:amq="http://activemq.apache.org/schema/core"
@@ -23,13 +30,14 @@
   http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
 
     <!-- Allows us to use system properties as variables in this configuration file-->
-    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-         <!--<property name="locations">-->
+    <bean class="org.apache.geronimo.activemq.GeronimoPropertyPlaceholderConfigurer">
+         <property name="locations">
             <!--<value>file://${activemq.base}/conf/credentials.properties</value>-->
-         <!--</property>      -->
+            <value>${activemq.geronimo.home.url}/var/config/config-substitutions.properties</value>
+         </property>
     </bean>
 
-    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="amq-broker">
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="${activemq.brokerName}">
 
         <!--
             Configure per-destination policies on the broker. The policies
@@ -101,7 +109,7 @@
             persistence. 
 
         <persistenceAdapter>
-            <journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
+            <journaledJDBC dataDirectory="${activemq.base}/data/${activemq.brokerName}" dataSource="#postgres-ds"/>
         </persistenceAdapter>
         -->
 
@@ -121,9 +129,9 @@
             http://activemq.apache.org/how-do-i-use-ssl.html 
 
         <sslContext>
-            <sslContext keyStore="file:${activemq.base}/conf/broker.ks" 
+            <sslContext keyStore="file:${activemq.base}/conf/${activemq.brokerName}/broker.ks" 
                 keyStorePassword="password" 
-                trustStore="file:${activemq.base}/conf/broker.ts" 
+                trustStore="file:${activemq.base}/conf/${activemq.brokerName}/broker.ts" 
                 trustStorePassword="password"/>
         </sslContext>
         -->
@@ -172,12 +180,12 @@
             http://activemq.apache.org/configuring-transports.html 
         -->
         <transportConnectors>
-            <transportConnector name="openwire" uri="tcp://localhost:61616" />
+            <transportConnector name="openwire" uri="tcp://localhost:${${ActiveMQPort} + ${PortOffset}}" />
             <!--
-            <transportConnector name="openwire" uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
-            <transportConnector name="ssl" uri="ssl://localhost:61617"/>
-            <transportConnector name="stomp" uri="stomp://localhost:61613"/>
-            <transportConnector name="xmpp" uri="xmpp://localhost:61222"/>
+            <transportConnector name="openwire2" uri="tcp://localhost:${* + ${PortOffset}}" discoveryUri="multicast://default"/>
+            <transportConnector name="ssl" uri="ssl://localhost:${61617 + ${PortOffset}}"/>
+            <transportConnector name="stomp" uri="stomp://localhost:${61613 + ${PortOffset}}"/>
+            <transportConnector name="xmpp" uri="xmpp://localhost:${61222 + ${PortOffset}}"/>
             -->
         </transportConnectors>
 

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/AmqJMSMessageHelper.java Wed Jan 21 11:47:28 2009
@@ -20,19 +20,21 @@
 import java.util.List;
 import java.util.Set;
 
+import javax.jms.Destination;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
 
-import org.apache.geronimo.activemq.BrokerServiceGBeanImpl;
-import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
-import org.apache.geronimo.system.jmx.MBeanServerReference;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
 import org.apache.activemq.broker.jmx.DestinationViewMBean;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.broker.jmx.TopicViewMBean;
+import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
+import org.apache.geronimo.console.jmsmanager.JMSMessageInfo;
+import org.apache.geronimo.system.jmx.MBeanServerReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,10 +44,9 @@
 public class AmqJMSMessageHelper extends JMSMessageHelper {
     private static final Logger log = LoggerFactory.getLogger(AmqJMSMessageHelper.class);
 
-    public void purge(PortletRequest renderRequest, String type, String physicalQName) {
+    public void purge(PortletRequest renderRequest, String brokerName, String type, String physicalQName) {
         try {
             MBeanServer server = getMBeanServer();
-            String brokerName = getBrokerName();
             ObjectName objName = new ObjectName("org.apache.activemq" + ":BrokerName=" + brokerName + ",Type=" + type + ",Destination=" + physicalQName);
             if ("Queue".equals(type)) {
                 QueueViewMBean proxy;
@@ -71,7 +72,8 @@
         }
     }
 
-    protected List getMessagesFromTopic(String type, String physicalQName) throws Exception {
+    protected List<JMSMessageInfo> getMessagesFromTopic(RenderRequest request, Destination destination,
+            String adapterObjectName, String adminObjName, String physicalName) throws Exception {
         /*
          * MBeanServer server = getMBeanServer(); ObjectName objName = new
          * ObjectName("org.apache.activemq"+":BrokerName=localhost,Type="+type+",Destination="+physicalQName);
@@ -84,11 +86,11 @@
          */
         return null;
     }
-    public  DestinationStatistics getDestinationStatistics(String destType,String physicalName){
+    
+    public DestinationStatistics getDestinationStatistics(String brokerName, String destType, String physicalName) {
         DestinationStatistics stat = new DestinationStatistics();
         try {
             MBeanServer server = getMBeanServer();
-            String brokerName = getBrokerName();
             ObjectName objName = new ObjectName("org.apache.activemq" + ":BrokerName=" + brokerName + ",Type=" + destType + ",Destination=" + physicalName);
             DestinationViewMBean proxy;
             if ("Queue".equals(destType)) {
@@ -134,17 +136,5 @@
     private MBeanServer getMBeanServer() throws Exception {
         MBeanServerReference ref = kernel.getGBean(MBeanServerReference.class);
         return ref.getMBeanServer();
-    }
-
-    private String getBrokerName() {
-        // default broker name
-        String brokerName = "localhost";
-        try {
-            BrokerServiceGBeanImpl ref = kernel.getGBean(BrokerServiceGBeanImpl.class);
-            brokerName = ref.getBrokerName();
-        } catch (Exception e) {
-            log.error("Failed to get broker name", e);
-        }
-        return brokerName;
-    }
+    }    
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelper.java Wed Jan 21 11:47:28 2009
@@ -17,6 +17,7 @@
 package org.apache.geronimo.console.jmsmanager.helper;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 
@@ -40,14 +41,10 @@
 import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.geronimo.console.core.jms.TopicBrowserGBean;
 import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
 import org.apache.geronimo.console.jmsmanager.JMSMessageInfo;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
@@ -55,6 +52,8 @@
 import org.apache.geronimo.management.geronimo.JCAAdminObject;
 import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -63,6 +62,10 @@
     protected static final Kernel kernel = KernelRegistry.getSingleKernel();
     private static final Logger log = LoggerFactory.getLogger(JMSMessageHelper.class);
 
+    public static final String QUEUE_TYPE = "Queue";
+    
+    public static final String TOPIC_TYPE = "Topic";
+    
     public void sendMessage(RenderRequest request, JMSMessageInfo messageInfo) throws Exception {
         Destination dest = getDestination(request, messageInfo.getAdapterObjectName(), messageInfo.getPhysicalName());
         if (dest == null) {
@@ -140,75 +143,16 @@
         }
     }
 
-    public List getMessagesList(RenderRequest request, String adapterObjectName, String adminObjName,
+    public List<JMSMessageInfo> getMessagesList(RenderRequest request, String adapterObjectName, String adminObjName,
             String physicalName, String type) throws Exception {
-        List ret = new ArrayList();
-        Destination dest = getDestination(request, adapterObjectName, physicalName);
-        if (dest == null)
-            return ret;
-
+        Destination destination = getDestination(request, adapterObjectName, physicalName);
+        if (destination == null)
+            return Collections.emptyList();
         if ("Queue".equals(type)) {
-            Queue queue = (Queue) dest;
-            QueueConnectionFactory qConFactory = null;
-            QueueConnection qConnection = null;
-            QueueSession qSession = null;
-            QueueBrowser qBrowser = null;
-            try {
-                qConFactory = (QueueConnectionFactory) getJCAManagedConnectionFactory(request, adapterObjectName, type)
-                        .getConnectionFactory();
-                if (qConFactory == null)
-                    return ret;
-                qConnection = qConFactory.createQueueConnection();
-                qSession = qConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-                qBrowser = qSession.createBrowser(queue);
-                qConnection.start();
-                for (Enumeration e = qBrowser.getEnumeration(); e.hasMoreElements();) {
-                    Message message = (Message)e.nextElement();
-                    JMSMessageInfo messageInfo = new JMSMessageInfo();
-                    messageInfo.setPriority(message.getJMSPriority());
-                    messageInfo.setMessageId(message.getJMSMessageID());
-                    messageInfo.setDestination(message.getJMSDestination().toString());
-                    messageInfo.setTimeStamp(message.getJMSTimestamp());
-                    messageInfo.setExpiration(message.getJMSExpiration());
-                    messageInfo.setJmsType(message.getJMSType());
-                    messageInfo.setReplyTo(message.getJMSReplyTo()==null?"":message.getJMSReplyTo().toString());
-                    messageInfo.setCorrelationId(message.getJMSCorrelationID());
-                    if (message instanceof TextMessage) {
-                        messageInfo.setMessage(((TextMessage) message).getText());
-                    } else {
-                        messageInfo.setMessage("Only Text Messages will be displayed..");
-                    }
-                    ret.add(messageInfo);
-                }
-                qConnection.stop();
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-            } finally {
-                try {
-                    if (qBrowser != null) {
-                        qBrowser.close();
-                    }
-                } catch (JMSException ignore) {
-                }
-                try {
-                    if (qSession != null) {
-                        qSession.close();
-                    }
-                } catch (JMSException ignore) {
-                }
-                try {
-                    if (qConnection != null) {
-                        qConnection.close();
-                    }
-                } catch (JMSException ignore) {
-                }
-            }
-
+            return getMessageFromQueue(request, destination, adapterObjectName, adminObjName, physicalName);
         } else {
-            ret = getMessagesFromTopic(type, physicalName);
-
+            return getMessagesFromTopic(request, destination, adapterObjectName, adminObjName, physicalName);
         }
-        return ret;
     }
 
     private JCAManagedConnectionFactory getJCAManagedConnectionFactory(RenderRequest renderRequest, String objectName,
@@ -221,18 +165,18 @@
             String objectNameTemp = module.getObjectName();
             if (objectName != null && objectName.equals(objectNameTemp)) {
                 JCAManagedConnectionFactory[] factories = null;
-                if ("Queue".equals(type)) {
+                if (QUEUE_TYPE.equals(type)) {
                     factories = PortletManager.getOutboundFactoriesForRA(renderRequest, module,
                             new String[] { "javax.jms.QueueConnectionFactory" });
-                } else if ("Topic".equals(type)) {
+                } else if (TOPIC_TYPE.equals(type)) {
                     factories = PortletManager.getOutboundFactoriesForRA(renderRequest, module,
                             new String[] { "javax.jms.TopicConnectionFactory" });
                 }
-                if (factories == null ) {
+                if (factories == null || factories.length == 0) {
                     factories = PortletManager.getOutboundFactoriesForRA(renderRequest, module,
                             new String[] { "javax.jms.ConnectionFactory" });
                 }
-                if (factories != null ) {
+                if (factories != null && factories.length != 0) {
                     return factories[0];
                 }
 
@@ -280,10 +224,73 @@
         return dest;
     }
 
-    protected abstract List getMessagesFromTopic(String type, String physicalQName) throws Exception;
+    protected abstract List<JMSMessageInfo> getMessagesFromTopic(RenderRequest request, Destination destination,
+            String adapterObjectName, String adminObjName, String physicalName) throws Exception;
 
-    public abstract void purge(PortletRequest renderRequest, String type, String physicalQName);
+    protected List<JMSMessageInfo> getMessageFromQueue(RenderRequest request, Destination destination,
+            String adapterObjectName, String adminObjName, String physicalName) throws Exception {
+        List<JMSMessageInfo> ret = new ArrayList<JMSMessageInfo>();
+        Queue queue = (Queue) destination;
+        QueueConnectionFactory qConFactory = null;
+        QueueConnection qConnection = null;
+        QueueSession qSession = null;
+        QueueBrowser qBrowser = null;
+        try {
+            qConFactory = (QueueConnectionFactory) getJCAManagedConnectionFactory(request, adapterObjectName, QUEUE_TYPE)
+                    .getConnectionFactory();
+            if (qConFactory == null)
+                return ret;
+            qConnection = qConFactory.createQueueConnection();
+            qSession = qConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+            qBrowser = qSession.createBrowser(queue);
+            qConnection.start();
+            for (Enumeration e = qBrowser.getEnumeration(); e.hasMoreElements();) {
+                Message message = (Message)e.nextElement();
+                JMSMessageInfo messageInfo = new JMSMessageInfo();
+                messageInfo.setPriority(message.getJMSPriority());
+                messageInfo.setMessageId(message.getJMSMessageID());
+                messageInfo.setDestination(message.getJMSDestination().toString());
+                messageInfo.setTimeStamp(message.getJMSTimestamp());
+                messageInfo.setExpiration(message.getJMSExpiration());
+                messageInfo.setJmsType(message.getJMSType());
+                messageInfo.setReplyTo(message.getJMSReplyTo()==null?"":message.getJMSReplyTo().toString());
+                messageInfo.setCorrelationId(message.getJMSCorrelationID());
+                if (message instanceof TextMessage) {
+                    messageInfo.setMessage(((TextMessage) message).getText());
+                } else {
+                    messageInfo.setMessage("Only Text Messages will be displayed..");
+                }
+                ret.add(messageInfo);
+            }
+            qConnection.stop();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        } finally {
+            try {
+                if (qBrowser != null) {
+                    qBrowser.close();
+                }
+            } catch (JMSException ignore) {
+            }
+            try {
+                if (qSession != null) {
+                    qSession.close();
+                }
+            } catch (JMSException ignore) {
+            }
+            try {
+                if (qConnection != null) {
+                    qConnection.close();
+                }
+            } catch (JMSException ignore) {
+            }
+        }
+        return ret;
+    }
+    
+    public abstract void purge(PortletRequest request, String adapterObjectName, String adminObjName,
+            String physicalName) throws Exception;
     
-    public abstract DestinationStatistics getDestinationStatistics(String destType,String physicalName);
+    public abstract DestinationStatistics getDestinationStatistics(String brokerName, String destType,String physicalName);
 
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/helper/JMSMessageHelperFactory.java Wed Jan 21 11:47:28 2009
@@ -17,14 +17,19 @@
 package org.apache.geronimo.console.jmsmanager.helper;
 
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
+import javax.jms.Destination;
 import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.console.jmsmanager.DestinationStatistics;
+import org.apache.geronimo.console.jmsmanager.JMSMessageInfo;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -32,11 +37,44 @@
 public class JMSMessageHelperFactory {
     private static final Logger log = LoggerFactory.getLogger(JMSMessageHelperFactory.class);
 
+    private static final Map<String,JMSMessageHelper> vendorNameJMSMessageHelperMap = new ConcurrentHashMap<String,JMSMessageHelper>();
+
+    public static final String DEFAULT_JMS_MESSAGEHELPER = "default_jms_messagehelper";
+
+    public static final String ACTIVEMQ_JMS_MESSAGEHELPER = "activemq.org";
+
+    static {
+        try {
+            vendorNameJMSMessageHelperMap.put(ACTIVEMQ_JMS_MESSAGEHELPER, new AmqJMSMessageHelper());
+            vendorNameJMSMessageHelperMap.put(DEFAULT_JMS_MESSAGEHELPER, new JMSMessageHelper() {
+
+                @Override
+                public DestinationStatistics getDestinationStatistics(String brokerName, String destType,
+                        String physicalName) {
+                    return null;
+                }
+
+                @Override
+                protected List<JMSMessageInfo> getMessagesFromTopic(RenderRequest request, Destination destination,
+                        String adapterObjectName, String adminObjName, String physicalName) throws Exception {
+                    return null;
+                }
+
+                @Override
+                public void purge(PortletRequest request, String adapterObjectName, String adminObjName,
+                        String physicalName) throws Exception {
+                }
+            });
+        } catch (Exception e) {
+            log.warn("Failed to init JMS message helpers");
+        }
+    }
+
     public static JMSMessageHelper getMessageHelper(PortletRequest renderRequest, String raName) {
-        JMSMessageHelper messageHelper = null;
         ResourceAdapterModule[] modules = PortletManager.getOutboundRAModules(renderRequest, new String[] {
-                "javax.jms.ConnectionFactory", "javax.jms.QueueConnectionFactory",
-                "javax.jms.TopicConnectionFactory", });
+                "javax.jms.ConnectionFactory",
+                "javax.jms.QueueConnectionFactory",
+                "javax.jms.TopicConnectionFactory" });
         String vendorName = null;
         for (int i = 0; i < modules.length; i++) {
             ResourceAdapterModule module = modules[i];
@@ -48,35 +86,16 @@
         return getJMSMessageHelper(vendorName);
     }
 
-    public static JMSMessageHelper getJMSMessageHelper(String vendorName){
-        JMSMessageHelper messageHelper = null;
-        if ("activemq.org".equals(vendorName)) {
-            try{
-                Class class_ = Class
-                    .forName("org.apache.geronimo.console.jmsmanager.helper.AmqJMSMessageHelper");
-                messageHelper = (JMSMessageHelper) class_.newInstance();
-            } catch (IllegalAccessException e) {
-                log.error("Failed to load class", e);
-            } catch (InstantiationException e) {
-                log.error("Failed to load class", e);
-            } catch (ClassNotFoundException e) {
-                log.error("Failed to load class", e);
-            }
-        }
-        if(messageHelper == null){
-            messageHelper = new JMSMessageHelper() {
-                public List getMessagesFromTopic(String type, String physicalQName) {
-                    return null;
-                }
- 
-                public void purge(PortletRequest renderRequest, String type, String physicalQName) {
-                    return;
-                }
-                public  DestinationStatistics getDestinationStatistics(String destType,String physicalName){
-                    return null;
-                }
-            };
-         }
-         return messageHelper;
-     }
+    public static JMSMessageHelper getJMSMessageHelper(String vendorName) {
+        JMSMessageHelper messageHelper = vendorNameJMSMessageHelperMap.get(vendorName);
+        return messageHelper == null ? vendorNameJMSMessageHelperMap.get(DEFAULT_JMS_MESSAGEHELPER) : messageHelper;
+    }
+    
+    public static void registerJMSMessageHelper(String vendorName, JMSMessageHelper jmsMessageHelper) {
+        vendorNameJMSMessageHelperMap.put(vendorName, jmsMessageHelper);
+    }
+    
+    public static JMSMessageHelper unregisterJMSMessageHelper(String vendorName){
+        return vendorNameJMSMessageHelperMap.remove(vendorName);
+    }
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/BaseJMSPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/BaseJMSPortlet.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/BaseJMSPortlet.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/BaseJMSPortlet.java Wed Jan 21 11:47:28 2009
@@ -16,52 +16,95 @@
  */
 package org.apache.geronimo.console.jmsmanager.server;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+
+import org.apache.geronimo.activemq.ActiveMQBroker;
+import org.apache.geronimo.activemq.ActiveMQManager;
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.management.geronimo.JMSBroker;
 import org.apache.geronimo.management.geronimo.JMSManager;
 
-import javax.portlet.PortletException;
-import javax.portlet.RenderRequest;
-
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * Common methods for JMS portlets
  *
  * @version $Rev$ $Date$
  */
 public class BaseJMSPortlet extends BasePortlet {
-    /**
-     * Gets a Map relating broker name to JMSBroker instance
-     */
-    protected static List<BrokerWrapper> getBrokerList(RenderRequest renderRequest, JMSManager manager) throws PortletException {
 
-        JMSBroker[] brokers = (JMSBroker[]) manager.getContainers();
+    protected List<BrokerWrapper> getBrokerList(PortletRequest renderRequest, JMSManager manager) throws PortletException {
         List<BrokerWrapper> beans = new ArrayList<BrokerWrapper>();
+        //For we need list all the brokers including running and stop on the page,
+        //While querying in the kernel, we could not get the full list.
+        //Currently, all the brokers are in the activemq-broker configuration, we will list all the gbeans in it.
+        //But we still could not load those GBeans which are marked with load="false"
+        Artifact activeMQBrokersConfig = PortletManager.getNameFor(renderRequest, manager).getArtifact();
+        Configuration configuration = PortletManager.getConfigurationManager().getConfiguration(activeMQBrokersConfig);
+        AbstractNameQuery query = new AbstractNameQuery(ActiveMQBroker.class.getName());
+        LinkedHashSet<GBeanData> brokerNameSet = configuration.findGBeanDatas(Collections.singleton(query));
+        Kernel kernel = PortletManager.getKernel();
         try {
-            for (JMSBroker broker : brokers) {
-                AbstractName abstractName = PortletManager.getNameFor(renderRequest, broker);
-                String displayName = abstractName.getName().get("name").toString();
-                beans.add(new BrokerWrapper(displayName, abstractName.toString(), broker));
+            for (GBeanData gBeanData : brokerNameSet) {
+                AbstractName abstractName = gBeanData.getAbstractName();
+                String brokerName = abstractName.getNameProperty("name");
+                if (kernel.isRunning(abstractName)) {
+                    beans.add(new BrokerWrapper(brokerName, abstractName.toString(), (JMSBroker) kernel.getGBean(abstractName), State.RUNNING));
+                } else {
+                    beans.add(new BrokerWrapper(brokerName, abstractName.toString(), null, State.STOPPED));
+                }
             }
         } catch (Exception e) {
             throw new PortletException(e);
         }
         return beans;
     }
-    
+
+    protected BrokerWrapper getBrokerWrapper(PortletRequest portletRequest, AbstractName brokerAbstractName) throws PortletException {
+        JMSBroker jmsBroker = PortletManager.getJMSBroker(portletRequest, brokerAbstractName);
+        if (jmsBroker == null)
+            return null;
+        String displayName = brokerAbstractName.getName().get("name").toString();
+        Kernel kernel = PortletManager.getKernel();
+        try {
+            return new BrokerWrapper(displayName, brokerAbstractName.toString(), jmsBroker, State.fromInt(kernel.getGBeanState(brokerAbstractName)));
+        } catch (GBeanNotFoundException e) {
+            throw new PortletException(e);
+        }
+    }
+
+    protected JMSManager getActiveMQManager(PortletRequest portletRequest) {
+        for (JMSManager jmsManager : PortletManager.getCurrentServer(portletRequest).getJMSManagers()) {
+            if (jmsManager instanceof ActiveMQManager)
+                return jmsManager;
+        }
+        return null;
+    }
+
     public static class BrokerWrapper {
         private String brokerName;
         private String brokerURI;
         private JMSBroker broker;
+        private State state;
 
-        public BrokerWrapper(String brokerName, String brokerURI, JMSBroker broker) {
+        public BrokerWrapper(String brokerName, String brokerURI, JMSBroker broker, State state) {
             this.brokerName = brokerName;
             this.brokerURI = brokerURI;
             this.broker = broker;
+            this.state = state;
         }
 
         public String getBrokerName() {
@@ -75,5 +118,9 @@
         public String getBrokerURI() {
             return brokerURI;
         }
+        
+        public State getState() {
+            return state;
+        }
     }
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/JMSBrokerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/JMSBrokerPortlet.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/JMSBrokerPortlet.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/server/JMSBrokerPortlet.java Wed Jan 21 11:47:28 2009
@@ -14,22 +14,45 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package org.apache.geronimo.console.jmsmanager.server;
 
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import java.util.List;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.net.URI;
-import javax.portlet.PortletRequestDispatcher;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
-import javax.portlet.PortletConfig;
+
+import org.apache.geronimo.activemq.BrokerServiceGBeanImpl;
 import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.management.geronimo.JMSManager;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
+import org.apache.geronimo.management.geronimo.JMSBroker;
+import org.apache.geronimo.system.jmx.MBeanServerReference;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,87 +62,394 @@
  * @version $Rev$ $Date$
  */
 public class JMSBrokerPortlet extends BaseJMSPortlet {
+
     private static final Logger log = LoggerFactory.getLogger(JMSBrokerPortlet.class);
-    private PortletRequestDispatcher normalView;
 
-    private PortletRequestDispatcher maximizedView;
+    private PortletRequestDispatcher editView;
 
     private PortletRequestDispatcher helpView;
 
-    public void processAction(ActionRequest actionRequest,
-                              ActionResponse actionResponse) throws PortletException, IOException {
+    private PortletRequestDispatcher maximizedView;
+
+    private PortletRequestDispatcher normalView;
+
+    private boolean deleteFolder(File folder) {
+        for (File file : folder.listFiles()) {
+            if (file.isFile())
+                file.delete();
+            else
+                deleteFolder(file);
+        }
+        return folder.delete();
+    }
+
+    public void destroy() {
+        helpView = null;
+        normalView = null;
+        maximizedView = null;
+        editView = null;
+        super.destroy();
+    }
+
+    protected void doCreate(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException,
+            PortletException {
+        renderRequest.setAttribute("mode", "create");
+        String sBrokerTemplateConfigurationXML = loadConfiguratonFileAsString(resolveConfigurationFile(renderRequest,
+                "var/activemq/template/activemq-template.xml"));
+        renderRequest.setAttribute("configXML", sBrokerTemplateConfigurationXML);
+        editView.include(renderRequest, renderResponse);
+    }
+
+    protected void doHelp(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException,
+            IOException {
+        helpView.include(renderRequest, renderResponse);
+    }
+
+    protected void doList(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException,
+            PortletException {
+        List<BrokerWrapper> beans = getBrokerList(renderRequest, this.getActiveMQManager(renderRequest));
+        renderRequest.setAttribute("brokers", beans);
+        if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
+            normalView.include(renderRequest, renderResponse);
+        } else {
+            maximizedView.include(renderRequest, renderResponse);
+        }
+    }
+
+    protected void doUpdate(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException,
+            PortletException {
+        String sBrokerURI = renderRequest.getParameter("brokerURI");
+        String sBrokerName = renderRequest.getParameter("brokerName");
+        String sBrokerConfigurationXML = null;
         try {
-            String mode = actionRequest.getParameter("mode");
-            String brokerURI = actionRequest.getParameter("brokerURI");
-            if(mode.equals("start")) {
-                try {
-                    //todo: this only goes into the "starting" state, doesn't make it to "running" -- what's up with that?
-                    PortletManager.getManagedBean(actionRequest, new AbstractName(URI.create(brokerURI))).startRecursive();
-                } catch (Exception e) {
-                    throw new PortletException(e);
-                }
-            } else if(mode.equals("stop")) {
-                try {
-                    PortletManager.getManagedBean(actionRequest,  new AbstractName(URI.create(brokerURI))).stop();
-                } catch (Exception e) {
-                    throw new PortletException(e);
-                }
-            } else if(mode.equals("edit")) {
-                //todo: is there anything to edit?
-            } else if(mode.equals("delete")) {
-                //todo: add a method to JMSManager to handle this
-            } else if(mode.equals("new")) {
-                //todo: add a method to JMSManager to handle this -- it needs to let you pick a configuration that has ActiveMQ on the path...
-            }
-            actionResponse.setRenderParameter("mode", "list");
-        } catch (Throwable e) {
-            log.error("Unable to process portlet action", e);
-            if(e instanceof PortletException) {
-                throw (PortletException)e;
-            }
+            Kernel kernel = PortletManager.getKernel();
+            GBeanData brokerGBeanData = kernel.getGBeanData(new AbstractName(URI.create(sBrokerURI)));
+            String sBrokerConfigurationXMLPath = brokerGBeanData.getAttribute("amqBaseDir").toString()
+                    + brokerGBeanData.getAttribute("amqConfigFile").toString();
+            sBrokerConfigurationXML = loadConfiguratonFileAsString(resolveConfigurationFile(renderRequest,
+                    sBrokerConfigurationXMLPath));
+        } catch (GBeanNotFoundException e) {
+            e.printStackTrace();
+        } catch (InternalKernelException e) {
+            e.printStackTrace();
         }
+        renderRequest.setAttribute("configXML", sBrokerConfigurationXML);
+        renderRequest.setAttribute("mode", "update");
+        renderRequest.setAttribute("brokerWrapper", getBrokerWrapper(renderRequest, new AbstractName(URI
+                .create(sBrokerURI))));
+        editView.include(renderRequest, renderResponse);
     }
 
-    protected void doView(RenderRequest renderRequest,
-                          RenderResponse renderResponse) throws IOException, PortletException {
+    protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException,
+            PortletException {
         try {
             if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
                 return;
             }
-            JMSManager manager = PortletManager.getCurrentServer(renderRequest).getJMSManagers()[0];  //todo: handle multiple
-            List beans = getBrokerList(renderRequest, manager);
-            renderRequest.setAttribute("brokers", beans);
-            if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
-                normalView.include(renderRequest, renderResponse);
+            String mode = renderRequest.getParameter("mode");
+            if (mode == null)
+                mode = "list";
+            renderRequest.setAttribute("mode", mode);
+            if (mode.equals("create")) {
+                doCreate(renderRequest, renderResponse);
+            } else if (mode.equals("update")) {
+                doUpdate(renderRequest, renderResponse);
             } else {
-                maximizedView.include(renderRequest, renderResponse);
+                doList(renderRequest, renderResponse);
             }
         } catch (Throwable e) {
-            log.error("Unable to render portlet", e);
+            addErrorMessage(renderRequest, e.getMessage());
+            log.error(e.getMessage(), e);
         }
     }
 
-    protected void doHelp(RenderRequest renderRequest,
-                          RenderResponse renderResponse) throws PortletException, IOException {
-        helpView.include(renderRequest, renderResponse);
-    }
-
     public void init(PortletConfig portletConfig) throws PortletException {
         super.init(portletConfig);
-
         normalView = portletConfig.getPortletContext().getRequestDispatcher(
                 "/WEB-INF/view/jmsmanager/server/normal.jsp");
         maximizedView = portletConfig.getPortletContext().getRequestDispatcher(
                 "/WEB-INF/view/jmsmanager/server/maximized.jsp");
-        helpView = portletConfig.getPortletContext().getRequestDispatcher(
-                "/WEB-INF/view/jmsmanager/server/help.jsp");
+        helpView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/jmsmanager/server/help.jsp");
+        editView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/jmsmanager/server/edit.jsp");
     }
 
-    public void destroy() {
-        helpView = null;
-        normalView = null;
-        maximizedView = null;
-        super.destroy();
+    protected String loadConfiguratonFileAsString(File brokerConfigFile) throws IOException {
+        if (!brokerConfigFile.exists())
+            throw new IOException("Can not load the ActiveMQ broker configuration file ["
+                    + brokerConfigFile.getAbsolutePath() + "]");
+        BufferedReader reader = null;
+        StringBuilder configBuilder = new StringBuilder();
+        try {
+            reader = new BufferedReader(new InputStreamReader(new FileInputStream(brokerConfigFile), "iso-8859-1"));
+            String sCurrentReadLine = null;
+            while ((sCurrentReadLine = reader.readLine()) != null)
+                configBuilder.append(sCurrentReadLine).append("\n");
+            return configBuilder.toString();
+        } finally {
+            if (reader != null)
+                try {
+                    reader.close();
+                } catch (Exception e) {
+                }
+        }
+    }
+
+    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException,
+            IOException {
+        try {
+            String mode = actionRequest.getParameter("mode");
+            if (mode == null)
+                mode = "list";
+            if (mode.equals("start")) {
+                processStartAction(actionRequest, actionResponse);
+            } else if (mode.equals("stop")) {
+                processStopAction(actionRequest, actionResponse);
+            } else if (mode.equals("delete")) {
+                processDeleteAction(actionRequest, actionResponse);
+            } else if (mode.equals("create")) {
+                processCreateAction(actionRequest, actionResponse);
+            } else if (mode.equals("update")) {
+                processUpdateAction(actionRequest, actionResponse);
+            } else
+                actionResponse.setRenderParameter("mode", mode);
+        } catch (Throwable e) {
+            log.error(e.getMessage(), e);
+            addErrorMessage(actionRequest, e.getMessage());
+        }
+    }
+
+    /**
+     * 1. Save the configuration XML file to /var/activemq/conf with the name ${brokerName}.xml
+     * 2. Start the broker GBean     
+     * @param actionRequest
+     * @param actionResponse
+     * @throws PortletException
+     * @throws IOException
+     */
+    protected void processCreateAction(ActionRequest actionRequest, ActionResponse actionResponse)
+            throws PortletException, IOException {
+        String sConfigurationXML = actionRequest.getParameter("configXML");
+        validateConfigXML(sConfigurationXML, actionRequest);
+        String sBrokerName = actionRequest.getParameter("brokerName");
+        Kernel kernel = PortletManager.getKernel();
+        AbstractName brokerAbstractName = kernel.getNaming().createSiblingName(
+                PortletManager.getNameFor(actionRequest, getActiveMQManager(actionRequest)), sBrokerName, "JMSServer");
+        validateBrokerName(brokerAbstractName, actionRequest);
+        saveConfigurationFile(resolveConfigurationFile(actionRequest, "/var/activemq/conf/" + sBrokerName + ".xml"),
+                sConfigurationXML);
+        GBeanData brokerGBeanData = new GBeanData(brokerAbstractName, BrokerServiceGBeanImpl.class);
+        brokerGBeanData.setAttribute("brokerName", sBrokerName);
+        brokerGBeanData.setAttribute("amqBaseDir", "var/activemq/");
+        brokerGBeanData.setAttribute("amqDataDir", "data/" + sBrokerName);
+        brokerGBeanData.setAttribute("amqConfigFile", "conf/" + sBrokerName + ".xml");
+        brokerGBeanData.setAttribute("useShutdownHook", false);
+        brokerGBeanData.setReferencePattern("ServerInfo", new AbstractNameQuery(null, Collections.EMPTY_MAP,
+                ServerInfo.class.getName()));
+        brokerGBeanData.setReferencePattern("MBeanServerReference", new AbstractNameQuery(null, Collections.EMPTY_MAP,
+                MBeanServerReference.class.getName()));
+        try {
+            JMSBroker jmsBroker = getActiveMQManager(actionRequest).addBroker(sBrokerName, brokerGBeanData);
+            ((GeronimoManagedBean) jmsBroker).startRecursive();
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successAddBroker",
+                    sBrokerName));
+        } catch (PortletException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failAddBroker",
+                    sBrokerName, e.getMessage()), e);
+        }
+        actionResponse.setRenderParameter("mode", "list");
+    }
+
+    /**
+     * 1. Remove the configuration XML file
+     * 2. Remove the broker GBean
+     * @param actionRequest
+     * @param actionResponse
+     * @throws PortletException
+     * @throws IOException
+     */
+    protected void processDeleteAction(ActionRequest actionRequest, ActionResponse actionResponse)
+            throws PortletException, IOException {
+        String sBrokerName = actionRequest.getParameter("brokerName");
+        String sBrokerURI = actionRequest.getParameter("brokerURI");
+        try {
+            Kernel kernel = PortletManager.getKernel();
+            AbstractName brokerAbstractName = new AbstractName(URI.create(sBrokerURI));
+            GBeanData brokerGBeanData = kernel.getGBeanData(brokerAbstractName);
+            String sBrokerConfigurationXMLPath = brokerGBeanData.getAttribute("amqBaseDir").toString()
+                    + brokerGBeanData.getAttribute("amqConfigFile").toString();
+            getActiveMQManager(actionRequest).removeBroker(brokerAbstractName);
+            File brokerConfigFile = resolveConfigurationFile(actionRequest, sBrokerConfigurationXMLPath);
+            if (!brokerConfigFile.delete()) {
+                String sWarningMessage = getLocalizedString(actionRequest, "jmsmanager.broker.failDeleteBrokerConfig",
+                        brokerConfigFile.getAbsolutePath());
+                log.warn(sWarningMessage);
+                addWarningMessage(actionRequest, sWarningMessage);
+            } else {
+                String sInfoMessage = getLocalizedString(actionRequest, "jmsmanager.broker.successDeleteBrokerConfig",
+                        brokerConfigFile.getAbsolutePath());
+                log.info(sInfoMessage);
+                addInfoMessage(actionRequest, sInfoMessage);
+            }
+            String sBrokerDataDirectoryPath = brokerGBeanData.getAttribute("amqBaseDir").toString()
+                    + brokerGBeanData.getAttribute("amqDataDir").toString();
+            File brokerDataDirectory = resolveConfigurationFile(actionRequest, sBrokerDataDirectoryPath);
+            if (!deleteFolder(brokerDataDirectory)) {
+                String sWarningMessage = getLocalizedString(actionRequest, "jmsmanager.broker.failDeleteBrokerData",
+                        brokerDataDirectory.getAbsolutePath());
+                log.warn(sWarningMessage);
+                addWarningMessage(actionRequest, sWarningMessage);
+            } else {
+                String sInfoMessage = getLocalizedString(actionRequest, "jmsmanager.broker.successDeleteBrokerData",
+                        brokerDataDirectory.getAbsolutePath());
+                log.info(sInfoMessage);
+                addInfoMessage(actionRequest, sInfoMessage);
+            }
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successDeleteBroker",
+                    sBrokerName));
+        } catch (GBeanNotFoundException e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failFindBroker",
+                    sBrokerName, e.getMessage()), e);
+        } catch (Exception e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failDeleteBroker",
+                    sBrokerName, e.getMessage()), e);
+        }
+        actionResponse.setRenderParameter("mode", "list");
+    }
+
+    protected void processStartAction(ActionRequest actionRequest, ActionResponse actionResponse)
+            throws PortletException, IOException {
+        String sBrokerURI = actionRequest.getParameter("brokerURI");
+        String sBrokerName = actionRequest.getParameter("brokerName");
+        try {
+            AbstractName abstractName = new AbstractName(URI.create(sBrokerURI));
+            Kernel kernel = PortletManager.getKernel();
+            if (kernel.isRunning(abstractName))
+                return;
+            kernel.startRecursiveGBean(abstractName);
+            //TODO While the broker gbean does not start correctly, sometimes no exception is threw ?
+            if (!kernel.isRunning(abstractName)) {
+                throw new PortletException(getLocalizedString(actionRequest,
+                        "jmsmanager.broker.failStartBrokerNoReason", sBrokerName));
+            }
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successStartBroker",
+                    sBrokerName));
+        } catch (PortletException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failStartBroker",
+                    sBrokerName, e.getMessage()));
+        }
+        actionResponse.setRenderParameter("mode", "list");
+    }
+
+    protected void processStopAction(ActionRequest actionRequest, ActionResponse actionResponse)
+            throws PortletException, IOException {
+        String sBrokerURI = actionRequest.getParameter("brokerURI");
+        String sBrokerName = actionRequest.getParameter("brokerName");
+        try {
+            AbstractName abstractName = new AbstractName(URI.create(sBrokerURI));
+            Kernel kernel = PortletManager.getKernel();
+            if (!kernel.isRunning(abstractName))
+                return;
+            kernel.stopGBean(abstractName);
+            if (kernel.isRunning(abstractName)) {
+                throw new PortletException(getLocalizedString(actionRequest,
+                        "jmsmanager.broker.failStopBrokerNoReason", sBrokerName));
+            }
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successStopBroker",
+                    sBrokerName));
+        } catch (PortletException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failStopBroker",
+                    sBrokerName, e.getMessage()));
+        }
+        actionResponse.setRenderParameter("mode", "list");
     }
 
+    /**
+     * 1. Save the configuration XML file to to /var/activemq/conf with the name ${brokerName}.xml
+     * 2. Restart the broker GBean
+     * @param actionRequest
+     * @param actionResponse
+     * @throws PortletException
+     * @throws IOException
+     */
+    protected void processUpdateAction(ActionRequest actionRequest, ActionResponse actionResponse)
+            throws PortletException, IOException {
+        String sConfigurationXML = actionRequest.getParameter("configXML");
+        String sBrokerName = actionRequest.getParameter("brokerName");
+        String sBrokerURI = actionRequest.getParameter("brokerURI");
+        validateConfigXML(sConfigurationXML, actionRequest);
+        Kernel kernel = PortletManager.getKernel();
+        try {
+            AbstractName brokerAbstractName = new AbstractName(URI.create(sBrokerURI));
+            GBeanData brokerGBeanData = kernel.getGBeanData(new AbstractName(URI.create(sBrokerURI)));
+            String sBrokerConfigurationXMLPath = brokerGBeanData.getAttribute("amqBaseDir").toString()
+                    + brokerGBeanData.getAttribute("amqConfigFile").toString();
+            saveConfigurationFile(resolveConfigurationFile(actionRequest, sBrokerConfigurationXMLPath),
+                    sConfigurationXML);
+            GeronimoManagedBean jmsBroker = PortletManager.getManagedBean(actionRequest, brokerAbstractName);
+            if (kernel.isRunning(brokerAbstractName)) {
+                jmsBroker.stop();
+            }
+            jmsBroker.startRecursive();
+            if (!kernel.isRunning(brokerAbstractName)) {
+                throw new PortletException(getLocalizedString(actionRequest,
+                        "jmsmanager.broker.failUpdateBrokerNoReason", sBrokerName));
+            }
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successUpdateBroker",
+                    sBrokerName));
+        } catch (PortletException e) {
+            throw e;
+        } catch (GBeanNotFoundException e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failFindBroker",
+                    sBrokerName, e.getMessage()));
+        } catch (Exception e) {
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.failUpdateBroker",
+                    sBrokerName, e.getMessage()));
+        }
+        actionResponse.setRenderParameter("mode", "list");
+    }
+
+    protected File resolveConfigurationFile(PortletRequest portletRequest, String filePath) {
+        ServerInfo serverInfo = PortletManager.getCurrentServer(portletRequest).getServerInfo();
+        return serverInfo.resolve(filePath);
+    }
+
+    protected void saveConfigurationFile(File brokerConfigFile, String configurationXML) throws IOException {
+        BufferedWriter writer = null;
+        try {
+            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(brokerConfigFile), "iso-8859-1"));
+            writer.write(configurationXML);
+        } finally {
+            if (writer != null)
+                try {
+                    writer.close();
+                } catch (Exception e) {
+                }
+        }
+    }
+
+    private void validateBrokerName(AbstractName brokerAbName, ActionRequest actionRequest) throws PortletException {
+        Configuration brokersConfiguration = PortletManager.getConfigurationManager().getConfiguration(
+                brokerAbName.getArtifact());
+        Map<AbstractName, GBeanData> abNameGBeanDataMap = (Map<AbstractName, GBeanData>) brokersConfiguration
+                .getGBeans();
+        String sNewBrokerName = brokerAbName.getNameProperty("name");
+        for (AbstractName abName : abNameGBeanDataMap.keySet()) {
+            String sGBeanName = abName.getNameProperty("name");
+            if (sNewBrokerName.equals(sGBeanName)) {
+                throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.invalidBrokerName",
+                        sGBeanName));
+            }
+        }
+    }
+
+    private void validateConfigXML(String configXML, ActionRequest actionRequest) throws PortletException {
+        if (configXML == null || configXML.trim().length() == 0)
+            throw new PortletException(getLocalizedString(actionRequest, "jmsmanager.broker.invalidBrokerConfig"));
+    }
 }

Modified: geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java?rev=736391&r1=736390&r2=736391&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java (original)
+++ geronimo/server/trunk/plugins/activemq/activemq-portlets/src/main/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java Wed Jan 21 11:47:28 2009
@@ -94,6 +94,7 @@
     protected final static String MESSAGES = "messages";
     protected final static String MESSAGE_ID = "messageId";
     protected final static String MESSAGE_TXT="messageTxt";
+    protected final static String BROKER_NAME = "brokerName";
 
     protected final static String PROVIDER_PARAMETER="provider";
     protected final static String RAR_FILE_PARAMETER="rar";



Mime
View raw message