001 /* 002 * Copyright 2009 Red Hat, Inc. 003 * Red Hat licenses this file to you under the Apache License, version 004 * 2.0 (the "License"); you may not use this file except in compliance 005 * with the License. You may obtain a copy of the License at 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * Unless required by applicable law or agreed to in writing, software 008 * distributed under the License is distributed on an "AS IS" BASIS, 009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 010 * implied. See the License for the specific language governing 011 * permissions and limitations under the License. 012 */ 013 package org.hornetq.spi.core.remoting; 014 015 import java.util.Map; 016 017 /** 018 * A Connector is used by the client for creating and controlling a connection. 019 * 020 * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a> 021 */ 022 public interface Connector 023 { 024 /** 025 * starts the connector 026 */ 027 void start(); 028 029 /** 030 * closes the connector 031 */ 032 void close(); 033 034 /** 035 * returns true if the connector is started, oterwise false. 036 * 037 * @return true if the connector is started 038 */ 039 boolean isStarted(); 040 041 /** 042 * Create and return a connection from this connector. 043 * <p/> 044 * This method must NOT throw an exception if it fails to create the connection 045 * (e.g. network is not available), in this case it MUST return null 046 * 047 * @return The connection, or null if unable to create a connection (e.g. network is unavailable) 048 */ 049 Connection createConnection(); 050 051 /** 052 * If the configuration is equivalent to this connector, which means 053 * if the parameter configuration is used to create a connection to a target 054 * node, it will be the same node as of the connections made with this connector. 055 * @param configuration 056 * @return true means the configuration is equivalent to the connector. false otherwise. 057 */ 058 boolean isEquivalent(Map<String, Object> configuration); 059 }