geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r955877 [2/6] - in /geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins: org.apache.geronimo.runtime.common/ org.apache.geronimo.runtime.common/META-INF/ org.apache.geronimo.runtime.v20/ org.apache.geronimo.runtime.v20/META-INF/ org.apa...
Date Fri, 18 Jun 2010 08:10:16 GMT
Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20ServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20ServerInfo.java?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20ServerInfo.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20ServerInfo.java Fri Jun 18 08:10:13 2010
@@ -0,0 +1,471 @@
+/*
+ * 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.st.v20.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.management.MBeanServerConnection;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.st.v21.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v21.core.IGeronimoServerInfo;
+import org.apache.geronimo.st.v21.core.internal.Trace;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+
+/**
+ * @version $Rev: 952535 $ $Date: 2010-06-08 12:40:16 +0800 (Tue, 08 Jun 2010) $
+ */
+public class GeronimoV20ServerInfo implements IGeronimoServerInfo{
+    static final long serialVersionUID = 1L;
+
+    private ArrayList<Kernel> kernels;
+
+    private ArrayList<Pattern> deployedEJBs;
+    private ArrayList<String> securityRealms;
+    private ArrayList<Pattern> jmsConnectionFactories;
+    private ArrayList<Pattern> jmsDestinations;
+    private ArrayList<Pattern> jdbcConnectionPools;
+    private ArrayList<Pattern> javaMailResources;
+    private ArrayList<org.apache.geronimo.jee.deployment.Pattern> credentialStores;
+    private HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> credentialStoreAttributes;
+    private ArrayList<Dependency> commonLibs;
+
+    // singleton class
+    private GeronimoV20ServerInfo() {
+    }
+
+    private static GeronimoV20ServerInfo instance = new GeronimoV20ServerInfo();
+
+    public static GeronimoV20ServerInfo getInstance() {
+        return instance;
+    }
+
+    public ArrayList<Pattern> getDeployedEjbs() {
+        return deployedEJBs;
+    }
+
+    public ArrayList<String> getSecurityRealms() {
+        return securityRealms;
+    }
+
+    public ArrayList<Pattern> getJmsConnectionFactories() {
+        return jmsConnectionFactories;
+    }
+
+    public ArrayList<Pattern> getJmsDestinations() {
+        return jmsDestinations;
+    }
+
+    public ArrayList<Pattern> getJdbcConnectionPools() {
+        return jdbcConnectionPools;
+    }
+
+    public ArrayList<Pattern> getJavaMailSessions() {
+        return javaMailResources;
+    }
+
+    public ArrayList<org.apache.geronimo.jee.deployment.Pattern> getDeployedCredentialStores() {
+        return credentialStores;
+    }
+    
+    public HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> getDeployedCredentialStoreAttributes() {
+        return credentialStoreAttributes;
+    }
+
+    public ArrayList<Dependency> getCommonLibs() {
+        return commonLibs;
+    }
+
+    public void updateInfo() {
+        Job job = new Job("Getting Dynamic Information from Server"){
+            protected IStatus run(IProgressMonitor arg0) {
+                updateKernels();
+                updateDeployedEJBs();
+                updateSecurityRealms();
+                updateJmsConnectionFactories();
+                updateJmsDestinations();
+                updateJdbcConnectionPools();
+                updateJavaMailSessions();
+                updateDeployedCredentialStores();
+                updateCommonLibs();
+                return Status.OK_STATUS;
+            }
+        };
+        job.setPriority(Job.SHORT);
+        job.schedule();
+    }
+
+    private void updateKernels() {
+        kernels = new ArrayList<Kernel>();
+        IServer[] servers = ServerCore.getServers();
+        for (int i = 0; i < servers.length; i++) {
+            if (servers[i].getServerState() == IServer.STATE_STARTED) {
+                try {
+                    GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) servers[i]
+                            .getAdapter(GeronimoServerBehaviourDelegate.class);
+                    if (delegate != null) {
+                        MBeanServerConnection connection = delegate
+                                .getServerConnection();
+                        if (connection != null) {
+                            kernels.add(new KernelDelegate(connection));
+                        }
+                    }
+                } catch (SecurityException e) {
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
+                            + e.getMessage());
+                }
+            }
+        }
+    }
+
+    private void updateDeployedEJBs() {
+        deployedEJBs = new ArrayList<Pattern>();
+        ArrayList<Pattern> statelessSessionBeans = getByType("StatelessSessionBean");
+        ArrayList<Pattern> statefulSessionBeans = getByType("StatefulSessionBean");
+        ArrayList<Pattern> messageDrivenBeans = getByType("MessageDrivenBean");
+        ArrayList<Pattern> entityBeans = getByType("EntityBean");
+        deployedEJBs.addAll(statelessSessionBeans);
+        deployedEJBs.addAll(statefulSessionBeans);
+        deployedEJBs.addAll(messageDrivenBeans);
+        deployedEJBs.addAll(entityBeans);
+    }
+
+    private void updateSecurityRealms() {
+        securityRealms = new ArrayList<String>();
+        Map map = Collections.singletonMap("j2eeType", "SecurityRealm");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                String name = (String) abstractName.getName().get("name");
+                if (!securityRealms.contains(name)) {
+                    securityRealms.add(name);
+                }
+            }
+        }
+    }
+
+    private void updateJmsConnectionFactories() {
+        String[] requiredInterfaces = new String[] {
+                "javax.jms.ConnectionFactory",
+                "javax.jms.QueueConnectionFactory",
+                "javax.jms.TopicConnectionFactory", };
+        String attribute = "implementedInterfaces";
+        jmsConnectionFactories = getByTypeAttributeValues(
+                "JCAManagedConnectionFactory", attribute, requiredInterfaces);
+    }
+
+    private void updateJmsDestinations() {
+        String[] requiredInterfaces = new String[] { "javax.jms.Queue",
+                "javax.jms.Topic" };
+        String attribute = "adminObjectInterface";
+        jmsDestinations = getByTypeAttributeValues("JCAAdminObject", attribute,
+                requiredInterfaces);
+    }
+
+    private void updateJdbcConnectionPools() {
+        String[] acceptedValues = new String[] { "javax.sql.DataSource" };
+        String attribute = "connectionFactoryInterface";
+        jdbcConnectionPools = getByTypeAttributeValues(
+                "JCAManagedConnectionFactory", attribute, acceptedValues);
+
+    }
+
+    private void updateJavaMailSessions() {
+        javaMailResources = getByType("JavaMailResource");
+    }
+
+    private void updateDeployedCredentialStores() {
+        credentialStores = new ArrayList<org.apache.geronimo.jee.deployment.Pattern>();
+        credentialStoreAttributes = new HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> ();
+        Map map = Collections.singletonMap("j2eeType", "GBean");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+        	Kernel kernel = (Kernel)kernels.get(i);
+            Set beans = kernel.listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    GBeanInfo info = kernel.getGBeanInfo(abstractName);
+                    GAttributeInfo attribInfo = info
+                            .getAttribute("credentialStore");
+                    if (attribInfo != null) {
+                        Artifact artifact = abstractName.getArtifact();
+                        Object name = abstractName.getName().get("name");
+                        org.apache.geronimo.jee.deployment.Pattern pattern = new org.apache.geronimo.jee.deployment.Pattern();
+                        pattern.setArtifactId(artifact.getArtifactId());
+                        pattern.setGroupId(artifact.getGroupId());
+                        pattern.setType(artifact.getType());
+                        pattern.setVersion(artifact.getVersion().toString());
+                        pattern.setCustomFoo((String) name);
+                        if (!credentialStores.contains(pattern)) {
+                            credentialStores.add(pattern);
+                        }
+                        
+                      //update attributes of credentialStore
+                    	Map attributeMap = (Map)kernel.getAttribute(abstractName, "credentialStore");
+                    	if (attributeMap!=null){
+                    		HashMap<String,ArrayList<String>> realmMap = new HashMap<String,ArrayList<String>>();
+                    		for (Object obj:attributeMap.keySet()){
+                    			String realmName = (String)obj;
+                    			Map idMap = (Map)attributeMap.get(obj);
+                    			ArrayList<String> idList = new ArrayList<String>();
+                    			idList.addAll(idMap.keySet());                    			
+                    			
+                    			realmMap.put(realmName, idList);
+                    		}               		
+                    		credentialStoreAttributes.put(pattern, realmMap);
+                    	}
+                    }
+                } catch (GBeanNotFoundException e) {
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+    
+
+    private void updateCommonLibs() {
+        List<Object> artifacts = null;
+        commonLibs = new ArrayList<Dependency>();
+        Map map = Collections.singletonMap("j2eeType", "Repository");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    GBeanInfo info = kernels.get(i).getGBeanInfo(abstractName);
+                    Object value = kernels.get(i).invoke(abstractName, "list");
+                    if (value instanceof TreeSet) {
+                        artifacts = Arrays.asList(((TreeSet) value).toArray());
+                    }
+                } catch (GBeanNotFoundException e) {
+                    Trace.trace(Trace.WARNING, "GBean Not Found. "
+                            + e.getMessage());
+                } catch (NoSuchOperationException e) {
+                    Trace.trace(Trace.WARNING, "The operation cant invoked. "
+                            + e.getMessage());
+                } catch (InternalKernelException e) {
+                    throw e;
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed.  "
+                            + e.getMessage());
+                }
+
+            }
+        }
+        if (artifacts != null) {
+            for (int i = 0; i < artifacts.size(); i++) {
+                Dependency dependency = new Dependency();
+                dependency.setArtifactId(((Artifact) artifacts.get(i))
+                        .getArtifactId());
+                dependency.setGroupId(((Artifact) artifacts.get(i))
+                        .getGroupId());
+                dependency.setVersion(((Artifact) artifacts.get(i))
+                        .getVersion().toString());
+                dependency.setType(((Artifact) artifacts.get(i)).getType());
+                if (!commonLibs.contains(dependency)) {
+                    commonLibs.add(dependency);
+                }
+            }
+        }
+    }
+
+    private ArrayList<Pattern> getByTypeAttributeValues(String type,
+            String attribute, String[] acceptedValues) {
+        ArrayList<Pattern> result = new ArrayList<Pattern>();
+        Map map = Collections.singletonMap("j2eeType", type);
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    Object value = kernels.get(i).getAttribute(abstractName,
+                            attribute);
+                    if (value != null) {
+                        if (value instanceof String[]) {
+                            List<String> interfaces = Arrays
+                                    .asList((String[]) value);
+                            for (int j = 0; j < acceptedValues.length; j++) {
+                                if (interfaces.contains(acceptedValues[j])) {
+                                    Pattern pattern = new Pattern();
+                                    Artifact artifact = abstractName
+                                            .getArtifact();
+                                    pattern.setArtifactId(artifact
+                                            .getArtifactId());
+                                    pattern.setGroupId(artifact.getGroupId());
+                                    pattern.setVersion(artifact.getVersion()
+                                            .toString());
+                                    pattern.setName((String) abstractName
+                                            .getName().get("name"));
+                                    if (!result.contains(pattern)) {
+                                        result.add(pattern);
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                        if (value instanceof String) {
+                            String interfaces = (String) value;
+                            for (int j = 0; j < acceptedValues.length; j++) {
+                                if (interfaces.contains(acceptedValues[j])) {
+                                    Pattern pattern = new Pattern();
+                                    Artifact artifact = abstractName
+                                            .getArtifact();
+                                    pattern.setArtifactId(artifact
+                                            .getArtifactId());
+                                    pattern.setGroupId(artifact.getGroupId());
+                                    pattern.setVersion(artifact.getVersion()
+                                            .toString());
+                                    pattern.setName((String) abstractName
+                                            .getName().get("name"));
+                                    if (!result.contains(pattern)) {
+                                        result.add(pattern);
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                } catch (GBeanNotFoundException e) {
+                } catch (NoSuchAttributeException e) {
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
+                            + e.getMessage());
+                }
+            }
+        }
+        return result;
+    }
+
+    private ArrayList<Pattern> getByType(String type) {
+        ArrayList<Pattern> result = new ArrayList<Pattern>();
+        Map map = Collections.singletonMap("j2eeType", type);
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                Pattern pattern = new Pattern();
+                Artifact artifact = abstractName.getArtifact();
+                pattern.setArtifactId(artifact.getArtifactId());
+                pattern.setGroupId(artifact.getGroupId());
+                pattern.setVersion(artifact.getVersion().toString());
+                pattern.setName((String) abstractName.getName().get("name"));
+                if (!result.contains(pattern)) {
+                    result.add(pattern);
+                }
+            }
+        }
+        return result;
+    }
+
+    protected void printNamingPatternList(List<Pattern> patternList) {
+        for (int i = 0; i < patternList.size(); i++) {
+            Pattern pattern = patternList.get(i);
+            System.out.println("ArtifactID:" + pattern.getArtifactId()
+                    + " GroupID:" + pattern.getGroupId() + " Module:"
+                    + pattern.getModule() + " Version:" + pattern.getVersion()
+                    + " Name:" + pattern.getName());
+        }
+    }
+
+    protected void printDeploymentPatternList(
+            List<org.apache.geronimo.jee.deployment.Pattern> patternList) {
+        for (int i = 0; i < patternList.size(); i++) {
+            org.apache.geronimo.jee.deployment.Pattern pattern = patternList
+                    .get(i);
+            System.out.println("ArtifactID:" + pattern.getArtifactId()
+                    + " GroupID:" + pattern.getGroupId() + " Module:"
+                    + pattern.getVersion() + " Version:" + pattern.getType()
+                    + " Name:" + pattern.getCustomFoo());
+        }
+    }
+
+    protected void printDependencies(List<Dependency> dependencyList) {
+        for (int i = 0; i < dependencyList.size(); i++) {
+            Dependency dependency = dependencyList.get(i);
+            System.out.println("ArtifactID:" + dependency.getArtifactId()
+                    + " GroupID:" + dependency.getGroupId() + " Type:"
+                    + dependency.getType() + " Version:"
+                    + dependency.getVersion());
+        }
+    }
+
+    public void printServerInfo() {
+        System.out.println("EJB Modules: \n");
+        List<Pattern> ejbModules = getDeployedEjbs();
+        printNamingPatternList(ejbModules);
+        System.out.println("\n\nSecurity Realms: \n");
+        List<String> securityRealms = getSecurityRealms();
+        System.out.println(securityRealms.toString());
+        System.out.println("\n\nJMS Connection Factories: \n");
+        List<Pattern> jmsConnectionFactories = getJmsConnectionFactories();
+        printNamingPatternList(jmsConnectionFactories);
+        System.out.println("\n\nJMS Destinations: \n");
+        List<Pattern> jmsDestinations = getJmsDestinations();
+        printNamingPatternList(jmsDestinations);
+        System.out.println("\n\nJDBC Connection Pools: \n");
+        List<Pattern> jdbcConnectionPools = getJdbcConnectionPools();
+        printNamingPatternList(jdbcConnectionPools);
+        System.out.println("\n\nJava Mail Resources: \n");
+        List<Pattern> javaMailResources = getJavaMailSessions();
+        printNamingPatternList(javaMailResources);
+        System.out.println("\n\nCredential Stores: \n");
+        List<org.apache.geronimo.jee.deployment.Pattern> credentialStores = getDeployedCredentialStores();
+        printDeploymentPatternList(credentialStores);
+        System.out.println("\n\nCommon Libs: \n");
+        List<Dependency> dependencies = getCommonLibs();
+        printDependencies(dependencies);
+    }
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20VersionHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20VersionHandler.java?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20VersionHandler.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20VersionHandler.java Fri Jun 18 08:10:13 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.st.v20.core;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
+import org.apache.geronimo.st.v21.core.GeronimoV21Utils;
+import org.apache.geronimo.st.v21.core.IGeronimoVersionHandler;
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev: 513891 $ $Date: 2007-03-02 14:09:25 -0500 (Fri, 02 Mar 2007) $
+ */
+public class GeronimoV20VersionHandler implements IGeronimoVersionHandler {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#getConfigID(org.eclipse.wst.server.core.IModule)
+	 */
+	public String getConfigID(IModule module) throws Exception {
+		return GeronimoV21Utils.getConfigId(module);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#createTargetModuleId(java.lang.String)
+	 */
+	public TargetModuleID createTargetModuleId(String configId) {
+		return new TargetModuleIDImpl(null, configId);
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/internal/Trace.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/internal/Trace.java?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/internal/Trace.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/internal/Trace.java Fri Jun 18 08:10:13 2010
@@ -0,0 +1,114 @@
+/*
+ * 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.st.v20.core.internal;
+
+import org.apache.geronimo.st.v21.core.Activator;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Helper class to route trace output.
+ *
+ * @version $Rev: 589873 $ $Date: 2007-10-29 17:48:35 -0400 (Mon, 29 Oct 2007) $
+ */
+public class Trace {
+
+    /**
+     * Finest trace event.
+     */
+    public static byte INFO = 0;
+
+    /**
+     * Warning trace event.
+     */
+    public static byte WARNING = 1;
+
+    /**
+     * Severe trace event.
+     */
+    public static byte SEVERE = 2;
+
+    /**
+     * Trace constructor comment.
+     */
+    private Trace() {
+        super();
+    }
+
+    /**
+     * Trace the given text.
+     * 
+     * @param level
+     *            the trace level
+     * @param s
+     *            a message
+     */
+    public static void trace(byte level, String s) {
+        trace(level, s, null);
+    }
+
+    /**
+     * Trace the given message and exception.
+     * 
+     * @param level
+     *            the trace level
+     * @param s
+     *            a message
+     * @param t
+     *            a throwable
+     */
+    public static void trace(byte level, String s, Throwable t) {
+    	if (Activator.getDefault() == null
+				|| !Activator.getDefault().isDebugging())
+			return;
+
+        System.out.println(Activator.PLUGIN_ID + ":  " + s);
+        if (t != null)
+            t.printStackTrace();
+        
+    }
+
+    /**
+     * Trace the given message 
+     * 
+     * @param tracePoint
+     *            The trace point (e.g., "Exit", "Entry", "Constructor", etc....
+     *            
+     * @param classDotMethod
+     *            The class name + method name (e.g., "Class.method()")
+     *            
+     * @param parms
+     *            Method parameter(s) if the trace point is an "Entry"
+     *            or
+     *            Return value if the trace point is an "Exit"
+     */
+    public static void tracePoint(String tracePoint, String classDotMethod) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "()" );
+    }   
+    public static void tracePoint(String tracePoint, String classDotMethod, Object... parms) {
+        if ( parms == null ) {
+            trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( null )" );
+        }
+        else {
+            trace(Trace.INFO, tracePoint + ": " + classDotMethod + "(" );
+            for ( int ii=0; ii<parms.length; ii++) {
+                Object parm = parms[ii];
+                trace(Trace.INFO, "    parm" + (ii+1) + "=[" + (parm == null ? null : parm.toString()) + "]" );
+            }
+            trace(Trace.INFO, ")" );
+        }
+    }   
+}

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/META-INF/MANIFEST.MF?rev=955877&r1=955876&r2=955877&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/META-INF/MANIFEST.MF Fri Jun 18 08:10:13 2010
@@ -6,9 +6,9 @@ Bundle-Version: 2.2.1
 Bundle-Activator: org.apache.geronimo.st.v21.core.Activator
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-Require-Bundle: org.apache.geronimo.jee.v21.jaxbmodel,
- org.apache.geronimo.runtime.v22,
- org.apache.geronimo.st.core,
+Require-Bundle: org.apache.geronimo.jee.v21.jaxbmodel, 
+ org.apache.geronimo.runtime.v21,
+ org.apache.geronimo.st.core;visibility:=reexport,
  org.eclipse.jst.j2ee,
  org.eclipse.core.runtime,
  org.eclipse.wst.server.core,
@@ -26,5 +26,6 @@ Export-Package: 
  org.apache.geronimo.st.v21.core,
  org.apache.geronimo.st.v21.core.internal,
  org.apache.geronimo.st.v21.core.jaxb,
- org.apache.geronimo.st.v21.core.operations 
+ org.apache.geronimo.st.v21.core.operations
 Import-Package: junit.framework;version="3.8.2"
+

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.properties?rev=955877&r1=955876&r2=955877&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.properties (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.properties Fri Jun 18 08:10:13 2010
@@ -18,6 +18,7 @@
 #
 pluginName=Geronimo v2.1 Server Adapter
 providerName=Apache Software Foundation
+geronimoLaunchConfigurationType=Apache Geronimo
 
 runtimeTypeName=Apache Geronimo v2.1
 runtimeTypeDescription=Apache Geronimo v2.1 supports Java EE 5.0.

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.xml?rev=955877&r1=955876&r2=955877&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.xml (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/plugin.xml Fri Jun 18 08:10:13 2010
@@ -20,6 +20,7 @@
 <!-- $Rev: 589873 $ $Date: 2007-10-29 17:48:35 -0400 (Mon, 29 Oct 2007) $ -->
 
 <plugin>
+   <extension-point id="geronimoinfo" name="Geronimo Server Info" schema="schema/geronimoinfo.exsd"/>
 
 
     <!-- 
@@ -61,7 +62,7 @@
             stopTimeout="30000"
             startBeforePublish="true"
             runtimeTypeId="org.apache.geronimo.runtime.21"
-            launchConfigId="org.apache.geronimo.st.core.launchConfigurationType"
+            launchConfigId="org.apache.geronimo.st.v21.core.launchConfigurationType"
             behaviourClass="org.apache.geronimo.st.v21.core.GeronimoServerBehaviour"
             hasConfiguration="false"
             launchModes="run,debug,profile">
@@ -184,6 +185,38 @@
             postOperationClass="org.apache.geronimo.st.v21.core.operations.ImportDeploymentPlanOperation">
         </operationExtension>
     </extension>
+    <extension
+          point="org.apache.geronimo.st.v21.core.geronimoinfo">
+       <provider
+             class="org.apache.geronimo.st.v21.core.GeronimoV21ServerInfo"
+             versions="2.1">
+       </provider>
+    </extension>
+
 
+    <extension
+       point="org.eclipse.hyades.trace.ui.launchConfigMechanismAssociator">
+       <association            
+           launchConfigID = "org.apache.geronimo.st.v21.core.launchConfigurationType">
+   
+           <mechanism mechanismID = "org.eclipse.tptp.trace.ui.jvmpiMechanism"> 
+               <configuration
+                   launchDelegate = "org.eclipse.tptp.trace.ui.internal.launcher.deleg.application.PIAttachLauncherDelegate"
+                   configurationId = "org.eclipse.tptp.trace.ui.jvmpiConfiguration"
+                   associatedAgent = "org.eclipse.tptp.trace.ui.jvmpiAgent"        
+                   filter = "org.eclipse.tptp.platform.profile.server.core.internal.PICollectorFiltration">                
+               </configuration>            
+           </mechanism>        
+           
+           <mechanism mechanismID = "org.eclipse.tptp.trace.jvmti.jvmtiMechanism"> 
+               <configuration
+                   launchDelegate = "org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIAttachLauncherDelegate"
+                   configurationId = "org.eclipse.tptp.trace.jvmti.tiConfiguration"
+                   associatedAgent = "org.eclipse.tptp.platform.jvmti.TIAgent"
+                   filter = "org.eclipse.tptp.platform.profile.server.core.internal.TICollectorFiltration">                            
+               </configuration>            
+           </mechanism>    
+       </association>
+   </extension>
 
 </plugin>

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/pom.xml?rev=955877&r1=955876&r2=955877&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/pom.xml Fri Jun 18 08:10:13 2010
@@ -152,7 +152,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.devtools</groupId>
-            <artifactId>org.apache.geronimo.runtime.v22</artifactId>
+            <artifactId>org.apache.geronimo.runtime.v21</artifactId>
             <version>${version}</version>
             <exclusions>
                     <exclusion>

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/schema/geronimoinfo.exsd
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/schema/geronimoinfo.exsd?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/schema/geronimoinfo.exsd (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/schema/geronimoinfo.exsd Fri Jun 18 08:10:13 2010
@@ -0,0 +1,106 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.apache.geronimo.st.v21.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.apache.geronimo.st.v21.core" id="geronimoinfo" name="Geronimo Server Info"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="provider"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="provider">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="versions" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

Copied: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfoManager.java (from r953557, geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfo.java)
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfoManager.java?p2=geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfoManager.java&p1=geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfo.java&r1=953557&r2=955877&rev=955877&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfo.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerInfoManager.java Fri Jun 18 08:10:13 2010
@@ -16,455 +16,64 @@
  */
 package org.apache.geronimo.st.v21.core;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 
-import javax.management.MBeanServerConnection;
-
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.GAttributeInfo;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.jee.deployment.Dependency;
-import org.apache.geronimo.jee.naming.Pattern;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.InternalKernelException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.NoSuchAttributeException;
-import org.apache.geronimo.kernel.NoSuchOperationException;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.st.v21.core.GeronimoServerBehaviourDelegate;
 import org.apache.geronimo.st.v21.core.internal.Trace;
-import org.apache.geronimo.system.jmx.KernelDelegate;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
 
 /**
  * @version $Rev$ $Date$
  */
-public class GeronimoServerInfo {
-    static final long serialVersionUID = 1L;
-
-    private ArrayList<Kernel> kernels;
-
-    private ArrayList<Pattern> deployedEJBs;
-    private ArrayList<String> securityRealms;
-    private ArrayList<Pattern> jmsConnectionFactories;
-    private ArrayList<Pattern> jmsDestinations;
-    private ArrayList<Pattern> jdbcConnectionPools;
-    private ArrayList<Pattern> javaMailResources;
-    private ArrayList<org.apache.geronimo.jee.deployment.Pattern> credentialStores;
-    private HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> credentialStoreAttributes;
-    private ArrayList<Dependency> commonLibs;
+public class GeronimoServerInfoManager {
+	
+	private static Map<String, IGeronimoServerInfo> providers = new HashMap<String, IGeronimoServerInfo>();
+
+	static {
+		loadExtensionPoints();
+	}
+
+	private static synchronized void loadExtensionPoints() {
+		Trace.tracePoint("ENTRY", "GeronimoServerInfo.loadExtensionPoints");
+
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+				Activator.PLUGIN_ID, "geronimoinfo");
+		for (int i = 0; i < cf.length; i++) {
+			IConfigurationElement element = cf[i];
+			if ("provider".equals(element.getName())) {
+				try {
+					IGeronimoServerInfo provider = (IGeronimoServerInfo) element
+							.createExecutableExtension("class");
+					String versions = element.getAttribute("version");
+					String[] versionArray = versions.split(",");
+					for (int j = 0; j < versionArray.length; j++) {
+						providers.put(versionArray[j], provider);
+					}
+				} catch (CoreException e) {
+					Trace.tracePoint("CoreException",
+							"GeronimoServerInfo.loadExtensionPoints");
+					e.printStackTrace();
+				}
+			}
+		}
+
+		Trace.tracePoint("EXIT", "GeronimoServerInfo.loadExtensionPoints");
+	}
+	
 
     // singleton class
-    private GeronimoServerInfo() {
-    }
-
-    private static GeronimoServerInfo instance = new GeronimoServerInfo();
-
-    public static GeronimoServerInfo getInstance() {
-        return instance;
-    }
-
-    public ArrayList<Pattern> getDeployedEjbs() {
-        return deployedEJBs;
-    }
-
-    public ArrayList<String> getSecurityRealms() {
-        return securityRealms;
-    }
-
-    public ArrayList<Pattern> getJmsConnectionFactories() {
-        return jmsConnectionFactories;
-    }
-
-    public ArrayList<Pattern> getJmsDestinations() {
-        return jmsDestinations;
-    }
-
-    public ArrayList<Pattern> getJdbcConnectionPools() {
-        return jdbcConnectionPools;
-    }
-
-    public ArrayList<Pattern> getJavaMailSessions() {
-        return javaMailResources;
-    }
-
-    public ArrayList<org.apache.geronimo.jee.deployment.Pattern> getDeployedCredentialStores() {
-        return credentialStores;
-    }
-    
-    public HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> getDeployedCredentialStoreAttributes() {
-        return credentialStoreAttributes;
-    }
-
-    public ArrayList<Dependency> getCommonLibs() {
-        return commonLibs;
-    }
-
-    public void updateInfo() {
-        Job job = new Job("Getting Dynamic Information from Server"){
-            protected IStatus run(IProgressMonitor arg0) {
-                updateKernels();
-                updateDeployedEJBs();
-                updateSecurityRealms();
-                updateJmsConnectionFactories();
-                updateJmsDestinations();
-                updateJdbcConnectionPools();
-                updateJavaMailSessions();
-                updateDeployedCredentialStores();
-                updateCommonLibs();
-                return Status.OK_STATUS;
-            }
-        };
-        job.setPriority(Job.SHORT);
-        job.schedule();
-    }
-
-    private void updateKernels() {
-        kernels = new ArrayList<Kernel>();
-        IServer[] servers = ServerCore.getServers();
-        for (int i = 0; i < servers.length; i++) {
-            if (servers[i].getServerState() == IServer.STATE_STARTED) {
-                try {
-                    GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) servers[i]
-                            .getAdapter(GeronimoServerBehaviourDelegate.class);
-                    if (delegate != null) {
-                        MBeanServerConnection connection = delegate
-                                .getServerConnection();
-                        if (connection != null) {
-                            kernels.add(new KernelDelegate(connection));
-                        }
-                    }
-                } catch (SecurityException e) {
-                } catch (Exception e) {
-                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
-                            + e.getMessage());
-                }
-            }
-        }
-    }
-
-    private void updateDeployedEJBs() {
-        deployedEJBs = new ArrayList<Pattern>();
-        ArrayList<Pattern> statelessSessionBeans = getByType("StatelessSessionBean");
-        ArrayList<Pattern> statefulSessionBeans = getByType("StatefulSessionBean");
-        ArrayList<Pattern> messageDrivenBeans = getByType("MessageDrivenBean");
-        ArrayList<Pattern> entityBeans = getByType("EntityBean");
-        deployedEJBs.addAll(statelessSessionBeans);
-        deployedEJBs.addAll(statefulSessionBeans);
-        deployedEJBs.addAll(messageDrivenBeans);
-        deployedEJBs.addAll(entityBeans);
-    }
-
-    private void updateSecurityRealms() {
-        securityRealms = new ArrayList<String>();
-        Map map = Collections.singletonMap("j2eeType", "SecurityRealm");
-        AbstractNameQuery query = new AbstractNameQuery(null, map,
-                Collections.EMPTY_SET);
-        for (int i = 0; i < kernels.size(); i++) {
-            Set beans = kernels.get(i).listGBeans(query);
-            for (Iterator it = beans.iterator(); it.hasNext();) {
-                AbstractName abstractName = (AbstractName) it.next();
-                String name = (String) abstractName.getName().get("name");
-                if (!securityRealms.contains(name)) {
-                    securityRealms.add(name);
-                }
-            }
-        }
-    }
-
-    private void updateJmsConnectionFactories() {
-        String[] requiredInterfaces = new String[] {
-                "javax.jms.ConnectionFactory",
-                "javax.jms.QueueConnectionFactory",
-                "javax.jms.TopicConnectionFactory", };
-        String attribute = "implementedInterfaces";
-        jmsConnectionFactories = getByTypeAttributeValues(
-                "JCAManagedConnectionFactory", attribute, requiredInterfaces);
-    }
-
-    private void updateJmsDestinations() {
-        String[] requiredInterfaces = new String[] { "javax.jms.Queue",
-                "javax.jms.Topic" };
-        String attribute = "adminObjectInterface";
-        jmsDestinations = getByTypeAttributeValues("JCAAdminObject", attribute,
-                requiredInterfaces);
-    }
-
-    private void updateJdbcConnectionPools() {
-        String[] acceptedValues = new String[] { "javax.sql.DataSource" };
-        String attribute = "connectionFactoryInterface";
-        jdbcConnectionPools = getByTypeAttributeValues(
-                "JCAManagedConnectionFactory", attribute, acceptedValues);
-
-    }
-
-    private void updateJavaMailSessions() {
-        javaMailResources = getByType("JavaMailResource");
-    }
-
-    private void updateDeployedCredentialStores() {
-        credentialStores = new ArrayList<org.apache.geronimo.jee.deployment.Pattern>();
-        credentialStoreAttributes = new HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> ();
-        Map map = Collections.singletonMap("j2eeType", "GBean");
-        AbstractNameQuery query = new AbstractNameQuery(null, map,
-                Collections.EMPTY_SET);
-        for (int i = 0; i < kernels.size(); i++) {
-        	Kernel kernel = (Kernel)kernels.get(i);
-            Set beans = kernel.listGBeans(query);
-            for (Iterator it = beans.iterator(); it.hasNext();) {
-                AbstractName abstractName = (AbstractName) it.next();
-                try {
-                    GBeanInfo info = kernel.getGBeanInfo(abstractName);
-                    GAttributeInfo attribInfo = info
-                            .getAttribute("credentialStore");
-                    if (attribInfo != null) {
-                        Artifact artifact = abstractName.getArtifact();
-                        Object name = abstractName.getName().get("name");
-                        org.apache.geronimo.jee.deployment.Pattern pattern = new org.apache.geronimo.jee.deployment.Pattern();
-                        pattern.setArtifactId(artifact.getArtifactId());
-                        pattern.setGroupId(artifact.getGroupId());
-                        pattern.setType(artifact.getType());
-                        pattern.setVersion(artifact.getVersion().toString());
-                        pattern.setCustomFoo((String) name);
-                        if (!credentialStores.contains(pattern)) {
-                            credentialStores.add(pattern);
-                        }
-                        
-                      //update attributes of credentialStore
-                    	Map attributeMap = (Map)kernel.getAttribute(abstractName, "credentialStore");
-                    	if (attributeMap!=null){
-                    		HashMap<String,ArrayList<String>> realmMap = new HashMap<String,ArrayList<String>>();
-                    		for (Object obj:attributeMap.keySet()){
-                    			String realmName = (String)obj;
-                    			Map idMap = (Map)attributeMap.get(obj);
-                    			ArrayList<String> idList = new ArrayList<String>();
-                    			idList.addAll(idMap.keySet());                    			
-                    			
-                    			realmMap.put(realmName, idList);
-                    		}               		
-                    		credentialStoreAttributes.put(pattern, realmMap);
-                    	}
-                    }
-                } catch (GBeanNotFoundException e) {
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
+    private GeronimoServerInfoManager() {
     }
-    
 
-    private void updateCommonLibs() {
-        List<Object> artifacts = null;
-        commonLibs = new ArrayList<Dependency>();
-        Map map = Collections.singletonMap("j2eeType", "Repository");
-        AbstractNameQuery query = new AbstractNameQuery(null, map,
-                Collections.EMPTY_SET);
-        for (int i = 0; i < kernels.size(); i++) {
-            Set beans = kernels.get(i).listGBeans(query);
-            for (Iterator it = beans.iterator(); it.hasNext();) {
-                AbstractName abstractName = (AbstractName) it.next();
-                try {
-                    GBeanInfo info = kernels.get(i).getGBeanInfo(abstractName);
-                    Object value = kernels.get(i).invoke(abstractName, "list");
-                    if (value instanceof TreeSet) {
-                        artifacts = Arrays.asList(((TreeSet) value).toArray());
-                    }
-                } catch (GBeanNotFoundException e) {
-                    Trace.trace(Trace.WARNING, "GBean Not Found. "
-                            + e.getMessage());
-                } catch (NoSuchOperationException e) {
-                    Trace.trace(Trace.WARNING, "The operation cant invoked. "
-                            + e.getMessage());
-                } catch (InternalKernelException e) {
-                    throw e;
-                } catch (Exception e) {
-                    Trace.trace(Trace.WARNING, "Kernel connection failed.  "
-                            + e.getMessage());
-                }
-
-            }
-        }
-        if (artifacts != null) {
-            for (int i = 0; i < artifacts.size(); i++) {
-                Dependency dependency = new Dependency();
-                dependency.setArtifactId(((Artifact) artifacts.get(i))
-                        .getArtifactId());
-                dependency.setGroupId(((Artifact) artifacts.get(i))
-                        .getGroupId());
-                dependency.setVersion(((Artifact) artifacts.get(i))
-                        .getVersion().toString());
-                dependency.setType(((Artifact) artifacts.get(i)).getType());
-                if (!commonLibs.contains(dependency)) {
-                    commonLibs.add(dependency);
-                }
-            }
-        }
-    }
 
-    private ArrayList<Pattern> getByTypeAttributeValues(String type,
-            String attribute, String[] acceptedValues) {
-        ArrayList<Pattern> result = new ArrayList<Pattern>();
-        Map map = Collections.singletonMap("j2eeType", type);
-        AbstractNameQuery query = new AbstractNameQuery(null, map,
-                Collections.EMPTY_SET);
-        for (int i = 0; i < kernels.size(); i++) {
-            Set beans = kernels.get(i).listGBeans(query);
-            for (Iterator it = beans.iterator(); it.hasNext();) {
-                AbstractName abstractName = (AbstractName) it.next();
-                try {
-                    Object value = kernels.get(i).getAttribute(abstractName,
-                            attribute);
-                    if (value != null) {
-                        if (value instanceof String[]) {
-                            List<String> interfaces = Arrays
-                                    .asList((String[]) value);
-                            for (int j = 0; j < acceptedValues.length; j++) {
-                                if (interfaces.contains(acceptedValues[j])) {
-                                    Pattern pattern = new Pattern();
-                                    Artifact artifact = abstractName
-                                            .getArtifact();
-                                    pattern.setArtifactId(artifact
-                                            .getArtifactId());
-                                    pattern.setGroupId(artifact.getGroupId());
-                                    pattern.setVersion(artifact.getVersion()
-                                            .toString());
-                                    pattern.setName((String) abstractName
-                                            .getName().get("name"));
-                                    if (!result.contains(pattern)) {
-                                        result.add(pattern);
-                                    }
-                                    break;
-                                }
-                            }
-                        }
-                        if (value instanceof String) {
-                            String interfaces = (String) value;
-                            for (int j = 0; j < acceptedValues.length; j++) {
-                                if (interfaces.contains(acceptedValues[j])) {
-                                    Pattern pattern = new Pattern();
-                                    Artifact artifact = abstractName
-                                            .getArtifact();
-                                    pattern.setArtifactId(artifact
-                                            .getArtifactId());
-                                    pattern.setGroupId(artifact.getGroupId());
-                                    pattern.setVersion(artifact.getVersion()
-                                            .toString());
-                                    pattern.setName((String) abstractName
-                                            .getName().get("name"));
-                                    if (!result.contains(pattern)) {
-                                        result.add(pattern);
-                                    }
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                } catch (GBeanNotFoundException e) {
-                } catch (NoSuchAttributeException e) {
-                } catch (Exception e) {
-                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
-                            + e.getMessage());
-                }
-            }
-        }
-        return result;
+    public static IGeronimoServerInfo getProvider(String version) {
+        return providers.get(version);
     }
 
-    private ArrayList<Pattern> getByType(String type) {
-        ArrayList<Pattern> result = new ArrayList<Pattern>();
-        Map map = Collections.singletonMap("j2eeType", type);
-        AbstractNameQuery query = new AbstractNameQuery(null, map,
-                Collections.EMPTY_SET);
-        for (int i = 0; i < kernels.size(); i++) {
-            Set beans = kernels.get(i).listGBeans(query);
-            for (Iterator it = beans.iterator(); it.hasNext();) {
-                AbstractName abstractName = (AbstractName) it.next();
-                Pattern pattern = new Pattern();
-                Artifact artifact = abstractName.getArtifact();
-                pattern.setArtifactId(artifact.getArtifactId());
-                pattern.setGroupId(artifact.getGroupId());
-                pattern.setVersion(artifact.getVersion().toString());
-                pattern.setName((String) abstractName.getName().get("name"));
-                if (!result.contains(pattern)) {
-                    result.add(pattern);
-                }
-            }
-        }
-        return result;
-    }
-
-    protected void printNamingPatternList(List<Pattern> patternList) {
-        for (int i = 0; i < patternList.size(); i++) {
-            Pattern pattern = patternList.get(i);
-            System.out.println("ArtifactID:" + pattern.getArtifactId()
-                    + " GroupID:" + pattern.getGroupId() + " Module:"
-                    + pattern.getModule() + " Version:" + pattern.getVersion()
-                    + " Name:" + pattern.getName());
-        }
-    }
-
-    protected void printDeploymentPatternList(
-            List<org.apache.geronimo.jee.deployment.Pattern> patternList) {
-        for (int i = 0; i < patternList.size(); i++) {
-            org.apache.geronimo.jee.deployment.Pattern pattern = patternList
-                    .get(i);
-            System.out.println("ArtifactID:" + pattern.getArtifactId()
-                    + " GroupID:" + pattern.getGroupId() + " Module:"
-                    + pattern.getVersion() + " Version:" + pattern.getType()
-                    + " Name:" + pattern.getCustomFoo());
-        }
-    }
-
-    protected void printDependencies(List<Dependency> dependencyList) {
-        for (int i = 0; i < dependencyList.size(); i++) {
-            Dependency dependency = dependencyList.get(i);
-            System.out.println("ArtifactID:" + dependency.getArtifactId()
-                    + " GroupID:" + dependency.getGroupId() + " Type:"
-                    + dependency.getType() + " Version:"
-                    + dependency.getVersion());
-        }
-    }
-
-    public void printServerInfo() {
-        System.out.println("EJB Modules: \n");
-        List<Pattern> ejbModules = getDeployedEjbs();
-        printNamingPatternList(ejbModules);
-        System.out.println("\n\nSecurity Realms: \n");
-        List<String> securityRealms = getSecurityRealms();
-        System.out.println(securityRealms.toString());
-        System.out.println("\n\nJMS Connection Factories: \n");
-        List<Pattern> jmsConnectionFactories = getJmsConnectionFactories();
-        printNamingPatternList(jmsConnectionFactories);
-        System.out.println("\n\nJMS Destinations: \n");
-        List<Pattern> jmsDestinations = getJmsDestinations();
-        printNamingPatternList(jmsDestinations);
-        System.out.println("\n\nJDBC Connection Pools: \n");
-        List<Pattern> jdbcConnectionPools = getJdbcConnectionPools();
-        printNamingPatternList(jdbcConnectionPools);
-        System.out.println("\n\nJava Mail Resources: \n");
-        List<Pattern> javaMailResources = getJavaMailSessions();
-        printNamingPatternList(javaMailResources);
-        System.out.println("\n\nCredential Stores: \n");
-        List<org.apache.geronimo.jee.deployment.Pattern> credentialStores = getDeployedCredentialStores();
-        printDeploymentPatternList(credentialStores);
-        System.out.println("\n\nCommon Libs: \n");
-        List<Dependency> dependencies = getCommonLibs();
-        printDependencies(dependencies);
-    }
+  
 
 }

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java Fri Jun 18 08:10:13 2010
@@ -0,0 +1,470 @@
+/*
+ * 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.st.v21.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.management.MBeanServerConnection;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.st.v21.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v21.core.internal.Trace;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+
+/**
+ * @version $Rev: 952535 $ $Date: 2010-06-08 12:40:16 +0800 (Tue, 08 Jun 2010) $
+ */
+public class GeronimoV21ServerInfo implements IGeronimoServerInfo{
+    static final long serialVersionUID = 1L;
+
+    private ArrayList<Kernel> kernels;
+
+    private ArrayList<Pattern> deployedEJBs;
+    private ArrayList<String> securityRealms;
+    private ArrayList<Pattern> jmsConnectionFactories;
+    private ArrayList<Pattern> jmsDestinations;
+    private ArrayList<Pattern> jdbcConnectionPools;
+    private ArrayList<Pattern> javaMailResources;
+    private ArrayList<org.apache.geronimo.jee.deployment.Pattern> credentialStores;
+    private HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> credentialStoreAttributes;
+    private ArrayList<Dependency> commonLibs;
+
+    // singleton class
+    private GeronimoV21ServerInfo() {
+    }
+
+    private static GeronimoV21ServerInfo instance = new GeronimoV21ServerInfo();
+
+    public static GeronimoV21ServerInfo getInstance() {
+        return instance;
+    }
+
+    public ArrayList<Pattern> getDeployedEjbs() {
+        return deployedEJBs;
+    }
+
+    public ArrayList<String> getSecurityRealms() {
+        return securityRealms;
+    }
+
+    public ArrayList<Pattern> getJmsConnectionFactories() {
+        return jmsConnectionFactories;
+    }
+
+    public ArrayList<Pattern> getJmsDestinations() {
+        return jmsDestinations;
+    }
+
+    public ArrayList<Pattern> getJdbcConnectionPools() {
+        return jdbcConnectionPools;
+    }
+
+    public ArrayList<Pattern> getJavaMailSessions() {
+        return javaMailResources;
+    }
+
+    public ArrayList<org.apache.geronimo.jee.deployment.Pattern> getDeployedCredentialStores() {
+        return credentialStores;
+    }
+    
+    public HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> getDeployedCredentialStoreAttributes() {
+        return credentialStoreAttributes;
+    }
+
+    public ArrayList<Dependency> getCommonLibs() {
+        return commonLibs;
+    }
+
+    public void updateInfo() {
+        Job job = new Job("Getting Dynamic Information from Server"){
+            protected IStatus run(IProgressMonitor arg0) {
+                updateKernels();
+                updateDeployedEJBs();
+                updateSecurityRealms();
+                updateJmsConnectionFactories();
+                updateJmsDestinations();
+                updateJdbcConnectionPools();
+                updateJavaMailSessions();
+                updateDeployedCredentialStores();
+                updateCommonLibs();
+                return Status.OK_STATUS;
+            }
+        };
+        job.setPriority(Job.SHORT);
+        job.schedule();
+    }
+
+    private void updateKernels() {
+        kernels = new ArrayList<Kernel>();
+        IServer[] servers = ServerCore.getServers();
+        for (int i = 0; i < servers.length; i++) {
+            if (servers[i].getServerState() == IServer.STATE_STARTED) {
+                try {
+                    GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) servers[i]
+                            .getAdapter(GeronimoServerBehaviourDelegate.class);
+                    if (delegate != null) {
+                        MBeanServerConnection connection = delegate
+                                .getServerConnection();
+                        if (connection != null) {
+                            kernels.add(new KernelDelegate(connection));
+                        }
+                    }
+                } catch (SecurityException e) {
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
+                            + e.getMessage());
+                }
+            }
+        }
+    }
+
+    private void updateDeployedEJBs() {
+        deployedEJBs = new ArrayList<Pattern>();
+        ArrayList<Pattern> statelessSessionBeans = getByType("StatelessSessionBean");
+        ArrayList<Pattern> statefulSessionBeans = getByType("StatefulSessionBean");
+        ArrayList<Pattern> messageDrivenBeans = getByType("MessageDrivenBean");
+        ArrayList<Pattern> entityBeans = getByType("EntityBean");
+        deployedEJBs.addAll(statelessSessionBeans);
+        deployedEJBs.addAll(statefulSessionBeans);
+        deployedEJBs.addAll(messageDrivenBeans);
+        deployedEJBs.addAll(entityBeans);
+    }
+
+    private void updateSecurityRealms() {
+        securityRealms = new ArrayList<String>();
+        Map map = Collections.singletonMap("j2eeType", "SecurityRealm");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                String name = (String) abstractName.getName().get("name");
+                if (!securityRealms.contains(name)) {
+                    securityRealms.add(name);
+                }
+            }
+        }
+    }
+
+    private void updateJmsConnectionFactories() {
+        String[] requiredInterfaces = new String[] {
+                "javax.jms.ConnectionFactory",
+                "javax.jms.QueueConnectionFactory",
+                "javax.jms.TopicConnectionFactory", };
+        String attribute = "implementedInterfaces";
+        jmsConnectionFactories = getByTypeAttributeValues(
+                "JCAManagedConnectionFactory", attribute, requiredInterfaces);
+    }
+
+    private void updateJmsDestinations() {
+        String[] requiredInterfaces = new String[] { "javax.jms.Queue",
+                "javax.jms.Topic" };
+        String attribute = "adminObjectInterface";
+        jmsDestinations = getByTypeAttributeValues("JCAAdminObject", attribute,
+                requiredInterfaces);
+    }
+
+    private void updateJdbcConnectionPools() {
+        String[] acceptedValues = new String[] { "javax.sql.DataSource" };
+        String attribute = "connectionFactoryInterface";
+        jdbcConnectionPools = getByTypeAttributeValues(
+                "JCAManagedConnectionFactory", attribute, acceptedValues);
+
+    }
+
+    private void updateJavaMailSessions() {
+        javaMailResources = getByType("JavaMailResource");
+    }
+
+    private void updateDeployedCredentialStores() {
+        credentialStores = new ArrayList<org.apache.geronimo.jee.deployment.Pattern>();
+        credentialStoreAttributes = new HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> ();
+        Map map = Collections.singletonMap("j2eeType", "GBean");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+        	Kernel kernel = (Kernel)kernels.get(i);
+            Set beans = kernel.listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    GBeanInfo info = kernel.getGBeanInfo(abstractName);
+                    GAttributeInfo attribInfo = info
+                            .getAttribute("credentialStore");
+                    if (attribInfo != null) {
+                        Artifact artifact = abstractName.getArtifact();
+                        Object name = abstractName.getName().get("name");
+                        org.apache.geronimo.jee.deployment.Pattern pattern = new org.apache.geronimo.jee.deployment.Pattern();
+                        pattern.setArtifactId(artifact.getArtifactId());
+                        pattern.setGroupId(artifact.getGroupId());
+                        pattern.setType(artifact.getType());
+                        pattern.setVersion(artifact.getVersion().toString());
+                        pattern.setCustomFoo((String) name);
+                        if (!credentialStores.contains(pattern)) {
+                            credentialStores.add(pattern);
+                        }
+                        
+                      //update attributes of credentialStore
+                    	Map attributeMap = (Map)kernel.getAttribute(abstractName, "credentialStore");
+                    	if (attributeMap!=null){
+                    		HashMap<String,ArrayList<String>> realmMap = new HashMap<String,ArrayList<String>>();
+                    		for (Object obj:attributeMap.keySet()){
+                    			String realmName = (String)obj;
+                    			Map idMap = (Map)attributeMap.get(obj);
+                    			ArrayList<String> idList = new ArrayList<String>();
+                    			idList.addAll(idMap.keySet());                    			
+                    			
+                    			realmMap.put(realmName, idList);
+                    		}               		
+                    		credentialStoreAttributes.put(pattern, realmMap);
+                    	}
+                    }
+                } catch (GBeanNotFoundException e) {
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+    
+
+    private void updateCommonLibs() {
+        List<Object> artifacts = null;
+        commonLibs = new ArrayList<Dependency>();
+        Map map = Collections.singletonMap("j2eeType", "Repository");
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    GBeanInfo info = kernels.get(i).getGBeanInfo(abstractName);
+                    Object value = kernels.get(i).invoke(abstractName, "list");
+                    if (value instanceof TreeSet) {
+                        artifacts = Arrays.asList(((TreeSet) value).toArray());
+                    }
+                } catch (GBeanNotFoundException e) {
+                    Trace.trace(Trace.WARNING, "GBean Not Found. "
+                            + e.getMessage());
+                } catch (NoSuchOperationException e) {
+                    Trace.trace(Trace.WARNING, "The operation cant invoked. "
+                            + e.getMessage());
+                } catch (InternalKernelException e) {
+                    throw e;
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed.  "
+                            + e.getMessage());
+                }
+
+            }
+        }
+        if (artifacts != null) {
+            for (int i = 0; i < artifacts.size(); i++) {
+                Dependency dependency = new Dependency();
+                dependency.setArtifactId(((Artifact) artifacts.get(i))
+                        .getArtifactId());
+                dependency.setGroupId(((Artifact) artifacts.get(i))
+                        .getGroupId());
+                dependency.setVersion(((Artifact) artifacts.get(i))
+                        .getVersion().toString());
+                dependency.setType(((Artifact) artifacts.get(i)).getType());
+                if (!commonLibs.contains(dependency)) {
+                    commonLibs.add(dependency);
+                }
+            }
+        }
+    }
+
+    private ArrayList<Pattern> getByTypeAttributeValues(String type,
+            String attribute, String[] acceptedValues) {
+        ArrayList<Pattern> result = new ArrayList<Pattern>();
+        Map map = Collections.singletonMap("j2eeType", type);
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                try {
+                    Object value = kernels.get(i).getAttribute(abstractName,
+                            attribute);
+                    if (value != null) {
+                        if (value instanceof String[]) {
+                            List<String> interfaces = Arrays
+                                    .asList((String[]) value);
+                            for (int j = 0; j < acceptedValues.length; j++) {
+                                if (interfaces.contains(acceptedValues[j])) {
+                                    Pattern pattern = new Pattern();
+                                    Artifact artifact = abstractName
+                                            .getArtifact();
+                                    pattern.setArtifactId(artifact
+                                            .getArtifactId());
+                                    pattern.setGroupId(artifact.getGroupId());
+                                    pattern.setVersion(artifact.getVersion()
+                                            .toString());
+                                    pattern.setName((String) abstractName
+                                            .getName().get("name"));
+                                    if (!result.contains(pattern)) {
+                                        result.add(pattern);
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                        if (value instanceof String) {
+                            String interfaces = (String) value;
+                            for (int j = 0; j < acceptedValues.length; j++) {
+                                if (interfaces.contains(acceptedValues[j])) {
+                                    Pattern pattern = new Pattern();
+                                    Artifact artifact = abstractName
+                                            .getArtifact();
+                                    pattern.setArtifactId(artifact
+                                            .getArtifactId());
+                                    pattern.setGroupId(artifact.getGroupId());
+                                    pattern.setVersion(artifact.getVersion()
+                                            .toString());
+                                    pattern.setName((String) abstractName
+                                            .getName().get("name"));
+                                    if (!result.contains(pattern)) {
+                                        result.add(pattern);
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                } catch (GBeanNotFoundException e) {
+                } catch (NoSuchAttributeException e) {
+                } catch (Exception e) {
+                    Trace.trace(Trace.WARNING, "Kernel connection failed. "
+                            + e.getMessage());
+                }
+            }
+        }
+        return result;
+    }
+
+    private ArrayList<Pattern> getByType(String type) {
+        ArrayList<Pattern> result = new ArrayList<Pattern>();
+        Map map = Collections.singletonMap("j2eeType", type);
+        AbstractNameQuery query = new AbstractNameQuery(null, map,
+                Collections.EMPTY_SET);
+        for (int i = 0; i < kernels.size(); i++) {
+            Set beans = kernels.get(i).listGBeans(query);
+            for (Iterator it = beans.iterator(); it.hasNext();) {
+                AbstractName abstractName = (AbstractName) it.next();
+                Pattern pattern = new Pattern();
+                Artifact artifact = abstractName.getArtifact();
+                pattern.setArtifactId(artifact.getArtifactId());
+                pattern.setGroupId(artifact.getGroupId());
+                pattern.setVersion(artifact.getVersion().toString());
+                pattern.setName((String) abstractName.getName().get("name"));
+                if (!result.contains(pattern)) {
+                    result.add(pattern);
+                }
+            }
+        }
+        return result;
+    }
+
+    protected void printNamingPatternList(List<Pattern> patternList) {
+        for (int i = 0; i < patternList.size(); i++) {
+            Pattern pattern = patternList.get(i);
+            System.out.println("ArtifactID:" + pattern.getArtifactId()
+                    + " GroupID:" + pattern.getGroupId() + " Module:"
+                    + pattern.getModule() + " Version:" + pattern.getVersion()
+                    + " Name:" + pattern.getName());
+        }
+    }
+
+    protected void printDeploymentPatternList(
+            List<org.apache.geronimo.jee.deployment.Pattern> patternList) {
+        for (int i = 0; i < patternList.size(); i++) {
+            org.apache.geronimo.jee.deployment.Pattern pattern = patternList
+                    .get(i);
+            System.out.println("ArtifactID:" + pattern.getArtifactId()
+                    + " GroupID:" + pattern.getGroupId() + " Module:"
+                    + pattern.getVersion() + " Version:" + pattern.getType()
+                    + " Name:" + pattern.getCustomFoo());
+        }
+    }
+
+    protected void printDependencies(List<Dependency> dependencyList) {
+        for (int i = 0; i < dependencyList.size(); i++) {
+            Dependency dependency = dependencyList.get(i);
+            System.out.println("ArtifactID:" + dependency.getArtifactId()
+                    + " GroupID:" + dependency.getGroupId() + " Type:"
+                    + dependency.getType() + " Version:"
+                    + dependency.getVersion());
+        }
+    }
+
+    public void printServerInfo() {
+        System.out.println("EJB Modules: \n");
+        List<Pattern> ejbModules = getDeployedEjbs();
+        printNamingPatternList(ejbModules);
+        System.out.println("\n\nSecurity Realms: \n");
+        List<String> securityRealms = getSecurityRealms();
+        System.out.println(securityRealms.toString());
+        System.out.println("\n\nJMS Connection Factories: \n");
+        List<Pattern> jmsConnectionFactories = getJmsConnectionFactories();
+        printNamingPatternList(jmsConnectionFactories);
+        System.out.println("\n\nJMS Destinations: \n");
+        List<Pattern> jmsDestinations = getJmsDestinations();
+        printNamingPatternList(jmsDestinations);
+        System.out.println("\n\nJDBC Connection Pools: \n");
+        List<Pattern> jdbcConnectionPools = getJdbcConnectionPools();
+        printNamingPatternList(jdbcConnectionPools);
+        System.out.println("\n\nJava Mail Resources: \n");
+        List<Pattern> javaMailResources = getJavaMailSessions();
+        printNamingPatternList(javaMailResources);
+        System.out.println("\n\nCredential Stores: \n");
+        List<org.apache.geronimo.jee.deployment.Pattern> credentialStores = getDeployedCredentialStores();
+        printDeploymentPatternList(credentialStores);
+        System.out.println("\n\nCommon Libs: \n");
+        List<Dependency> dependencies = getCommonLibs();
+        printDependencies(dependencies);
+    }
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/IGeronimoServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/IGeronimoServerInfo.java?rev=955877&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/IGeronimoServerInfo.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/IGeronimoServerInfo.java Fri Jun 18 08:10:13 2010
@@ -0,0 +1,52 @@
+/*
+ * 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.st.v21.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.naming.Pattern;
+
+/**
+ * @version $Rev: 952535 $ $Date: 2010-06-08 12:40:16 +0800 (Tue, 08 Jun 2010) $
+ */
+public interface IGeronimoServerInfo {
+    
+    public ArrayList<String> getSecurityRealms();
+
+    public ArrayList<Pattern> getJmsConnectionFactories() ;
+
+    public ArrayList<Pattern> getJmsDestinations();
+
+    public ArrayList<Pattern> getJdbcConnectionPools();
+    
+    public ArrayList<Pattern> getDeployedEjbs();
+
+    public ArrayList<Pattern> getJavaMailSessions();
+    
+    public ArrayList<Dependency> getCommonLibs();
+
+    public ArrayList<org.apache.geronimo.jee.deployment.Pattern> getDeployedCredentialStores() ;
+    
+    public HashMap<org.apache.geronimo.jee.deployment.Pattern,HashMap<String,ArrayList<String>>> getDeployedCredentialStoreAttributes();
+
+    public void updateInfo();
+
+    public void printServerInfo() ;
+    
+}



Mime
View raw message