diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2007-08-17 12:44:40 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2007-08-17 12:44:40 +0000 |
| commit | ec0dbb9127997b060fd0a631d96a3b27c5653d33 (patch) | |
| tree | 0463368c71ef8d98deb015f709f4a46937c0734e /java/common | |
| parent | c47ffec9b9e4608e511c03ed597a6c988460703f (diff) | |
| download | qpid-python-ec0dbb9127997b060fd0a631d96a3b27c5653d33.tar.gz | |
added destination URL handling
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@567047 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpidity/BrokerDetails.java | 115 | ||||
| -rw-r--r-- | java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java | 204 | ||||
| -rw-r--r-- | java/common/src/main/java/org/apache/qpidity/url/BindingURLImpl.java (renamed from java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java) | 6 | ||||
| -rw-r--r-- | java/common/src/main/java/org/apache/qpidity/url/QpidURL.java | 57 | ||||
| -rw-r--r-- | java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java | 65 |
5 files changed, 444 insertions, 3 deletions
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/BindingURLImpl.java index 0edf9ac21b..427e0f1413 100644 --- a/java/common/src/main/java/org/apache/qpidity/url/AMQBindingURL.java +++ b/java/common/src/main/java/org/apache/qpidity/url/BindingURLImpl.java @@ -25,9 +25,9 @@ import java.util.HashMap; import java.net.URI; import java.net.URISyntaxException; -public class AMQBindingURL implements BindingURL +public class BindingURLImpl implements BindingURL { - private static final Logger _logger = LoggerFactory.getLogger(AMQBindingURL.class); + private static final Logger _logger = LoggerFactory.getLogger(BindingURLImpl.class); String _url; String _exchangeClass; @@ -36,7 +36,7 @@ public class AMQBindingURL implements BindingURL String _queueName; private HashMap<String, String> _options; - public AMQBindingURL(String url) throws URLSyntaxException + public BindingURLImpl(String url) throws URLSyntaxException { // format: // <exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']* diff --git a/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java b/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java new file mode 100644 index 0000000000..ad0d69b5b2 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java @@ -0,0 +1,57 @@ +/* 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.BrokerDetails; + +import java.util.List; + +/** + * The format of the Qpid URL is based on the AMQP one. + * The grammar is as follows: + * <p> qpid_url = "qpid:" prot_addr_list ["/" future-parameters] + * <p> prot_addr_list = [prot_addr ","]* prot_addr + * <p> prot_addr = tcp_prot_addr | tls_prot_addr | future_prot_addr + * <p> tcp_prot_addr = tcp_id tcp_addr + * <p> tcp_id = "tcp:" | "" + * <p> tcp_addr = [host [":" port] ] + * <p> host = <as per [2]> + * <p> port = number + * <p> tls_prot_addr = tls_id tls_addr + * <p> tls_id = "tls:" | "" + * <p> tls_addr = [host [":" port] ] + * <p> future_prot_addr = future_prot_id future_prot_addr + * <p> future_prot_id = <placeholder, must end in ":". Example "sctp:"> + * <p> future_prot_addr = <placeholder, protocl-specific address> + * <p> future_parameters = <placeholder, not used in failover addresses> + */ +public interface QpidURL +{ + /** + * Get all the broker details + * + * @return A list of BrokerDetails. + */ + public List<BrokerDetails> getAllBrokerDetails(); + + /** + * Get this URL string form + * @return This URL string form. + */ + public String getURL(); +} diff --git a/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java b/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java new file mode 100644 index 0000000000..c0ce6617d0 --- /dev/null +++ b/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java @@ -0,0 +1,65 @@ +/* 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.BrokerDetails; + +import java.util.List; + +/** + * The format Qpid URL is based on the AMQP one. + * The grammar is as follows: + * <p> qpid_url = "qpid:" port_addr_list ["/" future-parameters] + * <p> port_addr_list = [port_addr ","]* port_addr + * <p> port_addr = tcp_port_addr | tls_prot_addr | future_prot_addr + * <p> tcp_port_addr = tcp_id tcp_addr + * <p> tcp_id = "tcp:" | "" + * <p> tcp_addr = [host [":" port] ] + * <p> host = <as per [2]> + * <p> port = number + * <p> tls_prot_addr = tls_id tls_addr + * <p> tls_id = "tls:" | "" + * <p> tls_addr = [host [":" port] ] + * <p> future_prot_addr = future_prot_id future_prot_addr + * <p> future_prot_id = <placeholder, must end in ":". Example "sctp:"> + * <p> future_prot_addr = <placeholder, protocl-specific address> + * <p> future_parameters = <placeholder, not used in failover addresses> + */ +public class QpidURLImpl implements QpidURL +{ + //-- Constructors + + public QpidURLImpl(String url) + { + // todo pars this URL + } + + //-- interface QpidURL + + public List<BrokerDetails> getAllBrokerDetails() + { + // TODO + return null; + } + + public String getURL() + { + //TODO + return ""; + } +} |
