jadex.bridge.sensor.service.ExecutionTimeProperty Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.sensor.service;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import jadex.bridge.IInternalAccess;
import jadex.bridge.ProxyFactory;
import jadex.bridge.sensor.time.TimedProperty;
import jadex.bridge.service.IService;
import jadex.bridge.service.IServiceIdentifier;
import jadex.bridge.service.component.IProvidedServicesFeature;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.component.ServiceInvocationContext;
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.clock.IClockService;
import jadex.commons.MethodInfo;
import jadex.commons.future.IFuture;
/**
* Property for the overall execution time of a method or a service.
*/
public class ExecutionTimeProperty extends TimedProperty
{
/** The name of the property. */
public static final String NAME = "waiting time";
/** The service identifier. */
protected IServiceIdentifier sid;
/** The listener. */
protected IMethodInvocationListener listener;
/** The method info. */
protected MethodInfo method;
/** The clock. */
protected IClockService clock;
/**
* Create a new property.
*/
public ExecutionTimeProperty(final IInternalAccess comp, IService service, MethodInfo method)
{
super(NAME, comp, true);
this.method = method;
if(service!=null)
{
this.sid = service.getServiceId();
clock = comp.getFeature(IRequiredServicesFeature.class).getLocalService(new ServiceQuery<>(IClockService.class));
if(ProxyFactory.isProxyClass(service.getClass()))
{
listener = new UserMethodInvocationListener(new IMethodInvocationListener()
{
Map