All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.seam.async.AsynchronousEvent Maven / Gradle / Ivy

There is a newer version: 3.2.26.ayg
Show newest version
package org.jboss.seam.async;

import org.jboss.seam.core.Events;
import org.jboss.seam.util.CloneUtils;

/**
 * An asynchronous event
 * 
 * @author Gavin King
 *
 */
public class AsynchronousEvent extends Asynchronous {
	static final long serialVersionUID = 2074586442931427819L;

	private String type;
	private Object[] parameters;

	public AsynchronousEvent(String type, Object[] parameters) {
		super();
		this.type = type;
		this.parameters = CloneUtils.cloneArray(parameters);
	}

	@Override
	public void execute(Object timer) {
		new ContextualAsynchronousRequest(timer) {

			@Override
			protected void process() {
				Events.instance().raiseEvent(type, parameters);
			}

		}.run();
	}

	@Override
	public String toString() {
		return "AsynchronousEvent(" + type + ')';
	}

	protected String getType() {
		return type;
	}

	@Override
	protected void handleException(final Exception exception, Object timer) {
		new ContextualAsynchronousRequest(timer) {
			@Override
			protected void process() {
				AsynchronousExceptionHandler.instance().handleException(exception);
			}
		}.run();

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy