public void initialize(int capacity) throws SessionException {
        synchronized (lock) {
            if (sessionList != null && sessionList.size() == capacity) {
                throw new java.lang.IllegalStateException("Session pool has be initialized.");
            }
            try {
                for (int i = 0; i < capacity; i++) {
                    Object obj = sessionHandler.newInstance();
                    Session session = (Session) obj;
                    session.setId(i);
                    session.setCurrentEvent(Session.Event.READ);
                    session.setIdle(true);
                    session.setReadBuffer(new IoBuffer());
                    session.setWriteBuffer(new IoBuffer());
                    sessionList.add(session);
                }
            } catch (Exception e) {
                throw new SessionException("session", e);
            }
        }
    }