@Nonnull
  public Serializable serializeState ()
  {
    final ICommonsMap <String, Object> aState = new CommonsHashMap <> ();
    for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ())
    {
      final String sName = entry.getKey ();
      final Object aValue = entry.getValue ();
      if (aValue instanceof Serializable)
      {
        aState.put (sName, aValue);
      }
      else
      {
        // Not serializable... Servlet containers usually automatically
        // unbind the attribute in this case.
        if (aValue instanceof HttpSessionBindingListener)
        {
          ((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue));
        }
      }
    }
    m_aAttributes.clear ();
    return aState;
  }
@ Nonnull public Serializable serializeState ( ) { final ICommonsMap < String , Object > aState = new CommonsHashMap < > ( ) ; for ( final Map . Entry < String , Object > entry : m_aAttributes . entrySet ( ) ) { final String sName = entry . getKey ( ) ; final Object aValue = entry . getValue ( ) ; if ( aValue instanceof Serializable ) { aState . put ( sName , aValue ) ; } else { if ( aValue instanceof HttpSessionBindingListener ) { ( ( HttpSessionBindingListener ) aValue ) . valueUnbound ( new HttpSessionBindingEvent ( this , sName , aValue ) ) ; } } } m_aAttributes . clear ( ) ; return aState ; }
Serialize the attributes of this session into an object that can be turned
into a byte array with standard Java serialization.

@return a representation of this session's serialized state