001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.command;
018
019import java.util.Map;
020
021import org.apache.activemq.util.IntrospectionSupport;
022
023/**
024 *
025 * @openwire:marshaller
026 *
027 */
028public abstract class BaseCommand implements Command {
029
030    protected int commandId;
031    protected boolean responseRequired;
032
033    private transient Endpoint from;
034    private transient Endpoint to;
035
036    public void copy(BaseCommand copy) {
037        copy.commandId = commandId;
038        copy.responseRequired = responseRequired;
039    }
040
041    /**
042     * @openwire:property version=1
043     */
044    @Override
045    public int getCommandId() {
046        return commandId;
047    }
048
049    @Override
050    public void setCommandId(int commandId) {
051        this.commandId = commandId;
052    }
053
054    /**
055     * @openwire:property version=1
056     */
057    @Override
058    public boolean isResponseRequired() {
059        return responseRequired;
060    }
061
062    @Override
063    public void setResponseRequired(boolean responseRequired) {
064        this.responseRequired = responseRequired;
065    }
066
067    @Override
068    public String toString() {
069        return toString(null);
070    }
071
072    public String toString(Map<String, Object> overrideFields) {
073        return IntrospectionSupport.toString(this, BaseCommand.class, overrideFields);
074    }
075
076    @Override
077    public boolean isWireFormatInfo() {
078        return false;
079    }
080
081    @Override
082    public boolean isBrokerInfo() {
083        return false;
084    }
085
086    @Override
087    public boolean isResponse() {
088        return false;
089    }
090
091    @Override
092    public boolean isMessageDispatch() {
093        return false;
094    }
095
096    @Override
097    public boolean isMessage() {
098        return false;
099    }
100
101    @Override
102    public boolean isMarshallAware() {
103        return false;
104    }
105
106    @Override
107    public boolean isMessageAck() {
108        return false;
109    }
110
111    @Override
112    public boolean isMessageDispatchNotification() {
113        return false;
114    }
115
116    @Override
117    public boolean isShutdownInfo() {
118        return false;
119    }
120
121    @Override
122    public boolean isConnectionControl() {
123        return false;
124    }
125
126    @Override
127    public boolean isConsumerControl() {
128        return false;
129    }
130
131    /**
132     * The endpoint within the transport where this message came from.
133     */
134    @Override
135    public Endpoint getFrom() {
136        return from;
137    }
138
139    @Override
140    public void setFrom(Endpoint from) {
141        this.from = from;
142    }
143
144    /**
145     * The endpoint within the transport where this message is going to - null
146     * means all endpoints.
147     */
148    @Override
149    public Endpoint getTo() {
150        return to;
151    }
152
153    @Override
154    public void setTo(Endpoint to) {
155        this.to = to;
156    }
157}