geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [3/9] incubator-geode git commit: GEODE-584: Removes ReflectionUtils class
Date Sat, 28 Nov 2015 06:14:39 GMT
GEODE-584: Removes ReflectionUtils class

Replaces uses of .../cli/util/spring/ReflectionUtils to spring-core library.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/eba2219c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/eba2219c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/eba2219c

Branch: refs/heads/develop
Commit: eba2219c5f055c2533c848a16b71c245982133bc
Parents: e6e1466
Author: Anthony Baker <abaker@pivotal.io>
Authored: Fri Nov 20 13:21:41 2015 -0800
Committer: Anthony Baker <abaker@pivotal.io>
Committed: Fri Nov 20 13:21:41 2015 -0800

----------------------------------------------------------------------
 .../cli/multistep/CLIMultiStepHelper.java       |   6 +-
 .../cli/remote/RemoteExecutionStrategy.java     |   2 +-
 .../cli/shell/GfshExecutionStrategy.java        |   2 +-
 .../cli/util/spring/ReflectionUtils.java        | 132 -------------------
 4 files changed, 5 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eba2219c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/multistep/CLIMultiStepHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/multistep/CLIMultiStepHelper.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/multistep/CLIMultiStepHelper.java
index e04f444..f1a2ede 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/multistep/CLIMultiStepHelper.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/multistep/CLIMultiStepHelper.java
@@ -20,6 +20,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.springframework.shell.event.ParseResult;
+import org.springframework.util.ReflectionUtils;
+
 import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.management.cli.Result;
@@ -38,9 +41,6 @@ import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
 import com.gemstone.gemfire.management.internal.cli.result.ResultData;
 import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
 import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
-import com.gemstone.gemfire.management.internal.cli.util.spring.ReflectionUtils;
-
-import org.springframework.shell.event.ParseResult;
 
 /**
  * Utility class to abstract CompositeResultData for Multi-step commands

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eba2219c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/remote/RemoteExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/remote/RemoteExecutionStrategy.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/remote/RemoteExecutionStrategy.java
index 33c2f8b..375a387 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/remote/RemoteExecutionStrategy.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/remote/RemoteExecutionStrategy.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
 
 import org.springframework.shell.event.ParseResult;
 import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
 
 import com.gemstone.gemfire.distributed.DistributedLockService;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -35,7 +36,6 @@ import com.gemstone.gemfire.management.internal.cli.GfshParseResult;
 import com.gemstone.gemfire.management.internal.cli.LogWrapper;
 import com.gemstone.gemfire.management.internal.cli.result.FileResult;
 import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
-import com.gemstone.gemfire.management.internal.cli.util.spring.ReflectionUtils;
 
 /**
  * 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eba2219c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategy.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategy.java
index a51c763..f259ca1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -25,6 +25,7 @@ import org.springframework.shell.core.ExecutionStrategy;
 import org.springframework.shell.core.Shell;
 import org.springframework.shell.event.ParseResult;
 import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
 
 import com.gemstone.gemfire.internal.ClassPathLoader;
 import com.gemstone.gemfire.management.cli.CliMetaData;
@@ -41,7 +42,6 @@ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.multistep.MultiStepCommand;
 import com.gemstone.gemfire.management.internal.cli.result.FileResult;
 import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
-import com.gemstone.gemfire.management.internal.cli.util.spring.ReflectionUtils;
 
 /**
  * Defines the {@link ExecutionStrategy} for commands that are executed in

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eba2219c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ReflectionUtils.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ReflectionUtils.java
deleted file mode 100644
index 4fe0759..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ReflectionUtils.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.
- */
-/*
- * Copyright 2011-2012 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.management.internal.cli.util.spring;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Replaces org.springframework.shell.support.util.ReflectionUtils which
- * is now removed from SPring Shell & the same class is referred from Spring
- * Core. With this we can avoid GemFire member's runtime dependency on Spring
- * Core.
- */
-/*
- * Code selectively taken from the original org.springframework.shell.support.util.ReflectionUtils
- */
-public class ReflectionUtils {
-
-  /**
-   * Invoke the specified {@link Method} against the supplied target object
-   * with the supplied arguments. The target object can be <code>null</code>
-   * when invoking a static {@link Method}.
-   * <p>Thrown exceptions are handled via a call to {@link #handleReflectionException}.
-   * @param method the method to invoke
-   * @param target the target object to invoke the method on
-   * @param args the invocation arguments (may be <code>null</code>)
-   * @return the invocation result, if any
-   */
-  public static Object invokeMethod(final Method method, final Object target, final Object[]
args) {
-    try {
-      return method.invoke(target, args);
-    }
-    catch (Exception ex) {
-      handleReflectionException(ex);
-    }
-    throw new IllegalStateException("Should never get here");
-  }
-
-  /**
-   * Handle the given reflection exception. Should only be called if
-   * no checked exception is expected to be thrown by the target method.
-   * <p>Throws the underlying RuntimeException or Error in case of an
-   * InvocationTargetException with such a root cause. Throws an
-   * IllegalStateException with an appropriate message else.
-   * @param ex the reflection exception to handle
-   */
-  public static void handleReflectionException(final Exception ex) {
-    if (ex instanceof NoSuchMethodException) {
-      throw new IllegalStateException("Method not found: " + ex.getMessage());
-    }
-    if (ex instanceof IllegalAccessException) {
-      throw new IllegalStateException("Could not access method: " + ex.getMessage());
-    }
-    if (ex instanceof InvocationTargetException) {
-      handleInvocationTargetException((InvocationTargetException) ex);
-    }
-    if (ex instanceof RuntimeException) {
-      throw (RuntimeException) ex;
-    }
-    handleUnexpectedException(ex);
-  }
-
-  /**
-   * Handle the given invocation target exception. Should only be called if
-   * no checked exception is expected to be thrown by the target method.
-   * <p>Throws the underlying RuntimeException or Error in case of such
-   * a root cause. Throws an IllegalStateException else.
-   * @param ex the invocation target exception to handle
-   */
-  public static void handleInvocationTargetException(final InvocationTargetException ex)
{
-    rethrowRuntimeException(ex.getTargetException());
-  }
-
-  /**
-   * Rethrow the given {@link Throwable exception}, which is presumably the
-   * <em>target exception</em> of an {@link InvocationTargetException}.
-   * Should only be called if no checked exception is expected to be thrown by
-   * the target method.
-   * <p>Rethrows the underlying exception cast to an {@link RuntimeException}
-   * or {@link Error} if appropriate; otherwise, throws an
-   * {@link IllegalStateException}.
-   * @param ex the exception to rethrow
-   * @throws RuntimeException the rethrown exception
-   */
-  public static void rethrowRuntimeException(final Throwable ex) {
-    if (ex instanceof RuntimeException) {
-      throw (RuntimeException) ex;
-    }
-    if (ex instanceof Error) {
-      throw (Error) ex;
-    }
-    handleUnexpectedException(ex);
-  }
-
-  /**
-   * Throws an IllegalStateException with the given exception as root cause.
-   * @param ex the unexpected exception
-   */
-  private static void handleUnexpectedException(final Throwable ex) {
-    throw new IllegalStateException("Unexpected exception thrown", ex);
-  }
-
-}


Mime
View raw message