Exemplo n.º 1
0
 @Override
 public String negotiate(String target, Object context) {
   String res = null;
   NegotiationDescriptor negd = negReg.getNegotiation(target);
   if (negd != null) {
     List<NegotiatorDescriptor> nds = negd.getNegotiators();
     for (NegotiatorDescriptor nd : nds) {
       Class<Negotiator> ndc = nd.getNegotiatorClass();
       try {
         Negotiator neg = ndc.newInstance();
         neg.setProperties(nd.getProperties());
         res = neg.getResult(target, context);
         if (res != null) {
           break;
         }
       } catch (IllegalAccessException | InstantiationException e) {
         throw new RuntimeException(e);
       }
     }
   }
   return res;
 }