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

info.kwarc.sally4.activemq.impl.ActiveMQServiceImpl Maven / Gradle / Ivy

The newest version!
package info.kwarc.sally4.activemq.impl;

import info.kwarc.sally4.activemq.ActiveMQService;

import java.util.Dictionary;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Property;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.Updated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(managedservice="sally.activemq")
@Provides
@Instantiate
public class ActiveMQServiceImpl implements ActiveMQService {
	Logger log;
	
	@Property(name="SallyUser")
	String SallyUser = "karaf";

	@Property(name="SallyPassword")
	String SallyPassword = "karaf";

	@Property(name="SallyHost")
	String SallyHost = "tcp://localhost:61616";

	public ActiveMQServiceImpl() {
		log = LoggerFactory.getLogger(getClass());
	}
	
	public ActiveMQServiceImpl(String host, String user, String password) {
		this.SallyHost = host;
		this.SallyUser = user;
		this.SallyPassword = password;
	}
	
	@Updated
	public void updated(Dictionary conf) {
		SallyHost = conf.get("SallyHost");
		SallyUser = conf.get("SallyUser");
		SallyPassword = conf.get("SallyPassword");
	}

	@Override
	public org.apache.camel.Component getDefaultActiveMQConnection() {
		return createActiveMQConnection(SallyHost, SallyUser, SallyPassword);
	}

	@Override
	public org.apache.camel.Component createActiveMQConnection(String broker,
			String user, String password) {
		ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker);
		connectionFactory.setUserName(user);
		connectionFactory.setPassword(password);		
		return JmsComponent.jmsComponent(connectionFactory);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy