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 boolean |
equal(Throwable ex1,
Throwable ex2)
This is needed because Throwable doesn't override equals() and object
equality is not what we want to test.
|
protected static Throwable |
instantiateThrowable(String type,
String message,
Throwable cause,
StackTraceElement[] stes) |
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 boolean |
nullSafeEquals(Object obj1,
Object obj2)
Test for equality.
|
protected static StackTraceElement[] |
recreateStackTrace(List<String> bTrace) |
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, ReflectiveOperationException
JesqueUtils.createBacktrace(Throwable)).
Limitations:
This method cannot recreate Throwables with unusual/custom Constructors.
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 exceptionReflectiveOperationExceptioncreateBacktrace(Throwable)protected static Throwable instantiateThrowable(String type, String message, Throwable cause, StackTraceElement[] stes) throws ClassNotFoundException, AmbiguousConstructorException, ReflectiveOperationException, NoSuchConstructorException
protected static StackTraceElement[] recreateStackTrace(List<String> bTrace) throws ParseException
ParseException@SafeVarargs public static <K,V> Map<K,V> map(Map.Entry<? extends K,? extends V>... entries)
K - the key typeV - the value typeentries - Map.Entry objects to be added to the mappublic static <K,V> Map.Entry<K,V> entry(K key, V value)
K - the key typeV - the value typekey - the keyvalue - the value@SafeVarargs public static <K> Set<K> set(K... keys)
K - the key typekeys - the keyspublic static boolean nullSafeEquals(Object obj1, Object obj2)
obj1 - the first objectobj2 - the second objectpublic 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-2015. All Rights Reserved.