private void destroyBeans(Map<String,Object> viewMap,Map<String,ViewScopeContextObject> contextMap){
  ArrayList<String> removalNameList=new ArrayList<>();
  if (contextMap != null) {
    for (    Map.Entry<String,ViewScopeContextObject> entry : contextMap.entrySet()) {
      String passivationCapableId=entry.getKey();
      Contextual contextual=beanManager.getPassivationCapableBean(passivationCapableId);
      ViewScopeContextObject contextObject=entry.getValue();
      CreationalContext creationalContext=beanManager.createCreationalContext(contextual);
      contextual.destroy(viewMap.get(contextObject.getName()),creationalContext);
      removalNameList.add(contextObject.getName());
    }
    Iterator<String> removalNames=removalNameList.iterator();
    while (removalNames.hasNext()) {
      String name=removalNames.next();
      viewMap.remove(name);
    }
    contextMap.clear();
  }
}

private void destroyBeans ( Map < String , Object > viewMap , Map < String , ViewScopeContextObject > contextMap ) { ArrayList < String > removalNameList = new ArrayList < > ( ) ; if ( contextMap != null ) { for ( Map . Entry < String , ViewScopeContextObject > entry : contextMap . entrySet ( ) ) { String passivationCapableId = entry . getKey ( ) ; Contextual contextual = beanManager . getPassivationCapableBean ( passivationCapableId ) ; ViewScopeContextObject contextObject = entry . getValue ( ) ; CreationalContext creationalContext = beanManager . createCreationalContext ( contextual ) ; contextual . destroy ( viewMap . get ( contextObject . getName ( ) ) , creationalContext ) ; removalNameList . add ( contextObject . getName ( ) ) ; } Iterator < String > removalNames = removalNameList . iterator ( ) ; while ( removalNames . hasNext ( ) ) { String name = removalNames . next ( ) ; viewMap . remove ( name ) ; } contextMap . clear ( ) ; } }
destroy the view scoped beans for the given view and context map .
