Exemplo n.º 1
0
 /**
  * Sends an event to the registered sessions.
  *
  * @param ctx query context
  * @return event result
  * @throws QueryException query exception
  */
 private Item event(final QueryContext ctx) throws QueryException {
   final byte[] name = checkStr(expr[0], ctx);
   final ArrayOutput ao = new ArrayOutput();
   try {
     // run serialization
     final Serializer ser = Serializer.get(ao, ctx.serProp(true));
     final ValueIter ir = ctx.value(expr[1]).iter();
     for (Item it; (it = ir.next()) != null; ) it.serialize(ser);
     ser.close();
   } catch (final SerializerException ex) {
     throw ex.getCause(input);
   } catch (final IOException ex) {
     SERANY.thrw(input, ex);
   }
   // throw exception if event is unknown
   if (!ctx.context.events.notify(ctx.context, name, ao.toArray())) {
     NOEVENT.thrw(input, name);
   }
   return null;
 }