private void processEventsFromQueue(int timeoutValue, TimeUnit timeoutUnit) throws InterruptedException {
        TeamEvent event = memberQueue.getVal(timeoutValue, timeoutUnit);
        while (null != event) {
            if (TeamEvent.Type.NEW == event.type) {
                getServerDolphin().presentationModel(null, TYPE_TEAM_MEMBER, event.dto); // create on server side
            }
            if (TeamEvent.Type.CHANGE == event.type) {
                silent = true; // do not issue additional posts on the bus from value changes that come from the bus
                List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
                for (ServerAttribute attribute : attributes) {
                    PresentationModel pm = attribute.getPresentationModel();
                    if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
                        attribute.setValue(event.value);
                    }
                }
                silent = false;
            }
            if (TeamEvent.Type.REBASE == event.type) {
                List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
                for (ServerAttribute attribute : attributes) {
                    attribute.rebase();
                }
            }
            if (TeamEvent.Type.REMOVE == event.type) {
                List<ServerAttribute> attributes = getServerDolphin().findAllAttributesByQualifier(event.qualifier);
                Set<ServerPresentationModel> toDelete = new HashSet<ServerPresentationModel>();
                for (ServerAttribute attribute : attributes) {
                    ServerPresentationModel pm = attribute.getPresentationModel();
                    if (TYPE_TEAM_MEMBER.equals(pm.getPresentationModelType())) {
                        toDelete.add(pm);
                    }
                }
                for (ServerPresentationModel pm : toDelete) {
                    getServerDolphin().remove(pm);
                }
            }
            event = memberQueue.getVal(20, TimeUnit.MILLISECONDS);
        }
    }
private void processEventsFromQueue ( int timeoutValue , TimeUnit timeoutUnit ) throws InterruptedException { TeamEvent event = memberQueue . getVal ( timeoutValue , timeoutUnit ) ; while ( null != event ) { if ( TeamEvent . Type . NEW == event . type ) { getServerDolphin ( ) . presentationModel ( null , TYPE_TEAM_MEMBER , event . dto ) ; } if ( TeamEvent . Type . CHANGE == event . type ) { silent = true ; List < ServerAttribute > attributes = getServerDolphin ( ) . findAllAttributesByQualifier ( event . qualifier ) ; for ( ServerAttribute attribute : attributes ) { PresentationModel pm = attribute . getPresentationModel ( ) ; if ( TYPE_TEAM_MEMBER . equals ( pm . getPresentationModelType ( ) ) ) { attribute . setValue ( event . value ) ; } } silent = false ; } if ( TeamEvent . Type . REBASE == event . type ) { List < ServerAttribute > attributes = getServerDolphin ( ) . findAllAttributesByQualifier ( event . qualifier ) ; for ( ServerAttribute attribute : attributes ) { attribute . rebase ( ) ; } } if ( TeamEvent . Type . REMOVE == event . type ) { List < ServerAttribute > attributes = getServerDolphin ( ) . findAllAttributesByQualifier ( event . qualifier ) ; Set < ServerPresentationModel > toDelete = new HashSet < ServerPresentationModel > ( ) ; for ( ServerAttribute attribute : attributes ) { ServerPresentationModel pm = attribute . getPresentationModel ( ) ; if ( TYPE_TEAM_MEMBER . equals ( pm . getPresentationModelType ( ) ) ) { toDelete . add ( pm ) ; } } for ( ServerPresentationModel pm : toDelete ) { getServerDolphin ( ) . remove ( pm ) ; } } event = memberQueue . getVal ( 20 , TimeUnit . MILLISECONDS ) ; } }
with user interactions and is thus safe to process in a more efficient manner.