Package net.sf.ehcache

Examples of net.sf.ehcache.Ehcache


        return match;
    }

    private void remove(Queue queue, String uid, String reason) {
        queue.remove();
        Ehcache cache = null;
        try {
            cache = getMessageCache();
        } catch (AsynchronousCommandException e) {
            LOG.log(Level.SEVERE, "Unable to get cache + " + e.getMessage(), e);
        }
        cache.remove(uid);
        if (reason.equals(SUCCESSFUL_EXECUTION)) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Deleting command with uid " + uid + ". " + reason);
            }
        } else {
View Full Code Here


    private InstrumentedCommand retrieveInstrumentedCommandFromCache(String uid)
            throws CommandNotFoundInCacheException {
        Element element = null;
        try {
            //Cache not alive here. Why?
            Ehcache cache = getMessageCache();
            element = cache.get(uid);
        } catch (Exception e) {
            throw new CommandNotFoundInCacheException("Cache error while retrieving command", e);
        }

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

     * @return the approximate number of PublishCommands stored in the cache
     */
    public synchronized int countCachedPublishCommands() {
        int messageCount = 0;
        try {
            Ehcache cache = getMessageCache();
            messageCount = cache.getSize();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "Unable to determine the number"
                    + " of messages in the messageCache.", e);
        }
        if (messageCount != 0) {
View Full Code Here

     * @throws AsynchronousCommandException
     */
    String storeCommandToCache(InstrumentedCommand instrumentedCommand) throws AsynchronousCommandException {
        String uid = generateUniqueIdentifier();
        Element element = new Element(uid, instrumentedCommand);
        Ehcache messageCache = getMessageCache();
        messageCache.put(element);
        return uid;
    }
View Full Code Here

        Set caches = new HashSet();
        Set cacheConfigurations = configuration.getCacheConfigurations().entrySet();
        for (Iterator iterator = cacheConfigurations.iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            CacheConfiguration cacheConfiguration = (CacheConfiguration) entry.getValue();
            Ehcache cache = createCache(cacheConfiguration);
            caches.add(cache);
        }
        return caches;
    }
View Full Code Here

     * Create a cache given a cache configuration
     *
     * @param cacheConfiguration
     */
    final Ehcache createCache(CacheConfiguration cacheConfiguration) {
        Ehcache cache = new Cache(cacheConfiguration.name,
                cacheConfiguration.maxElementsInMemory,
                cacheConfiguration.memoryStoreEvictionPolicy,
                cacheConfiguration.overflowToDisk,
                getDiskStorePath(),
                cacheConfiguration.eternal,
                cacheConfiguration.timeToLiveSeconds,
                cacheConfiguration.timeToIdleSeconds,
                cacheConfiguration.diskPersistent,
                cacheConfiguration.diskExpiryThreadIntervalSeconds,
                null,
                null,
                cacheConfiguration.maxElementsOnDisk,
                cacheConfiguration.diskSpoolBufferSizeMB);
        RegisteredEventListeners listeners = cache.getCacheEventNotificationService();
        registerCacheListeners(cacheConfiguration, listeners);
        registerCacheExtensions(cacheConfiguration, cache);
        BootstrapCacheLoader bootstrapCacheLoader = createBootstrapCacheLoader(
                cacheConfiguration.getBootstrapCacheLoaderFactoryConfiguration());
        cache.setBootstrapCacheLoader(bootstrapCacheLoader);
        registerCacheLoaders(cacheConfiguration, cache);
        cache = applyCacheExceptionHandler(cacheConfiguration, cache);
        return cache;
    }
View Full Code Here

     */
    public void doInit(FilterConfig filterConfig) throws CacheException {
        synchronized (this.getClass()) {
            if (blockingCache == null) {
                final String cacheName = getCacheName();
                Ehcache cache = getCacheManager().getEhcache(cacheName);
                if (!(cache instanceof BlockingCache)) {
                    //decorate and substitute
                    BlockingCache newBlockingCache = new BlockingCache(cache);
                    getCacheManager().replaceCacheWithDecoratedCache(cache, newBlockingCache);
                }
View Full Code Here

     */
    protected void populateListOfRemoteCachePeers() throws RemoteException {
        String[] names = cacheManager.getCacheNames();
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            Ehcache cache = cacheManager.getEhcache(name);
            synchronized (cachePeers) {
                if (cachePeers.get(name) == null) {
                    if (isDistributed(cache)) {
                        RMICachePeer peer = new RMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis);
                        cachePeers.put(name, peer);
View Full Code Here

            if (cachePeers.get(cacheName) != null) {
                return;
            }
        }

        Ehcache cache = cacheManager.getEhcache(cacheName);
        if (isDistributed(cache)) {
            RMICachePeer rmiCachePeer = null;
            String url = null;
            try {
                rmiCachePeer = new RMICachePeer(cache, hostName, port, remoteObjectPort, socketTimeoutMillis);
View Full Code Here

            replicationQueueCopy = new ArrayList(replicationQueue);
            replicationQueue.clear();
        }


        Ehcache cache = ((CacheEventMessage) replicationQueueCopy.get(0)).cache;
        List cachePeers = listRemoteCachePeers(cache);

        List resolvedEventMessages = extractAndResolveEventMessages(replicationQueueCopy);

View Full Code Here

TOP

Related Classes of net.sf.ehcache.Ehcache

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.