protected MessageDeliverer getDeliverer() { if (deliverer == null) { ServiceBroker sb = getServiceBroker(); deliverer = sb.getService(this, MessageDeliverer.class, null); } return deliverer; }
private boolean haveServices() { if (conditionService != null) return true; if (acquireServices()) { ServiceBroker sb = getServiceBroker(); conditionService = sb.getService(this, ConditionService.class, null); return true; } return false; }
@Override public void load() { super.load(); // get root service broker ServiceBroker sb = getServiceBroker(); NodeControlService ncs = sb.getService(this, NodeControlService.class, null); if (ncs == null) { throw new RuntimeException("Unable to obtain NodeControlService"); } rootsb = ncs.getRootServiceBroker(); sb.releaseService(this, NodeControlService.class, ncs); // advertise service _sfsp = new SFSP(); _sfs = new SFS(); rootsb.addService(SocketFactoryService.class, _sfsp); }
@Override public void unload() { if (rootsb != null) { rootsb.revokeService(SocketFactoryService.class, _sfsp); } _sfsp = null; _sfs = null; super.unload(); }
public static boolean findServiceLater( final ServiceBroker sb, final Class cl, final Object requestor, final Callback cb) { final Object req = (requestor == null ? ServiceFinder.class : requestor); if (sb.hasService(cl)) { Service s = (Service) sb.getService(req, cl, null); cb.foundService(s); return true; } ServiceAvailableListener sal = new ServiceAvailableListener() { public void serviceAvailable(ServiceAvailableEvent ae) { if (cl.isAssignableFrom(ae.getService())) { Service s = (Service) sb.getService(req, cl, null); cb.foundService(s); // sb.removeServiceListener(this); } } }; sb.addServiceListener(sal); return false; }
/** Load requires services. */ public void load() { ServiceBroker sb = getBindingSite().getServiceBroker(); setAgentIdentificationService( (AgentIdentificationService) sb.getService(this, AgentIdentificationService.class, null)); setAlarmService((AlarmService) sb.getService(this, AlarmService.class, null)); setSchedulerService((SchedulerService) sb.getService(this, SchedulerService.class, null)); setBlackboardService((BlackboardService) sb.getService(this, BlackboardService.class, null)); logger = (LoggingService) sb.getService(this, LoggingService.class, null); logger = org.cougaar.core.logging.LoggingServiceWithPrefix.add(logger, agentId + ": "); uidService = (UIDService) sb.getService(this, UIDService.class, null); super.load(); }
@Override public void load() { super.load(); // we want the servlet service, but it's loaded after the MTS. // Also, we want the agent's proxy to the node-level // ServletService. The blackboard is loaded late enough, so we // wait 'til then... if (sb.hasService(BlackboardService.class)) { registerServlet(); } else { ServiceAvailableListener sal = new ServiceAvailableListener() { public void serviceAvailable(ServiceAvailableEvent ae) { Class<?> cl = ae.getService(); if (BlackboardService.class.isAssignableFrom(cl)) { registerServlet(); } } }; sb.addServiceListener(sal); } }
// Node DataScopes can be the first element in a path. They must // find or make the corresponding HostDS and return that as the // preferred parent. @Override protected ResourceContext preferredParent(RSS root) { ServiceBroker sb = (ServiceBroker) root.getProperty("ServiceBroker"); AgentTopologyService ats = sb.getService(this, AgentTopologyService.class, null); String nodename = (String) getSymbolValue(NODENAME); String hostname = null; if (ats != null) { hostname = ats.getNodeHost(MessageAddress.getMessageAddress(nodename)); } else { // AgentTopologyService not loaded. Try a direct WP // call, even though it can give an inconsistent picture. WhitePagesService svc = sb.getService(this, WhitePagesService.class, null); try { AddressEntry entry = svc.get(nodename, TOPOLOGY, -1); if (entry == null) { if (logger.isWarnEnabled()) { logger.warn("Can't find host for node " + nodename); } } else { hostname = entry.getURI().getHost(); } } catch (Exception ex) { // log this? } } String[] params = {hostname == null ? UNKNOWN_HOST_IP : hostname}; ResourceNode node = new ResourceNode(); node.kind = "Host"; node.parameters = params; ResourceNode[] path = {node}; ResourceContext parent = root.getPathContext(path); setParent(parent); return parent; }
public BlackboardQueryService getBlackboardQueryService(Object requestor) { return (BlackboardQueryService) serviceBroker.getService(requestor, BlackboardQueryService.class, null); }
public LoggingService getLoggingService(Object requestor) { return (LoggingService) serviceBroker.getService(requestor, LoggingService.class, null); }