001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * 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     **/
018    
019    package org.activemq.transport.peer;
020    import java.net.URI;
021    import javax.jms.JMSException;
022    import org.activemq.io.WireFormat;
023    import org.activemq.transport.TransportChannel;
024    import org.activemq.transport.TransportChannelFactorySupport;
025    
026    /**
027     * Creates peer based transport. A PeerTransportChannel creates an embedded broker, and uses discovery and/or defined
028     * list of urls to create a p-2-p interconnected network.
029     * 
030     * @see PeerTransportChannel
031     * @version $Revision: 1.1.1.1 $
032     */
033    public class PeerTransportChannelFactory extends TransportChannelFactorySupport {
034        /**
035         * Create a Channel
036         * 
037         * @param wireFormat
038         * @param remoteLocation
039         * @return the TransportChannel bound to the remote node
040         * @throws JMSException
041         */
042        public TransportChannel create(WireFormat wireFormat, URI remoteLocation) throws JMSException {
043            TransportChannel result = new PeerTransportChannel(wireFormat, remoteLocation.getHost());
044            return populateProperties(result, remoteLocation);
045        }
046        
047        /**
048         * Create a peer channel
049         * @param wireFormat
050         * @param remoteLocation
051         * @param localLocation
052         * @return
053         * @throws JMSException
054         * 
055         */
056        
057        public TransportChannel create(WireFormat wireFormat, URI remoteLocation, URI localLocation) throws JMSException {
058            PeerTransportChannel result = new PeerTransportChannel(wireFormat, remoteLocation.getHost());
059            result.setBrokerConnectorURI(localLocation.toString());
060            return populateProperties(result, remoteLocation);
061        }
062    
063        /**
064         * Does this channel require an embedded broker to perform such as VM or multicast based transports
065         * 
066         * @return true if an embedded broker is a requirement of using the channel
067         */
068        public boolean requiresEmbeddedBroker() {
069            return true;
070        }
071    }