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; } }
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); }
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)); } } }
@Override public Value unmarshal(Env env, FeatureExpr ctx, Object value) { return env.wrapJava(value, _def, _isUnmarshalNullAsFalse); }
@Override public Value unmarshal(Env env, FeatureExpr ctx, Object value) { return env.wrapJava(value); }