final ServiceDescription service = new ServiceDescription(descs.get(0)); service.setServiceFactory(true); service.addInterface(i);
final ServiceDescription sd = new ServiceDescription(cad); sd.addInterface("javax.servlet.Servlet"); classDescription.add(sd);
/** * Process service directives */ private void processServices(final ClassDescription current, final ComponentContainer component) { final ServiceDescription serviceDesc = current.getDescription(ServiceDescription.class); if ( serviceDesc != null ) { ServiceDescription service = component.getServiceDescription(); if ( service == null ) { service = new ServiceDescription(serviceDesc.getAnnotation()); service.setServiceFactory(false); component.setServiceDescription(service); } if ( serviceDesc.isServiceFactory() ) { service.setServiceFactory(true); } for(final String className : serviceDesc.getInterfaces()) { service.addInterface(className); } } }
@Override public AbstractDescription clone() { final ServiceDescription cd = new ServiceDescription(this.annotation); cd.setServiceFactory(this.isServiceFactory); for(final String i : this.getInterfaces()) { cd.addInterface(i); } return cd; } }
DFAgentDescription template = new DFAgentDescription(); ServiceDescription sd= new ServiceDescription(); sd.setType(Service); sd.setName(agentName); template.addServices(sd); try { DFAgentDescription[] result = DFService.search(this, template); listAgents.clear(); for(int i = 0; i<result.length;++i) { listAgents.addElement(result[i].getName()); } //System.out.println(listAgents); } catch (FIPAException e) { // TODO Auto-generated catch block e.printStackTrace(); log(this.getAID() +"!!error in requesting service ="+Service); } return (AID) listAgents.get(0);
ServiceDescription templateSd = new ServiceDescription(); templateSd.setType("weather-forecast"); templateSd.addProperties(new Property("country", "Italy")); template.addServices(templateSd); DFAgentDescription dfd = new DFAgentDescription(); dfd.setName(getAID()); ServiceDescription sd = new ServiceDescription(); sd.setName(serviceName); sd.setType("weather-forecast2"); ServiceDescription sd = new ServiceDescription(); sd.setName(getLocalName() + "-sub-df"); sd.setType("fipa-df");
/** * Recursively add interfaces to the service. */ private void addInterfaces(final ServiceDescription service, final Class<?> javaClass) { if (javaClass != null) { final Class<?>[] interfaces = javaClass.getInterfaces(); for (final Class<?> i : interfaces) { service.addInterface(i.getName()); // recursivly add interfaces implemented by this interface this.addInterfaces(service, i); } // try super class this.addInterfaces(service, javaClass.getSuperclass()); } }
/** * Write the xml for a service. * * @param service * @param contentHandler * @throws SAXException */ private static void generateServiceXML( final ServiceDescription service, final ContentHandler contentHandler, final int indent) throws SAXException { final AttributesImpl ai = new AttributesImpl(); IOUtils.addAttribute(ai, SERVICE_ATTR_FACTORY, String.valueOf(service.isServiceFactory())); IOUtils.indent(contentHandler, indent); contentHandler.startElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.SERVICE, ComponentDescriptorIO.SERVICE_QNAME, ai); if (service.getInterfaces() != null && service.getInterfaces().size() > 0) { IOUtils.newline(contentHandler); for (final String interf : service.getInterfaces()) { generateServiceXML(interf, contentHandler, indent+1); } IOUtils.indent(contentHandler, indent); } contentHandler.endElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.SERVICE, ComponentDescriptorIO.SERVICE_QNAME); IOUtils.newline(contentHandler); }
/** * Validate the service and its interfaces * If errors occur a message is added to the issues list, * warnings can be added to the warnings list. */ private void validateService(final ServiceDescription service) throws SCRDescriptorException { for (final String interfaceName : service.getInterfaces()) { if (this.container.getClassDescription().getDescribedClass().isInterface()) { this.logError(service, "Must be declared in a Java class - not an interface"); } else { try { final Class<?> interfaceClass = project.getClassLoader().loadClass(interfaceName); if (!interfaceClass.isAssignableFrom(this.container.getClassDescription().getDescribedClass())) { // interface not implemented this.logError(service, "Class must implement provided interface " + interfaceName); } } catch (final ClassNotFoundException cnfe) { throw new SCRDescriptorException("Unable to load interface class.", cnfe); } } } }
final ServiceDescription sd = new ServiceDescription(cad); sd.addInterface("javax.servlet.Filter"); classDescription.add(sd);
protected void setup() { ... // Register the book-selling service in the yellow pages DFAgentDescription dfd = new DFAgentDescription(); dfd.setName(getAID()); ServiceDescription sd = new ServiceDescription(); sd.setType("book-selling"); sd.setName("JADE-book-trading"); dfd.addServices(sd); try { DFService.register(this, dfd); } catch (FIPAException fe) { fe.printStackTrace(); } ... }
if (this.container.getServiceDescription().getInterfaces().size() == 0) { this.logError(component, "Service interface information is missing!"); isServiceFactory = this.container.getServiceDescription().isServiceFactory();
for(final String interfaceName : container.getServiceDescription().getInterfaces()) { try { final Class<?> interfaceClass = project.getClassLoader().loadClass(interfaceName);
this.currentService = new ServiceDescription(null); this.currentService.setServiceFactory(Boolean.valueOf(attributes.getValue(SERVICE_ATTR_FACTORY))); this.currentService.addInterface(attributes.getValue(INTERFACE_ATTR_NAME));
final ServiceDescription sd = new ServiceDescription(cad); sd.addInterface(HealthCheck.class.getName()); classDescription.add(sd);
final ServiceDescription serviceDesc = new ServiceDescription(cad); describedClass.add(serviceDesc); serviceDesc.addInterface(name); serviceDesc.setServiceFactory(cad.getBooleanValue("servicefactory", false));