geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r393787 [9/22] - in /geronimo/trunk/applications: ./ console/ console/console-core/ console/console-core/src/ console/console-core/src/java/ console/console-core/src/java/org/ console/console-core/src/java/org/apache/ console/console-core/s...
Date Thu, 13 Apr 2006 11:36:26 GMT
Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,123 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.console.GeronimoVersion;
+
+public abstract class AbstractJMSManager {
+
+    protected static final String JMS_SERVER_MBEAN_NAME = "geronimo.server:J2EEApplication=null,J2EEModule=geronimo/activemq-broker/" + GeronimoVersion.GERONIMO_VERSION + "/car,J2EEServer=geronimo,j2eeType=JMSServer,name=ActiveMQl";
+
+    protected static final String GET_BROKER_ADMIN_FUNCTION = "getBrokerAdmin";
+
+    public static final String TOPIC_TYPE = "Topic";
+
+    public static final String QUEUE_TYPE = "Queue";
+
+    //ViewDestinations attribute names
+    protected static final String DESTINATION_LIST = "destinations";
+
+    protected static final String DESTINATION_MSG = "destinationsMsg";
+
+    //CreateDestinations attribute names
+    protected static final String DESTINATION_NAME = "destinationMessageDestinationName";
+
+    protected static final String DESTINATION_PHYSICAL_NAME = "destinationPhysicalName";
+
+    protected static final String DESTINATION_TYPE = "destinationType";
+
+    protected static final String DESTINATION_APPLICATION_NAME = "destinationApplicationName";
+
+    protected static final String DESTINATION_MODULE_NAME = "destinationModuleName";
+
+    protected static final String DESTINATION_CONFIG_URI = "destinationConfigURI";
+
+    protected static final String CONNECTION_FACTORY_NAME = "geronimo.server:J2EEApplication=null,J2EEServer=geronimo,JCAResource=geronimo/activemq/" + GeronimoVersion.GERONIMO_VERSION + "/car,j2eeType=JCAManagedConnectionFactory,name=DefaultActiveMQConnectionFactory";
+
+    protected static Object[] no_args = new Object[0];
+
+    protected static String[] no_params = new String[0];
+
+    protected static Kernel kernel = KernelRegistry.getSingleKernel();
+
+    protected static final String BASE_CONFIG_URI = "runtimedestination/";
+
+    protected ObjectName mBeanName;
+
+    public static final ObjectName DESTINATION_QUERY;
+
+    public static final ObjectName ACTIVEMQJCA_RESOURCE_QUERY;
+
+    public static final String ACTIVEMQJCA_RESOURCE;
+
+    static {
+        try {
+
+            DESTINATION_QUERY = ObjectName
+                    .getInstance("geronimo.server:j2eeType="
+                            + NameFactory.JCA_ADMIN_OBJECT + ",*");
+            ACTIVEMQJCA_RESOURCE_QUERY = ObjectName
+                    .getInstance("*:j2eeType=JCAManagedConnectionFactory,name=DefaultActiveMQConnectionFactory,*");
+            ACTIVEMQJCA_RESOURCE = getActiveMQJCA_RESOURCE(ACTIVEMQJCA_RESOURCE_QUERY);
+
+            if (null == ACTIVEMQJCA_RESOURCE) {
+                throw new RuntimeException(
+                        "No JCA resource was found for DefaultActiveMQConnectionFactory");
+            }
+
+        } catch (MalformedObjectNameException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static final J2eeContext baseContext = new J2eeContextImpl(
+            "geronimo.server", "geronimo", "null", ACTIVEMQJCA_RESOURCE, null,
+            null, NameFactory.JCA_ADMIN_OBJECT);
+
+    /**
+     * Get the JCA resource name of the activemq bean.
+     *
+     * @return JCA resource name
+     */
+    public static String getActiveMQJCA_RESOURCE(ObjectName obj) {
+
+        Set modules = kernel.listGBeans(obj);
+
+        String JCA_Resource = null;
+
+        for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
+            ObjectName activemqObject = (ObjectName) iterator.next();
+            JCA_Resource = activemqObject
+                    .getKeyProperty(NameFactory.JCA_RESOURCE);
+        }
+
+        return JCA_Resource;
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/AbstractJMSManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,132 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager;
+
+import javax.jms.Queue;
+
+public class DestinationInfo implements Comparable {
+
+    private final String name;
+
+    private final String physicalName;
+
+    private final Class type;
+
+    private final String applicationName;
+
+    private final String moduleName;
+
+    private final String configURI;
+
+    public DestinationInfo(String name, String physicalName, Class type,
+            String applicationName, String moduleName, String configURI) {
+        this.name = name;
+        this.physicalName = physicalName;
+        this.type = type;
+        this.applicationName = applicationName;
+        this.moduleName = moduleName;
+        this.configURI = configURI;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getPhysicalName() {
+        return physicalName;
+    }
+
+    public Class getType() {
+        return type;
+    }
+
+    public String getApplicationName() {
+        return applicationName;
+    }
+
+    public String getModuleName() {
+        return moduleName;
+    }
+
+    public String getConfigURI() {
+        return configURI;
+    }
+
+    /**
+     * Determines if the destination that this objects represents is viewable
+     * from the console this means that either the destination that this object
+     * represents was added via the Geronimo JMS Console or it is a Queue.
+     *
+     * @return true if the console knows how to display this Destination
+     *         otherwise returns false.
+     */
+    public boolean isViewable() {
+        return Queue.class.isAssignableFrom(type) || isConsoleManaged();
+    }
+
+    /**
+     * Determines if the destination that this objects represents is removable
+     * from the console this means that the destination that this object
+     * represents was added via the Geronimo JMS Console.
+     *
+     * @return true if the console knows how to remove this Destination
+     *         otherwise returns false.
+     */
+    public boolean isRemovable() {
+        return isConsoleManaged();
+    }
+
+    /**
+     * Determines if the destination that this objects represents was added via
+     * the console.
+     *
+     * @return true if the destination that this objects represents was added
+     *         via the console otherwise returns false.
+     */
+    private boolean isConsoleManaged() {
+        return configURI.indexOf(AbstractJMSManager.BASE_CONFIG_URI + name) > -1;
+    }
+
+    public int compareTo(Object o) {
+        if (o instanceof DestinationInfo) {
+            DestinationInfo rhs = (DestinationInfo) o;
+            // If one of the objects is removable and the other is not, the
+            // removable one is less (comes first in a descending sort).
+            if (rhs.isRemovable() != this.isRemovable()) {
+                if (this.isRemovable()) {
+                    return -1;
+                } else {
+                    return 1;
+                }
+                // If one of the objects is viewable and the other is not the
+                // viewable one is less (comes first in a descending sort).
+            } else if (rhs.isViewable() != this.isViewable()) {
+                if (this.isViewable()) {
+                    return -1;
+                } else {
+                    return 1;
+                }
+                // Sort by name if all else fails.
+            } else {
+                return this.name.compareTo(rhs.getName());
+            }
+        }
+        return 1;
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/DestinationInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,300 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager;
+
+import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.console.GeronimoVersion;
+import org.apache.geronimo.console.databasemanager.DataSourceInfo;
+import org.apache.geronimo.console.jmsmanager.activemqCF.ActiveMQConnectorHelper;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class JMSConnectionFactoryManagerPortlet extends BasePortlet {
+
+    private final static ActiveMQConnectorHelper helper = new ActiveMQConnectorHelper();
+
+    private final static String PARENT_ID = "geronimo/activemq-broker/" + GeronimoVersion.GERONIMO_VERSION + "/car";
+
+    private final static String ADD_MODE = "addACF";
+
+    private final static String SUBMIT_CREATE = "Create";
+
+    private final ObjectName DATABASE_QUERY = JMXUtil
+            .getObjectName("*:j2eeType=JCAManagedConnectionFactory,*");
+
+    protected final String NORMAL_VIEW = "/WEB-INF/view/jmsmanager/activemq/normal.jsp";;
+
+    protected final String DETAIL_VIEW = "/WEB-INF/view/jmsmanager/activemq/detail.jsp";
+
+    protected final String HELP_VIEW = "/WEB-INF/view/jmsmanager/activemq/help.jsp";;
+
+    protected final String ADD_VIEW = "/WEB-INF/view/jmsmanager/activemq/addACF.jsp";
+
+    protected Kernel kernel;
+
+    private PortletRequestDispatcher normalView;
+
+    private PortletRequestDispatcher detailView;
+
+    private PortletRequestDispatcher helpView;
+
+    private PortletRequestDispatcher addView;
+
+    private static final Set HIDDEN_ATTRIBUTES;
+
+    static {
+        HIDDEN_ATTRIBUTES = new HashSet();
+        HIDDEN_ATTRIBUTES.add("kernel");
+        HIDDEN_ATTRIBUTES.add("connectionImplClass");
+        HIDDEN_ATTRIBUTES.add("connectionInterface");
+        HIDDEN_ATTRIBUTES.add("connectionFactoryInterface");
+        HIDDEN_ATTRIBUTES.add("connectionFactoryImplClass");
+        HIDDEN_ATTRIBUTES.add("implementedInterfaces");
+        HIDDEN_ATTRIBUTES.add("managedConnectionFactoryClass");
+        HIDDEN_ATTRIBUTES.add("recoveryXAResources");
+    }
+
+    public void init(PortletConfig portletConfig) throws PortletException {
+        super.init(portletConfig);
+        kernel = KernelRegistry.getSingleKernel();
+        PortletContext context = portletConfig.getPortletContext();
+        normalView = context.getRequestDispatcher(NORMAL_VIEW);
+        detailView = context.getRequestDispatcher(DETAIL_VIEW);
+        helpView = context.getRequestDispatcher(HELP_VIEW);
+        addView = context.getRequestDispatcher(ADD_VIEW);
+    }
+
+    public void processAction(ActionRequest actionRequest,
+            ActionResponse actionResponse) throws PortletException, IOException {
+        String mode = actionRequest.getParameter("mode");
+        String submit = actionRequest.getParameter("submit");
+
+        if (mode == null) {
+            return;
+        } else if (ADD_MODE.equals(mode)) {
+            actionResponse.setRenderParameter("mode", mode);
+            if (SUBMIT_CREATE.equals(submit)) {
+                String acfName = actionRequest.getParameter("acfName");
+                String serverURL = actionRequest.getParameter("serverURL");
+                String userName = actionRequest.getParameter("userName");
+                String pword = actionRequest.getParameter("pword");
+                String poolMaxSize = actionRequest.getParameter("poolMaxSize");
+                String blocking = actionRequest.getParameter("blocking");
+
+                String[] args = { trimStr(acfName), trimStr(PARENT_ID),
+                        trimStr(acfName), trimStr(serverURL),
+                        trimStr(userName), pword, trimStr(acfName),
+                        trimStr(poolMaxSize), trimStr(blocking) };
+                helper.deployPlan(actionRequest, args);
+                // Set mode to list after creating the new ConnectionFactories
+                actionResponse.setRenderParameter("mode", "list");
+            }
+            return;
+        }
+
+        String name = actionRequest.getParameter("name");
+        if (name != null) {
+            actionResponse.setRenderParameter("mode", "list");
+            return;
+        }
+    }
+
+    protected void doView(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws IOException, PortletException {
+        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
+            return;
+        }
+
+        List dependencies = helper.getDependencies(renderRequest);
+        // pass them to the render request
+        renderRequest.setAttribute("dependencies", (String[]) dependencies
+                .toArray(new String[dependencies.size()]));
+
+        String name = renderRequest.getParameter("name");
+        String mode = renderRequest.getParameter("mode");
+        String check = renderRequest.getParameter("check");
+
+        if (ADD_MODE.equals(mode)) {
+            addView.include(renderRequest, renderResponse);
+            return;
+        }
+
+        boolean test = false;
+        if (name == null || mode == null) {
+            mode = "list";
+        }
+        if ("true".equals(check)) {
+            test = true;
+        }
+        if ("detail".equals(mode) || "config".equals(mode)) {
+            renderDetail(renderRequest, renderResponse, name);
+        } else {
+            renderList(renderRequest, renderResponse, name, test);
+        }
+    }
+
+    private void renderList(RenderRequest renderRequest,
+            RenderResponse renderResponse, String name, boolean check)
+            throws PortletException, IOException {
+
+        Set gbeanNames = kernel.listGBeans(DATABASE_QUERY);
+        List connectionFactories = new ArrayList(gbeanNames.size());
+        for (Iterator i = gbeanNames.iterator(); i.hasNext();) {
+            ObjectName gbeanName = (ObjectName) i.next();
+
+            // check that this connector is a DataSource
+            try {
+                Class cfInterface = Class.forName((String) kernel.getAttribute(
+                        gbeanName, "connectionFactoryInterface"));
+                if (!(ConnectionFactory.class).isAssignableFrom(cfInterface)) {
+                    continue;
+                }
+            } catch (Exception e) {
+                throw new PortletException(e);
+            }
+
+            DataSourceInfo info = new DataSourceInfo();
+            info.setObjectName(gbeanName);
+            info.setName(gbeanName.getKeyProperty("name"));
+            try {
+                info.setState(new Integer(kernel.getGBeanState(gbeanName)));
+                //check if user asked this connection to be tested
+                if ((gbeanName.toString().equals(name)) && (check)) {
+                    info.setWorking(true);
+                    try {
+                        Object cf = kernel.invoke(gbeanName, "$getResource");
+                        testConnection(cf);
+                        info.setMessage("Connected");
+                    } catch (Exception e) {
+                        Throwable t = e;
+                        String message = "Failed: ";
+                        if (t.getMessage() != null) {
+                            message = message + t.getMessage();
+                        } else {
+                            while (t.getMessage() == null) {
+                                t = t.getCause();
+                                if (t != null) {
+                                    message = message + t.getMessage();
+                                } else {
+                                    message = message + "Unknown reason";
+                                }
+                            }
+                        }
+                        info.setMessage(message);
+                    }
+                } else {
+                    info.setWorking(false);
+                }
+
+            } catch (Exception e) {
+                throw new PortletException(e);
+            }
+            connectionFactories.add(info);
+        }
+        Collections.sort(connectionFactories);
+        renderRequest.setAttribute("cFactories", connectionFactories);
+
+        normalView.include(renderRequest, renderResponse);
+    }
+
+    private void renderDetail(RenderRequest renderRequest,
+            RenderResponse renderResponse, String name)
+            throws PortletException, IOException {
+        ObjectName gbeanName;
+
+        try {
+            gbeanName = new ObjectName(name);
+        } catch (MalformedObjectNameException e) {
+            throw new PortletException("Malformed parameter name: "
+                    + renderRequest.getParameter("name"));
+        }
+
+        try {
+            GBeanInfo gbeanInfo = kernel.getGBeanInfo(gbeanName);
+            Set attributes = gbeanInfo.getAttributes();
+            Map values = new HashMap(attributes.size());
+            for (Iterator i = attributes.iterator(); i.hasNext();) {
+                GAttributeInfo attribute = (GAttributeInfo) i.next();
+                String gname = attribute.getName();
+                if (HIDDEN_ATTRIBUTES.contains(gname)) {
+                    continue;
+                }
+                Object value = kernel.getAttribute(gbeanName, gname);
+                values.put(gname, value);
+            }
+            renderRequest.setAttribute("attributeMap", values);
+        } catch (Exception e) {
+            throw new PortletException(e);
+        }
+
+        detailView.include(renderRequest, renderResponse);
+    }
+
+    protected void doHelp(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws PortletException, IOException {
+        helpView.include(renderRequest, renderResponse);
+    }
+
+    public void destroy() {
+        normalView = null;
+        helpView = null;
+        addView = null;
+        kernel = null;
+        super.destroy();
+    }
+
+    private String trimStr(String str) {
+        if (str != null) {
+            return str.trim();
+        }
+        return "";
+    }
+
+    protected void testConnection(Object cf) throws Exception {
+        ConnectionFactory jmscf = (ConnectionFactory) cf;
+        Connection c = jmscf.createConnection();
+        c.close();
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSConnectionFactoryManagerPortlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,141 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.ConnectionFactory;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
+
+import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.console.jmsmanager.handlers.CreateDestinationHandler;
+import org.apache.geronimo.console.jmsmanager.handlers.PortletResponseHandler;
+import org.apache.geronimo.console.jmsmanager.handlers.RemoveDestinationHandler;
+import org.apache.geronimo.console.jmsmanager.handlers.StatisticsHandler;
+import org.apache.geronimo.console.jmsmanager.renderers.CreateDestinationRenderer;
+import org.apache.geronimo.console.jmsmanager.renderers.PortletRenderer;
+import org.apache.geronimo.console.jmsmanager.renderers.StatisticsRenderer;
+import org.apache.geronimo.console.jmsmanager.renderers.ViewDLQRenderer;
+import org.apache.geronimo.console.jmsmanager.renderers.ViewDestinationsRenderer;
+import org.apache.geronimo.console.jmsmanager.renderers.ViewMessagesRenderer;
+
+public class JMSManagerPortlet extends BasePortlet {
+
+    private PortletRequestDispatcher edit;
+
+    private PortletRequestDispatcher help;
+
+    private ConnectionFactory cf;
+
+    private Map handlers;
+
+    private Map renderers;
+
+    private PortletContext context;
+
+    public void init(PortletConfig portletConfig) throws PortletException {
+        super.init(portletConfig);
+
+        context = portletConfig.getPortletContext();
+
+        help = context
+                .getRequestDispatcher("/WEB-INF/view/jmsmanager/help.jsp");
+        edit = context
+                .getRequestDispatcher("/WEB-INF/view/jmsmanager/edit.jsp");
+
+        renderers = new HashMap();
+        renderers.put("createDestination", new CreateDestinationRenderer());
+        renderers.put("viewDestinations", new ViewDestinationsRenderer());
+        renderers.put("statistics", new StatisticsRenderer());
+        renderers.put("viewMessages", new ViewMessagesRenderer());
+        renderers.put("viewDLQ", new ViewDLQRenderer());
+
+        handlers = new HashMap();
+        handlers.put("createDestination", new CreateDestinationHandler());
+        handlers.put("removeDestination", new RemoveDestinationHandler());
+        handlers.put("statistics", new StatisticsHandler());
+
+    }
+
+    public void doHelp(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws PortletException, IOException {
+        help.include(renderRequest, renderResponse);
+    }
+
+    public void doView(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws IOException, PortletException {
+
+        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
+            return;
+        }
+
+        String view = renderRequest.getParameter("processAction");
+        if (view == null) {
+            // no specific content requested - show the destinations list
+            view = "viewDestinations";
+        }
+
+        PortletRenderer renderer = (PortletRenderer) renderers.get(view);
+        if (renderer == null) {
+            throw new PortletException("Invalid view parameter specified: "
+                    + view);
+        }
+
+        String include = renderer.render(renderRequest, renderResponse);
+        if (include != null) {
+            PortletRequestDispatcher requestDispatcher = context
+                    .getRequestDispatcher(include);
+            requestDispatcher.include(renderRequest, renderResponse);
+        }
+
+    }
+
+    public void processAction(ActionRequest actionRequest,
+            ActionResponse actionResponse) throws PortletException, IOException {
+        String processAction = actionRequest.getParameter("processaction");
+
+        PortletResponseHandler handler = (PortletResponseHandler) handlers
+                .get(processAction);
+
+        if (handler == null) {
+            // throw new RuntimeException( "no handlers for processAction = " +
+            // processAction );
+            handler = (PortletResponseHandler) handlers.get("viewDestinations");
+        }
+
+        handler.processAction(actionRequest, actionResponse);
+    }
+
+    public void destroy() {
+
+        help = null;
+        edit = null;
+        super.destroy();
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/JMSManagerPortlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,200 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.activemqCF;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.console.util.ObjectNameConstants;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+
+import javax.portlet.PortletRequest;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ActiveMQConnectorHelper {
+    //todo: this class is horrible and needs to be burned!
+    private final static Log log = LogFactory.getLog(ActiveMQConnectorHelper.class);
+
+    private static String MODULE_FILE;
+
+    private final static String ACTIVEMQ_RAR = "repository/activemq/rars/activemq-ra-3.2.1.rar";
+
+    private static final String LINE_SEP = System.getProperty("line.separator");
+
+    private static final String PLAN_TEMPLATE = getPlanTemplate();
+
+    private static final String[] DEPLOYER_ARGS = { File.class.getName(),
+            File.class.getName() };
+
+    private static final String DEPLOY_METHOD = "deploy";
+
+    private static String getPlanTemplate() {
+        StringBuffer sb = new StringBuffer();
+        sb.append("<?xml version=\"1.0\"?>\n");
+        sb
+                .append("<connector xmlns=\"http://geronimo.apache.org/xml/ns/j2ee/connector-1.0\"\n");
+        sb.append("    configId=\"{0}\" parentId=\"{1}\">\n");
+        sb.append("  <resourceadapter>\n");
+        sb.append("    <resourceadapter-instance>\n");
+        sb.append("      <resourceadapter-name>{2}</resourceadapter-name>\n");
+        sb
+                .append("      <config-property-setting name=\"ServerUrl\">{3}</config-property-setting>\n");
+        sb
+                .append("      <config-property-setting name=\"UserName\">{4}</config-property-setting>\n");
+        sb
+                .append("      <config-property-setting name=\"Password\">{5}</config-property-setting>\n");
+        sb
+                .append("      <workmanager><gbean-link>DefaultWorkManager</gbean-link></workmanager>\n");
+        sb.append("    </resourceadapter-instance>\n");
+        sb.append("    <outbound-resourceadapter>\n");
+        sb.append("      <connection-definition>\n");
+        sb
+                .append("        <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>\n");
+        sb.append("        <connectiondefinition-instance>\n");
+        sb.append("          <name>{6}</name>\n");
+        sb
+                .append("          <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>\n");
+        sb
+                .append("          <implemented-interface>javax.jms.TopicConnectionFactory</implemented-interface>\n");
+        sb.append("          <connectionmanager>\n");
+        sb.append("            <xa-transaction>\n");
+        sb.append("              <transaction-caching/>\n");
+        sb.append("            </xa-transaction>\n");
+        sb.append("            <single-pool>\n");
+        sb.append("              <max-size>{7}</max-size>\n");
+        sb
+                .append("              <blocking-timeout-milliseconds>{8}</blocking-timeout-milliseconds>\n");
+        sb.append("              <match-one/>\n");
+        sb.append("            </single-pool>\n");
+        sb.append("          </connectionmanager>\n");
+        sb.append("        </connectiondefinition-instance>\n");
+        sb.append("      </connection-definition>\n");
+        sb.append("    </outbound-resourceadapter>\n");
+        sb.append("  </resourceadapter>\n");
+        sb.append("</connector>\n");
+
+        return sb.toString();
+    }
+
+    private void savePlan(File f, Object[] args) {
+        MessageFormat mf = new MessageFormat(PLAN_TEMPLATE);
+        String plan = mf.format(args);
+
+        try {
+            f.createNewFile();
+            FileOutputStream fos = new FileOutputStream(f);
+            OutputStreamWriter osw = new OutputStreamWriter(fos);
+            Writer out = new BufferedWriter(osw);
+            out.write(plan);
+            out.flush();
+            out.close();
+            osw.close();
+            fos.close();
+        } catch (Exception e) {
+            System.out.println("ERROR: Problem creating the plan file");
+            e.printStackTrace();
+        }
+    }
+
+    public void deployPlan(PortletRequest request, Object[] args) {
+        try {
+            File file = File.createTempFile("console-jms-connector-plan-", ".xml");
+            file.deleteOnExit();
+            savePlan(file, args);
+            if(MODULE_FILE == null) {
+                MODULE_FILE = PortletManager.getServerInfo(request).resolvePath(ACTIVEMQ_RAR);
+            }
+            deployPlan(new File(MODULE_FILE), file);
+        } catch (IOException e) {
+            log.error("Unable to write deployment plan", e);
+        }
+    }
+
+    public void deployPlan(File moduleFile, File planFile) {
+        try {
+            Kernel kernel = KernelRegistry.getSingleKernel();
+            List list = (List) kernel.invoke(ObjectNameConstants.DEPLOYER_OBJECT_NAME, DEPLOY_METHOD,
+                    new Object[] {moduleFile, planFile}, DEPLOYER_ARGS);
+            ConfigurationManager configurationManager = ConfigurationUtil
+                    .getConfigurationManager(kernel);
+            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+                URI configID = URI.create((String)iterator.next());
+                if (!configurationManager.isLoaded(configID)) {
+                    configurationManager.load(configID);
+                }
+
+                configurationManager.loadGBeans(configID);
+                configurationManager.start(configID);
+            }
+        } catch (DeploymentException e) {
+            StringBuffer buf = new StringBuffer(256);
+            Throwable cause = e;
+            while (cause != null) {
+                buf.append(cause.getMessage());
+                buf.append(LINE_SEP);
+                cause = cause.getCause();
+            }
+            System.out
+                    .println("ERROR: Problem deploying the ActiveMQ connector: "
+                            + buf.toString());
+            e.printStackTrace();
+        } catch (URISyntaxException e) {
+            System.out
+                    .println("ERROR: Newly installed app has invalid config ID");
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("ERROR: Problem creating the datasource");
+            e.printStackTrace();
+        }
+    }
+
+    public List getDependencies(PortletRequest request) {
+        ListableRepository[] repo = PortletManager.getListableRepositories(request);
+        List dependencies = new ArrayList();
+        for (int i = 0; i < repo.length; i++) {
+            ListableRepository repository = repo[i];
+            try {
+                URI[] uris = repository.listURIs();
+                for (int j = 0; j < uris.length; j++) {
+                    URI uri = uris[j];
+                    dependencies.add(uri.toString());
+                }
+            } catch (URISyntaxException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return dependencies;
+    }
+}
\ No newline at end of file

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,160 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.handlers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.connector.AdminObjectWrapper;
+import org.apache.geronimo.connector.AdminObjectWrapperGBean;
+import org.apache.geronimo.console.core.jms.TopicBrowserGBean;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+import org.apache.geronimo.console.GeronimoVersion;
+import org.apache.geronimo.gbean.DynamicGAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.ObjectName;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+public class CreateDestinationHandler extends AbstractJMSManager implements PortletResponseHandler {
+    protected static Log log = LogFactory
+            .getLog(CreateDestinationHandler.class);
+
+    private static final List parentId = Arrays.asList(new URI[] {URI.create("geronimo/activemq-broker/" + GeronimoVersion.GERONIMO_VERSION + "/car")});
+
+    static final GBeanInfo QUEUE_INFO;
+
+    static final GBeanInfo TOPIC_INFO;
+
+    static {
+        GBeanInfoBuilder queueInfoBuilder = new GBeanInfoBuilder(
+                AdminObjectWrapper.class, AdminObjectWrapperGBean.GBEAN_INFO);
+        queueInfoBuilder.addAttribute(new DynamicGAttributeInfo("PhysicalName",
+                String.class.getName(), true, true, true, true));
+        QUEUE_INFO = queueInfoBuilder.getBeanInfo();
+        GBeanInfoBuilder topicInfoBuilder = new GBeanInfoBuilder(
+                AdminObjectWrapper.class, AdminObjectWrapperGBean.GBEAN_INFO);
+        topicInfoBuilder.addAttribute(new DynamicGAttributeInfo("PhysicalName",
+                String.class.getName(), true, true, true, true));
+        TOPIC_INFO = topicInfoBuilder.getBeanInfo();
+    }
+
+    public void processAction(ActionRequest request, ActionResponse response)
+            throws IOException, PortletException {
+        String destinationName = request.getParameter(DESTINATION_NAME);
+        String destinationPhysicalName = request
+                .getParameter(DESTINATION_PHYSICAL_NAME);
+        String destinationType = request.getParameter(DESTINATION_TYPE);
+        String destinationApplicationName = request
+                .getParameter(DESTINATION_APPLICATION_NAME);
+        String destinationModuleName = request
+                .getParameter(DESTINATION_MODULE_NAME);
+        try {
+            ObjectName adminObjectName = NameFactory.getComponentName(null,
+                    null, destinationApplicationName, NameFactory.JCA_RESOURCE,
+                    destinationModuleName, destinationName, null, baseContext);
+
+            GBeanData adminObjectData;
+            if (Topic.class.getName().equals(destinationType)) {
+                adminObjectData = new GBeanData(adminObjectName, TOPIC_INFO);
+                adminObjectData.setAttribute("adminObjectInterface", "javax.jms.Topic");
+                adminObjectData.setAttribute("adminObjectClass", "org.activemq.message.ActiveMQTopic");
+            } else if (Queue.class.getName().equals(destinationType)) {
+                adminObjectData = new GBeanData(adminObjectName, QUEUE_INFO);
+                adminObjectData.setAttribute("adminObjectInterface", "javax.jms.Queue");
+                adminObjectData.setAttribute("adminObjectClass", "org.activemq.message.ActiveMQQueue.class");
+            } else {
+                throw new PortletException(
+                        "Invalid choice destination, must be FQCL of Topic or Queue, not "
+                                + destinationType);
+            }
+            adminObjectData.setAttribute("PhysicalName",
+                    destinationPhysicalName);
+
+            URI configId = new URI(BASE_CONFIG_URI + destinationName);
+
+            ConfigurationManager configurationManager = ConfigurationUtil
+                    .getConfigurationManager(kernel);
+            List stores = configurationManager.listStores();
+            assert stores.size() == 1 : "Piling one hack on another, this code only works with exactly one store";
+
+            ObjectName storeName = (ObjectName) stores.iterator().next();
+            File installDir = (File) kernel.invoke(storeName,
+                    "createNewConfigurationDir");
+            //DeploymentContext deploymentContext = new
+            // DeploymentContext(installDir, configId,
+            // ConfigurationModuleType.SERVICE, parentId, kernel);
+            ConfigurationData configData = new ConfigurationData();
+            configData.setId(configId);
+            configData.setParentId(parentId);
+            configData.setModuleType(ConfigurationModuleType.SERVICE);
+            //deploymentContext.addGBean(adminObjectData);
+            configData.addGBean(adminObjectData);
+            // If we are adding a topic we have to add a browser so we can view
+            // its messages later.
+            if (Topic.class.getName().equals(destinationType)) {
+                GBeanData tBrowserBeanData = new GBeanData(NameFactory
+                        .getComponentName(null, null,
+                                destinationApplicationName,
+                                NameFactory.JCA_RESOURCE,
+                                destinationModuleName, destinationName,
+                                "TopicBrowser", baseContext),
+                        TopicBrowserGBean.GBEAN_INFO);
+                tBrowserBeanData
+                        .setAttribute("subscriberName", destinationName);
+                tBrowserBeanData.setReferencePattern(
+                        "ConnectionFactoryWrapper", ObjectName
+                                .getInstance(CONNECTION_FACTORY_NAME));
+                tBrowserBeanData.setReferencePattern("TopicWrapper",
+                        adminObjectName);
+
+                configData.addGBean(tBrowserBeanData);
+            }
+
+            //saves it.
+            //deploymentContext.close();
+            kernel.invoke(storeName, "install", new Object[] {configData,
+                    installDir}, new String[] {
+                    ConfigurationData.class.getName(), File.class.getName() });
+
+            configurationManager.load(configId);
+            configurationManager.loadGBeans(configId);
+            configurationManager.start(configId);
+
+        } catch (Exception e) {
+            log.error("problem", e);
+        }
+        response.setRenderParameter("processAction", "viewDestinations");
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.handlers;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+
+public interface PortletResponseHandler {
+
+    public void processAction(ActionRequest request, ActionResponse response)
+            throws IOException, PortletException;
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.handlers;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.ObjectName;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+import org.apache.geronimo.console.util.ObjectNameConstants;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+
+public class RemoveDestinationHandler extends AbstractJMSManager implements
+        PortletResponseHandler {
+
+    protected static Log log = LogFactory
+            .getLog(RemoveDestinationHandler.class);
+
+    public void processAction(ActionRequest request, ActionResponse response)
+            throws IOException, PortletException {
+        String destinationConfigURIName = request
+                .getParameter(DESTINATION_CONFIG_URI);
+        try {
+            ConfigurationManager configurationManager = ConfigurationUtil
+                    .getConfigurationManager(kernel);
+            URI destinationConfigURI = new URI(destinationConfigURIName);
+            ObjectName configurationObjectName = Configuration.getConfigurationObjectName(destinationConfigURI);
+
+            List stores = configurationManager.listStores();
+            assert stores.size() == 1 :"Piling one hack on another, this code only works with exactly one store";
+            ObjectName storeName = (ObjectName) stores.iterator().next();
+
+            // Unsubscribe topicbrowser before uninstalling the configuration.
+            DependencyManager dm = kernel.getDependencyManager();
+            //GBeanData topicBrowser = (GBeanData) kernel.invoke(storeName,
+            // "getConfiguration", new Object[]{destinationConfigURI}, new
+            // String[]{URI.class.getName()});
+            GBeanData topicBrowser = kernel.getGBeanData(configurationObjectName);
+            java.util.Set children = dm.getChildren(topicBrowser.getName());
+            for (Iterator i = children.iterator(); i.hasNext();) {
+                ObjectName o = (ObjectName) i.next();
+                if ("TopicBrowser".equals(o.getKeyProperty("j2eeType"))) {
+                    kernel.invoke(o, "unsubscribe");
+                    break;
+                }
+            }
+
+            // Uninstall configuration
+            //kernel.stopConfiguration(destinationConfigURI);
+            kernel.stopGBean(configurationObjectName);
+            kernel.invoke(storeName, "uninstall",
+                    new Object[] {destinationConfigURI},
+                    new String[] {URI.class.getName()});
+        } catch (Exception e) {
+            log.error("problem removing destination: "
+                    + destinationConfigURIName, e);
+        }
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.handlers;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+
+public class StatisticsHandler extends AbstractJMSManager implements
+        PortletResponseHandler {
+
+    protected static Log log = LogFactory.getLog(StatisticsHandler.class);
+
+    public void processAction(ActionRequest request, ActionResponse response)
+            throws IOException, PortletException {
+        String destinationName = request.getParameter(DESTINATION_NAME);
+        String destinationType = request.getParameter(DESTINATION_TYPE);
+
+        response.setRenderParameter("destinationName", destinationName);
+        response.setRenderParameter("destinationType", destinationType);
+        response.setRenderParameter("processAction", "statistics");
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.renderers;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+
+public class CreateDestinationRenderer extends AbstractJMSManager implements
+        PortletRenderer {
+
+    protected static Log log = LogFactory
+            .getLog(CreateDestinationRenderer.class);
+
+    public String render(RenderRequest request, RenderResponse response)
+            throws PortletException, IOException {
+
+        return "/WEB-INF/view/jmsmanager/createdestination.jsp";
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.renderers;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+public interface PortletRenderer {
+
+    String render(RenderRequest request, RenderResponse response)
+            throws PortletException, IOException;
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.renderers;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+
+public class StatisticsRenderer extends AbstractJMSManager implements
+        PortletRenderer {
+
+    protected static Log log = LogFactory.getLog(StatisticsRenderer.class);
+
+    public String render(RenderRequest request, RenderResponse response)
+            throws PortletException, IOException {
+
+        Hashtable statistics = getStatistics(request, response);
+
+        request.setAttribute("statistics", statistics);
+
+        return "/WEB-INF/view/jmsmanager/statistics.jsp";
+    }
+
+    public static Hashtable getStatistics(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws IOException, PortletException {
+        String description = "My Descrition";
+        String currentDepth = "11";
+        String openInputCount = "1";
+        String openOutputCount = "1";
+        String inhibitGet = "false";
+        String inhibitPut = "false";
+        String sharable = "true";
+        String triggerControl = "false";
+        String maximumDepth = "10000";
+        String maximumMessageLength = "2342344";
+
+        String destinationName = renderRequest.getParameter("destinationName");
+        if (destinationName == null) {
+            destinationName = "";
+        }
+        Hashtable statsHash = new Hashtable();
+
+        return statsHash;
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,143 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.renderers;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.management.ObjectName;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.activemq.service.DeadLetterPolicy;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+public class ViewDLQRenderer extends AbstractJMSManager implements
+        PortletRenderer {
+
+    private Destination destination = null;
+
+    private Destination dlq = null;
+
+    private QueueBrowser dlqBrowser = null;
+
+    private Connection connection = null;
+
+    private Session session = null;
+
+    private String dlqName;
+
+    public ViewDLQRenderer() {
+    }
+
+    public void setup(RenderRequest request, RenderResponse response) {
+        String destinationApplicationName = request
+                .getParameter("destinationApplicationName");
+        String destinationModuleName = request
+                .getParameter("destinationModuleName");
+        String destinationName = request.getParameter("destinationName");
+
+        try {
+            ObjectName adminObjectName = NameFactory.getComponentName(null,
+                    null, destinationApplicationName, NameFactory.JCA_RESOURCE,
+                    destinationModuleName, destinationName, null, baseContext);
+            destination = (Destination) kernel.invoke(adminObjectName,
+                    "$getResource");
+            ConnectionFactory connectionFactory = (ConnectionFactory) kernel
+                    .invoke(ObjectName.getInstance(CONNECTION_FACTORY_NAME),
+                            "$getResource");
+            connection = connectionFactory.createConnection();
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            DeadLetterPolicy dlp = new DeadLetterPolicy();
+
+            //dlqName =
+            // dlp.getDeadLetterNameFromDestination((ActiveMQDestination)
+            // destination);
+            // This is a hack to get around the fact that the code commented
+            // above throws a ClassCastException due to ClassLoader weirdness.
+            Field f = dlp.getClass().getDeclaredField(
+                    "deadLetterPerDestinationName");
+            f.setAccessible(true);
+            boolean deadLetterPerDestinationName = f.getBoolean(dlp);
+            f = dlp.getClass().getDeclaredField("deadLetterPrefix");
+            f.setAccessible(true);
+            String deadLetterPrefix = "" + f.get(dlp);
+            if (deadLetterPerDestinationName) {
+                dlqName = deadLetterPrefix
+                        + destination.getClass().getMethod("getPhysicalName",
+                                null).invoke(destination, null);
+            } else {
+                dlqName = deadLetterPrefix + deadLetterPrefix;
+            }
+
+            dlq = session.createQueue(dlqName);
+            dlqBrowser = session.createBrowser((Queue) dlq);
+
+            connection.start();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public List getDLQContents(QueueBrowser qb) {
+
+        List list = new ArrayList();
+
+        try {
+            for (Enumeration e = qb.getEnumeration(); e.hasMoreElements();) {
+                Object o = e.nextElement();
+                list.add(o);
+            }
+
+            connection.stop();
+            dlqBrowser.close();
+            session.close();
+            connection.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return list;
+    }
+
+    public String render(RenderRequest request, RenderResponse response)
+            throws PortletException, IOException {
+
+        setup(request, response);
+        List dlqContents = getDLQContents(dlqBrowser);
+        request.setAttribute("dlqcontents", dlqContents);
+        request.setAttribute("dlqname", dlqName);
+
+        return "/WEB-INF/view/jmsmanager/viewDLQ.jsp";
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java?rev=393787&view=auto
==============================================================================
--- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java (added)
+++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java Thu Apr 13 04:34:08 2006
@@ -0,0 +1,114 @@
+/**
+ *
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.jmsmanager.renderers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.ObjectName;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.jmsmanager.AbstractJMSManager;
+import org.apache.geronimo.console.jmsmanager.DestinationInfo;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+
+public class ViewDestinationsRenderer extends AbstractJMSManager implements
+        PortletRenderer {
+
+    protected static Log log = LogFactory
+            .getLog(ViewDestinationsRenderer.class);
+
+    public String render(RenderRequest request, RenderResponse response)
+            throws PortletException, IOException {
+
+        List destinationList = getDestinationList(request, response);
+
+        request.setAttribute(DESTINATION_LIST, destinationList);
+
+        return "/WEB-INF/view/jmsmanager/view.jsp";
+    }
+
+    public List getDestinationList(RenderRequest request,
+            RenderResponse response) {
+        Kernel kernel = KernelRegistry.getSingleKernel();
+
+        Set destinations = kernel.listGBeans(DESTINATION_QUERY);
+        List destinationInfos = new ArrayList(destinations.size());
+        DependencyManager dm = kernel.getDependencyManager();
+        for (Iterator iterator = destinations.iterator(); iterator.hasNext();) {
+            ObjectName destinationName = (ObjectName) iterator.next();
+
+            try {
+                Class type;
+                try {
+                    type = Class.forName((String) kernel.getAttribute(
+                            destinationName, "adminObjectInterface"));
+                } catch (ClassCastException cce) {
+                    type = (Class) kernel.getAttribute(destinationName,
+                            "adminObjectInterface");
+                }
+                Set parents = dm.getParents(destinationName);
+                Iterator i = parents.iterator();
+                // If no parents this is a configuration we don't need those
+                // here.
+                if (!i.hasNext()) {
+                    continue;
+                }
+                ObjectName parent = (ObjectName) i.next();
+                String adminObjectName = destinationName
+                        .getKeyProperty(NameFactory.J2EE_NAME);
+                if (adminObjectName.equals("MDBTransferBeanOutQueue")
+                        || adminObjectName.equals("SendReceiveQueue")) {
+                    continue;
+                }
+                String configURI = parent.getKeyProperty("name");
+                if (configURI.startsWith("\"")) {
+                    configURI = configURI.substring(1);
+                }
+                if (configURI.endsWith("\"")) {
+                    configURI = configURI.substring(0, configURI.length() - 1);
+                }
+
+                DestinationInfo info = new DestinationInfo(adminObjectName,
+                        (String) kernel.getAttribute(destinationName,
+                                "PhysicalName"), type, destinationName
+                                .getKeyProperty(NameFactory.J2EE_APPLICATION),
+                        destinationName
+                                .getKeyProperty(NameFactory.JCA_RESOURCE),
+                        configURI);
+                destinationInfos.add(info);
+            } catch (Exception e) {
+                log.error(e);
+            }
+        }
+        Collections.sort(destinationInfos);
+        return destinationInfos;
+    }
+
+}

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message