All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.web.config.dom.MultiSiteConfig Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.alachisoft.ncache.web.config.dom;

import Alachisoft.NCache.Common.Configuration.ConfigurationAttributeAnnotation;
import Alachisoft.NCache.Common.Configuration.ConfigurationSectionAnnotation;
import java.io.Serializable;
import java.util.HashMap;

/**
 *
 * @author huma_kauser
 */
public class MultiSiteConfig implements Serializable {

    private int _recyleInterval;
    private java.util.HashMap primaryCaches;
    private java.util.HashMap secondaryCaches;
    private HashMap primaryPrefixes;
    private HashMap secondaryPrefixes;

    public MultiSiteConfig() {
        primaryCaches = new java.util.HashMap();
        secondaryCaches = new java.util.HashMap();
        primaryPrefixes = new HashMap();
        secondaryPrefixes = new HashMap();
    }

    @ConfigurationAttributeAnnotation(value = "secondary-connection-recycle-interval", appendText = "sec")
    public final int getRecycleInterval() {
        return _recyleInterval;
    }

    @ConfigurationAttributeAnnotation(value = "secondary-connection-recycle-interval", appendText = "sec")
    public final void setRecycleInterval(int value) {
        _recyleInterval = value;
    }

    @ConfigurationSectionAnnotation(value = "primary-cache")
    public final PrimaryCache[] getPrimaryCache() {
        PrimaryCache[] caches = new PrimaryCache[primaryCaches.size()];
        //Huma:
        primaryCaches.values().toArray(caches);
        //attributesTable.values().CopyTo(attribs, 0);
        return caches;
    }

    @ConfigurationSectionAnnotation(value = "primary-cache")
    public final void setPrimaryCache(Object value) {
        primaryCaches.clear();
        Object[] objs = (Object[]) value;
        PrimaryCache caches;
        for (int i = 0; i < objs.length; i++) {
            caches = (PrimaryCache) objs[i];
            if (!primaryCaches.containsKey(caches.getId())) {
                primaryCaches.put(caches.getId(), caches);
            }
        }
    }

    @ConfigurationSectionAnnotation(value = "secondary-cache")
    public final SecondaryCache[] getSecondaryCache() {
        SecondaryCache[] attribs = new SecondaryCache[secondaryCaches.size()];
        //Huma:
        secondaryCaches.values().toArray(attribs);
        //attributesTable.values().CopyTo(attribs, 0);
        return attribs;
    }

    @ConfigurationSectionAnnotation(value = "secondary-cache")
    public final void setSecondaryCache(Object value) {
        secondaryCaches.clear();
        Object[] objs = (Object[]) value;
        SecondaryCache caches;
        for (int i = 0; i < objs.length; i++) {
            caches = (SecondaryCache) objs[i];
            if (!secondaryCaches.containsKey(caches.getId())) {
                secondaryCaches.put(caches.getId(), caches);
            }
        }
    }

    public HashMap getPrimaryPrefixes() {
        for (PrimaryCache value : primaryCaches.values()) {
            primaryPrefixes.put(value.getPrefix(), value.getId());
        }
        return primaryPrefixes;
    }

    public HashMap getSecondaryPrefixes() {
        for (SecondaryCache value : secondaryCaches.values()) {
            secondaryPrefixes.put(value.getPrefix(), value.getId());
        }
        return secondaryPrefixes;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy