We've been looking at beepcore-java but recently checked out beeplite. I read some comments somewhere that beeplite is more active and solves a number of issues with beepcore-java. However, I encountered a couple of issues on the way:
#1 InputDataStream.read fails
Say I send a MSG like this:
final Reply reply = new Reply();
channel.sendMSG(new StringOutputDataStream("text/xml", "UTF-8", "<root>This is a message from initiator to listener</root>"), reply);
And it is handled by a RequestHandler. If I try to read it via the InputStream interface, I get an exception:
public void receiveMSG(Message message) {
final InputDataStream inputDs = message.getInputStream();
try {
final StringBuffer result = new StringBuffer();
byte[] buf = new byte
1024;
int count = -1;
while ((count = inputDs.read(buf)) != -1) { // <-- Error occurs here
result.append(new String(buf, 0, count, "UTF-8"));
}
System.out.println(result);
} catch (IOException e) {
e.printStackTrace();
}
}
java.lang.StringIndexOutOfBoundsException: String index out of range: -14
at java.lang.String.checkBounds(String.java:283)
at java.lang.String.<init>(String.java:370)
at com.ibm.beeplite.MimeHeaders.a(SourceFile:265)
at com.ibm.beeplite.InputDataStream.a(SourceFile:287)
at com.ibm.beeplite.InputDataStream.a(SourceFile:267)
at com.ibm.beeplite.InputDataStream.read(SourceFile:199)
at <mypackages>.RequestHandler.receiveMSG(RequestHandler.java:42)
at com.ibm.beeplite.z.run(SourceFile:675)
at java.lang.Thread.run(Thread.java:534)
This also happens when the client receives ANS replies.
I can, of course, read the buffer segments directly, but I was actually trying to pass the InputDataStream to a method that accepts an InputStream. This works fine:
while (inputDs.segmentAvailable()) {
BufferSegment segment = inputDs.getNextSegment();
result.append(new String(segment.getData(), "UTF-8"));
}
#2 Passing empty tuning Properties to ProfileRegistry.addStartChannelListener causes the profile to not be recognized.
Say I add a listener for a profile as follows:
registry.addStartChannelListener(myUri, myStartChannelListener, new Properties());
When the client tries to open a channel with a matching URI, it fails with this exception:
com.ibm.beeplite.BEEPException: all profiles unsupported by peer
at com.ibm.beeplite.Session.a(SourceFile:772)
at com.ibm.beeplite.Session.startChannel(SourceFile:195)
at com.ibm.beeplite.Session.startChannel(SourceFile:108)
snip
Specifying null seems to work fine:
registry.addStartChannelListener(profileConfig.getUri(), profileConfig.getStartChannelListener(), null);
This was a bit surprising and not mentioned in the Javadoc, so I'm assuming it is a bug?
Finally, 2 questions:
1) Are sources available? Issues like these would be easier to troubleshoot if I could browse the source.
2) What's the likelihood of bepplite working in a J2ME environment or does anyone know of an implementation that does work in a J2ME environment?
Thanks,
Tim