/** * Get the agent identifier. * @return The agent identifier. */ public IComponentIdentifier getComponentIdentifier() { return agent.getComponentIdentifier(); }
/** * Get the id of the component. * @return The component id. */ public IComponentIdentifier getComponentIdentifier() { return access.getComponentIdentifier(); }
/** * Create a new synchronous executor service. */ public SyncExecutionService(IInternalAccess provider, Map<String, Object> properties) { super(provider.getComponentIdentifier(), IExecutionService.class, properties); this.provider = provider; this.state = State.CREATED; this.queue = SCollection.createLinkedHashSet(); this.removedfut = new ArrayList<Future<Void>>(); }
/** * Init method. */ @AgentCreated public void agentCreated() { System.out.println("firefly created: "+agent.getComponentIdentifier()); }
/** * Get all services of a type. // * (Returns required service proxy). * @param type The class. * @return The corresponding services. */ public static <T> ITerminableIntermediateFuture<T> getServices(final IInternalAccess component, final Class<T> type, final String scope, final IAsyncFilter<T> filter, final boolean proxy) { return getServices(component, component.getComponentIdentifier(), type, scope, filter, proxy); }
/** * Get the address book from a component. */ public static TransportAddressBook getAddressBook(IInternalAccess agent) { return getAddressBook(agent.getComponentIdentifier()); } }
/** * Create a new component factory. * @param provider The component. */ public BDIXComponentFactory(IInternalAccess provider, Map<String, Object> properties) { super(provider.getComponentIdentifier(), IComponentFactory.class, properties); this.provider = provider; this.features = SComponentFactory.orderComponentFeatures(SReflect.getUnqualifiedClassName(getClass()), Arrays.asList(SComponentFactory.DEFAULT_FEATURES, BDI_FEATURES)); }
public void exceptionOccurred(Exception exception) { if(!(exception instanceof ComponentTerminatedException) || !((ComponentTerminatedException)exception).getComponentIdentifier().equals(component.getComponentIdentifier())) { // Todo: fail fast components? StringWriter sw = new StringWriter(); exception.printStackTrace(new PrintWriter(sw)); getComponent().getLogger().severe("Exception during message processing\n"+sw); } } });
/** * Test if a component identifier is a remote component. */ protected boolean isRemoteComponent(IComponentIdentifier cid) { return !cid.getPlatformName().equals(agent.getComponentIdentifier().getName()); }
public void intermediateResultAvailable(String item) { // System.out.println("Item offered: "+item); System.out.println(agent.getComponentIdentifier()+": "+(ls.claimItem(item).get()? "I won item: ": "I did not win item: ")+item); }
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IComponentIdentifier getParentIdentifier(CreationInfo ci) { IComponentIdentifier ret = ci!=null && ci.getParent()!=null ? ci.getParent() : agent.getComponentIdentifier(); // System.out.println("parent id: "+ret); return ret; }
/** * */ protected IFuture<TestReport> testLocal(int testno) { return performTest(agent.getComponentIdentifier().getRoot(), testno); }
/** * Get an item. */ public IFuture<String> getItem() { return new Future<String>("item: "+agent.getComponentIdentifier().getName()); }
/** * Create a required service proxy. */ protected static <T> T createRequiredProxy(IInternalAccess component, T ser, Class<?> type) { return (T)BasicServiceInvocationHandler.createRequiredServiceProxy(component, (IService)ser, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(component.getComponentIdentifier())); }
/** * Test if current thread is the component thread. * @return True if the current thread is the component thread. */ public boolean isComponentThread() { return Thread.currentThread()==componentthread || IComponentDescription.STATE_TERMINATED.equals(getComponent().getComponentDescription().getState()) && Starter.isRescueThread(getComponent().getComponentIdentifier()); }
public void exceptionOccurred(Exception exception) { System.out.println(agent.getComponentFeature(IExecutionFeature.class).isComponentThread()+" "+agent.getComponentIdentifier()); agent.getComponentFeature(IArgumentsResultsFeature.class).getResults().put("testresults", tc); agent.killComponent(); } }));
public void exceptionOccurred(Exception exception) { System.out.println(agent.getComponentFeature(IExecutionFeature.class).isComponentThread()+" "+agent.getComponentIdentifier()); agent.getComponentFeature(IArgumentsResultsFeature.class).getResults().put("testresults", tc); agent.killComponent(); } }));
/** * Create a service fetcher. */ public IRequiredServiceFetcher createServiceFetcher(String name) { return new DefaultServiceFetcher(getComponent(), Starter.isRealtimeTimeout(getComponent().getComponentIdentifier())); }
/** * Add a service query to the registry. * @param type The service type. * @param scope The scope. * @param filter The filter. */ public <T> ISubscriptionIntermediateFuture<T> addQuery(Class<T> type, String scope, IAsyncFilter<T> filter) { ServiceQuery<T> query = new ServiceQuery<T>(type, scope, filter, getComponent().getComponentIdentifier()); return SynchronizedServiceRegistry.getRegistry(getComponent()).addQuery(query); } }
public void customResultAvailable(final TestReport result1) { performTestB(agent.getComponentIdentifier().getRoot(), testno+1, delay, max) .addResultListener(agent.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener<TestReport, TestReport[]>(ret) { public void customResultAvailable(final TestReport result2) { ret.setResult(new TestReport[]{result1, result2}); } })); } }));