/** * A minimal micro agent. */ @Agent public class MinimalAgent { }
Boolean susp = val.suspend().toBoolean(); Boolean mast = val.master().toBoolean(); Boolean daem = val.daemon().toBoolean(); Boolean auto = val.autoshutdown().toBoolean(); Boolean sync = val.synchronous().toBoolean(); Boolean persist = val.persistable().toBoolean(); Boolean keep = val.keepalive().toBoolean(); PublishEventLevel moni = val.monitoring(); if(!PublishEventLevel.NULL.equals(moni)) if(isAnnotationPresent(clazz, Agent.class, cl) && getAnnotation(clazz, Agent.class, cl).autoprovide() && !serifaces.isEmpty())
Boolean susp = val.suspend().toBoolean(); Boolean mast = val.master().toBoolean(); Boolean daem = val.daemon().toBoolean(); Boolean auto = val.autoshutdown().toBoolean(); PublishEventLevel moni = val.monitoring(); Boolean sync = val.synchronous().toBoolean(); if(susp!=null) if(isAnnotationPresent(clazz, Agent.class, cl) && getAnnotation(clazz, Agent.class, cl).autoprovide() && !serifaces.isEmpty())
public void customResultAvailable(Tuple2<Method, Object> res) { // Only end body if future or void and kill is true Boolean found = null; Method method = res!=null? res.getFirstEntity(): null; if(method!=null) { if(SReflect.isSupertype(IFuture.class, method.getReturnType())) { found = Boolean.TRUE; } else if(void.class.equals(method.getReturnType())) { AgentBody ab = method.getAnnotation(AgentBody.class); found = ab.keepalive()? Boolean.FALSE: Boolean.TRUE; } } else { Agent ag = agent.getClass().getAnnotation(Agent.class); found = ag.keepalive()? Boolean.FALSE: Boolean.TRUE; } if(found!=null && found.booleanValue()) ret.setResult(null); } }));
/** * Just a simple agent that holds remote platform proxies. */ @Agent public class RemotePlatformAgent { }
/** * The invocation agent is used to execute the * synchronous web service call. The agent is * blocked during the call is running. For each * call a new invocation agent is used. */ @Agent public class WebServiceInvocationAgent { }
/** * Just a simple agent that holds remote platform proxies. */ @Agent public class RemotePlatformAgent { }
/** * The invocation agent is used to execute the * synchronous web service call. The agent is * blocked during the call is running. For each * call a new invocation agent is used. */ @Agent public class RestServiceInvocationAgent { }
@Agent public class EmptyCAgent { }
@Agent public class EmptyAAgent { }
@Agent public class EmptyBAgent { }
/** * Test what happens if an exception is thrown in body. */ @Agent public class BodyExceptionAgent { /** * The agent body. */ @AgentBody public IFuture<Void> executeBody() { // System.out.println("execute ExceptionTest ..."); throw new RuntimeException("Exception in agent body"); // System.out.println("... finished"); } }
@Agent public class BlockingBenchmarkBDI extends BlockingSokratesBDI { /** * Overwrite wait time. */ public BlockingBenchmarkBDI() { delay = 0; } /** * Overridden to skip gui creation. */ protected void createGui(IInternalAccess agent) { } }
/** * Simple agent that offers the math service. */ @Agent public class MathAgent { @Agent protected IInternalAccess agent; /** * Called once after agent creation. */ @AgentCreated public IFuture<Void> agentCreated() { //agent.getComponentFeature(IProvidedServicesFeature.class) agent.getComponentFeature(IProvidedServicesFeature.class).addService("mathservice", IMathService.class, new MathService(agent.getComponentIdentifier()), BasicServiceInvocationHandler.PROXYTYPE_DIRECT); return IFuture.DONE; } }
@Agent public class BenchmarkBDI extends SokratesBDI { /** * Overwrite wait time. */ public BenchmarkBDI() { delay = 0; } /** * Overridden to skip gui creation. */ protected void createGui(IInternalAccess agent) { } }
/** * Agent that tests if bdi agent factory detects non-enhanced bdi classes. */ @Agent public class NotEnhancedBDI { /** The injected agent (not injected when not enhanced). */ @Agent protected IInternalAccess agent; /** * The agent body. */ @AgentBody public void body() { if(agent==null) { throw new RuntimeException("Agent class was not enhaned but creation was initiated."); } } }
/** * Test what happens if an exception is thrown in body. */ @Agent public class PojoBodyExceptionAgent { /** * Create a new agent. */ public PojoBodyExceptionAgent() { // throw new RuntimeException("Exception in constructor"); } /** * The agent body. */ @AgentBody public void executeBody() { // System.out.println("execute ExceptionTest ..."); throw new RuntimeException("Exception in agent body"); // System.out.println("... finished"); } }
/** * Service 2 agent. * Offers service that needs long time (exceeds def timeout). */ @Service @Agent(autoprovide=true) public class Service2Agent implements IService2 { @Agent protected IInternalAccess agent; public IFuture<Void> service() { // wait longer than default 30 secs // get must set no timeout to avoid being interrupted agent.getComponentFeature(IExecutionFeature.class).waitForDelay(35000).get(); return IFuture.DONE; } }
/** * Chat micro agent. */ @Description("This agent offers a chat service.") @Agent public class ChatB2Agent { }