> I have following Problem.
> I am developing entity bean which should handle big amounts of data. I
> don't want to ship this data in a byte array, but to pass an remote
> InputStream to this data. Is there a way to do it without creating own
> Socket conection (this causes a security leak).
> I am affraid there is not other solution, but maybe somebody
> of you had
> similar problem and could point me to a better solution.

If you create your own subclass of InputStream this should be no problem.
This EntityInputStream should be serializable, and hold the entity remote
reference and current location in the stream. For example

class EntityInputStream extends InputStream implements Serializable {

    private MyEntity entity;
    private long pos;

    public int read() {
        ...
    }

    public int read(byte[] buf, inf off, int len) {
        byte[] result = entity.fetchBytes(pos, len);
          pos += len;
        ...
    }

}

You would initialize the EntityInputStream in the entity itself:

class MyEntityBean implements EntityBean {

    public InputStream getInputStream() {
        return new EntityInputStream((MyEntity)context.getEJBObject());
    }

    public byte[] fetch(long pos, int len) {
        ...
    }
}

It is important to keep the state (the 'pos' member) in the client, so that
you can have multiple clients for the same entity. Also, there's nowhere to
store that state during passivation.


- Avi
--
s/\be(\w+)/e-\1/g;

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to