Skip to content

Instantly share code, notes, and snippets.

@pierre
Created April 15, 2011 21:53
Show Gist options
  • Save pierre/922541 to your computer and use it in GitHub Desktop.
Save pierre/922541 to your computer and use it in GitHub Desktop.
public class SubscriberConfig {
@JsonValue
public String name;
@JsonValue
public String type;
@JsonMagicThisIsHowYouShouldResolveMyType
public Class getClassForJsonNode(HashMap<Object, Object> rawJson) {
return Class.forName(((String) rawJson).get("type") + "Config");
}
}
public class AMQSubscriberConfig extends SubscriberConfig {
@JsonValue
public String host;
}
public class FileSubscriberConfig extends SubscriberConfig {
@JsonValue
public String fileName;
}
{
"subscribers": [
{
"name": "AMQ"
"type": "com.ning.metrics.AMQSubscriber", // The actual class dealing with AMQ connection
"host": "127.0.0.1"
},
{
"name": "File"
"type": "com.ning.metrics.FileSubscriber", // The actual class dealing with File stuff
"fileName": "/tmp/bleh.dat"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment