Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:imdario/murdock
Browse files Browse the repository at this point in the history
Conflicts:
	src/main/java/hm/murdock/cli/Router.java
	src/main/java/hm/murdock/modules/HelloHook.java
	src/main/java/hm/murdock/modules/action/Action.java
	src/main/java/hm/murdock/modules/action/ActionHook.java
  • Loading branch information
darccio committed Jul 17, 2010
2 parents b525257 + d34dbc8 commit e4acd85
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
11 changes: 11 additions & 0 deletions src/main/java/hm/murdock/cli/Router.java
Expand Up @@ -103,6 +103,16 @@ private void registerModules(Reflections reflections,
Set<Class<? extends Module>> modules = reflections
.getSubTypesOf(Module.class);

/*
* Set<Method> notOverridableMethods = new HashSet<Method>();
* notOverridableMethods
* .addAll(Arrays.asList(Object.class.getMethods()));
*
* Map<String, Map<Hook, Method>> hooks = new HashMap<String, Map<Hook,
* Method>>(); this.actions = new HashMap<String, Map<String,
* Action>>();
*/

for (Class<? extends Module> module : modules) {
List<Action> moduleActions = new ArrayList<Action>();

Expand Down Expand Up @@ -133,6 +143,7 @@ private void registerModules(Reflections reflections,
"Ignoring action " + method.getName(), e);
}
} else {

trackHook(hooks, method, hookAnnotation);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hm/murdock/modules/action/Action.java
Expand Up @@ -3,8 +3,8 @@
import hm.murdock.Murdock;
import hm.murdock.exceptions.ActionException;
import hm.murdock.exceptions.ActionException.ActionExceptionType;
import hm.murdock.modules.Module;
import hm.murdock.modules.Addon;
import hm.murdock.modules.Module;
import hm.murdock.modules.annotations.Hook;
import hm.murdock.modules.annotations.Hook.HookType;
import hm.murdock.utils.Context;
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/hm/murdock/utils/Context.java
Expand Up @@ -127,17 +127,19 @@ public <T> T getProperty(ContextProperty<T> property) {
public <T, E> E setProperty(ContextProperty<T> property, E value)
throws ConfigurationException {
E oldValue = (E) this.configuration.put(property.toString(), value);
try {
this.configuration.storeToXML(new FileOutputStream(
configurationFile), null);
} catch (FileNotFoundException e) {
throw new ConfigurationException(
ConfigurationExceptionType.UNABLE_WRITE_CONFIG, e,
configurationFile.getAbsolutePath());
} catch (IOException e) {
throw new ConfigurationException(
ConfigurationExceptionType.UNABLE_WRITE_CONFIG, e,
configurationFile.getAbsolutePath());
if (!property.isFlash()) {
try {
this.configuration.storeToXML(new FileOutputStream(
configurationFile), null);
} catch (FileNotFoundException e) {
throw new ConfigurationException(
ConfigurationExceptionType.UNABLE_WRITE_CONFIG, e,
configurationFile.getAbsolutePath());
} catch (IOException e) {
throw new ConfigurationException(
ConfigurationExceptionType.UNABLE_WRITE_CONFIG, e,
configurationFile.getAbsolutePath());
}
}

return oldValue;
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/hm/murdock/utils/ContextProperty.java
@@ -1,5 +1,7 @@
package hm.murdock.utils;

import hm.murdock.cli.Router;

/**
* Enum-like class to handle all properties keys.
*
Expand All @@ -12,6 +14,9 @@
*/
public class ContextProperty<T> {

public static final ContextProperty<Router> ROUTER = new ContextProperty<Router>(
"router", true);

public static final ContextProperty<String> TEST = new ContextProperty<String>(
"test");

Expand All @@ -21,8 +26,30 @@ public class ContextProperty<T> {

private String fullId;

private final boolean isFlash;

private final boolean isPrivileged;

protected ContextProperty(String id) {
this(id, false);
}

protected ContextProperty(String id, boolean flash) {
this(id, flash, false);
}

protected ContextProperty(String id, boolean flash, boolean privileged) {
this.id = id;
this.isFlash = flash;
this.isPrivileged = privileged;
}

public final boolean isFlash() {
return this.isFlash;
}

public final boolean isPrivileged() {
return this.isPrivileged;
}

@Override
Expand Down

0 comments on commit e4acd85

Please sign in to comment.