Skip to content

Use OGNL more pervasively throughout Mallet #3

@RoganDawes

Description

@RoganDawes

It is looking like OGNL actually provides a lot of capability that could be useful throughout Mallet. From defining Object -> byte[] -> Object pipelines for persistence purposes, as well as Object.toString() implementations, as well as Handler initialiser strings instead of the existing InstanceFactory implementation.

For example, to provide two lists of ChannelHandler instances to convert String -> byte[] -> String, and an expression to convert the Object to a String evaluate

java.lang.String.encode = "{ new io.netty.codec.handler.string.StringEncoder(@io.netty.util.CharSetUtil@UTF_8)} "
java.lang.String.decode = "{ new io.netty.codec.handler.string.StringDecoder(@io.netty.util.CharSetUtil@UTF_8)} "
java.lang.String.toString = "toString()"

Encoders/Decoders/toString() expressions for ByteBuf and byte[] should probably be hard coded given how fundamental they are, but it should be possible to do something like:

toString = @io.netty.buffer.ByteBufUtil@isText(#root,@io.netty.util.CharsetUtil@UTF_8) ? #root.retainedDuplicate().toString(@io.netty.util.CharsetUtil@UTF_8) : @io.netty.buffer.ByteBufUtil@prettyHexDump(#root, #root.readerIndex,@java.lang.Math@min(16, #root.readableBytes)).split("\n")[3]

Turns out that ByteBufUtil.isText() is not particularly useful, when it comes to detecting special characters. May need to provide a more useful ByteProcessor.

OGNL expressions could also be used to implement searching and filtering on connections, with some supporting infrastructure. e.g. show only connections that have instances of a particular class/interface being read or written through them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions