Пример #1
0
  public Value receive(Env env, @Optional("1") long timeout) throws JMSException {
    Message message = _consumer.receive(timeout);

    if (message == null) return BooleanValue.FALSE;

    if (message instanceof ObjectMessage) {
      Object object = ((ObjectMessage) message).getObject();

      return env.wrapJava(object);
    } else if (message instanceof TextMessage) {
      return env.createString(((TextMessage) message).getText());
    } else if (message instanceof StreamMessage) {
      Object object = ((StreamMessage) message).readObject();

      return env.wrapJava(object);
    } else if (message instanceof BytesMessage) {
      BytesMessage bytesMessage = (BytesMessage) message;
      int length = (int) bytesMessage.getBodyLength();

      StringValue bb = env.createBinaryBuilder(length);

      TempBuffer tempBuffer = TempBuffer.allocate();
      int sublen;

      while (true) {
        sublen = bytesMessage.readBytes(tempBuffer.getBuffer());

        if (sublen > 0) bb.append(tempBuffer.getBuffer(), 0, sublen);
        else break;
      }

      TempBuffer.free(tempBuffer);

      return bb;
    } else if (message instanceof MapMessage) {
      MapMessage mapMessage = (MapMessage) message;

      Enumeration mapNames = mapMessage.getMapNames();

      ArrayValue array = new ArrayValueImpl();

      while (mapNames.hasMoreElements()) {
        String name = mapNames.nextElement().toString();

        Object object = mapMessage.getObject(name);

        array.put(env.createString(name), env.wrapJava(object));
      }

      return array;
    } else {
      return BooleanValue.FALSE;
    }
  }
Пример #2
0
  public static Value __construct(Env env, @Optional String queueName) {
    JMSQueue queue = JMSModule.message_get_queue(env, queueName, null);

    if (queue == null) {
      env.warning(L.l("'{0}' is an unknown JMSQueue", queueName));
      return NullValue.NULL;
    }

    return env.wrapJava(queue);
  }
Пример #3
0
  private void getNamespaces(Env env, ArrayValue array) {
    if (_namespaceMap != null) {
      for (Map.Entry<String, String> entry : _namespaceMap.entrySet()) {
        StringValue name = env.createString(entry.getKey());
        StringValue uri = env.createString(entry.getValue());

        SimpleXMLAttribute attr = new SimpleXMLAttribute(env, _cls, this, entry.getKey());
        attr.setText(uri);

        array.append(name, env.wrapJava(attr));
      }
    }
  }
Пример #4
0
 @Override
 public Value unmarshal(Env env, FeatureExpr ctx, Object value) {
   return env.wrapJava(value, _def, _isUnmarshalNullAsFalse);
 }
Пример #5
0
 @Override
 public Value unmarshal(Env env, FeatureExpr ctx, Object value) {
   return env.wrapJava(value);
 }