pull up URI scheme for RabbitMQ

This commit is contained in:
Christopher Smith
2014-07-09 19:25:57 -05:00
parent 5ce0b402bf
commit 5987c05c6e
3 changed files with 16 additions and 13 deletions

View File

@@ -5,20 +5,20 @@ import java.util.Map;
import org.springframework.cloud.service.common.AmqpServiceInfo;
/**
*
*
* @author Ramnivas Laddad
*
*/
public class AmqpServiceInfoCreator extends CloudFoundryServiceInfoCreator<AmqpServiceInfo> {
public AmqpServiceInfoCreator() {
super(new Tags("rabbitmq"), "amqp");
super(new Tags("rabbitmq"), AmqpServiceInfo.URI_SCHEME);
}
public AmqpServiceInfo createServiceInfo(Map<String,Object> serviceData) {
@SuppressWarnings("unchecked")
Map<String,Object> credentials = (Map<String, Object>) serviceData.get("credentials");
String id = (String) serviceData.get("name");
String uri = getStringFromCredentials(credentials, "uri", "url");

View File

@@ -1,8 +1,8 @@
package org.springframework.cloud.service.common;
import org.springframework.cloud.CloudException;
import org.springframework.cloud.service.UriBasedServiceInfo;
import org.springframework.cloud.service.ServiceInfo.ServiceLabel;
import org.springframework.cloud.service.UriBasedServiceInfo;
import org.springframework.cloud.util.UriInfo;
/**
@@ -13,29 +13,32 @@ import org.springframework.cloud.util.UriInfo;
*/
@ServiceLabel("rabbitmq")
public class AmqpServiceInfo extends UriBasedServiceInfo {
public static final String URI_SCHEME = "amqp";
public AmqpServiceInfo(String id, String host, int port, String username, String password, String virtualHost) {
super(id, "amqp", host, port, username, password, virtualHost);
super(id, URI_SCHEME, host, port, username, password, virtualHost);
}
public AmqpServiceInfo(String id, String uri) throws CloudException {
super(id, uri);
}
@ServiceProperty(category="connection")
public String getVirtualHost() {
return getUriInfo().getPath();
}
@Override
protected UriInfo validateAndCleanUriInfo(UriInfo uriInfo) {
if (!"amqp".equals(uriInfo.getScheme())) {
if (!URI_SCHEME.equals(uriInfo.getScheme())) {
throw new IllegalArgumentException("wrong scheme in amqp URI: " + uriInfo);
}
if (uriInfo.getHost() == null) {
throw new IllegalArgumentException("missing authority in amqp URI: " + uriInfo);
}
int port = uriInfo.getPort();
if (port == -1) {
port = 5672;
@@ -43,7 +46,7 @@ public class AmqpServiceInfo extends UriBasedServiceInfo {
String userName = uriInfo.getUserName();
String password = uriInfo.getPassword();
if (userName == null || password == null) {
throw new IllegalArgumentException("missing userinfo in amqp URI: " + uriInfo);
}

View File

@@ -3,14 +3,14 @@ package org.springframework.cloud.heroku;
import org.springframework.cloud.service.common.AmqpServiceInfo;
/**
*
*
* @author Ramnivas Laddad
*
*/
public class AmqpServiceInfoCreator extends HerokuServiceInfoCreator<AmqpServiceInfo> {
public AmqpServiceInfoCreator() {
super("amqp");
super(AmqpServiceInfo.URI_SCHEME);
}
@Override