001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.network;
018
019 import org.apache.activemq.transport.Transport;
020
021 /**
022 * Factory for network bridges
023 *
024 *
025 */
026 public final class NetworkBridgeFactory {
027
028 private NetworkBridgeFactory() {
029 }
030
031 /**
032 * Create a network bridge
033 *
034 * @param config
035 * @param localTransport
036 * @param remoteTransport
037 * @return the NetworkBridge
038 */
039 public static DemandForwardingBridge createBridge(NetworkBridgeConfiguration config,
040 Transport localTransport, Transport remoteTransport) {
041 return createBridge(config, localTransport, remoteTransport, null);
042 }
043
044 /**
045 * create a network bridge
046 *
047 * @param configuration
048 * @param localTransport
049 * @param remoteTransport
050 * @param listener
051 * @return the NetworkBridge
052 */
053 public static DemandForwardingBridge createBridge(NetworkBridgeConfiguration configuration,
054 Transport localTransport, Transport remoteTransport,
055 final NetworkBridgeListener listener) {
056 DemandForwardingBridge result = null;
057 if (configuration.isConduitSubscriptions()) {
058 // dynamicOnly determines whether durables are auto bridged
059 result = new DurableConduitBridge(configuration, localTransport, remoteTransport);
060 } else {
061 result = new DemandForwardingBridge(configuration, localTransport, remoteTransport);
062 }
063 if (listener != null) {
064 result.setNetworkBridgeListener(listener);
065 }
066 return result;
067 }
068 }