public final class JesqueUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
createBacktrace(Throwable t)
Creates a Resque backtrace from a Throwable's stack trace.
|
static String |
createKey(String namespace,
Iterable<String> parts)
Builds a namespaced Redis key with the given arguments.
|
static String |
createKey(String namespace,
String... parts)
Builds a namespaced Redis key with the given arguments.
|
static <K,V> Map.Entry<K,V> |
entry(K key,
V value)
Creates a Map.Entry out of the given key and value.
|
static String |
join(String sep,
Iterable<String> strs)
Join the given strings, separated by the given separator.
|
static String |
join(String sep,
String... strs)
Join the given strings, separated by the given separator.
|
static <K,V> Map<K,V> |
map(Map.Entry<? extends K,? extends V>... entries)
A convenient way of creating a map on the fly.
|
static Object |
materializeJob(Job job)
Materializes a job by assuming the
Job.getClassName() is a fully-qualified Java type. |
static Object |
materializeJob(Job job,
Map<String,Class<?>> jobTypes)
Materializes a job by looking up
Job.getClassName() in the provided map of job types. |
static Throwable |
recreateThrowable(String type,
String message,
List<String> backtrace)
Recreate an exception from a type name, a message and a backtrace
(created from
JesqueUtils.createBacktrace(Throwable)). |
static <K> Set<K> |
set(K... keys)
Creates a Set out of the given keys
|
public static String join(String sep, String... strs)
sep - the separatorstrs - the strings to joinpublic static String join(String sep, Iterable<String> strs)
sep - the separatorstrs - the strings to joinpublic static String createKey(String namespace, String... parts)
namespace - the namespace to useparts - the key parts to be joinedpublic static String createKey(String namespace, Iterable<String> parts)
namespace - the namespace to useparts - the key parts to be joinedpublic static List<String> createBacktrace(Throwable t)
t - the Exception to usepublic static Throwable recreateThrowable(String type, String message, List<String> backtrace) throws ParseException, ClassNotFoundException, NoSuchConstructorException, AmbiguousConstructorException, InstantiationException, IllegalAccessException, InvocationTargetException
JesqueUtils.createBacktrace(Throwable)).
Limitations:type - the String name of the Throwable typemessage - the message of the exceptionbacktrace - the backtrace of the exceptionParseException - if there is a problem parsing the given backtraceClassNotFoundException - if the given type is not availableNoSuchConstructorException - if there is not a common constructor available for the given typeAmbiguousConstructorException - if there is more than one constructor that is viableInstantiationException - if there is a problem instantiating the given typeIllegalAccessException - if the common constructor is not visibleInvocationTargetException - if the constructor threw an exceptioncreateBacktrace(Throwable)public static <K,V> Map<K,V> map(Map.Entry<? extends K,? extends V>... entries)
entries - Map.Entry objects to be added to the mappublic static <K,V> Map.Entry<K,V> entry(K key, V value)
key - the keyvalue - the valuepublic static <K> Set<K> set(K... keys)
keys - the keyspublic static Object materializeJob(Job job) throws ClassNotFoundException, Exception
Job.getClassName() is a fully-qualified Java type.job - the job to materializeClassNotFoundException - if the class could not be foundException - if there was an exception creating the objectpublic static Object materializeJob(Job job, Map<String,Class<?>> jobTypes) throws UnpermittedJobException, Exception
Job.getClassName() in the provided map of job types.job - the job to materializejobTypes - a map of String names to Java typesUnpermittedJobException - if there was not a non-null mapping in jobTypes for the class nameException - if there was an exception creating the objectCopyright © 2011-2013. All Rights Reserved.