com.atlassian.scheduler.core.util
Class ParameterMapSerializer

java.lang.Object
  extended by com.atlassian.scheduler.core.util.ParameterMapSerializer

public class ParameterMapSerializer
extends Object

Utility for serializing the parameters map to a byte[] and restoring it to its original form.

Since:
v1.0

Constructor Summary
ParameterMapSerializer()
           
 
Method Summary
static Map<String,Serializable> deserializeParameters(ClassLoader classLoader, byte[] parameters)
          Deserializes the parameters map from a byte array using the provided ClassLoader.
static byte[] serializeParameters(Map<String,Serializable> parameters)
          Serializes the parameters to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterMapSerializer

public ParameterMapSerializer()
Method Detail

serializeParameters

@Nullable
public static byte[] serializeParameters(@Nullable
                                                  Map<String,Serializable> parameters)
                                  throws SchedulerServiceException
Serializes the parameters to a byte array. It is highly recommended that SchedulerService implementations use this serialization to make it possible to AbstractJobDetailsFactory.buildJobDetails(JobId,Object,RunMode) reconstruct} the JobDetails even when the JobRunner for it has not been registered. Otherwise, it will be difficult to recover any information about the job at all.

Parameters:
parameters - the parameters map to serialize; may be null as shorthand for an empty map
Returns:
the serialized parameters map, or null if parameters was either null or empty
Throws:
SchedulerServiceException - if the parameters map cannot be serialized, presumably because it contains an object that cannot be serialized

deserializeParameters

@Nonnull
public static Map<String,Serializable> deserializeParameters(@Nonnull
                                                                     ClassLoader classLoader,
                                                                     @Nullable
                                                                     byte[] parameters)
                                                      throws ClassNotFoundException,
                                                             IOException
Deserializes the parameters map from a byte array using the provided ClassLoader.

Parameters:
classLoader - the class loader to use for resolving classes
parameters - the parameters to be deserialized; may be null, which results in an empty map
Returns:
the deserialized parameters
Throws:
ClassNotFoundException - if ClassLoaderAwareObjectInputStream does
IOException - if ClassLoaderAwareObjectInputStream does


Copyright © 2014 Atlassian. All Rights Reserved.