Package org.jgrapes.webconsole.base
Class KVStoreBasedConsolePolicy
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.webconsole.base.KVStoreBasedConsolePolicy
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
A component that restores the console layout
using key/value events for persisting the data between sessions.
This component requires another component that handles the key/value
store events (KeyValueStoreUpdate
, KeyValueStoreQuery
)
used by this component for implementing persistence. When the web console
becomesready, this policy sends a query for the persisted data.
When the web console has been prepared, the policy sends the last layout as retrieved from persistent storage to the web console and then generates render events for all web console components contained in this layout.
Each time the layout is changed in the web console, the web console sends the new layout data and this component updates the persistent storage accordingly.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final com.fasterxml.jackson.databind.ObjectMapper
The mapper. -
Constructor Summary
ConstructorDescriptionCreates a new component with its channel set to itself.KVStoreBasedConsolePolicy
(Channel componentChannel) Creates a new component with its channel set to the given channel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
onConsoleLayoutChanged
(ConsoleLayoutChanged event, ConsoleConnection channel) Forward layout changed event to browser session scoped storage.void
onConsolePrepared
(ConsolePrepared event, ConsoleConnection channel) Create browser session scoped storage and forward event to it.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
mapper
The mapper.
-
-
Constructor Details
-
KVStoreBasedConsolePolicy
public KVStoreBasedConsolePolicy()Creates a new component with its channel set to itself. -
KVStoreBasedConsolePolicy
Creates a new component with its channel set to the given channel.- Parameters:
componentChannel
-
-
-
Method Details
-
onConsolePrepared
Create browser session scoped storage and forward event to it.- Parameters:
event
- the eventchannel
- the channel
-
onConsoleLayoutChanged
@Handler public void onConsoleLayoutChanged(ConsoleLayoutChanged event, ConsoleConnection channel) throws IOException Forward layout changed event to browser session scoped storage.- Parameters:
event
- the eventchannel
- the channel- Throws:
IOException
- Signals that an I/O exception has occurred.
-