/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE
* or https://OpenDS.dev.java.net/OpenDS.LICENSE.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2010 Sun Microsystems, Inc.
*/
package com.sun.opends.sdk.util;
import java.util.Collection;
import org.opends.sdk.*;
import org.opends.sdk.requests.*;
import org.opends.sdk.responses.*;
import org.opends.sdk.schema.Schema;
/**
* A base class from which asynchronous connection decorators may be easily
* implemented. The default implementation of each method is to delegate to the
* decorated connection.
*/
public abstract class AsynchronousConnectionDecorator implements
AsynchronousConnection
{
/**
* The decorated asynchronous connection.
*/
protected final AsynchronousConnection connection;
/**
* Creates a new asynchronous connection decorator.
*
* @param connection
* The asynchronous connection to be decorated.
*/
protected AsynchronousConnectionDecorator(AsynchronousConnection connection)
{
Validator.ensureNotNull(connection);
this.connection = connection;
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult abandon(AbandonRequest request)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.abandon(request);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult add(AddRequest request,
ResultHandler super Result> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.add(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult add(AddRequest request,
ResultHandler super Result> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.add(request, resultHandler, intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public void addConnectionEventListener(ConnectionEventListener listener)
throws IllegalStateException, NullPointerException
{
connection.addConnectionEventListener(listener);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult bind(BindRequest request,
ResultHandler super BindResult> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.bind(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult bind(BindRequest request,
ResultHandler super BindResult> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.bind(request, resultHandler, intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public void close()
{
connection.close();
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public void close(UnbindRequest request, String reason)
throws NullPointerException
{
connection.close(request, reason);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult compare(CompareRequest request,
ResultHandler super CompareResult> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.compare(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult compare(CompareRequest request,
ResultHandler super CompareResult> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.compare(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult delete(DeleteRequest request,
ResultHandler super Result> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.delete(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult delete(DeleteRequest request,
ResultHandler super Result> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.delete(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult extendedRequest(
ExtendedRequest request, ResultHandler super R> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.extendedRequest(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult extendedRequest(
ExtendedRequest request, ResultHandler super R> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.extendedRequest(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to return a synchronous view of this
* decorated connection.
*/
public Connection getSynchronousConnection()
{
return new SynchronousConnection(this);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public boolean isClosed()
{
return connection.isClosed();
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public boolean isValid()
{
return connection.isValid();
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult modify(ModifyRequest request,
ResultHandler super Result> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.modify(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult modify(ModifyRequest request,
ResultHandler super Result> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.modify(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult modifyDN(ModifyDNRequest request,
ResultHandler super Result> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.modifyDN(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult modifyDN(ModifyDNRequest request,
ResultHandler super Result> resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.modifyDN(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult readEntry(DN name,
Collection attributeDescriptions,
ResultHandler super SearchResultEntry> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.readEntry(name, attributeDescriptions, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult readRootDSE(
ResultHandler super RootDSE> handler)
throws UnsupportedOperationException, IllegalStateException
{
return connection.readRootDSE(handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult readSchema(DN name,
ResultHandler super Schema> handler)
throws UnsupportedOperationException, IllegalStateException
{
return connection.readSchema(name, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult readSchemaForEntry(DN name,
ResultHandler super Schema> handler)
throws UnsupportedOperationException, IllegalStateException
{
return connection.readSchemaForEntry(name, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public void removeConnectionEventListener(ConnectionEventListener listener)
throws NullPointerException
{
connection.removeConnectionEventListener(listener);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult search(SearchRequest request,
SearchResultHandler handler) throws UnsupportedOperationException,
IllegalStateException, NullPointerException
{
return connection.search(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult search(SearchRequest request,
SearchResultHandler resultHandler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.search(request, resultHandler,
intermediateResponseHandler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public FutureResult searchSingleEntry(
SearchRequest request, ResultHandler super SearchResultEntry> handler)
throws UnsupportedOperationException, IllegalStateException,
NullPointerException
{
return connection.searchSingleEntry(request, handler);
}
/**
* {@inheritDoc}
*
* The default implementation is to delegate.
*/
public String toString()
{
return connection.toString();
}
}