package org.cloudfoundry.runtime.service.messaging;

import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.cloudfoundry.runtime.env.RabbitServiceInfo;
import org.cloudfoundry.runtime.service.AbstractServiceCreator;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.SingleConnectionFactory;

/**
 * Simplified access to creating RabbitMQ service objects.
 * 
 * @author Ramnivas Laddad
 *
 */
public class RabbitServiceCreator 
	extends AbstractServiceCreator<ConnectionFactory, RabbitServiceInfo> {

	public RabbitServiceCreator(CloudEnvironment cloudEnvironment) {
		super(cloudEnvironment, RabbitServiceInfo.class);
	}
	
	public ConnectionFactory createService(RabbitServiceInfo serviceInfo) {
		SingleConnectionFactory connectionFactory 
		    = new SingleConnectionFactory(serviceInfo.getHost());
		connectionFactory.setVirtualHost(serviceInfo.getVirtualHost());
		connectionFactory.setUsername(serviceInfo.getUserName());
		connectionFactory.setPassword(serviceInfo.getPassword());
		connectionFactory.setPort(serviceInfo.getPort());
		return connectionFactory;
	}

}

@@ -269,16 +269,23 @@
 nection.
+Caching
 Connecti
@@ -345,22 +345,16 @@
 nection.
-Single
 Connecti
@@ -459,16 +459,37 @@
  Laddad%0A
+ * @author Dave Syer%0A
  *%0A */%0Ap
@@ -793,22 +793,23 @@
 fo) %7B%0A%09%09
-S
+Cach
 ing
-le
 Connecti
@@ -853,14 +853,15 @@
 new 
-S
+Cach
 ing
-le
 Conn

Use CachingConnectionFactory when creating Rabbit connections