From ec0dbb9127997b060fd0a631d96a3b27c5653d33 Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Fri, 17 Aug 2007 12:44:40 +0000 Subject: added destination URL handling git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@567047 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpidity/BrokerDetails.java | 115 +++++++++ .../java/org/apache/qpidity/BrokerDetailsImpl.java | 204 ++++++++++++++++ .../java/org/apache/qpidity/url/AMQBindingURL.java | 261 --------------------- .../org/apache/qpidity/url/BindingURLImpl.java | 261 +++++++++++++++++++++ .../main/java/org/apache/qpidity/url/QpidURL.java | 57 +++++ .../java/org/apache/qpidity/url/QpidURLImpl.java | 65 +++++ 6 files changed, 702 insertions(+), 261 deletions(-) create mode 100644 java/common/src/main/java/org/apache/qpidity/BrokerDetails.java create mode 100644 java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java delete mode 100644 java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java create mode 100644 java/common/src/main/java/org/apache/qpidity/url/BindingURLImpl.java create mode 100644 java/common/src/main/java/org/apache/qpidity/url/QpidURL.java create mode 100644 java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java (limited to 'java') diff --git a/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java b/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java new file mode 100644 index 0000000000..e1974f1859 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java @@ -0,0 +1,115 @@ +/* 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 + * + * 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 org.apache.qpidity; + +/** + * This interface represents a broker and provides the basic information + * required for opening a connection with a broker. + */ +public interface BrokerDetails +{ + /** + * Those are the supported protocols + */ + public static final String PROTOCOL_TCP = "tcp"; + public static final String PROTOCOL_TLS = "tls"; + + /** + * Get the broker host name. + * + * @return The broker host name. + */ + public String getHost(); + + /** + * Get the broker port number. + * + * @return The broker port number. + */ + public int getPort(); + + /** + * Get the virtual host to connect to. + * + * @return The virtual host of this broker. + */ + public String getVirtualHost(); + + /** + * Get the user name. + * + * @return The user name + */ + public String getUserName(); + + /** + * Get the user password + * + * @return The user password + */ + public String getPassword(); + + /** + * Get the protocol used to connect to hise broker. + * + * @return the protocol used to connect to the broker. + */ + public String getProtocol(); + + /** + * Set the broker host name. + * + * @param host The broker host name. + */ + public void setHost(String host); + + /** + * Set the broker port number. + * + * @param port The broker port number. + */ + public void setPort(int port); + + /** + * Set the virtual host to connect to. + * + * @param virtualHost The virtual host of this broker. + */ + public void setVirtualHost(String virtualHost); + + /** + * Set the user name. + * + * @param userName The user name + */ + public void getUserName(String userName); + + /** + * Set the user password + * + * @param password The user password + */ + public void setPassword(String password); + + /** + * Set the protocol used to connect to hise broker. + * + * @param protocol the protocol used to connect to the broker. + */ + public void setProtocol(String protocol); +} diff --git a/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java b/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java new file mode 100644 index 0000000000..e5b5fb215b --- /dev/null +++ b/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java @@ -0,0 +1,204 @@ +/* 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 + * + * 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 org.apache.qpidity; + +/** + * Implements the interface BrokerDetails + */ +public class BrokerDetailsImpl implements BrokerDetails +{ + //--- Those are the default values + private final String DEFAULT_USERNAME = "guest"; + private final String DEFAULT_PASSWORD = "guest"; + private final String DEFAULT_VIRTUALHOST = ""; + + //---- The brker details + private String _host; + private int _port; + private String _virtualHost; + private String _userName; + private String _password; + private String _protocol; + //--- Constructors + + /** + * Create a new broker details given all the reuqired information + * + * @param protocol The protocol used for this broker connection + * @param host The host name. + * @param port The port number. + * @param virtualHost The virtual host. + * @param userName The user name. + * @param password The user password. + */ + public BrokerDetailsImpl(String protocol, String host, int port, String virtualHost, String userName, + String password) + { + _protocol = protocol; + _host = host; + _port = port; + _virtualHost = virtualHost; + _userName = userName; + _password = password; + } + + /** + * Create a new broker details given the host name and the procol type, + * default values are used for the other details. + * + * @param protocol The protocol used for this broker connection + * @param host The host name. + */ + public BrokerDetailsImpl(String protocol, String host) + { + _protocol = protocol; + _host = host; + if (protocol.equals(BrokerDetails.PROTOCOL_TCP)) + { + _port = 1234; + } + else if (protocol.equals(BrokerDetails.PROTOCOL_TLS)) + { + _port = 5555; + } + _virtualHost = DEFAULT_VIRTUALHOST; + _userName = DEFAULT_USERNAME; + _password = DEFAULT_PASSWORD; + } + + //--- API BrokerDetails + /** + * Get the user password + * + * @return The user password + */ + public String getPassword() + { + return _password; + } + + /** + * Get the broker host name. + * + * @return The broker host name. + */ + public String getHost() + { + return _host; + } + + /** + * Get the broker port number. + * + * @return The broker port number. + */ + public int getPort() + { + return _port; + } + + /** + * Get the virtual host to connect to. + * + * @return The virtual host of this broker. + */ + public String getVirtualHost() + { + return _virtualHost; + } + + /** + * Get the user name. + * + * @return The user name + */ + public String getUserName() + { + return _userName; + } + + /** + * Get the protocol used to connect to hise broker. + * + * @return the protocol used to connect to the broker. + */ + public String getProtocol() + { + return _protocol; + } + + /** + * Set the broker host name. + * + * @param host The broker host name. + */ + public void setHost(String host) + { + _host = host; + } + + /** + * Set the broker port number. + * + * @param port The broker port number. + */ + public void setPort(int port) + { + _port = port; + } + + /** + * Set the virtual host to connect to. + * + * @param virtualHost The virtual host of this broker. + */ + public void setVirtualHost(String virtualHost) + { + _virtualHost = virtualHost; + } + + /** + * Set the user name. + * + * @param userName The user name + */ + public void getUserName(String userName) + { + _userName = userName; + } + + /** + * Set the user password + * + * @param password The user password + */ + public void setPassword(String password) + { + _password = password; + } + + /** + * Set the protocol used to connect to hise broker. + * + * @param protocol the protocol used to connect to the broker. + */ + public void setProtocol(String protocol) + { + _protocol = protocol; + } +} diff --git a/java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java b/java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java deleted file mode 100644 index 0edf9ac21b..0000000000 --- a/java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java +++ /dev/null @@ -1,261 +0,0 @@ -/* 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 - * - * 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 org.apache.qpidity.url; - -import org.apache.qpidity.exchange.ExchangeDefaults; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; - -import java.util.HashMap; -import java.net.URI; -import java.net.URISyntaxException; - -public class AMQBindingURL implements BindingURL -{ - private static final Logger _logger = LoggerFactory.getLogger(AMQBindingURL.class); - - String _url; - String _exchangeClass; - String _exchangeName; - String _destinationName; - String _queueName; - private HashMap _options; - - public AMQBindingURL(String url) throws URLSyntaxException - { - // format: - // :///[]/[]?