From da8bc22192eb85879c3fb440d801a6f3519af3d3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 22 Sep 2014 09:17:28 +0000
Subject: [PATCH] OperationWrapper.java, AbstractOperation.java, Operation.java, PluginOperation.java: In getAttachment(), removeAttachment() and setAttachment(), changed the return type to a generic type. This simplifies client code by removing the need to cast the returned value.
---
opendj3-server-dev/src/server/org/opends/server/types/operation/PluginOperation.java | 59 +++---
opendj3-server-dev/src/server/org/opends/server/types/Operation.java | 121 ++++++--------
opendj3-server-dev/src/server/org/opends/server/types/AbstractOperation.java | 29 ++-
opendj3-server-dev/src/server/org/opends/server/core/OperationWrapper.java | 238 ++++++++---------------------
4 files changed, 173 insertions(+), 274 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/core/OperationWrapper.java b/opendj3-server-dev/src/server/org/opends/server/core/OperationWrapper.java
index 5ce7c77..0d40c88 100644
--- a/opendj3-server-dev/src/server/org/opends/server/core/OperationWrapper.java
+++ b/opendj3-server-dev/src/server/org/opends/server/core/OperationWrapper.java
@@ -31,10 +31,20 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
import org.opends.server.controls.ControlDecoder;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.types.AdditionalLogItem;
+import org.opends.server.types.CancelRequest;
+import org.opends.server.types.CancelResult;
+import org.opends.server.types.CanceledOperationException;
+import org.opends.server.types.Control;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.DisconnectReason;
+import org.opends.server.types.Entry;
+import org.opends.server.types.Operation;
+import org.opends.server.types.OperationType;
/**
* This abstract class is a generic operation wrapper intended to be subclassed
@@ -59,27 +69,21 @@
this.operation = operation;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void addRequestControl(Control control)
{
operation.addRequestControl(control);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void addResponseControl(Control control)
{
operation.addResponseControl(control);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void appendErrorMessage(LocalizableMessage message)
{
@@ -93,27 +97,21 @@
operation.appendMaskedErrorMessage(maskedMessage);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public CancelResult cancel(CancelRequest cancelRequest)
{
return operation.cancel(cancelRequest);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void abort(CancelRequest cancelRequest)
{
operation.abort(cancelRequest);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void disconnectClient(
DisconnectReason disconnectReason,
@@ -125,90 +123,70 @@
disconnectReason, sendNotification, message);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean dontSynchronize()
{
return operation.dontSynchronize();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
- public Object getAttachment(String name)
+ public <T> T getAttachment(String name)
{
return operation.getAttachment(name);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public Map<String, Object> getAttachments()
{
return operation.getAttachments();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public DN getAuthorizationDN()
{
return operation.getAuthorizationDN();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public Entry getAuthorizationEntry()
{
return operation.getAuthorizationEntry();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public CancelRequest getCancelRequest()
{
return operation.getCancelRequest();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public CancelResult getCancelResult()
{
return operation.getCancelResult();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public ClientConnection getClientConnection()
{
return operation.getClientConnection();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getConnectionID()
{
return operation.getConnectionID();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public LocalizableMessageBuilder getErrorMessage()
{
@@ -229,18 +207,14 @@
return operation.getMaskedResultCode();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public DN getMatchedDN()
{
return operation.getMatchedDN();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public int getMessageID()
{
@@ -257,81 +231,63 @@
return operation;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getOperationID()
{
return operation.getOperationID();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public OperationType getOperationType()
{
return operation.getOperationType();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getProcessingStartTime()
{
return operation.getProcessingStartTime();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getProcessingStopTime()
{
return operation.getProcessingStopTime();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getProcessingTime()
{
return operation.getProcessingTime();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public long getProcessingNanoTime()
{
return operation.getProcessingNanoTime();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public List<String> getReferralURLs()
{
return operation.getReferralURLs();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public List<Control> getRequestControls()
{
return operation.getRequestControls();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T extends Control> T getRequestControl(
ControlDecoder<T> d)throws DirectoryException
@@ -339,135 +295,105 @@
return operation.getRequestControl(d);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public List<Control> getResponseControls()
{
return operation.getResponseControls();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public ResultCode getResultCode()
{
return operation.getResultCode();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isInnerOperation()
{
return operation.isInnerOperation();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isInternalOperation()
{
return operation.isInternalOperation();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isSynchronizationOperation()
{
return operation.isSynchronizationOperation();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void operationCompleted()
{
operation.operationCompleted();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
- public Object removeAttachment(String name)
+ public <T> T removeAttachment(String name)
{
return operation.removeAttachment(name);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void removeResponseControl(Control control)
{
operation.removeResponseControl(control);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
- public Object setAttachment(String name, Object value)
+ public <T> T setAttachment(String name, Object value)
{
return operation.setAttachment(name, value);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setAttachments(Map<String, Object> attachments)
{
operation.setAttachments(attachments);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setAuthorizationEntry(Entry authorizationEntry)
{
operation.setAuthorizationEntry(authorizationEntry);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setDontSynchronize(boolean dontSynchronize)
{
operation.setDontSynchronize(dontSynchronize);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setErrorMessage(LocalizableMessageBuilder errorMessage)
{
operation.setErrorMessage(errorMessage);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setInnerOperation(boolean isInnerOperation)
{
operation.setInnerOperation(isInnerOperation);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setInternalOperation(boolean isInternalOperation)
{
@@ -488,63 +414,49 @@
operation.setMaskedResultCode(maskedResultCode);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setMatchedDN(DN matchedDN)
{
operation.setMatchedDN(matchedDN);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setReferralURLs(List<String> referralURLs)
{
operation.setReferralURLs(referralURLs);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setResponseData(DirectoryException directoryException)
{
operation.setResponseData(directoryException);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setResultCode(ResultCode resultCode)
{
operation.setResultCode(resultCode);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setSynchronizationOperation(boolean isSynchronizationOperation)
{
operation.setSynchronizationOperation(isSynchronizationOperation);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public final int hashCode()
{
return getClientConnection().hashCode() * (int) getOperationID();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public final boolean equals(Object obj)
{
@@ -569,30 +481,24 @@
@Override
public String toString()
{
- return "Wrapped " + operation.toString();
+ return "Wrapped " + operation;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void toString(StringBuilder buffer)
{
operation.toString(buffer);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public synchronized final void checkIfCanceled(boolean signalTooLate)
throws CanceledOperationException {
operation.checkIfCanceled(signalTooLate);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void registerPostResponseCallback(Runnable callback)
{
@@ -606,18 +512,14 @@
operation.run();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public List<AdditionalLogItem> getAdditionalLogItems()
{
return operation.getAdditionalLogItems();
}
- /**
- *{@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void addAdditionalLogItem(AdditionalLogItem item)
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/AbstractOperation.java b/opendj3-server-dev/src/server/org/opends/server/types/AbstractOperation.java
index 61a1544..041a9c3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/AbstractOperation.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/AbstractOperation.java
@@ -26,7 +26,12 @@
*/
package org.opends.server.types;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
@@ -175,7 +180,7 @@
private long processingStopNanoTime;
/** The callbacks to be invoked once a response has been sent. */
- private List<Runnable> postResponseCallbacks = null;
+ private List<Runnable> postResponseCallbacks;
/**
* Creates a new operation with the provided information.
@@ -562,23 +567,26 @@
/** {@inheritDoc} */
@Override
- public final Object getAttachment(String name)
+ @SuppressWarnings("unchecked")
+ public final <T> T getAttachment(String name)
{
- return attachments.get(name);
+ return (T) attachments.get(name);
}
/** {@inheritDoc} */
@Override
- public final Object removeAttachment(String name)
+ @SuppressWarnings("unchecked")
+ public final <T> T removeAttachment(String name)
{
- return attachments.remove(name);
+ return (T) attachments.remove(name);
}
/** {@inheritDoc} */
@Override
- public final Object setAttachment(String name, Object value)
+ @SuppressWarnings("unchecked")
+ public final <T> T setAttachment(String name, Object value)
{
- return attachments.put(name, value);
+ return (T) attachments.put(name, value);
}
/** {@inheritDoc} */
@@ -597,8 +605,7 @@
abort(cancelRequest);
long stopWaitingTime = System.currentTimeMillis() + 5000;
- while ((cancelResult == null) &&
- (System.currentTimeMillis() < stopWaitingTime))
+ while (cancelResult == null && System.currentTimeMillis() < stopWaitingTime)
{
try
{
@@ -634,7 +641,7 @@
/** {@inheritDoc} */
@Override
- final synchronized public void checkIfCanceled(boolean signalTooLate)
+ public final synchronized void checkIfCanceled(boolean signalTooLate)
throws CanceledOperationException
{
if(cancelRequest != null)
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/Operation.java b/opendj3-server-dev/src/server/org/opends/server/types/Operation.java
index d099d86..d423987 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/Operation.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/Operation.java
@@ -35,7 +35,6 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.controls.ControlDecoder;
-
/**
* This interface defines a generic operation that may be processed by
* the Directory Server. Specific subclasses should implement
@@ -57,15 +56,14 @@
* Identifier used to get the local operation [if any] in the
* attachments.
*/
- public static final String LOCALBACKENDOPERATIONS =
- "LocalBackendOperations";
+ String LOCALBACKENDOPERATIONS = "LocalBackendOperations";
/**
* Retrieves the operation type for this operation.
*
* @return The operation type for this operation.
*/
- public abstract OperationType getOperationType();
+ OperationType getOperationType();
/**
* Terminates the client connection being used to process this
@@ -83,10 +81,7 @@
* may be {@code null} if no notification
* is to be sent.
*/
- public abstract void disconnectClient(
- DisconnectReason disconnectReason,
- boolean sendNotification, LocalizableMessage message
- );
+ void disconnectClient(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message);
/**
* Retrieves the client connection with which this operation is
@@ -95,7 +90,7 @@
* @return The client connection with which this operation is
* associated.
*/
- public abstract ClientConnection getClientConnection();
+ ClientConnection getClientConnection();
/**
* Retrieves the unique identifier that is assigned to the client
@@ -104,21 +99,21 @@
* @return The unique identifier that is assigned to the client
* connection that submitted this operation.
*/
- public abstract long getConnectionID();
+ long getConnectionID();
/**
* Retrieves the operation ID for this operation.
*
* @return The operation ID for this operation.
*/
- public abstract long getOperationID();
+ long getOperationID();
/**
* Retrieves the message ID assigned to this operation.
*
* @return The message ID assigned to this operation.
*/
- public abstract int getMessageID();
+ int getMessageID();
/**
* Retrieves the set of controls included in the request from the
@@ -127,7 +122,7 @@
* @return The set of controls included in the request from the
* client.
*/
- public abstract List<Control> getRequestControls();
+ List<Control> getRequestControls();
/**
* Retrieves a control included in the request from the client.
@@ -142,8 +137,7 @@
* @throws DirectoryException
* if an error occurs while decoding the control.
*/
- public abstract <T extends Control> T getRequestControl(
- ControlDecoder<T> d) throws DirectoryException;
+ <T extends Control> T getRequestControl(ControlDecoder<T> d) throws DirectoryException;
/**
* Adds the provided control to the set of request controls for this
@@ -152,7 +146,7 @@
* @param control The control to add to the set of request
* controls for this operation.
*/
- public abstract void addRequestControl(Control control);
+ void addRequestControl(Control control);
/**
* Retrieves the set of controls to include in the response to the
@@ -161,7 +155,7 @@
* @return The set of controls to include in the response to the
* client.
*/
- public abstract List<Control> getResponseControls();
+ List<Control> getResponseControls();
/**
* Adds the provided control to the set of controls to include in
@@ -171,7 +165,7 @@
* @param control The control to add to the set of controls to
* include in the response to the client.
*/
- public abstract void addResponseControl(Control control);
+ void addResponseControl(Control control);
/**
* Removes the provided control from the set of controls to include
@@ -181,7 +175,7 @@
* @param control The control to remove from the set of controls
* to include in the response to the client.
*/
- public abstract void removeResponseControl(Control control);
+ void removeResponseControl(Control control);
/**
* Retrieves the result code for this operation.
@@ -190,7 +184,7 @@
* {@code UNDEFINED} if the operation has not yet
* completed.
*/
- public abstract ResultCode getResultCode();
+ ResultCode getResultCode();
/**
* Specifies the result code for this operation. This method may
@@ -198,7 +192,7 @@
*
* @param resultCode The result code for this operation.
*/
- public abstract void setResultCode(ResultCode resultCode);
+ void setResultCode(ResultCode resultCode);
/**
* Retrieves the real, masked result code for this operation.
@@ -224,7 +218,7 @@
*
* @return The error message for this operation.
*/
- public abstract LocalizableMessageBuilder getErrorMessage();
+ LocalizableMessageBuilder getErrorMessage();
/**
* Specifies the error message for this operation. This method may
@@ -232,7 +226,7 @@
*
* @param errorMessage The error message for this operation.
*/
- public abstract void setErrorMessage(LocalizableMessageBuilder errorMessage);
+ void setErrorMessage(LocalizableMessageBuilder errorMessage);
/**
* Appends the provided message to the error message buffer. If the
@@ -242,7 +236,7 @@
*
* @param message The message to append to the error message
*/
- public abstract void appendErrorMessage(LocalizableMessage message);
+ void appendErrorMessage(LocalizableMessage message);
/**
* Retrieves the real, masked error message for this operation. Its contents
@@ -281,7 +275,7 @@
* @return An unmodifiable list containing the additional log items for this
* operation.
*/
- public abstract List<AdditionalLogItem> getAdditionalLogItems();
+ List<AdditionalLogItem> getAdditionalLogItems();
/**
* Adds an additional log item to this operation, which should be written to
@@ -291,7 +285,7 @@
* @param item
* The additional log item for this operation.
*/
- public abstract void addAdditionalLogItem(AdditionalLogItem item);
+ void addAdditionalLogItem(AdditionalLogItem item);
/**
* Retrieves the matched DN for this operation.
@@ -300,7 +294,7 @@
* the operation has not yet completed or does not have a
* matched DN.
*/
- public abstract DN getMatchedDN();
+ DN getMatchedDN();
/**
* Specifies the matched DN for this operation. This may not be
@@ -308,7 +302,7 @@
*
* @param matchedDN The matched DN for this operation.
*/
- public abstract void setMatchedDN(DN matchedDN);
+ void setMatchedDN(DN matchedDN);
/**
* Retrieves the set of referral URLs for this operation. Its
@@ -318,7 +312,7 @@
* {@code null} if the operation is not yet complete or
* does not have a set of referral URLs.
*/
- public abstract List<String> getReferralURLs();
+ List<String> getReferralURLs();
/**
* Specifies the set of referral URLs for this operation. This may
@@ -327,7 +321,7 @@
* @param referralURLs The set of referral URLs for this
* operation.
*/
- public abstract void setReferralURLs(List<String> referralURLs);
+ void setReferralURLs(List<String> referralURLs);
/**
* Sets the response elements for this operation based on the
@@ -338,8 +332,7 @@
* information to use for the response
* elements.
*/
- public abstract void setResponseData(
- DirectoryException directoryException);
+ void setResponseData(DirectoryException directoryException);
/**
* Indicates whether this is an internal operation rather than one
@@ -348,7 +341,7 @@
* @return {@code true} if this is an internal operation, or
* {@code false} if it is not.
*/
- public abstract boolean isInternalOperation();
+ boolean isInternalOperation();
/**
* Specifies whether this is an internal operation rather than one
@@ -360,8 +353,7 @@
* that was requested by an external
* client.
*/
- public abstract void setInternalOperation(boolean
- isInternalOperation);
+ void setInternalOperation(boolean isInternalOperation);
/**
* Indicates whether this is an inner operation rather than one that was
@@ -395,7 +387,7 @@
* @return {@code true} if this is a data synchronization
* operation, or {@code false} if it is not.
*/
- public abstract boolean isSynchronizationOperation();
+ boolean isSynchronizationOperation();
/**
* Specifies whether this is a synchronization operation rather than
@@ -408,8 +400,7 @@
* requested by an external
* client.
*/
- public abstract void setSynchronizationOperation(
- boolean isSynchronizationOperation);
+ void setSynchronizationOperation(boolean isSynchronizationOperation);
/**
* Specifies whether this operation must be synchronized to other
@@ -419,7 +410,7 @@
* synchronized to other copies
* of the data.
*/
- public abstract void setDontSynchronize(boolean dontSynchronize);
+ void setDontSynchronize(boolean dontSynchronize);
/**
* Retrieves the entry for the user that should be considered the
@@ -437,7 +428,7 @@
* {@code null} if the authorization identity should be the
* unauthenticated user.
*/
- public abstract Entry getAuthorizationEntry();
+ Entry getAuthorizationEntry();
/**
* Provides the entry for the user that should be considered the
@@ -450,8 +441,7 @@
* if it should be the unauthenticated
* user.
*/
- public abstract void setAuthorizationEntry(Entry
- authorizationEntry);
+ void setAuthorizationEntry(Entry authorizationEntry);
/**
* Retrieves the authorization DN for this operation. In many
@@ -466,7 +456,7 @@
* @return The authorization DN for this operation, or the null DN
* if it should be the unauthenticated user..
*/
- public abstract DN getAuthorizationDN();
+ DN getAuthorizationDN();
/**
* Retrieves the set of attachments defined for this operation, as a
@@ -474,35 +464,38 @@
*
* @return The set of attachments defined for this operation.
*/
- public abstract Map<String, Object> getAttachments();
+ Map<String, Object> getAttachments();
/**
* Retrieves the attachment with the specified name.
*
+ * @param <T> the type of the attached object
* @param name The name for the attachment to retrieve. It will
* be treated in a case-sensitive manner.
*
* @return The requested attachment object, or {@code null} if it
* does not exist.
*/
- public abstract Object getAttachment(String name);
+ <T> T getAttachment(String name);
/**
* Removes the attachment with the specified name.
*
+ * @param <T> the type of the attached object
* @param name The name for the attachment to remove. It will be
* treated in a case-sensitive manner.
*
* @return The attachment that was removed, or {@code null} if it
* does not exist.
*/
- public abstract Object removeAttachment(String name);
+ <T> T removeAttachment(String name);
/**
* Sets the value of the specified attachment. If an attachment
* already exists with the same name, it will be replaced.
* Otherwise, a new attachment will be added.
*
+ * @param <T> the type of the attached object
* @param name The name to use for the attachment.
* @param value The value to use for the attachment.
*
@@ -510,14 +503,14 @@
* name, or {@code null} if there was previously no such
* attachment.
*/
- public abstract Object setAttachment(String name, Object value);
+ <T> T setAttachment(String name, Object value);
/**
* Retrieves the time that processing started for this operation.
*
* @return The time that processing started for this operation.
*/
- public abstract long getProcessingStartTime();
+ long getProcessingStartTime();
/**
* Retrieves the time that processing stopped for this operation.
@@ -526,7 +519,7 @@
*
* @return The time that processing stopped for this operation.
*/
- public abstract long getProcessingStopTime();
+ long getProcessingStopTime();
/**
* Retrieves the length of time in milliseconds that the server
@@ -536,7 +529,7 @@
* @return The length of time in milliseconds that the server spent
* processing this operation.
*/
- public abstract long getProcessingTime();
+ long getProcessingTime();
/**
* Retrieves the length of time in nanoseconds that
@@ -548,14 +541,14 @@
* spent processing this operation or -1 if its not
* available.
*/
- public abstract long getProcessingNanoTime();
+ long getProcessingNanoTime();
/**
* Indicates that processing on this operation has completed
* successfully and that the client should perform any associated
* cleanup work.
*/
- public abstract void operationCompleted();
+ void operationCompleted();
/**
* Attempts to cancel this operation before processing has
@@ -567,7 +560,7 @@
* @return A code providing information on the result of the
* cancellation.
*/
- public abstract CancelResult cancel(CancelRequest cancelRequest);
+ CancelResult cancel(CancelRequest cancelRequest);
/**
* Attempts to abort this operation before processing has
@@ -576,8 +569,7 @@
* @param cancelRequest Information about the way in which the
* operation should be canceled.
*/
- public abstract void abort(CancelRequest cancelRequest);
-
+ void abort(CancelRequest cancelRequest);
/**
* Retrieves the cancel request that has been issued for this
@@ -588,7 +580,7 @@
* operation, or {@code null} if there has not been any
* request to cancel.
*/
- public abstract CancelRequest getCancelRequest();
+ CancelRequest getCancelRequest();
/**
* Retrieves the cancel result for this operation.
@@ -597,15 +589,14 @@
* {@code null} if the operation has not seen and reacted
* to a cancel request.
*/
- public abstract CancelResult getCancelResult();
+ CancelResult getCancelResult();
/**
* Retrieves a string representation of this operation.
*
* @return A string representation of this operation.
*/
- @Override
- public abstract String toString();
+ @Override String toString();
/**
* Appends a string representation of this operation to the provided
@@ -614,7 +605,7 @@
* @param buffer The buffer into which a string representation of
* this operation should be appended.
*/
- public abstract void toString(StringBuilder buffer);
+ void toString(StringBuilder buffer);
/**
* Indicates whether this operation needs to be synchronized to
@@ -624,7 +615,7 @@
* synchronized, or {@code false} if it should be
* synchronized.
*/
- public abstract boolean dontSynchronize();
+ boolean dontSynchronize();
/**
* Set the attachments to the operation.
@@ -632,8 +623,7 @@
* @param attachments - Attachments to register within the
* operation
*/
- public abstract void setAttachments(Map<String,
- Object> attachments);
+ void setAttachments(Map<String, Object> attachments);
/**
* Checks to see if this operation requested to cancel in which case
@@ -647,8 +637,7 @@
* @throws CanceledOperationException if this operation should
* be cancelled.
*/
- public void checkIfCanceled(boolean signalTooLate)
- throws CanceledOperationException;
+ void checkIfCanceled(boolean signalTooLate) throws CanceledOperationException;
/**
* Registers a callback which should be run once this operation has
@@ -658,7 +647,7 @@
* The callback to be run once this operation has completed
* and the response sent back to the client.
*/
- public void registerPostResponseCallback(Runnable callback);
+ void registerPostResponseCallback(Runnable callback);
/**
* Performs the work of actually processing this operation. This should
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/operation/PluginOperation.java b/opendj3-server-dev/src/server/org/opends/server/types/operation/PluginOperation.java
index 00dcda4..29ec99a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/operation/PluginOperation.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/operation/PluginOperation.java
@@ -25,17 +25,18 @@
* Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.types.operation;
-import org.forgerock.i18n.LocalizableMessage;
-
-
import java.util.List;
import java.util.Map;
+import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.api.ClientConnection;
-import org.opends.server.types.*;
import org.opends.server.controls.ControlDecoder;
-
+import org.opends.server.types.CanceledOperationException;
+import org.opends.server.types.Control;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.DisconnectReason;
+import org.opends.server.types.OperationType;
/**
* This class defines a set of methods that are available for use by
@@ -57,7 +58,7 @@
*
* @return The operation type for this operation.
*/
- public OperationType getOperationType();
+ OperationType getOperationType();
@@ -68,14 +69,14 @@
* @return The client connection with which this operation is
* associated.
*/
- public ClientConnection getClientConnection();
+ ClientConnection getClientConnection();
/**
* Terminates the client connection being used to process this
* operation. The plugin must return a result indicating that the
- * client connection has been teriminated.
+ * client connection has been terminated.
*
* @param disconnectReason The disconnect reason that provides the
* generic cause for the disconnect.
@@ -86,9 +87,7 @@
* may be <CODE>null</CODE> if no
* notification is to be sent.
*/
- public void disconnectClient(DisconnectReason disconnectReason,
- boolean sendNotification,
- LocalizableMessage message);
+ void disconnectClient(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message);
@@ -99,7 +98,7 @@
* @return The unique identifier that is assigned to the client
* connection that submitted this operation.
*/
- public long getConnectionID();
+ long getConnectionID();
@@ -108,7 +107,7 @@
*
* @return The operation ID for this operation.
*/
- public long getOperationID();
+ long getOperationID();
@@ -117,7 +116,7 @@
*
* @return The message ID assigned to this operation.
*/
- public int getMessageID();
+ int getMessageID();
@@ -128,7 +127,7 @@
* @return The set of controls included in the request from the
* client.
*/
- public List<Control> getRequestControls();
+ List<Control> getRequestControls();
@@ -145,8 +144,7 @@
* @throws DirectoryException
* if an error occurs while decoding the control.
*/
- public <T extends Control> T getRequestControl(ControlDecoder<T> d)
- throws DirectoryException;
+ <T extends Control> T getRequestControl(ControlDecoder<T> d) throws DirectoryException;
@@ -157,7 +155,7 @@
* @return The set of controls to include in the response to the
* client.
*/
- public List<Control> getResponseControls();
+ List<Control> getResponseControls();
@@ -168,7 +166,7 @@
* @return <CODE>true</CODE> if this is an internal operation, or
* <CODE>false</CODE> if it is not.
*/
- public boolean isInternalOperation();
+ boolean isInternalOperation();
@@ -179,7 +177,7 @@
* @return <CODE>true</CODE> if this is a data synchronization
* operation, or <CODE>false</CODE> if it is not.
*/
- public boolean isSynchronizationOperation();
+ boolean isSynchronizationOperation();
@@ -189,33 +187,35 @@
*
* @return The set of attachments defined for this operation.
*/
- public Map<String,Object> getAttachments();
+ Map<String,Object> getAttachments();
/**
* Retrieves the attachment with the specified name.
*
+ * @param <T> the type of the attached object
* @param name The name for the attachment to retrieve. It will
* be treated in a case-sensitive manner.
*
* @return The requested attachment object, or <CODE>null</CODE> if
* it does not exist.
*/
- public Object getAttachment(String name);
+ <T> T getAttachment(String name);
/**
* Removes the attachment with the specified name.
*
+ * @param <T> the type of the attached object
* @param name The name for the attachment to remove. It will be
* treated in a case-sensitive manner.
*
* @return The attachment that was removed, or <CODE>null</CODE> if
* it does not exist.
*/
- public Object removeAttachment(String name);
+ <T> T removeAttachment(String name);
@@ -224,6 +224,7 @@
* already exists with the same name, it will be replaced.
* Otherwise, a new attachment will be added.
*
+ * @param <T> the type of the attached object
* @param name The name to use for the attachment.
* @param value The value to use for the attachment.
*
@@ -231,7 +232,7 @@
* name, or <CODE>null</CODE> if there was previously no
* such attachment.
*/
- public Object setAttachment(String name, Object value);
+ <T> T setAttachment(String name, Object value);
@@ -240,7 +241,7 @@
*
* @return The time that processing started for this operation.
*/
- public long getProcessingStartTime();
+ long getProcessingStartTime();
@@ -249,7 +250,8 @@
*
* @return A string representation of this operation.
*/
- public String toString();
+ @Override
+ String toString();
@@ -260,7 +262,7 @@
* @param buffer The buffer into which a string representation of
* this operation should be appended.
*/
- public void toString(StringBuilder buffer);
+ void toString(StringBuilder buffer);
@@ -276,7 +278,6 @@
* @throws CanceledOperationException if this operation should
* be cancelled.
*/
- public void checkIfCanceled(boolean signalTooLate)
- throws CanceledOperationException;
+ void checkIfCanceled(boolean signalTooLate) throws CanceledOperationException;
}
--
Gitblit v1.10.0