001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.ksb.api.messaging;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
020
021import java.io.Serializable;
022
023/**
024 * Encapsulates an asynchronous call to a service.
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public class AsynchronousCall implements Serializable {
029
030    private static final long serialVersionUID = -1036656564567726747L;
031
032    private Object[] arguments;
033
034    private Class<?>[] paramTypes;
035
036    private ServiceConfiguration serviceConfiguration;
037
038    private Serializable context;
039
040    private String methodName;
041
042    private AsynchronousCallback callback;
043
044    private boolean ignoreStoreAndForward;
045
046    public AsynchronousCall(Class<?>[] paramTypes, Object[] arguments, ServiceConfiguration serviceConfiguration, String methodName, AsynchronousCallback callback, Serializable context) {
047        this.arguments = arguments;
048        this.paramTypes = paramTypes;
049        this.serviceConfiguration = serviceConfiguration;
050        this.methodName = methodName;
051        this.callback = callback;
052        this.context = context;
053    }
054
055    public Object[] getArguments() {
056        return this.arguments;
057    }
058
059    public Class<?>[] getParamTypes() {
060        return this.paramTypes;
061    }
062
063    public ServiceConfiguration getServiceConfiguration() {
064        return this.serviceConfiguration;
065    }
066
067    public String getMethodName() {
068        return this.methodName;
069    }
070
071    public AsynchronousCallback getCallback() {
072        return this.callback;
073    }
074
075    public String toString() {
076        return "[AsynchronousCall: " + "serviceInfo=" + this.serviceConfiguration + ", methodName=" + this.methodName + ", paramTypes=" + getStringifiedArray(this.paramTypes) + ", arguments=" + getStringifiedArray(this.arguments) + "]";
077    }
078
079    /**
080     * Takes an Object[] and returns a human-readable String of the contents
081     * Candidate for relocation to a utility class
082     *
083     * @param array the Object[]
084     * @return a human-readable String of the contents
085     */
086    private static final String getStringifiedArray(Object[] array) {
087        if (array == null) {
088            return null;
089        }
090        StringBuffer sb = new StringBuffer(array.getClass().toString());
091        sb.append("[");
092        StringUtils.join(array, ", ");
093        sb.append("]");
094        return sb.toString();
095    }
096
097    public boolean isIgnoreStoreAndForward() {
098        return this.ignoreStoreAndForward;
099    }
100
101    public void setIgnoreStoreAndForward(boolean ignoreStoreAndForward) {
102        this.ignoreStoreAndForward = ignoreStoreAndForward;
103    }
104
105    public Serializable getContext() {
106        return this.context;
107    }
108
109    public void setContext(Serializable context) {
110        this.context = context;
111    }
112
113
114}