http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JServerSocketFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JServerSocketFactory.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JServerSocketFactory.java index 474f8dd..e799279 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JServerSocketFactory.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JServerSocketFactory.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.geode.admin.jmx.internal; @@ -32,129 +30,107 @@ import java.util.Properties; /** * Creates <code>ServerSockets</code> for JMX adaptors. * <p> - * The interface {@link mx4j.tools.adaptor.AdaptorServerSocketFactory} is - * implemented in order to support securing of {@link - * mx4j.tools.adaptor.http.HttpAdaptor}. + * The interface {@link mx4j.tools.adaptor.AdaptorServerSocketFactory} is implemented in order to + * support securing of {@link mx4j.tools.adaptor.http.HttpAdaptor}. * <p> - * The interface {@link java.rmi.server.RMIServerSocketFactory} is implemented - * to support the securing of {@link - * javax.management.remote.JMXConnectorServer}. See {@link - * javax.management.remote.rmi.RMIConnectorServer} for the actual subclass that - * is used for the JMX RMI adaptor. + * The interface {@link java.rmi.server.RMIServerSocketFactory} is implemented to support the + * securing of {@link javax.management.remote.JMXConnectorServer}. See + * {@link javax.management.remote.rmi.RMIConnectorServer} for the actual subclass that is used for + * the JMX RMI adaptor. * <p> * Complete info on JSSE, including debugging, can be found at * <a href="http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html"> * http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html</a> * - * @since GemFire 3.5 (old name was SSLAdaptorServerSocketFactory) + * @since GemFire 3.5 (old name was SSLAdaptorServerSocketFactory) */ -public class MX4JServerSocketFactory -implements mx4j.tools.adaptor.AdaptorServerSocketFactory, - java.rmi.server.RMIServerSocketFactory { +public class MX4JServerSocketFactory implements mx4j.tools.adaptor.AdaptorServerSocketFactory, + java.rmi.server.RMIServerSocketFactory { private static final Logger logger = LogService.getLogger(); - + private static final int DEFAULT_BACKLOG = 50; - + private final SocketCreator socketCreator; private String bindAddress = DistributedSystemConfig.DEFAULT_BIND_ADDRESS; private int backlog = DEFAULT_BACKLOG; - + /** * Constructs new instance of MX4JServerSocketFactory. * - * @param useSSL - * true if ssl is to be enabled - * @param needClientAuth - * true if client authentication is required - * @param protocols - * space-delimited list of ssl protocols to use - * @param ciphers - * space-delimited list of ssl ciphers to use - * @param gfsecurityProps - * vendor properties passed in through gfsecurity.properties + * @param useSSL true if ssl is to be enabled + * @param needClientAuth true if client authentication is required + * @param protocols space-delimited list of ssl protocols to use + * @param ciphers space-delimited list of ssl ciphers to use + * @param gfsecurityProps vendor properties passed in through gfsecurity.properties */ - public MX4JServerSocketFactory(boolean useSSL, - boolean needClientAuth, - String protocols, - String ciphers, - Properties gfsecurityProps) { + public MX4JServerSocketFactory(boolean useSSL, boolean needClientAuth, String protocols, + String ciphers, Properties gfsecurityProps) { if (protocols == null || protocols.length() == 0) { protocols = DistributionConfig.DEFAULT_SSL_PROTOCOLS; } if (ciphers == null || ciphers.length() == 0) { ciphers = DistributionConfig.DEFAULT_SSL_CIPHERS; } - this.socketCreator = SocketCreatorFactory.createNonDefaultInstance( - useSSL, needClientAuth, protocols, ciphers, gfsecurityProps); + this.socketCreator = SocketCreatorFactory.createNonDefaultInstance(useSSL, needClientAuth, + protocols, ciphers, gfsecurityProps); } /** * Constructs new instance of MX4JServerSocketFactory. * - * @param useSSL - * true if ssl is to be enabled - * @param needClientAuth - * true if client authentication is required - * @param protocols - * space-delimited list of ssl protocols to use - * @param ciphers - * space-delimited list of ssl ciphers to use - * @param bindAddress - * host or address to bind to (bind-address) - * @param backlog - * how many connections are queued - * @param gfsecurityProps - * vendor properties passed in through gfsecurity.properties + * @param useSSL true if ssl is to be enabled + * @param needClientAuth true if client authentication is required + * @param protocols space-delimited list of ssl protocols to use + * @param ciphers space-delimited list of ssl ciphers to use + * @param bindAddress host or address to bind to (bind-address) + * @param backlog how many connections are queued + * @param gfsecurityProps vendor properties passed in through gfsecurity.properties */ - public MX4JServerSocketFactory(boolean useSSL, - boolean needClientAuth, - String protocols, - String ciphers, - String bindAddress, // optional for RMI impl - int backlog, // optional for RMI impl - Properties gfsecurityProps) { + public MX4JServerSocketFactory(boolean useSSL, boolean needClientAuth, String protocols, + String ciphers, String bindAddress, // optional for RMI impl + int backlog, // optional for RMI impl + Properties gfsecurityProps) { this(useSSL, needClientAuth, protocols, ciphers, gfsecurityProps); this.bindAddress = bindAddress; this.backlog = backlog; } // ------------------------------------------------------------------------- - // mx4j.tools.adaptor.AdaptorServerSocketFactory impl... + // mx4j.tools.adaptor.AdaptorServerSocketFactory impl... // ------------------------------------------------------------------------- - - public ServerSocket createServerSocket(int port, - int backlog, - String bindAddress) throws IOException { - if ("".equals(bindAddress)) { - return socketCreator.createServerSocket( - port, backlog); - - } else { - return socketCreator.createServerSocket( - port, backlog, InetAddressUtil.toInetAddress(bindAddress)); - } + + public ServerSocket createServerSocket(int port, int backlog, String bindAddress) + throws IOException { + if ("".equals(bindAddress)) { + return socketCreator.createServerSocket(port, backlog); + + } else { + return socketCreator.createServerSocket(port, backlog, + InetAddressUtil.toInetAddress(bindAddress)); + } } - + // ------------------------------------------------------------------------- - // java.rmi.server.RMIServerSocketFactory impl... + // java.rmi.server.RMIServerSocketFactory impl... // ------------------------------------------------------------------------- - - public ServerSocket createServerSocket(int port) throws IOException { - ServerSocket sock = null; - if ("".equals(bindAddress)) { - sock = socketCreator.createServerSocket(port, this.backlog); - } else { - sock = socketCreator.createServerSocket( - port, this.backlog, InetAddressUtil.toInetAddress(this.bindAddress)); - } - - if (logger.isDebugEnabled()) { - logger.debug("MX4JServerSocketFactory RMIServerSocketFactory, INetAddress {}, LocalPort {}, LocalSocketAddress {}", + + public ServerSocket createServerSocket(int port) throws IOException { + ServerSocket sock = null; + if ("".equals(bindAddress)) { + sock = socketCreator.createServerSocket(port, this.backlog); + } else { + sock = socketCreator.createServerSocket(port, this.backlog, + InetAddressUtil.toInetAddress(this.bindAddress)); + } + + if (logger.isDebugEnabled()) { + logger.debug( + "MX4JServerSocketFactory RMIServerSocketFactory, INetAddress {}, LocalPort {}, LocalSocketAddress {}", sock.getInetAddress(), sock.getLocalPort(), sock.getLocalSocketAddress()); - } - return sock; - } - + } + return sock; + } + }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MailManager.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MailManager.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MailManager.java index 1786406..a86d082 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MailManager.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MailManager.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.geode.admin.jmx.internal; @@ -36,18 +34,17 @@ import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.logging.log4j.LocalizedMessage; /** - * Provides the ways to send emails to all the registered email id It also - * provides the way to add/remove email ids. Can be used to send email in case - * of any alerts raised / warning / failure in gemfire. + * Provides the ways to send emails to all the registered email id It also provides the way to + * add/remove email ids. Can be used to send email in case of any alerts raised / warning / failure + * in gemfire. * * @since GemFire 5.1 */ public class MailManager { private static final Logger logger = LogService.getLogger(); - - public MailManager() { - } + + public MailManager() {} public MailManager(Properties mailProperties) { setMailProperties(mailProperties); @@ -58,8 +55,7 @@ public class MailManager { FileInputStream fio = new FileInputStream(mailPropertiesFile); try { prop.load(fio); - } - finally { + } finally { fio.close(); } setMailProperties(prop); @@ -80,18 +76,18 @@ public class MailManager { /** * Send Emails to all the registered email id * - * @param emailData - * Instance of EmailData + * @param emailData Instance of EmailData */ - // Why a separate method & class EmailData needed??? + // Why a separate method & class EmailData needed??? private void processEmail(EmailData emailData) { if (logger.isTraceEnabled()) { logger.trace("Entered MailManager:processEmail"); } - if (mailHost == null || mailHost.length() == 0 - || emailData == null || mailToAddresses.length == 0) { - logger.error(LocalizedMessage.create(LocalizedStrings.MailManager_REQUIRED_MAILSERVER_CONFIGURATION_NOT_SPECIFIED)); + if (mailHost == null || mailHost.length() == 0 || emailData == null + || mailToAddresses.length == 0) { + logger.error(LocalizedMessage + .create(LocalizedStrings.MailManager_REQUIRED_MAILSERVER_CONFIGURATION_NOT_SPECIFIED)); if (logger.isDebugEnabled()) { logger.debug("Exited MailManager:processEmail: Not sending email as conditions not met"); } @@ -106,8 +102,7 @@ public class MailManager { try { for (int i = 0; i < mailToAddresses.length; i++) { - mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress( - mailToAddresses[i])); + mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(mailToAddresses[i])); } if (subject == null) { @@ -121,27 +116,33 @@ public class MailManager { mimeMessage.setText(message); Transport.send(mimeMessage); - logger.info(LocalizedMessage.create( - LocalizedStrings.MailManager_EMAIL_ALERT_HAS_BEEN_SENT_0_1_2, - new Object[] { mailToList, subject, message })); + logger.info( + LocalizedMessage.create(LocalizedStrings.MailManager_EMAIL_ALERT_HAS_BEEN_SENT_0_1_2, + new Object[] {mailToList, subject, message})); } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); - // If this ever returns, rethrow the error. We're poisoned + // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Throwable ex) { // Whenever you catch Error or Throwable, you must also - // catch VirtualMachineError (see above). However, there is + // catch VirtualMachineError (see above). However, there is // _still_ a possibility that you are dealing with a cascading // error condition, so you also need to check to see if the JVM // is still usable: SystemFailure.checkFailure(); StringBuilder buf = new StringBuilder(); - buf.append(LocalizedStrings.MailManager_AN_EXCEPTION_OCCURRED_WHILE_SENDING_EMAIL.toLocalizedString()); - buf.append(LocalizedStrings.MailManager_UNABLE_TO_SEND_EMAIL_PLEASE_CHECK_YOUR_EMAIL_SETTINGS_AND_LOG_FILE.toLocalizedString()); - buf.append("\n\n").append(LocalizedStrings.MailManager_EXCEPTION_MESSAGE_0.toLocalizedString(ex.getMessage())); - buf.append("\n\n").append(LocalizedStrings.MailManager_FOLLOWING_EMAIL_WAS_NOT_DELIVERED.toLocalizedString()); - buf.append("\n\t").append(LocalizedStrings.MailManager_MAIL_HOST_0.toLocalizedString(mailHost)); + buf.append(LocalizedStrings.MailManager_AN_EXCEPTION_OCCURRED_WHILE_SENDING_EMAIL + .toLocalizedString()); + buf.append( + LocalizedStrings.MailManager_UNABLE_TO_SEND_EMAIL_PLEASE_CHECK_YOUR_EMAIL_SETTINGS_AND_LOG_FILE + .toLocalizedString()); + buf.append("\n\n").append( + LocalizedStrings.MailManager_EXCEPTION_MESSAGE_0.toLocalizedString(ex.getMessage())); + buf.append("\n\n").append( + LocalizedStrings.MailManager_FOLLOWING_EMAIL_WAS_NOT_DELIVERED.toLocalizedString()); + buf.append("\n\t") + .append(LocalizedStrings.MailManager_MAIL_HOST_0.toLocalizedString(mailHost)); buf.append("\n\t").append(LocalizedStrings.MailManager_FROM_0.toLocalizedString(mailFrom)); buf.append("\n\t").append(LocalizedStrings.MailManager_TO_0.toLocalizedString(mailToList)); buf.append("\n\t").append(LocalizedStrings.MailManager_SUBJECT_0.toLocalizedString(subject)); @@ -157,8 +158,7 @@ public class MailManager { /** * Not yet implemented */ - public void close() { - } + public void close() {} /** * @return All the registered email id as string @@ -191,8 +191,7 @@ public class MailManager { /** * - * @param host - * mail host server name + * @param host mail host server name */ public void setMailHost(String host) { this.mailHost = host; @@ -208,8 +207,7 @@ public class MailManager { /** * - * @param fromAddress - * mailFrom email id + * @param fromAddress mailFrom email id */ public void setMailFromAddress(String fromAddress) { mailFrom = fromAddress; @@ -243,7 +241,7 @@ public class MailManager { * @return list all the registered email id */ public String[] getAllToAddresses() { - return (String[])mailToSet.toArray(new String[0]); + return (String[]) mailToSet.toArray(new String[0]); } /** @@ -285,8 +283,7 @@ public class MailManager { buffer.append(", "); } buffer.replace(buffer.length() - 2, buffer.length(), ""); - } - else { + } else { buffer.append(" Undefined"); } buffer.append("]"); @@ -324,8 +321,7 @@ public class MailManager { } public static void main(String args[]) { - MailManager mailManager = new MailManager("mailsrv1.gemstone.com", - "hkha...@gemstone.com"); + MailManager mailManager = new MailManager("mailsrv1.gemstone.com", "hkha...@gemstone.com"); mailManager.sendEmail("Alert!", "Test"); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResource.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResource.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResource.java index 2496013..5c2a81f 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResource.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResource.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.geode.admin.jmx.internal; @@ -20,25 +18,24 @@ import javax.management.ObjectName; import javax.management.modelmbean.ModelMBean; /** - * Represents a component or resource that is managed by a + * Represents a component or resource that is managed by a * {@link javax.management.modelmbean.ModelMBean}. * - * @since GemFire 3.5 + * @since GemFire 3.5 * */ public interface ManagedResource { - - /** - * The prefix of MBean names. Note: this is NOT used by Members, Stats, or - * any other MBean that has it's own domain. + + /** + * The prefix of MBean names. Note: this is NOT used by Members, Stats, or any other MBean that + * has it's own domain. * - * @see #getMBeanName + * @see #getMBeanName */ public static final String MBEAN_NAME_PREFIX = "GemFire:type="; - /** - * Returns the name of the ModelMBean that will manage this - * resource. They [some] are of the form + /** + * Returns the name of the ModelMBean that will manage this resource. They [some] are of the form * * <PRE> * MBEAN_NAME_PREFIX + typeName + ",id=" + id @@ -47,14 +44,14 @@ public interface ManagedResource { * @see #MBEAN_NAME_PREFIX */ public String getMBeanName(); - + /** Returns the ModelMBean that is configured to manage this resource */ public ModelMBean getModelMBean(); /** Sets the ModelMBean that is configured to manage this resource */ public void setModelMBean(ModelMBean modelMBean); - - /** + + /** * Returns the enumerated ManagedResourceType of this resource. * * @see ManagedResourceType @@ -67,11 +64,11 @@ public interface ManagedResource { * @see #getMBeanName */ public ObjectName getObjectName(); - + /** * Perform any cleanup necessary before stopping management of this resource. */ public void cleanupResource(); - + } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResourceType.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResourceType.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResourceType.java index cf9b792..3b5747f 100755 --- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResourceType.java +++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ManagedResourceType.java @@ -1,113 +1,109 @@ /* - * 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 + * 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 + * 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. + * 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.geode.admin.jmx.internal; import org.apache.commons.lang.StringUtils; /** - * Type-safe definition for ModelMBean managed resources. The class type - * ({@link #getClassTypeName}) must match the fully qualified class name listed - * in the type descriptor in mbeans-descriptors.xml. + * Type-safe definition for ModelMBean managed resources. The class type ({@link #getClassTypeName}) + * must match the fully qualified class name listed in the type descriptor in + * mbeans-descriptors.xml. * - * @since GemFire 3.5 + * @since GemFire 3.5 * */ public class ManagedResourceType implements java.io.Serializable { private static final long serialVersionUID = 3752874768667480449L; - + /** Agent managed resource type */ - public static final ManagedResourceType AGENT = + public static final ManagedResourceType AGENT = new ManagedResourceType("Agent", org.apache.geode.admin.jmx.Agent.class); /** DistributedSystem managed resource type */ - public static final ManagedResourceType DISTRIBUTED_SYSTEM = - new ManagedResourceType("AdminDistributedSystem", org.apache.geode.admin.AdminDistributedSystem.class); + public static final ManagedResourceType DISTRIBUTED_SYSTEM = new ManagedResourceType( + "AdminDistributedSystem", org.apache.geode.admin.AdminDistributedSystem.class); /** SystemMember managed resource type */ - public static final ManagedResourceType SYSTEM_MEMBER = + public static final ManagedResourceType SYSTEM_MEMBER = new ManagedResourceType("SystemMember", org.apache.geode.admin.SystemMember.class); /** SystemMemberCache managed resource type */ - public static final ManagedResourceType SYSTEM_MEMBER_CACHE = + public static final ManagedResourceType SYSTEM_MEMBER_CACHE = new ManagedResourceType("SystemMemberCache", org.apache.geode.admin.SystemMemberCache.class); /** SystemMemberCache managed resource type */ - public static final ManagedResourceType SYSTEM_MEMBER_REGION = - new ManagedResourceType("SystemMemberRegion", org.apache.geode.admin.SystemMemberRegion.class); + public static final ManagedResourceType SYSTEM_MEMBER_REGION = new ManagedResourceType( + "SystemMemberRegion", org.apache.geode.admin.SystemMemberRegion.class); /** SystemMemberCacheServer managed resource type */ - public static final ManagedResourceType SYSTEM_MEMBER_CACHE_SERVER = - new ManagedResourceType("SystemMemberCacheServer", org.apache.geode.admin.SystemMemberCacheServer.class); + public static final ManagedResourceType SYSTEM_MEMBER_CACHE_SERVER = new ManagedResourceType( + "SystemMemberCacheServer", org.apache.geode.admin.SystemMemberCacheServer.class); /** CacheVm managed resource type */ - public static final ManagedResourceType CACHE_VM = + public static final ManagedResourceType CACHE_VM = new ManagedResourceType("CacheVm", org.apache.geode.admin.CacheVm.class); /** StatisticResource managed resource type */ - public static final ManagedResourceType STATISTIC_RESOURCE = + public static final ManagedResourceType STATISTIC_RESOURCE = new ManagedResourceType("StatisticResource", org.apache.geode.admin.StatisticResource.class); - public static final ManagedResourceType GEMFIRE_HEALTH = + public static final ManagedResourceType GEMFIRE_HEALTH = new ManagedResourceType("GemFireHealth", org.apache.geode.admin.GemFireHealth.class); - public static final ManagedResourceType DISTRIBUTED_SYSTEM_HEALTH_CONFIG = - new ManagedResourceType("DistributedSystemHealthConfig", org.apache.geode.admin.DistributedSystemHealthConfig.class); + public static final ManagedResourceType DISTRIBUTED_SYSTEM_HEALTH_CONFIG = + new ManagedResourceType("DistributedSystemHealthConfig", + org.apache.geode.admin.DistributedSystemHealthConfig.class); - public static final ManagedResourceType GEMFIRE_HEALTH_CONFIG = - new ManagedResourceType("GemFireHealthConfig", org.apache.geode.admin.GemFireHealthConfig.class); + public static final ManagedResourceType GEMFIRE_HEALTH_CONFIG = new ManagedResourceType( + "GemFireHealthConfig", org.apache.geode.admin.GemFireHealthConfig.class); - public static final ManagedResourceType DISTRIBUTION_LOCATOR = - new ManagedResourceType("DistributionLocator", org.apache.geode.admin.DistributionLocator.class); + public static final ManagedResourceType DISTRIBUTION_LOCATOR = new ManagedResourceType( + "DistributionLocator", org.apache.geode.admin.DistributionLocator.class); - //////////////////// Instance Fields //////////////////// + //////////////////// Instance Fields //////////////////// /** The display-friendly name of this managed resource type. */ private final transient String name; - - /** - * The interface/class used to externally represent this type. Note: this must - * match the mbean type descriptor in mbeans-descriptors.xml. + + /** + * The interface/class used to externally represent this type. Note: this must match the mbean + * type descriptor in mbeans-descriptors.xml. */ private final transient Class clazz; - + // The 4 declarations below are necessary for serialization /** int used as ordinal to represent this Scope */ public final int ordinal = nextOrdinal++; private static int nextOrdinal = 0; - + private static final ManagedResourceType[] VALUES = - { AGENT, DISTRIBUTED_SYSTEM, SYSTEM_MEMBER, - SYSTEM_MEMBER_CACHE, SYSTEM_MEMBER_REGION, - SYSTEM_MEMBER_CACHE_SERVER, CACHE_VM, - STATISTIC_RESOURCE, GEMFIRE_HEALTH, DISTRIBUTED_SYSTEM_HEALTH_CONFIG, - GEMFIRE_HEALTH_CONFIG, DISTRIBUTION_LOCATOR - }; + {AGENT, DISTRIBUTED_SYSTEM, SYSTEM_MEMBER, SYSTEM_MEMBER_CACHE, SYSTEM_MEMBER_REGION, + SYSTEM_MEMBER_CACHE_SERVER, CACHE_VM, STATISTIC_RESOURCE, GEMFIRE_HEALTH, + DISTRIBUTED_SYSTEM_HEALTH_CONFIG, GEMFIRE_HEALTH_CONFIG, DISTRIBUTION_LOCATOR}; private Object readResolve() throws java.io.ObjectStreamException { - return VALUES[ordinal]; // Canonicalize + return VALUES[ordinal]; // Canonicalize } - + /** Creates a new instance of ManagedResourceType. */ private ManagedResourceType(String name, Class clazz) { this.name = name; this.clazz = clazz; } - + /** Returns the ManagedResourceType represented by specified ordinal */ public static ManagedResourceType fromOrdinal(int ordinal) { return VALUES[ordinal]; @@ -117,93 +113,92 @@ public class ManagedResourceType implements java.io.Serializable { public String getName() { return this.name; } - + /** Returns the interface/class used to externally represent this type */ public Class getClassType() { return this.clazz; } - - /** - * Returns the fully qualified name of the interface/class used to externally - * represent this type + + /** + * Returns the fully qualified name of the interface/class used to externally represent this type */ public String getClassTypeName() { return this.clazz.getName(); } - + /** Returns true if this is <code>AGENT</code>. */ public boolean isAgent() { return this.equals(AGENT); } - + /** Returns true if this is <code>DISTRIBUTED_SYSTEM</code>. */ public boolean isDistributedSystem() { return this.equals(DISTRIBUTED_SYSTEM); } - + /** Returns true if this is <code>SYSTEM_MEMBER</code>. */ public boolean isSystemMember() { return this.equals(SYSTEM_MEMBER); } - + /** Returns whether this is <code>STATISTIC_RESOURCE</code>. */ public boolean isStatisticResource() { return this.equals(STATISTIC_RESOURCE); } - + /** Return whether this is <code>GEMFIRE_HEALTH</code>. */ public boolean isGemFireHealth() { return this.equals(GEMFIRE_HEALTH); } - /** + /** * Returns a string representation for this type. */ @Override public String toString() { - return this.name; + return this.name; } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param other the reference object with which to compare. - * @return true if this object is the same as the obj argument; - * false otherwise. - */ + + /** + * Indicates whether some other object is "equal to" this one. + * + * @param other the reference object with which to compare. + * @return true if this object is the same as the obj argument; false otherwise. + */ @Override - public boolean equals(Object other) { - if (other == this) return true; - if (other == null) return false; - if (!(other instanceof ManagedResourceType)) return false; - final ManagedResourceType that = (ManagedResourceType) other; - - if (!StringUtils.equals(this.name, that.name)) return false; - if (this.clazz != that.clazz && - !(this.clazz != null && - this.clazz.equals(that.clazz))) return false; - - return true; - } - - /** - * Returns a hash code for the object. This method is supported for the - * benefit of hashtables such as those provided by java.util.Hashtable. - * - * @return the integer 0 if description is null; otherwise a unique integer. - */ + public boolean equals(Object other) { + if (other == this) + return true; + if (other == null) + return false; + if (!(other instanceof ManagedResourceType)) + return false; + final ManagedResourceType that = (ManagedResourceType) other; + + if (!StringUtils.equals(this.name, that.name)) + return false; + if (this.clazz != that.clazz && !(this.clazz != null && this.clazz.equals(that.clazz))) + return false; + + return true; + } + + /** + * Returns a hash code for the object. This method is supported for the benefit of hashtables such + * as those provided by java.util.Hashtable. + * + * @return the integer 0 if description is null; otherwise a unique integer. + */ @Override - public int hashCode() { - int result = 17; - final int mult = 37; + public int hashCode() { + int result = 17; + final int mult = 37; - result = mult * result + - (this.name == null ? 0 : this.name.hashCode()); - result = mult * result + - (this.clazz == null ? 0 : this.clazz.hashCode()); + result = mult * result + (this.name == null ? 0 : this.name.hashCode()); + result = mult * result + (this.clazz == null ? 0 : this.clazz.hashCode()); - return result; - } + return result; + } }