mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Isolate customizable code in activity reporting
Modularize the code for DNS count reporting to allow it to be customized for more flexible systems. Tested: Uploaded to alpha with hacks to allow admin initiating and logging from the DnsCountQueryCoordinatorModule, verified that the provider function is invoked and that the action runs successfully. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=225225587
This commit is contained in:
parent
6966151bed
commit
c396957d15
13 changed files with 208 additions and 12 deletions
|
@ -56,6 +56,22 @@ public class TypeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a class with the specified constructor argument.
|
||||
*
|
||||
* <p>Because we use arg1's type to lookup the constructor, this only works if arg1's class is
|
||||
* exactly the same type as the constructor argument. Subtypes are not allowed.
|
||||
*/
|
||||
public static <T, U> T instantiate(Class<? extends T> clazz, U arg1) {
|
||||
checkArgument(Modifier.isPublic(clazz.getModifiers()),
|
||||
"AppEngine's custom security manager won't let us reflectively access non-public types");
|
||||
try {
|
||||
return clazz.getConstructor(arg1.getClass()).newInstance(arg1);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class referred to by a fully qualified class name string.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue