geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shiva Kumar H R" <shiv...@gmail.com>
Subject Re: svn commit: r675220 - in /geronimo/server/trunk/plugins: console/console-core/src/main/java/org/apache/geronimo/console/util/ plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ plancreator/plancreator-portle
Date Wed, 09 Jul 2008 16:00:49 GMT
Thanks Jarek, I will explore JMX to see if I can get all the dynamic info I
am looking for. If JMX does provide such info, I will revert back all these
and use JMX instead.

On Wed, Jul 9, 2008 at 9:03 PM, Jarek Gawor <jgawor@gmail.com> wrote:

> Why can't GEP use JMX to get this information? Why expose this type of
> information using a Servlet and return serialized data? I would be ok
> with this if the servlet returned XML or JSON formatted data and work
> in RESTful way or something (so that we could write a nice AJAX based
> console) but otherwise I don't see a point to it (unless I missed
> something).
>
> Jarek
>
> On Wed, Jul 9, 2008 at 11:03 AM,  <shivahr@apache.org> wrote:
> > Author: shivahr
> > Date: Wed Jul  9 08:03:08 2008
> > New Revision: 675220
> >
> > URL: http://svn.apache.org/viewvc?rev=675220&view=rev
> > Log:
> > GERONIMO-4189 Enable Geronimo Eclipse Plug-in (GEP) to get dynamic
> information from server
> >
> > Added:
> >
>  geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
>   (with props)
> > Modified:
> >
>  geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/PortletManager.java
> >
>  geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
> >
>  geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/web.xml
> >
> > Modified:
> geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/PortletManager.java
> > URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/PortletManager.java?rev=675220&r1=675219&r2=675220&view=diff
> >
> ==============================================================================
> > ---
> geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/PortletManager.java
> (original)
> > +++
> geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/PortletManager.java
> Wed Jul  9 08:03:08 2008
> > @@ -40,7 +40,9 @@
> >  import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> >  import org.apache.geronimo.kernel.repository.Repository;
> > +import org.apache.geronimo.management.EJBModule;
> >  import org.apache.geronimo.management.J2EEDeployedObject;
> > +import org.apache.geronimo.management.J2EEResource;
> >  import org.apache.geronimo.management.geronimo.J2EEDomain;
> >  import org.apache.geronimo.management.geronimo.J2EEServer;
> >  import org.apache.geronimo.management.geronimo.JCAAdminObject;
> > @@ -121,7 +123,15 @@
> >             request.getPortletSession().setAttribute(DOMAIN_KEY, domain,
> PortletSession.APPLICATION_SCOPE);
> >         }
> >         return domain;
> > +    }
> >
> > +    public static J2EEDomain getCurrentDomain(HttpSession session) {
> > +        J2EEDomain domain = (J2EEDomain)
> session.getAttribute(DOMAIN_KEY);
> > +        if (domain == null) {
> > +            domain = getManagementHelper(session).getDomains()[0];
> //todo: some day, select a domain
> > +            session.setAttribute(DOMAIN_KEY, domain);
> > +        }
> > +        return domain;
> >     }
> >
> >     public static J2EEServer getCurrentServer(PortletRequest request) {
> > @@ -135,6 +145,17 @@
> >         return server;
> >     }
> >
> > +    public static J2EEServer getCurrentServer(HttpSession session) {
> > +        J2EEServer server = (J2EEServer)
> session.getAttribute(SERVER_KEY);
> > +        if (server == null) {
> > +            server = getCurrentDomain(session).getServerInstances()[0];
> //todo: some day, select a server from the domain
> > +            session.setAttribute(SERVER_KEY, server);
> > +        } else {
> > +            // to do     handle "should not occur" error   - message?
> > +        }
> > +        return server;
> > +    }
> > +
> >     public static JVM getCurrentJVM(PortletRequest request) {
> >         JVM jvm = (JVM)
> request.getPortletSession(true).getAttribute(JVM_KEY,
> PortletSession.APPLICATION_SCOPE);
> >         if (jvm == null) {
> > @@ -155,15 +176,43 @@
> >         return helper.testLoginModule(getCurrentServer(request), module,
> options, username, password);
> >     }
> >
> > +    public static EJBModule[] getEJBModules(PortletRequest request) {
> > +        ManagementHelper helper = getManagementHelper(request);
> > +        return
> helper.getEJBModules(PortletManager.getCurrentServer(request));
> > +    }
> > +
> > +    public static EJBModule[] getEJBModules(HttpSession session) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return
> helper.getEJBModules(PortletManager.getCurrentServer(session));
> > +    }
> > +
> > +    public static J2EEResource[] getJ2EEResources(PortletRequest
> request) {
> > +        ManagementHelper helper = getManagementHelper(request);
> > +        return
> helper.getResources(PortletManager.getCurrentServer(request));
> > +    }
> > +
> > +    public static J2EEResource[] getJ2EEResources(HttpSession session) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return
> helper.getResources(PortletManager.getCurrentServer(session));
> > +    }
> > +
> >     public static ResourceAdapterModule[]
> getOutboundRAModules(PortletRequest request, String iface) {
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getOutboundRAModules(getCurrentServer(request),
> iface);
> >     }
> > +    public static ResourceAdapterModule[]
> getOutboundRAModules(HttpSession session, String iface) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getOutboundRAModules(getCurrentServer(session),
> iface);
> > +    }
> >
> >     public static ResourceAdapterModule[]
> getOutboundRAModules(PortletRequest request, String[] iface) {
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getOutboundRAModules(getCurrentServer(request),
> iface);
> >     }
> > +    public static ResourceAdapterModule[]
> getOutboundRAModules(HttpSession session, String[] iface) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getOutboundRAModules(getCurrentServer(session),
> iface);
> > +    }
> >
> >     public static ResourceAdapterModule[]
> getAdminObjectModules(PortletRequest request, String[] ifaces) {
> >         ManagementHelper helper = getManagementHelper(request);
> > @@ -194,17 +243,29 @@
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getOutboundFactories(module, iface);
> >     }
> > +    public static JCAManagedConnectionFactory[]
> getOutboundFactoriesForRA(HttpSession session, ResourceAdapterModule module,
> String iface) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getOutboundFactories(module, iface);
> > +    }
> >
> >     public static JCAManagedConnectionFactory[]
> getOutboundFactoriesForRA(PortletRequest request, ResourceAdapterModule
> module, String[] iface) {
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getOutboundFactories(module, iface);
> >     }
> > +    public static JCAManagedConnectionFactory[]
> getOutboundFactoriesForRA(HttpSession session, ResourceAdapterModule module,
> String[] iface) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getOutboundFactories(module, iface);
> > +    }
> >
> >     //todo: Create an interface for admin objects
> >     public static JCAAdminObject[] getAdminObjectsForRA(PortletRequest
> request, ResourceAdapterModule module, String[] ifaces) {
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getAdminObjects(module, ifaces);
> >     }
> > +    public static JCAAdminObject[] getAdminObjectsForRA(HttpSession
> session, ResourceAdapterModule module, String[] ifaces) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getAdminObjects(module, ifaces);
> > +    }
> >
> >     public static WebManager[] getWebManagers(PortletRequest request) {
> >         return getCurrentServer(request).getWebManagers();
> > @@ -336,11 +397,19 @@
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getConfigurationNameFor(objectName);
> >     }
> > +    public static Artifact getConfigurationFor(HttpSession session,
> AbstractName objectName) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getConfigurationNameFor(objectName);
> > +    }
> >
> >     public static AbstractName getNameFor(PortletRequest request, Object
> component) {
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getNameFor(component);
> >     }
> > +    public static AbstractName getNameFor(HttpSession session, Object
> component) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getNameFor(component);
> > +    }
> >
> >     public static File getRepositoryEntry(PortletRequest request, String
> repositoryURI) {
> >         J2EEServer server = getCurrentServer(request);
> > @@ -377,6 +446,10 @@
> >         ManagementHelper helper = getManagementHelper(request);
> >         return helper.getGBeansImplementing(iface);
> >     }
> > +    public static Object[] getGBeansImplementing(HttpSession session,
> Class iface) {
> > +        ManagementHelper helper = getManagementHelper(session);
> > +        return helper.getGBeansImplementing(iface);
> > +    }
> >
> >     /**
> >      * This methods adds a GBean to an existing configuration.
> >
> > Modified:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
> > URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java?rev=675220&r1=675219&r2=675220&view=diff
> >
> ==============================================================================
> > ---
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
> (original)
> > +++
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR77_Util.java
> Wed Jul  9 08:03:08 2008
> > @@ -23,6 +23,7 @@
> >  import javax.management.MalformedObjectNameException;
> >  import javax.management.ObjectName;
> >  import javax.portlet.PortletRequest;
> > +import javax.servlet.http.HttpSession;
> >
> >  import org.apache.geronimo.console.util.PortletManager;
> >  import org.apache.geronimo.gbean.AbstractName;
> > @@ -31,6 +32,7 @@
> >  import org.apache.geronimo.kernel.repository.ListableRepository;
> >  import org.apache.geronimo.management.EJBModule;
> >  import org.apache.geronimo.management.J2EEResource;
> > +import org.apache.geronimo.management.geronimo.J2EEServer;
> >  import org.apache.geronimo.management.geronimo.JCAAdminObject;
> >  import
> org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
> >  import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
> > @@ -71,9 +73,13 @@
> >     }
> >
> >     protected static List<ReferredData> getDeployedEJBs(PortletRequest
> request) {
> > +        return getDeployedEJBs(PortletManager.getEJBModules(request));
> > +    }
> > +    protected static List<ReferredData> getDeployedEJBs(HttpSession
> session) {
> > +        return getDeployedEJBs(PortletManager.getEJBModules(session));
> > +    }
> > +    private static List<ReferredData> getDeployedEJBs(EJBModule[]
> ejbModules) {
> >         List<ReferredData> ejbList = new ArrayList<ReferredData>();
> > -        EJBModule[] ejbModules =
> PortletManager.getManagementHelper(request).getEJBModules(
> > -                PortletManager.getCurrentServer(request));
> >         for (int i = 0; ejbModules != null && i < ejbModules.length;
i++)
> {
> >             String[] ejbObjectNames = ejbModules[i].getEjbs();
> >             for (int j = 0; j < ejbObjectNames.length; j++) {
> > @@ -116,12 +122,44 @@
> >             for (int i = 0; i < modules.length; i++) {
> >                 ResourceAdapterModule module = modules[i];
> >                 String configurationName =
> PortletManager.getConfigurationFor(request,
> > -                        PortletManager.getNameFor(request,
> module)).toString()
> > -                        + "/";
> > +                        PortletManager.getNameFor(request,
> module)).toString() + "/";
> >
> >                 JCAManagedConnectionFactory[] factories =
> PortletManager.getOutboundFactoriesForRA(request,
> > -                        module, new String[] {
> "javax.jms.ConnectionFactory", "javax.jms.QueueConnectionFactory",
> > -                                "javax.jms.TopicConnectionFactory", });
> > +                        module, new String[] {
> "javax.jms.ConnectionFactory",
> > +                        "javax.jms.QueueConnectionFactory",
> "javax.jms.TopicConnectionFactory", });
> > +                for (int j = 0; j < factories.length; j++) {
> > +                    JCAManagedConnectionFactory factory = factories[j];
> > +                    String factoryName =
> ObjectName.getInstance(factory.getObjectName()).getKeyProperty(
> > +                            NameFactory.J2EE_NAME);
> > +                    ReferredData data = new ReferredData(factoryName + "
> (" + configurationName + ")",
> > +                            configurationName + "/" + factoryName);
> > +                    connectionFactories.add(data);
> > +                }
> > +            }
> > +        } catch (MalformedObjectNameException e) {
> > +            // log.error(e.getMessage(), e);
> > +        }
> > +        return connectionFactories;
> > +    }
> > +    protected static List<ReferredData>
> getJMSConnectionFactories(HttpSession session) {
> > +        // TODO this is a duplicate of the code from
> > +        //
> org.apache.geronimo.console.jmsmanager.wizard.ListScreenHandler.populateExistingList()
> > +        // TODO need to eliminate this duplicate code probably by
> putting it in a common place
> > +        List<ReferredData> connectionFactories = new
> ArrayList<ReferredData>();
> > +
> > +        // Get the list of connection factories
> > +        ResourceAdapterModule[] modules =
> PortletManager.getOutboundRAModules(session, new String[] {
> > +                "javax.jms.ConnectionFactory",
> "javax.jms.QueueConnectionFactory",
> > +                "javax.jms.TopicConnectionFactory", });
> > +        try {
> > +            for (int i = 0; i < modules.length; i++) {
> > +                ResourceAdapterModule module = modules[i];
> > +                String configurationName =
> PortletManager.getConfigurationFor(session,
> > +                        PortletManager.getNameFor(session,
> module)).toString() + "/";
> > +
> > +                JCAManagedConnectionFactory[] factories =
> PortletManager.getOutboundFactoriesForRA(session,
> > +                        module, new String[] {
> "javax.jms.ConnectionFactory",
> > +                        "javax.jms.QueueConnectionFactory",
> "javax.jms.TopicConnectionFactory", });
> >                 for (int j = 0; j < factories.length; j++) {
> >                     JCAManagedConnectionFactory factory = factories[j];
> >                     String factoryName =
> ObjectName.getInstance(factory.getObjectName()).getKeyProperty(
> > @@ -170,6 +208,38 @@
> >         }
> >         return jmsDestinations;
> >     }
> > +    protected static List<ReferredData> getJMSDestinations(HttpSession
> session) {
> > +        // TODO this is a duplicate of the code from
> > +        //
> org.apache.geronimo.console.jmsmanager.wizard.ListScreenHandler.populateExistingList()
> > +        // TODO need to eliminate this duplicate code probably by
> putting it in a common place
> > +        List<ReferredData> jmsDestinations = new
> ArrayList<ReferredData>();
> > +
> > +        // Get the list of connection factories
> > +        ResourceAdapterModule[] modules =
> PortletManager.getOutboundRAModules(session, new String[] {
> > +                "javax.jms.ConnectionFactory",
> "javax.jms.QueueConnectionFactory",
> > +                "javax.jms.TopicConnectionFactory", });
> > +        try {
> > +            for (int i = 0; i < modules.length; i++) {
> > +                ResourceAdapterModule module = modules[i];
> > +                String configurationName =
> PortletManager.getConfigurationFor(session,
> > +                        PortletManager.getNameFor(session,
> module)).toString() + "/";
> > +
> > +                JCAAdminObject[] admins =
> PortletManager.getAdminObjectsForRA(session, module, new String[] {
> > +                        "javax.jms.Queue", "javax.jms.Topic" });
> > +                for (int j = 0; j < admins.length; j++) {
> > +                    JCAAdminObject admin = admins[j];
> > +                    String destinationName =
> ObjectName.getInstance(admin.getObjectName()).getKeyProperty(
> > +                            NameFactory.J2EE_NAME);
> > +                    ReferredData data = new ReferredData(destinationName
> + " (" + configurationName + ")",
> > +                            configurationName + "/" + destinationName);
> > +                    jmsDestinations.add(data);
> > +                }
> > +            }
> > +        } catch (MalformedObjectNameException e) {
> > +            // log.error(e.getMessage(), e);
> > +        }
> > +        return jmsDestinations;
> > +    }
> >
> >     protected static List<ReferredData>
> getJDBCConnectionPools(PortletRequest request) {
> >         // TODO this is a duplicate of the code from
> > @@ -193,11 +263,37 @@
> >         }
> >         return list;
> >     }
> > +    protected static List<ReferredData>
> getJDBCConnectionPools(HttpSession session) {
> > +        // TODO this is a duplicate of the code from
> > +        //
> org.apache.geronimo.console.databasemanager.wizard.DatabasePoolPortlet.populatePoolList()
> > +        // TODO need to eliminate this duplicate code probably by
> putting it in a common place
> > +        List<ReferredData> list = new ArrayList<ReferredData>();
> > +        ResourceAdapterModule[] modules =
> PortletManager.getOutboundRAModules(session, "javax.sql.DataSource");
> > +        for (int i = 0; i < modules.length; i++) {
> > +            ResourceAdapterModule module = modules[i];
> > +            JCAManagedConnectionFactory[] databases =
> PortletManager.getOutboundFactoriesForRA(session, module,
> > +                    "javax.sql.DataSource");
> > +            for (int j = 0; j < databases.length; j++) {
> > +                JCAManagedConnectionFactory db = databases[j];
> > +                AbstractName dbName =
> PortletManager.getManagementHelper(session).getNameFor(db);
> > +                String poolName = (String)
> dbName.getName().get(NameFactory.J2EE_NAME);
> > +                String configurationName =
> dbName.getArtifact().toString() + "/";
> > +                ReferredData data = new ReferredData(poolName + " (" +
> configurationName + ")",
> > +                        configurationName + "/" + poolName);
> > +                list.add(data);
> > +            }
> > +        }
> > +        return list;
> > +    }
> >
> >     protected static List<ReferredData>
> getJavaMailSessions(PortletRequest request) {
> > +        return
> getJavaMailSessions(PortletManager.getJ2EEResources(request));
> > +    }
> > +    protected static List<ReferredData> getJavaMailSessions(HttpSession
> session) {
> > +        return
> getJavaMailSessions(PortletManager.getJ2EEResources(session));
> > +    }
> > +    private static List<ReferredData> getJavaMailSessions(J2EEResource[]
> j2eeResources) {
> >         List<ReferredData> mailSessionList = new
> ArrayList<ReferredData>();
> > -        J2EEResource[] j2eeResources =
> PortletManager.getManagementHelper(request).getResources(
> > -                PortletManager.getCurrentServer(request));
> >         for (int i = 0; i < j2eeResources.length; i++) {
> >             try {
> >                 ObjectName objectName =
> ObjectName.getInstance(j2eeResources[i].getObjectName());
> > @@ -233,13 +329,33 @@
> >         }
> >         return credentialStoreList;
> >     }
> > +    protected static List<ReferredData>
> getDeployedCredentialStores(HttpSession session) {
> > +        List<ReferredData> credentialStoreList = new
> ArrayList<ReferredData>();
> > +        Object[] objects = PortletManager.getGBeansImplementing(session,
> > +
>  org.apache.geronimo.security.credentialstore.CredentialStore.class);
> > +        for (int i = 0; i < objects.length; i++) {
> > +            ObjectName objectName = PortletManager.getNameFor(session,
> objects[i]).getObjectName();
> > +            String credentialStoreName =
> objectName.getKeyProperty(NameFactory.J2EE_NAME);
> > +            String configurationName =
> objectName.getKeyProperty(NameFactory.SERVICE_MODULE) + "/";
> > +            ReferredData data = new ReferredData(credentialStoreName + "
> (" + configurationName + ")",
> > +                    configurationName + "/" + credentialStoreName);
> > +            credentialStoreList.add(data);
> > +        }
> > +        return credentialStoreList;
> > +    }
> >
> >     protected static List<String> getCommonLibs(PortletRequest request) {
> > +        return getCommonLibs(PortletManager.getCurrentServer(request));
> > +    }
> > +    protected static List<String> getCommonLibs(HttpSession session) {
> > +        return getCommonLibs(PortletManager.getCurrentServer(session));
> > +    }
> > +    private static List<String> getCommonLibs(J2EEServer server) {
> >         // TODO this is a duplicate of the code from
> >         //
> org.apache.geronimo.console.repository.RepositoryViewPortlet.doView()
> >         // TODO need to eliminate this duplicate code probably by putting
> it in a common place
> >         List<String> list = new ArrayList<String>();
> > -        ListableRepository[] repos =
> PortletManager.getCurrentServer(request).getRepositories();
> > +        ListableRepository[] repos = server.getRepositories();
> >         for (int i = 0; i < repos.length; i++) {
> >             ListableRepository repo = repos[i];
> >             for (Iterator<Artifact> iterator = repo.list().iterator();
> iterator.hasNext();) {
> > @@ -250,7 +366,10 @@
> >         return list;
> >     }
> >
> > -    public static SecurityRealm[]
> getDeployedSecurityRealms(PortletRequest request) {
> > +    protected static SecurityRealm[]
> getDeployedSecurityRealms(HttpSession session) {
> > +        return
> PortletManager.getCurrentServer(session).getSecurityRealms();
> > +    }
> > +    protected static SecurityRealm[]
> getDeployedSecurityRealms(PortletRequest request) {
> >         return
> PortletManager.getCurrentServer(request).getSecurityRealms();
> >     }
> >  }
> >
> > Added:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> > URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java?rev=675220&view=auto
> >
> ==============================================================================
> > ---
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> (added)
> > +++
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> Wed Jul  9 08:03:08 2008
> > @@ -0,0 +1,128 @@
> > +/**
> > + *  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.
> > + */
> > +package org.apache.geronimo.console.configcreator;
> > +
> > +import java.io.IOException;
> > +import java.io.ObjectOutputStream;
> > +import java.util.List;
> > +
> > +import javax.servlet.ServletException;
> > +import javax.servlet.http.HttpServletRequest;
> > +import javax.servlet.http.HttpServletResponse;
> > +import javax.servlet.http.HttpSession;
> > +
> > +import
> org.apache.geronimo.console.configcreator.JSR77_Util.ReferredData;
> > +import org.apache.geronimo.management.geronimo.SecurityRealm;
> > +
> > +/**
> > + * @version $Rev$ $Date$
> > + */
> > +public class ServerInfoServlet extends javax.servlet.http.HttpServlet
> implements javax.servlet.Servlet {
> > +    /* (non-Java-doc)
> > +    * @see javax.servlet.http.HttpServlet#HttpServlet()
> > +    */
> > +    public ServerInfoServlet() {
> > +        super();
> > +    }
> > +
> > +    public static String REQUESTED_INFO = "requestedInfo";
> > +    public static String DEPLOYED_EJBS = "deployedEJBs";
> > +    public static String JMS_CONNECTION_FACTORIES =
> "jmsConnectionFactories";
> > +    public static String JMS_DESTINATIONS = "jmsDestinations";
> > +    public static String JDBC_CONNECTION_POOLS = "jdbcConnectionPools";
> > +    public static String JAVA_MAIL_SESSIONS = "javaMailSessions";
> > +    public static String DEPLOLYED_CREDENTIAL_STORES =
> "deployedCredentialStores";
> > +    public static String COMMON_LIBS = "commonLibs";
> > +    public static String DEPLOYED_SECURITY_REALMS =
> "deployedSecurityRealms";
> > +
> > +    /* (non-Java-doc)
> > +     * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest
> request, HttpServletResponse response)
> > +     */
> > +    protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> > +        response.setContentType("bin/obj");
> > +        ObjectOutputStream oout = new
> ObjectOutputStream(response.getOutputStream());
> > +        String requestedInfo = request.getParameter(REQUESTED_INFO);
> > +        HttpSession session = request.getSession();
> > +        if (DEPLOYED_EJBS.equalsIgnoreCase(requestedInfo)) {
> > +            writeDeployedEJBs(session, oout);
> > +        } else if
> (JMS_CONNECTION_FACTORIES.equalsIgnoreCase(requestedInfo)) {
> > +            writeJMSConnectionFactories(session, oout);
> > +        } else if (JMS_DESTINATIONS.equalsIgnoreCase(requestedInfo)) {
> > +            writeJMSDestinations(session, oout);
> > +        } else if
> (JDBC_CONNECTION_POOLS.equalsIgnoreCase(requestedInfo)) {
> > +            writeJDBCConnectionPools(session, oout);
> > +        } else if (JAVA_MAIL_SESSIONS.equalsIgnoreCase(requestedInfo)) {
> > +            writeJavaMailSessions(session, oout);
> > +        } else if
> (DEPLOLYED_CREDENTIAL_STORES.equalsIgnoreCase(requestedInfo)) {
> > +            writeDeployedCredentialStores(session, oout);
> > +        } else if (COMMON_LIBS.equalsIgnoreCase(requestedInfo)) {
> > +            writeCommonLibs(session, oout);
> > +        } else if
> (DEPLOYED_SECURITY_REALMS.equalsIgnoreCase(requestedInfo)) {
> > +            writeDeployedSecurityRealms(session, oout);
> > +        }
> > +    }
> > +
> > +    protected void writeDeployedEJBs(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getDeployedEJBs(session), oout);
> > +    }
> > +
> > +    protected void writeJMSConnectionFactories(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getJMSConnectionFactories(session), oout);
> > +    }
> > +
> > +    protected void writeJMSDestinations(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getJMSDestinations(session), oout);
> > +    }
> > +
> > +    protected void writeJDBCConnectionPools(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getJDBCConnectionPools(session), oout);
> > +    }
> > +
> > +    protected void writeJavaMailSessions(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getJavaMailSessions(session), oout);
> > +    }
> > +
> > +    protected void writeDeployedCredentialStores(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        writeList(JSR77_Util.getDeployedCredentialStores(session),
> oout);
> > +    }
> > +
> > +    private void writeList(List<ReferredData> list, ObjectOutputStream
> oout) throws IOException {
> > +        for (int i = 0; i < list.size(); ++i) {
> > +            ReferredData refData = list.get(i);
> > +            oout.writeObject(refData.getPatternName());
> > +            oout.flush();
> > +        }
> > +    }
> > +
> > +    protected void writeCommonLibs(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        List<String> list = JSR77_Util.getCommonLibs(session);
> > +        for (int i = 0; i < list.size(); ++i) {
> > +            String libName = list.get(i);
> > +            oout.writeObject(libName);
> > +            oout.flush();
> > +        }
> > +    }
> > +
> > +    protected void writeDeployedSecurityRealms(HttpSession session,
> ObjectOutputStream oout) throws IOException {
> > +        SecurityRealm[] realms =
> JSR77_Util.getDeployedSecurityRealms(session);
> > +        for (int i = 0; i < realms.length; ++i) {
> > +            String realmName = realms[i].getRealmName();
> > +            oout.writeObject(realmName);
> > +            oout.flush();
> > +        }
> > +    }
> > +}
> > \ No newline at end of file
> >
> > Propchange:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> >
> ------------------------------------------------------------------------------
> >    svn:eol-style = native
> >
> > Propchange:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> >
> ------------------------------------------------------------------------------
> >    svn:keywords = Date Revision
> >
> > Propchange:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/ServerInfoServlet.java
> >
> ------------------------------------------------------------------------------
> >    svn:mime-type = text/plain
> >
> > Modified:
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/web.xml
> > URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/web.xml?rev=675220&r1=675219&r2=675220&view=diff
> >
> ==============================================================================
> > ---
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/web.xml
> (original)
> > +++
> geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/WEB-INF/web.xml
> Wed Jul  9 08:03:08 2008
> > @@ -51,6 +51,17 @@
> >       </init-param>
> >     </servlet>
> >
> > +    <servlet>
> > +        <display-name>ServerInfoServlet</display-name>
> > +        <servlet-name>ServerInfoServlet</servlet-name>
> > +
>  <servlet-class>org.apache.geronimo.console.configcreator.ServerInfoServlet</servlet-class>
> > +    </servlet>
> > +
> > +    <servlet-mapping>
> > +        <servlet-name>ServerInfoServlet</servlet-name>
> > +        <url-pattern>/ServerInfoServlet</url-pattern>
> > +    </servlet-mapping>
> > +
> >     <servlet-mapping>
> >         <servlet-name>PlanCreator</servlet-name>
> >         <url-pattern>/PlutoInvoker/PlanCreator</url-pattern>
> >
> >
> >
>



-- 
Thanks,
Shiva

Mime
View raw message