You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jo...@apache.org on 2012/02/27 05:37:42 UTC
svn commit: r1294026 - in
/geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins:
org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/
org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/
org.apache.ge...
Author: johnxiao
Date: Mon Feb 27 04:37:41 2012
New Revision: 1294026
URL: http://svn.apache.org/viewvc?rev=1294026&view=rev
Log:
GERONIMODEVTOOLS-749 Open the Geronimo plan, an error occurs when the server is started
Added:
geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java (with props)
Modified:
geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java
geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v22.core/src/main/java/org/apache/geronimo/st/v22/core/GeronimoV22ServerInfo.java
geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
Added: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java?rev=1294026&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java Mon Feb 27 04:37:41 2012
@@ -0,0 +1,125 @@
+/**
+ * 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.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.st.core.internal.Trace;
+
+/**
+ * Create the JMX connector according to the server type, if the connector is already existed, will return the existing one immediately.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GeronimoJMXConnectorFactory {
+ private static final String JMX_REMOTE_CREDENTIALS_KEY = "jmx.remote.credentials";
+
+ private static final String JAVA_NAMING_FACTORY_INITIAL_KEY = "java.naming.factory.initial";
+ private static final String JAVA_NAMING_FACTORY_INITIAL_VALUE = "com.sun.jndi.rmi.registry.RegistryContextFactory";
+
+ private static final String JAVA_NAMING_FACTORY_URL_PKGS_KEY = "java.naming.factory.url.pkgs";
+ private static final String JAVA_NAMING_FACTORY_URL_PKGS_VALUE = "org.apache.geronimo.naming";
+
+ private static final String JAVA_NAMING_PROVIDER_URL_KEY = "java.naming.provider.url";
+
+ private static final String JMX_REMOTE_DEFAULT_CLASS_LOADER_KEY = "jmx.remote.default.class.loader";
+
+ public GeronimoJMXConnectorFactory() {
+ };
+
+ /**
+ *
+ * @param connectorInfo
+ * @param classloader
+ * @return
+ * @throws Exception
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static JMXConnector create(JMXConnectorInfo connectorInfo, ClassLoader classloader) throws Exception {
+ Trace.trace(Trace.INFO, "Start to get the MBeanServer connector", Activator.traceCore);
+ if(connectorInfo == null) throw new IllegalArgumentException("The connector info could not be null");
+
+ JMXConnector jmxConnector = null;
+ Map env = new HashMap();
+
+ env.put(JMX_REMOTE_CREDENTIALS_KEY, new String[] {connectorInfo.userName, connectorInfo.password});
+ env.put(JAVA_NAMING_FACTORY_INITIAL_KEY, JAVA_NAMING_FACTORY_INITIAL_VALUE);
+ env.put(JAVA_NAMING_FACTORY_URL_PKGS_KEY, JAVA_NAMING_FACTORY_URL_PKGS_VALUE);
+ env.put(JAVA_NAMING_PROVIDER_URL_KEY, "rmi://" + connectorInfo.host + ":" + connectorInfo.port);
+ env.put(JMX_REMOTE_DEFAULT_CLASS_LOADER_KEY, classloader);
+
+ String url = getJMXServiceURL(connectorInfo.host, connectorInfo.port);
+
+ JMXServiceURL address = new JMXServiceURL(url);
+ try {
+ jmxConnector = JMXConnectorFactory.connect(address, env);
+ } catch (SecurityException se) {
+ //FIXME once GERONIMO-3467 JIRA is fixed
+ Thread.sleep(10000);
+ jmxConnector = JMXConnectorFactory.connect(address, env);
+ }
+
+ Trace.trace(Trace.INFO, "Get the MBeanServer connector successfully", Activator.traceCore);
+ return jmxConnector;
+
+
+ }
+
+ public static class JMXConnectorInfo {
+ private final String userName;
+ private final String password;
+ private final String host;
+ private final String port;
+
+ public JMXConnectorInfo(String userName, String password, String host, String port) {
+ super();
+ this.userName = userName;
+ this.password = password;
+ this.host = host;
+ this.port = port;
+ }
+
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ }
+ protected static String getJMXServiceURL(String host, String port) {
+ return "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + port + "/JMXConnector";
+ }
+
+
+
+}
Propchange: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoJMXConnectorFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java?rev=1294026&r1=1294025&r2=1294026&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java Mon Feb 27 04:37:41 2012
@@ -40,6 +40,7 @@ import javax.management.remote.JMXConnec
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+import org.apache.geronimo.st.core.GeronimoJMXConnectorFactory.JMXConnectorInfo;
import org.apache.geronimo.st.core.commands.DeploymentCmdStatus;
import org.apache.geronimo.st.core.commands.DeploymentCommandFactory;
import org.apache.geronimo.st.core.commands.IDeploymentCommand;
@@ -924,37 +925,16 @@ abstract public class GeronimoServerBeha
}
public MBeanServerConnection getServerConnection() throws Exception {
- Map map = new HashMap();
+ String host = getServer().getHost();
String user = getGeronimoServer().getAdminID();
String password = getGeronimoServer().getAdminPassword();
String port = getGeronimoServer().getRMINamingPort();
- map.put("jmx.remote.credentials", new String[] { user, password });
- map.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
- map.put("java.naming.factory.url.pkgs", "org.apache.geronimo.naming");
- map.put("java.naming.provider.url", "rmi://" + getServer().getHost()
- + ":" + port);
-
- String url = getGeronimoServer().getJMXServiceURL();
- if (url != null) {
- try {
- JMXServiceURL address = new JMXServiceURL(url);
- JMXConnector jmxConnector;
- try {
- jmxConnector = JMXConnectorFactory.connect(address, map);
- } catch (SecurityException se) {
- //FIXME once GERONIMO-3467 JIRA is fixed
- Thread.sleep(10000);
- jmxConnector = JMXConnectorFactory.connect(address, map);
- }
- MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
- Trace.trace(Trace.INFO, "Connected to kernel. " + url, Activator.traceCore);
- return connection;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
+ JMXConnectorInfo connectorInfo = new JMXConnectorInfo(user, password, host, port);
+
+ // Using the classloader that loads the current's class as the default classloader when creating the JMXConnector
+ JMXConnector jmxConnector = GeronimoJMXConnectorFactory.create(connectorInfo, this.getClass().getClassLoader());
- return null;
+ return jmxConnector.getMBeanServerConnection();
}
public Target[] getTargets() {
Modified: geronimo/devtools/eclipse-plugin/branches/3.0-beta-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/3.0-beta-1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java?rev=1294026&r1=1294025&r2=1294026&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21ServerInfo.java Mon Feb 27 04:37:41 2012
@@ -67,10 +67,6 @@ public class GeronimoV21ServerInfo imple
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() {
@@ -175,12 +171,17 @@ public class GeronimoV21ServerInfo imple
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);
- }
+ try {
+ 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);
+ }
+ }
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
}
@@ -224,44 +225,48 @@ public class GeronimoV21ServerInfo imple
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);
+ try {
+ 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);
+ }
}
-
- //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();
}
- } catch (GBeanNotFoundException e) {
- } catch (Exception e) {
- e.printStackTrace();
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
}
@@ -275,27 +280,32 @@ public class GeronimoV21ServerInfo imple
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());
+ try {
+ 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(), Activator.logCore);
+ } catch (NoSuchOperationException e) {
+ Trace.trace(Trace.WARNING, "The operation cant invoked. "
+ + e.getMessage(), Activator.logCore);
+ } catch (InternalKernelException e) {
+ throw e;
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Kernel connection failed. "
+ + e.getMessage(), Activator.logCore);
}
- } catch (GBeanNotFoundException e) {
- Trace.trace(Trace.WARNING, "GBean Not Found. "
- + e.getMessage(), Activator.logCore);
- } catch (NoSuchOperationException e) {
- Trace.trace(Trace.WARNING, "The operation cant invoked. "
- + e.getMessage(), Activator.logCore);
- } catch (InternalKernelException e) {
- throw e;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Kernel connection failed. "
- + e.getMessage(), Activator.logCore);
+
}
-
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
if (artifacts != null) {
@@ -323,62 +333,67 @@ public class GeronimoV21ServerInfo imple
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);
+ try {
+ 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;
}
- 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);
+ 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;
}
- break;
}
}
}
+ } catch (GBeanNotFoundException e) {
+ } catch (NoSuchAttributeException e) {
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Kernel connection failed. "
+ + e.getMessage(), Activator.logCore);
}
- } catch (GBeanNotFoundException e) {
- } catch (NoSuchAttributeException e) {
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Kernel connection failed. "
- + e.getMessage(), Activator.logCore);
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
return result;
@@ -391,17 +406,22 @@ public class GeronimoV21ServerInfo imple
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);
+ try {
+ 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);
+ }
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
return result;
Modified: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v22.core/src/main/java/org/apache/geronimo/st/v22/core/GeronimoV22ServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v22.core/src/main/java/org/apache/geronimo/st/v22/core/GeronimoV22ServerInfo.java?rev=1294026&r1=1294025&r2=1294026&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v22.core/src/main/java/org/apache/geronimo/st/v22/core/GeronimoV22ServerInfo.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v22.core/src/main/java/org/apache/geronimo/st/v22/core/GeronimoV22ServerInfo.java Mon Feb 27 04:37:41 2012
@@ -175,13 +175,19 @@ public class GeronimoV22ServerInfo imple
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);
- }
+ try {
+ 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);
+ }
+ }
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
+
}
}
@@ -224,44 +230,48 @@ public class GeronimoV22ServerInfo imple
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);
+ try {
+ 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);
+ }
}
-
- //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();
}
- } catch (GBeanNotFoundException e) {
- } catch (Exception e) {
- e.printStackTrace();
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
}
@@ -275,27 +285,32 @@ public class GeronimoV22ServerInfo imple
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());
+ try {
+ 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(), Activator.logCore);
+ } catch (NoSuchOperationException e) {
+ Trace.trace(Trace.WARNING, "The operation cant invoked. "
+ + e.getMessage(), Activator.logCore);
+ } catch (InternalKernelException e) {
+ throw e;
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Kernel connection failed. "
+ + e.getMessage(), Activator.logCore);
}
- } catch (GBeanNotFoundException e) {
- Trace.trace(Trace.WARNING, "GBean Not Found. "
- + e.getMessage(), Activator.logCore);
- } catch (NoSuchOperationException e) {
- Trace.trace(Trace.WARNING, "The operation cant invoked. "
- + e.getMessage(), Activator.logCore);
- } catch (InternalKernelException e) {
- throw e;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Kernel connection failed. "
- + e.getMessage(), Activator.logCore);
+
}
-
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
if (artifacts != null) {
@@ -323,62 +338,67 @@ public class GeronimoV22ServerInfo imple
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);
+ try {
+ 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;
}
- 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);
+ 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;
}
- break;
}
}
}
+ } catch (GBeanNotFoundException e) {
+ } catch (NoSuchAttributeException e) {
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Kernel connection failed. "
+ + e.getMessage(), Activator.logCore);
}
- } catch (GBeanNotFoundException e) {
- } catch (NoSuchAttributeException e) {
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Kernel connection failed. "
- + e.getMessage(), Activator.logCore);
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
return result;
@@ -391,17 +411,22 @@ public class GeronimoV22ServerInfo imple
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);
+ try {
+ 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);
+ }
}
+ } catch(ClassCastException e) {
+ // Just ignore as could be 2.1's AbstractName even in 2.2
+ Trace.trace(Trace.INFO, "The class is not match: " + e.getMessage(), Activator.logCore);
}
}
return result;
Modified: geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1294026&r1=1294025&r2=1294026&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/3.0-beta-1/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java Mon Feb 27 04:37:41 2012
@@ -55,6 +55,8 @@ import org.apache.geronimo.kernel.config
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.st.core.GeronimoJMXConnectorFactory;
+import org.apache.geronimo.st.core.GeronimoJMXConnectorFactory.JMXConnectorInfo;
import org.apache.geronimo.st.v30.core.UpdateServerStateTask;
import org.apache.geronimo.st.v30.core.commands.DeploymentCommandFactory;
import org.apache.geronimo.st.v30.core.internal.DependencyHelper;
@@ -1277,9 +1279,9 @@ public class GeronimoServerBehaviourDele
public boolean isFullyStarted() {
if (isKernelAlive()) {
AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
- Set<AbstractName> configLists = kernel.listGBeans(query);
- if (!configLists.isEmpty()) {
- AbstractName on = (AbstractName) configLists.toArray()[0];
+ Set<AbstractName> configLists = kernel.listGBeans(query);configLists.toArray()[0].getClass().getClassLoader();
+ if (!configLists.isEmpty()) {kernel.getClass().getClassLoader();
+ AbstractName on = (AbstractName) configLists.toArray()[0];AbstractName.class.getClassLoader();
try {
Boolean b = (Boolean) kernel.getAttribute(on, "kernelFullyStarted");
return b.booleanValue();
@@ -1379,36 +1381,16 @@ public class GeronimoServerBehaviourDele
}
public MBeanServerConnection getServerConnection() throws Exception {
- Map<String, Object> map = new HashMap<String, Object>();
+ String host = getServer().getHost();
String user = getGeronimoServer().getAdminID();
String password = getGeronimoServer().getAdminPassword();
String port = getGeronimoServer().getRMINamingPort();
- map.put("jmx.remote.credentials", new String[] { user, password });
- map.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
- map.put("java.naming.factory.url.pkgs", "org.apache.geronimo.naming");
- map.put("java.naming.provider.url", "rmi://" + getServer().getHost()
- + ":" + port);
-
- String url = getGeronimoServer().getJMXServiceURL();
- if (url != null) {
- try {
- JMXServiceURL address = new JMXServiceURL(url);
- JMXConnector jmxConnector;
- try {
- jmxConnector = JMXConnectorFactory.connect(address, map);
- } catch (SecurityException se) {
- Thread.sleep(10000);
- jmxConnector = JMXConnectorFactory.connect(address, map);
- }
- MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
- Trace.trace(Trace.INFO, "Connected to kernel. " + url, Activator.traceCore);
- return connection;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
+ JMXConnectorInfo connectorInfo = new JMXConnectorInfo(user, password, host, port);
+
+ // Using the classloader that loads the current's class as the default classloader when creating the JMXConnector
+ JMXConnector jmxConnector = GeronimoJMXConnectorFactory.create(connectorInfo, this.getClass().getClassLoader());
- return null;
+ return jmxConnector.getMBeanServerConnection();
}
public ObjectName getMBean(MBeanServerConnection connection, String mbeanName, String name) throws Exception {