org.wildfly.naming.client.remote.RemoteNamingProvider Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file 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.wildfly.naming.client.remote;
import java.io.IOException;
import java.net.URI;
import javax.naming.NamingException;
import org.jboss.remoting3.ConnectionPeerIdentity;
import org.jboss.remoting3.Endpoint;
import org.wildfly.naming.client.NamingProvider;
import org.wildfly.naming.client._private.Messages;
import org.wildfly.security.auth.AuthenticationException;
import org.xnio.IoFuture;
/**
* A provider for JBoss Remoting-based JNDI contexts. Any scheme which uses JBoss Remoting using this provider will
* share a connection and a captured security context.
*
* @author David M. Lloyd
*/
public abstract class RemoteNamingProvider implements NamingProvider {
/**
* Construct a new instance.
*/
protected RemoteNamingProvider() {
}
/**
* Get the Remoting endpoint for this provider.
*
* @return the Remoting endpoint for this provider (not {@code null})
*/
public abstract Endpoint getEndpoint();
/**
* Get the connection peer identity for a naming operation. If the connection is not configured as {@code immediate}, then the connection
* will not actually be established until this method is called. The resultant connection should be closed and
* discarded in the event of an error, in order to facilitate automatic reconnection.
*
* @return the connection peer identity (not {@code null})
* @throws NamingException if connecting, authenticating, or re-authenticating the peer failed
*/
public ConnectionPeerIdentity getPeerIdentityForNaming() throws NamingException {
try {
return getPeerIdentity();
} catch (AuthenticationException e) {
throw Messages.log.authenticationFailed(e);
} catch (IOException e) {
throw Messages.log.connectFailed(e);
}
}
/**
* Get the connection peer identity. If the connection is not configured as {@code immediate}, then the connection
* will not actually be established until this method is called. The resultant connection should be closed and
* discarded in the event of an error, in order to facilitate automatic reconnection.
*
* @return the connection peer identity (not {@code null})
* @throws AuthenticationException if authenticating or re-authenticating the peer failed
* @throws IOException if connecting the peer failed
*/
public abstract ConnectionPeerIdentity getPeerIdentity() throws AuthenticationException, IOException;
/**
* Get the future connection peer identity. If the connection is not configured as {@code immediate}, then the connection
* will not actually be established until this method is called. The resultant connection should be closed and
* discarded in the event of an error, in order to facilitate automatic reconnection.
*
* @return the future connection peer identity (not {@code null})
*/
public abstract IoFuture getFuturePeerIdentity();
public abstract URI getProviderUri();
public abstract void close() throws NamingException;
}