KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > network > NetworkBridgeFactory


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.network;
16
17 import org.apache.activemq.transport.Transport;
18
19 /**
20  * Factory for network bridges
21  *
22  * @version $Revision: 1.1 $
23  */

24 public class NetworkBridgeFactory{
25
26     /**
27      * Create a network bridge
28      *
29      * @param config
30      * @param localTransport
31      * @param remoteTransport
32      * @return the NetworkBridge
33      */

34     public static DemandForwardingBridge createBridge(NetworkBridgeConfiguration config,Transport localTransport,
35             Transport remoteTransport){
36         return createBridge(config,localTransport,remoteTransport,null);
37     }
38
39     /**
40      * create a network bridge
41      *
42      * @param configuration
43      * @param localTransport
44      * @param remoteTransport
45      * @param listener
46      * @return the NetworkBridge
47      */

48     public static DemandForwardingBridge createBridge(NetworkBridgeConfiguration configuration,Transport localTransport,
49             Transport remoteTransport,NetworkBridgeFailedListener listener){
50         DemandForwardingBridge result=null;
51         if(configuration.isConduitSubscriptions()){
52             if(configuration.isDynamicOnly()){
53                 result=new ConduitBridge(configuration,localTransport,remoteTransport);
54             }else{
55                 result=new DurableConduitBridge(configuration,localTransport,remoteTransport);
56             }
57         }else{
58             result=new DemandForwardingBridge(configuration,localTransport,remoteTransport);
59         }
60         if(listener!=null){
61             result.setNetworkBridgeFailedListener(listener);
62         }
63         return result;
64     }
65 }
66
Popular Tags