Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.apache.activemq.transport.amqp;
Used to assign the best implementation of a AmqpProtocolConverter to the AmqpTransport based on the AmqpHeader that the client sends us.
 public class AMQPProtocolDiscriminator implements IAmqpProtocolConverter {
     final private AmqpTransport transport;
     interface Discriminator {
         boolean matches(AmqpHeader header);
         IAmqpProtocolConverter create(AmqpTransport transport);
     static final private ArrayList<DiscriminatorDISCRIMINATORS = new ArrayList<Discriminator>();
     static {
         .add(new Discriminator() {
             public IAmqpProtocolConverter create(AmqpTransport transport) {
                 return new AmqpProtocolConverter(transport);
             public boolean matches(AmqpHeader header) {
                 switch (header.getProtocolId()) {
                     case 0:
                     case 3:
                         if (header.getMajor() == 1 && header.getMinor() == 0 && header.getRevision() == 0) {
                             return true;
                 return false;
     final private ArrayList<CommandpendingCommands = new ArrayList<Command>();
     public AMQPProtocolDiscriminator(AmqpTransport transport) {
         this. = transport;
     public void onAMQPData(Object commandthrows Exception {
         if (command.getClass() == AmqpHeader.class) {
             AmqpHeader header = (AmqpHeadercommand;
             Discriminator match = null;
             for (Discriminator discriminator : ) {
                 if (discriminator.matches(header)) {
                     match = discriminator;
             // Lets use first in the list if none are a good match.
             if (match == null) {
                 match = .get(0);
             IAmqpProtocolConverter next = match.create();
             for (Command send : ) {
         } else {
             throw new IllegalStateException();
     public void onAMQPException(IOException error) {
    public void onActiveMQCommand(Command commandthrows Exception {
    public void updateTracer() {
New to GrepCode? Check out our FAQ X