Package org.apache.oodt.cas.pushpull.protocol

Examples of org.apache.oodt.cas.pushpull.protocol.ProtocolFactory


    public Protocol getAppropriateProtocolBySite(RemoteSite remoteSite,
            boolean allowReuse) throws ProtocolException {
        Protocol protocol = null;
        if ((allowReuse && ((protocol = reuseProtocols.get(remoteSite.getURL())) == null))
                || !allowReuse) {
            ProtocolFactory protocolFactory = this.urlAndProtocolFactory
                    .get(remoteSite.getURL());
            if (protocolFactory == null) {
                LinkedList<Class<ProtocolFactory>> protocolClasses = pi
                        .getProtocolClassesForProtocolType(remoteSite.getURL()
                                .getProtocol());
                for (Class<ProtocolFactory> clazz : protocolClasses) {
                    try {
                        if ((protocol = (protocolFactory = clazz.newInstance())
                                .newInstance()) != null) {
                            if (!connect(protocol, remoteSite, true)) {
                                LOG.log(Level.WARNING, "ProtocolFactory "
                                        + protocolFactory.getClass()
                                                .getCanonicalName()
                                        + " is not compatible with server at "
                                        + remoteSite.getURL());
                                protocol = null;
                            } else {
                                this.urlAndProtocolFactory.put(remoteSite
                                        .getURL(), protocolFactory);
                                break;
                            }
                        }
                    } catch (Exception e) {
                        LOG.log(Level.WARNING,
                                "Failed to instanciate protocol " + clazz
                                        + " for " + remoteSite.getURL());
                    }
                }
                if (protocol == null)
                    throw new ProtocolException(
                            "Failed to get appropriate protocol for "
                                    + remoteSite);
            } else {
                connect(protocol = protocolFactory.newInstance(), remoteSite,
                        false);
            }
            if (allowReuse)
                this.reuseProtocols.put(remoteSite.getURL(), protocol);
        }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.pushpull.protocol.ProtocolFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.