Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] StyleContent vs IPersister<T>

Okay a bit more detail:
- Layer uses SimpleBlackBoard which does not offer persistence; and StyleBlackBoardImpl which does
- Map uses BlackBoardImpl which uses IPersister

I have been adding a bunch of try/catch/finally code and generally making these persistence mechanisms a more reliable.
Jody

On 16/05/2010, at 11:02 AM, Jody Garnett wrote:

So I was tripping up on the fact that the layer blackboard (and map blackboard) are now persisted.

The two blackboards use different mechanisms:

StyleContent
- getId()
- StyleContent(String)
- getStyleClass()
- save(IMemento, Object)
- load(IMemento)
- load(URL, IProgressMonitor)
- createDefaultStyle(IGeoResource, Color, IProgressMonitor)

IPersister<T>
- setExtension(IExtension)
- getExtension()
- getPersistee()
- load(IMemento)
- save(T, IMemento)

Notes:
- main actual difference in their intent is the need of a StyleContent to make a good default style, and the possibility of it making a style from a provided URL.
- I would like to hava StyleContent extend IPersister to cut down on duplication.

There have also been a couple of attempts at persisting things "by default" even if a programmer has not explicitly provided instructions.

In BlackboardImpl there is an else statement that uses serializable:

// try serializability
if (entry.getObjectClass() != null
        && entry.getObjectClass().isAssignableFrom(Serializable.class)) {
    ByteArrayInputStream bin = new ByteArrayInputStream(memento2
            .getBytes());
    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(
            bin));
    object = in.readObject();
    in.close();

    entry.setObject(object);
    entry.setObjectClass(object.getClass());
} else {
    // either object not serializable, or type can not
    // derminated
}

Notes:
-The above code was commented out as the renderer was using it to keep a String of the last renderer chosen preventing render metics based switch overs from occurring)
- There is one ColorPersister implemented for uDig

In StyleBlackboard I have added a StyleContent.DEFAULT that performs a similar function.



Back to the top