jadex.bridge.sensor.service.LatencyProperty 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.ServiceInvocationContext;
import jadex.commons.MethodInfo;
import jadex.commons.future.IFuture;
/**
* Property for the overall latency a service call.
*
* Computes endtime-starttime-methodexetime
*
* The local method execution time is measured locally and
* stored as non-functional property in the call context.
*/
public class LatencyProperty extends TimedProperty
{
/** The name of the property. */
public static final String NAME = "latency";
/** The service identifier. */
protected IServiceIdentifier sid;
/** The listener. */
protected IMethodInvocationListener listener;
/** The method info. */
protected MethodInfo method;
/**
* Create a new property.
*/
public LatencyProperty(IInternalAccess comp, IService service, MethodInfo method)
{
super(NAME, comp, true);
this.method = method;
// Necessary for unbound required service property to fetch meta info :-(
if(service!=null)
{
this.sid = service.getServiceId();
if(ProxyFactory.isProxyClass(service.getClass()))
{
listener = new UserMethodInvocationListener(new IMethodInvocationListener()
{
Map