java - How to deal with GlazedLists's PluggableList requirement for shared publisher and lock -


I have just started using the glazed list in a Java project, which uses large-scale beansbending (MVVM pattern) Does.

PluggableList allows me to bind a source list into a table, and then change the source list on the runtime. To do this, each source list must share the same list event publisher and read-light lock, since the pluggable list needs to share a lock and public with its source. I can make it a static publisher and lock it in my class which is the owner of potential source lists, using the static values, to make the list using the class as a pluggable list, as shown in the pseudo code Is:

  public class ModelClass {last fixed EventList list = new BasicEventList (); Last Fixed ListEventPublisher LISTEVENTPUBLISHER = LIST.getPublisher (); Last Fixed ReadWriteLock READWRITELOCK = LIST.getReadWriteLock (); Final EventList sourceList = New Basic Item List (LISTEVENTPUBLISHER, READWRITELOCK); } Public class UiControllerClass {Final PluggableList pluggableList = new plug-in list (ModelClass.LISTEVENTPUBLISHER, ModelClass.READWRITELOCK); // ... call pluggableList.setSource (someSourceList)}   

I have two concerns about this:

(1) I have to make a decision in the model UiController Due to a specific requirement of a component, it seems that the MVVM pattern is violated.

(2) Share lock potentially affects the performance of lists if too many are and are accessed frequently, because they share the same lock. Each of these lists should be able to work independently, regardless of each other.

Am I going wrong about this? Is there a better way of working on a pluggable list without a model class that knows about a particular UiControllerClass requirement and without affecting the potential performance?

I came up with an elegant solution that preserves MVVM pattern as well as shared Eliminates the necessity of lock and publisher

I have created a custom list conversion which extends the pluggable list and overrides the set-source method. The new source list is then synchronized with a new list created by pluggableList (this will be locked in the same publisher and plagalable form).

  Public class HotSwappablePluggableList & lt; T & gt; Pluggable list extension & lt; T & gt; {Private event list & lt; T & gt; SyncSourceList = New Basic Items & lt; & Gt; (); Private ListEvent Listener & lt; T & gt; ListEventListener = Faucet; Public HotSpublicPlugList () {Super (New Basic Eventist & lt; T & gt; ()); } @ Override Public Own Setsource (Last Eventist & lt; T & gt; Source List) {getReadWriteLock () WriteLock () Lock (); Try {if (listEventListener! = Null) {syncSourceList.removeListEventListener (listEventListener); } SyncSourceList = sourceList; Last Event List & lt; T & gt; SyncTargetList = createSourceList (); ListEventListener = glazed lists. SyncEventList (Sync Sourlist, Syncteelist); Super.setSource (syncTargetList); } Finally {getReadWriteLock () writeLock () Unlock (); }}}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -