I have created the following FutureTask method to run a method asynchronously.
public FutureTask<Object> SendAggregateEventAsync(final
com.Company.Product.SDK.Device.AggregateEvent.ClassObject
request)
{
FutureTask<Object> futureTask;
futureTask = new FutureTask<Object>(new Runnable() {
public void run()
{
try {
SendAggregateEvent(request);
} catch (ResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, null);
return futureTask;
}
public void SendAggregateEvent(
com.Company.Product.SDK.Device.AggregateEvent.ClassObject
request) throws ResponseException
{
try
{
if(request == null) throw new IllegalArgumentException("request");
String[] s_array = new String[0];
s_array[0] = "EventTime";
String namespace = "http://Product.Company.com/" +
"v1.0/Device/AggregateEvent";
IBindingFactory factory;
factory = BindingDirectory.getFactory(
com.Compant.Product.SDK.Device.AggregateEvent.
ClassObject.class);
String message = ChangeDatesToUTC(MessageHelper.
SerializeObject(factory, request), s_array, namespace);
SendMessage(message);
} catch (JiBXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
In order to compile I must catch the ResponseException in the FutureTask, but it is vital that this ResponseException be thrown to the implementing application and not caught by FutureTask. Is there a way around this where I can throw this exception out of FutureTask?