Skip to content

Commit

Permalink
Merge pull request #13 from tvd12/master
Browse files Browse the repository at this point in the history
add AddCommand command
  • Loading branch information
tvd12 authored Jun 14, 2016
2 parents 4315c93 + 5a26ade commit 4ebaf5d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ We must spend a lot of time to declare, init variables. Some time we also have t
<dependency>
<groupId>com.tvd12</groupId>
<artifactId>ezyfox-core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
```

Expand Down
23 changes: 11 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.tvd12</groupId>
<artifactId>ezyfox-core</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.0.4-SNAPSHOT</version>
<packaging>jar</packaging>

<name>ezyfox-core</name>
Expand All @@ -34,7 +34,7 @@
<reflections.version>0.9.10</reflections.version>
<logback.version>1.1.7</logback.version>
<groovy.version>2.4.6</groovy.version>
<mockito.version>1.9.5</mockito.version>
<slf4j.version>1.7.21</slf4j.version>
</properties>

<licenses>
Expand Down Expand Up @@ -102,16 +102,21 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -133,12 +138,6 @@
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tvd12</groupId>
<artifactId>test-util</artifactId>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/tvd12/ezyfox/core/command/AddCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
*
*/
package com.tvd12.ezyfox.core.command;

import com.tvd12.ezyfox.core.content.AppContext;

/**
* Execute this command to add a command class to the application context
*
* @author tavandung12
*
*/
public interface AddCommand {

/**
* Add the command class to the application context
*
* @param baseClass the interface or abstract class
* @param implementation the implementation class
* @return the AppContext pointer for chaining
*/
AppContext add(Class<?> baseClass, Class<?> implementation);

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import org.apache.commons.lang3.reflect.MethodUtils;
import org.reflections.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tvd12.ezyfox.core.exception.ExtensionException;

Expand All @@ -24,6 +26,9 @@
*/

public final class ReflectMethodUtil {

private static final Logger LOGGER
= LoggerFactory.getLogger(ReflectMethodUtil.class);

// prevent new instance
private ReflectMethodUtil() {}
Expand Down Expand Up @@ -130,6 +135,7 @@ public static void invokeHandleMethod(Method method, Object obj, Object... args)
invokeMethod(method, obj, args);
} catch (ExtensionException e) {
e.printStackTrace();
LOGGER.error("Invoke handle method error", e);
throw new RuntimeException("Can not invoke handle method "
+ method.getName()
+ " on class " + method.getDeclaringClass(), e);
Expand All @@ -148,6 +154,7 @@ public static void invokeExecuteMethod(Method method, Object obj, Object... args
invokeMethod(method, obj, args);
} catch (ExtensionException e) {
e.printStackTrace();
LOGGER.error("Invoke execute method error", e);
throw new RuntimeException("Can not invoke execute method "
+ method.getName()
+ " on class " + method.getDeclaringClass(), e);
Expand Down

0 comments on commit 4ebaf5d

Please sign in to comment.