
org.jboss.remoting3.metadata.RemotingHelper Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.remoting3.metadata;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
import org.jboss.marshalling.river.RiverProviderDescriptor;
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.UnknownURISchemeException;
import org.jboss.remoting3.remote.RemoteProtocol;
import org.jboss.remoting3.security.ServerAuthenticationProvider;
import org.jboss.remoting3.spi.ConnectionProvider;
import org.jboss.remoting3.spi.ConnectionProviderContext;
import org.jboss.remoting3.spi.ConnectionProviderFactory;
import org.jboss.remoting3.spi.NetworkServerProvider;
import org.jboss.remoting3.spi.ProtocolServiceType;
import org.jboss.xnio.ChannelListener;
import org.jboss.xnio.OptionMap;
import org.jboss.xnio.SslTcpConnector;
import org.jboss.xnio.TcpConnector;
import org.jboss.xnio.channels.ConnectedStreamChannel;
/**
*
*/
public final class RemotingHelper {
private RemotingHelper() {}
public static ChannelListener> createServer(Endpoint endpoint, String protocol, OptionMap optionMap, final ServerAuthenticationProvider authHandler) throws UnknownURISchemeException {
return endpoint.getConnectionProviderInterface(protocol, NetworkServerProvider.class).getServerListener(optionMap, authHandler);
}
public static Endpoint createEndpoint(final String name, final TcpConnector tcpConnector, final SslTcpConnector sslConnector, final Executor executor, final OptionMap optionMap) throws IOException {
final Endpoint endpoint = Remoting.createEndpoint(name, executor, optionMap);
endpoint.addProtocolService(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "river", new RiverProviderDescriptor());
endpoint.addConnectionProvider("remote", new ConnectionProviderFactory() {
public ConnectionProvider createInstance(final ConnectionProviderContext context) {
return RemoteProtocol.getRemoteConnectionProvider(context, tcpConnector);
}
});
if (sslConnector != null) endpoint.addConnectionProvider("remote+ssl", new ConnectionProviderFactory() {
public ConnectionProvider createInstance(final ConnectionProviderContext context) {
return RemoteProtocol.getRemoteConnectionProvider(context, sslConnector);
}
});
return endpoint;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy