| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | |
| | | |
| | | import com.forgerock.opendj.ldap.InternalConnection; |
| | | import com.forgerock.opendj.util.AbstractConnectionFactory; |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | |
| | | |
| | |
| | | * @param <C> |
| | | * The type of client context. |
| | | */ |
| | | final class InternalConnectionFactory<C> extends AbstractConnectionFactory |
| | | final class InternalConnectionFactory<C> implements ConnectionFactory |
| | | { |
| | | |
| | | private final ServerConnectionFactory<C, Integer> factory; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public FutureResult<AsynchronousConnection> getAsynchronousConnection( |
| | | final ResultHandler<? super AsynchronousConnection> handler) |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Connection getConnection() throws ErrorResultException, |
| | | InterruptedException |
| | | { |
| | | final ServerConnection<Integer> serverConnection = factory |
| | | .handleAccept(clientContext); |
| | | return new InternalConnection(serverConnection); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public FutureResult<Connection> getConnectionAsync( |
| | | final ResultHandler<? super Connection> handler) |
| | | { |
| | | final ServerConnection<Integer> serverConnection; |
| | | try |
| | |
| | | { |
| | | handler.handleErrorResult(e); |
| | | } |
| | | return new CompletedFutureResult<AsynchronousConnection>(e); |
| | | return new CompletedFutureResult<Connection>(e); |
| | | } |
| | | |
| | | final InternalConnection connection = new InternalConnection( |
| | |
| | | { |
| | | handler.handleResult(connection); |
| | | } |
| | | return new CompletedFutureResult<AsynchronousConnection>(connection); |
| | | return new CompletedFutureResult<Connection>(connection); |
| | | } |
| | | |
| | | |