protected void createServiceDescription() { List<Operation> opList = new ArrayList<Operation>(); for (Method operation : this.getClass().getMethods()) { if (operation.getAnnotation(ServiceOperation.class) != null) { ServiceOperation serviceOperation = operation.getAnnotation(ServiceOperation.class); Operation op = new Operation( operation.getName(), operation.getParameterTypes(), operation.getReturnType().getName()); op.setOpCost(serviceOperation.OperationCost()); opList.add(op); } } description.setOperationList(opList); description.setServiceType(this.getClass().getSimpleName()); }
/** Helps to dynamically update the service description */ public void updateServiceDescription() { if (description.getRegisterID() > 0) this.sendRequest( ServiceRegistryInterface.NAME, ServiceRegistryInterface.ADDRESS, true, "update", this.description); else System.err.println("Service is not registered in the registy yet. It can't be updated."); }
/** Register to the service registry */ public void register() { int registerId = (int) this.sendRequest( ServiceRegistryInterface.NAME, ServiceRegistryInterface.ADDRESS, true, "register", description); this.description.setRegisterID(registerId); System.out.println( "The service " + description.getServiceType() + " has been registered. The registerID is " + this.description.getRegisterID()); }