blob: 9499191645d7c22ef38fb97cda35edf1657fa75a [file] [log] [blame]
// Copyright 2007, 2008 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry5.internal.services;
import org.apache.tapestry5.ComponentEventCallback;
import static org.apache.tapestry5.ioc.internal.util.Defense.notNull;
import org.apache.tapestry5.runtime.Event;
public class EventImpl implements Event
{
private boolean aborted;
private String methodDescription;
private final ComponentEventCallback handler;
public EventImpl(ComponentEventCallback handler)
{
this.handler = notNull(handler, "handler");
}
public boolean isAborted()
{
return aborted;
}
public void setMethodDescription(String methodDescription)
{
this.methodDescription = methodDescription;
}
@SuppressWarnings("unchecked")
public boolean storeResult(Object result)
{
// Given that this method is *only* invoked from code
// that is generated at runtime and proven to be correct,
// this should never, ever happen. But what the hell,
// let's check anyway.
if (aborted) throw new IllegalStateException(ServicesMessages
.componentEventIsAborted(methodDescription));
if (result != null) aborted |= handler.handleResult(result);
return aborted;
}
protected String getMethodDescription()
{
return methodDescription;
}
}