All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.config.BindingFactoryBean Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed 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
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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 io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.config;

import java.util.Map;

import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.AmqpAdmin;
import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.Binding;
import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.Binding.DestinationType;
import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.Exchange;
import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.Queue;
import io.bitsensor.plugins.shaded.org.springframework.beans.factory.FactoryBean;

/**
 * @author Dave Syer
 * @author Gary Russell
 *
 */
public class BindingFactoryBean implements FactoryBean {

	private Map arguments;

	private String routingKey = "";

	private String exchange;

	private Queue destinationQueue;

	private Exchange destinationExchange;

	private Boolean shouldDeclare;

	private Boolean ignoreDeclarationExceptions;

	private AmqpAdmin[] adminsThatShouldDeclare;

	public void setArguments(Map arguments) {
		this.arguments = arguments;
	}

	public void setRoutingKey(String routingKey) {
		this.routingKey = routingKey;
	}

	public void setExchange(String exchange) {
		this.exchange = exchange;
	}

	public void setDestinationQueue(Queue destinationQueue) {
		this.destinationQueue = destinationQueue;
	}

	public void setDestinationExchange(Exchange destinationExchange) {
		this.destinationExchange = destinationExchange;
	}

	public void setShouldDeclare(boolean shouldDeclare) {
		this.shouldDeclare = shouldDeclare;
	}

	public void setIgnoreDeclarationExceptions(Boolean ignoreDeclarationExceptions) {
		this.ignoreDeclarationExceptions = ignoreDeclarationExceptions;
	}

	public void setAdminsThatShouldDeclare(AmqpAdmin... adminsThatShouldDeclare) {
		this.adminsThatShouldDeclare = adminsThatShouldDeclare;
	}

	public Binding getObject() throws Exception {
		String destination;
		DestinationType destinationType;
		if (this.destinationQueue != null) {
			destination = this.destinationQueue.getName();
			destinationType = DestinationType.QUEUE;
		}
		else {
			destination = this.destinationExchange.getName();
			destinationType = DestinationType.EXCHANGE;
		}
		Binding binding = new Binding(destination, destinationType, this.exchange, this.routingKey, this.arguments);
		if (this.shouldDeclare != null) {
			binding.setShouldDeclare(this.shouldDeclare);
		}
		if (this.ignoreDeclarationExceptions != null) {
			binding.setIgnoreDeclarationExceptions(this.ignoreDeclarationExceptions);
		}
		if (this.adminsThatShouldDeclare != null) {
			binding.setAdminsThatShouldDeclare((Object[]) this.adminsThatShouldDeclare);
		}
		return binding;
	}

	public Class getObjectType() {
		return Binding.class;
	}

	public boolean isSingleton() {
		return true;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy