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 org.apache.activemq.state.CommandVisitor; 020 021/** 022 * Represents a partial command; a large command that has been split up into 023 * pieces. 024 * 025 * @openwire:marshaller code="60" 026 * 027 */ 028public class PartialCommand implements Command { 029 030 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.PARTIAL_COMMAND; 031 032 private int commandId; 033 private byte[] data; 034 035 private transient Endpoint from; 036 private transient Endpoint to; 037 038 public PartialCommand() { 039 } 040 041 @Override 042 public byte getDataStructureType() { 043 return DATA_STRUCTURE_TYPE; 044 } 045 046 /** 047 * @openwire:property version=1 048 */ 049 @Override 050 public int getCommandId() { 051 return commandId; 052 } 053 054 @Override 055 public void setCommandId(int commandId) { 056 this.commandId = commandId; 057 } 058 059 /** 060 * The data for this part of the command 061 * 062 * @openwire:property version=1 mandatory=true 063 */ 064 public byte[] getData() { 065 return data; 066 } 067 068 public void setData(byte[] data) { 069 this.data = data; 070 } 071 072 @Override 073 public Endpoint getFrom() { 074 return from; 075 } 076 077 @Override 078 public void setFrom(Endpoint from) { 079 this.from = from; 080 } 081 082 @Override 083 public Endpoint getTo() { 084 return to; 085 } 086 087 @Override 088 public void setTo(Endpoint to) { 089 this.to = to; 090 } 091 092 @Override 093 public Response visit(CommandVisitor visitor) throws Exception { 094 throw new IllegalStateException("The transport layer should filter out PartialCommand instances but received: " + this); 095 } 096 097 @Override 098 public boolean isResponseRequired() { 099 return false; 100 } 101 102 @Override 103 public boolean isResponse() { 104 return false; 105 } 106 107 @Override 108 public boolean isBrokerInfo() { 109 return false; 110 } 111 112 @Override 113 public boolean isMessageDispatch() { 114 return false; 115 } 116 117 @Override 118 public boolean isMessage() { 119 return false; 120 } 121 122 @Override 123 public boolean isMessageAck() { 124 return false; 125 } 126 127 @Override 128 public boolean isMessageDispatchNotification() { 129 return false; 130 } 131 132 @Override 133 public boolean isShutdownInfo() { 134 return false; 135 } 136 137 @Override 138 public boolean isConnectionControl() { 139 return false; 140 } 141 142 @Override 143 public boolean isConsumerControl() { 144 return false; 145 } 146 147 @Override 148 public void setResponseRequired(boolean responseRequired) { 149 } 150 151 @Override 152 public boolean isWireFormatInfo() { 153 return false; 154 } 155 156 @Override 157 public boolean isMarshallAware() { 158 return false; 159 } 160 161 @Override 162 public String toString() { 163 int size = 0; 164 if (data != null) { 165 size = data.length; 166 } 167 168 return "PartialCommand[id: " + commandId + " data: " + size + " byte(s)]"; 169 } 170}