blob: 4c5cf62e0bbfc3b9ae5b5acd44194337368b29d4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.common.utility.internal.command;
import java.io.Serializable;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.command.ExtendedCommandContext;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
/**
* Singleton implementation of the extended command context interface
* that simply executes the command without any sort of enhancement.
*/
public final class DefaultExtendedCommandContext
implements ExtendedCommandContext, Serializable
{
public static final ExtendedCommandContext INSTANCE = new DefaultExtendedCommandContext();
public static ExtendedCommandContext instance() {
return INSTANCE;
}
// ensure single instance
private DefaultExtendedCommandContext() {
super();
}
public void execute(Command command) {
command.execute();
}
public void waitToExecute(Command command) {
command.execute();
}
public boolean waitToExecute(Command command, long timeout) {
command.execute();
return true;
}
@Override
public String toString() {
return ObjectTools.singletonToString(this);
}
private static final long serialVersionUID = 1L;
private Object readResolve() {
// replace this object with the singleton
return INSTANCE;
}
}