Package com.alibaba.citrus.service.requestcontext.session

Examples of com.alibaba.citrus.service.requestcontext.session.SessionStore


        SessionConfig sessionConfig = requestContext.getSessionConfig();
        String[] storeNames = sessionConfig.getStores().getStoreNames();
        Set<String> attrNames = createLinkedHashSet();

        for (String storeName : storeNames) {
            SessionStore store = sessionConfig.getStores().getStore(storeName);

            for (String attrName : store.getAttributeNames(getId(), new StoreContextImpl(storeName))) {
                if (!isEquals(attrName, modelKey)) {
                    attrNames.add(attrName);
                }
            }
        }
View Full Code Here


            String attrName = entry.getKey();
            SessionAttribute attr = entry.getValue();

            if (attr.isModified()) {
                String storeName = attr.getStoreName();
                SessionStore store = attr.getStore();
                Object[] storeInfo = stores.get(storeName);

                if (storeInfo == null) {
                    storeInfo = new Object[] { store, createHashMap() };
                    stores.put(storeName, storeInfo);
                }

                @SuppressWarnings("unchecked")
                Map<String, Object> storeAttrs = (Map<String, Object>) storeInfo[1];
                Object attrValue = attr.getValue();

                // 特殊处理model,将其转换成store中的值。
                if (attrValue instanceof SessionModel) {
                    attrValue = requestContext.getSessionConfig().getSessionModelEncoders()[0]
                            .encode((SessionModel) attrValue);
                } else {
                    // 只检查非session model对象的modified状态
                    modified = true;
                }

                storeAttrs.put(attrName, attrValue);
            }
        }

        // 如果既没有参数改变(即没有调用setAttribute和removeAttribute),
        // 也没有被清除(即没有调用invalidate和clear),并且isKeepInTouch=false,
        // 则不提交了,直接退出。
        if (!modified && !cleared && !requestContext.getSessionConfig().isKeepInTouch()) {
            return;
        }

        // 对每一个store分别操作。
        for (Map.Entry<String, Object[]> entry : stores.entrySet()) {
            String storeName = entry.getKey();
            SessionStore store = (SessionStore) entry.getValue()[0];

            @SuppressWarnings("unchecked")
            Map<String, Object> storeAttrs = (Map<String, Object>) entry.getValue()[1];

            store.commit(storeAttrs, getId(), new StoreContextImpl(storeName));
        }

        // 假如invalidate和clear被调用,则检查剩余的store,通知它们清除当前的数据。
        if (cleared) {
            if (storeNames.length > stores.size()) {
                for (String storeName : storeNames) {
                    if (!stores.containsKey(storeName)) {
                        SessionStore store = requestContext.getSessionConfig().getStores().getStore(storeName);
                        Map<String, Object> storeAttrs = emptyMap();

                        store.commit(storeAttrs, sessionID, new StoreContextImpl(storeName));
                    }
                }
            }
        }
    }
View Full Code Here

            // 通知所有的store过期其数据
            SessionConfig sessionConfig = requestContext.getSessionConfig();
            String[] storeNames = sessionConfig.getStores().getStoreNames();

            for (String storeName : storeNames) {
                SessionStore store = sessionConfig.getStores().getStore(storeName);

                store.invaldiate(sessionID, new StoreContextImpl(storeName));
            }

            // 清除model
            if (model == null) {
                model = new SessionModelImpl(SessionImpl.this);
View Full Code Here

        SessionConfig sessionConfig = requestContext.getSessionConfig();
        String[] storeNames = sessionConfig.getStores().getStoreNames();
        Set<String> attrNames = createLinkedHashSet();

        for (String storeName : storeNames) {
            SessionStore store = sessionConfig.getStores().getStore(storeName);

            for (String attrName : store.getAttributeNames(getId(), new StoreContextImpl(storeName))) {
                if (!isEquals(attrName, modelKey)) {
                    attrNames.add(attrName);
                }
            }
        }
View Full Code Here

            String attrName = entry.getKey();
            SessionAttribute attr = entry.getValue();

            if (attr.isModified()) {
                String storeName = attr.getStoreName();
                SessionStore store = attr.getStore();
                Object[] storeInfo = stores.get(storeName);

                if (storeInfo == null) {
                    storeInfo = new Object[] { store, createHashMap() };
                    stores.put(storeName, storeInfo);
                }

                @SuppressWarnings("unchecked")
                Map<String, Object> storeAttrs = (Map<String, Object>) storeInfo[1];
                Object attrValue = attr.getValue();

                // ���⴦��model������ת����store�е�ֵ��
                if (attrValue instanceof SessionModel) {
                    attrValue = requestContext.getSessionConfig().getSessionModelEncoders()[0]
                            .encode((SessionModel) attrValue);
                } else {
                    // ֻ����session model�����modified״̬
                    modified = true;
                }

                storeAttrs.put(attrName, attrValue);
            }
        }

        // �����û�в����ı䣨��û�е���setAttribute��removeAttribute����
        // Ҳû�б��������û�е���invalidate��clear��������isKeepInTouch=false��
        // ���ύ�ˣ�ֱ���˳���
        if (!modified && !cleared && !requestContext.getSessionConfig().isKeepInTouch()) {
            return;
        }

        // ��ÿһ��store�ֱ������
        for (Map.Entry<String, Object[]> entry : stores.entrySet()) {
            String storeName = entry.getKey();
            SessionStore store = (SessionStore) entry.getValue()[0];

            @SuppressWarnings("unchecked")
            Map<String, Object> storeAttrs = (Map<String, Object>) entry.getValue()[1];

            store.commit(storeAttrs, getId(), new StoreContextImpl(storeName));
        }

        // ����invalidate��clear�����ã�����ʣ���store��֪ͨ���������ǰ�����ݡ�
        if (cleared) {
            if (storeNames.length > stores.size()) {
                for (String storeName : storeNames) {
                    if (!stores.containsKey(storeName)) {
                        SessionStore store = requestContext.getSessionConfig().getStores().getStore(storeName);
                        Map<String, Object> storeAttrs = emptyMap();

                        store.commit(storeAttrs, sessionID, new StoreContextImpl(storeName));
                    }
                }
            }
        }
    }
View Full Code Here

            // ֪ͨ���е�store����������
            SessionConfig sessionConfig = requestContext.getSessionConfig();
            String[] storeNames = sessionConfig.getStores().getStoreNames();

            for (String storeName : storeNames) {
                SessionStore store = sessionConfig.getStores().getStore(storeName);

                store.invaldiate(sessionID, new StoreContextImpl(storeName));
            }

            // ���model
            if (model == null) {
                model = new SessionModelImpl(SessionImpl.this);
View Full Code Here

            stores.init(this);
            storeMappings.init(stores);

            // �����е�ExactMatchesOnlySessionStore������attribute names��
            for (String storeName : stores.getStoreNames()) {
                SessionStore store = stores.getStore(storeName);

                if (store instanceof ExactMatchesOnlySessionStore) {
                    String[] exactMatchedAttrNames = storeMappings.getExactMatchedAttributeNames(storeName);

                    if (exactMatchedAttrNames == null) {
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.requestcontext.session.SessionStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.