Example usage for java.io NotSerializableException setStackTrace

List of usage examples for java.io NotSerializableException setStackTrace

Introduction

In this page you can find the example usage for java.io NotSerializableException setStackTrace.

Prototype

public void setStackTrace(StackTraceElement[] stackTrace) 

Source Link

Document

Sets the stack trace elements that will be returned by #getStackTrace() and printed by #printStackTrace() and related methods.

Usage

From source file:org.eclipse.ecf.provider.internal.org.change.ChangeClientContainer.java

public void connect(ID targetID, IConnectContext connectContext1) throws ContainerConnectException {
    // Set the connectTargetID in the AbstractClientContainer super class
    super.connect(targetID, connectContext1);

    // Create callables prior to registering them via registerCallables
    // below//w w  w  .j  a  v a2s . com
    List<IRemoteCallable> petitionCallables = new ArrayList<IRemoteCallable>();
    // add callable for getPetitionId
    petitionCallables.add(new RemoteCallable.Builder("getPetitionId", "/v1/petitions/get_id")
            .setRequestType(new HttpGetRequestType()).build());
    // add callables for other IPetitionService methods

    // Register callables
    registration = registerCallables(IPetitionService.class,
            petitionCallables.toArray(new IRemoteCallable[petitionCallables.size()]), null);

    setResponseDeserializer(new IRemoteResponseDeserializer() {

        @Override
        public Object deserializeResponse(String endpoint, IRemoteCall call, IRemoteCallable callable,
                @SuppressWarnings("rawtypes") Map responseHeaders, byte[] responseBody)
                throws NotSerializableException {
            try {
                return new JSONObject(new String(responseBody)).getInt("petition_id");
            } catch (JSONException e) {
                NotSerializableException t = new NotSerializableException(
                        "response from endpoint=" + endpoint + " could not be parsed");
                t.setStackTrace(e.getStackTrace());
                throw t;
            }
        }
    });
}