Package at.newmedialab.ldpath.backend.linkeddata

Source Code of at.newmedialab.ldpath.backend.linkeddata.LDMemoryBackend

/**
* Copyright (C) 2013 Salzburg Research.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package at.newmedialab.ldpath.backend.linkeddata;

import at.newmedialab.ldclient.model.CacheEntry;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.memory.MemoryStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
* A Linked Data backend implementation with no persistent storage. All retrieved data is kept in memory and discarded
* when the virtual machine exits.
* <p/>
* Author: Sebastian Schaffert
*/
public class LDMemoryBackend extends AbstractLDBackend {

    private static final Logger log = LoggerFactory.getLogger(LDMemoryBackend.class);

    private Map<String,CacheEntry> cacheEntries;

    public LDMemoryBackend() {
        super();

        cacheEntries = new HashMap<String,CacheEntry>();

        try {
            Repository repository = new SailRepository(new MemoryStore());
            repository.initialize();
            setRepository(repository);

        } catch (RepositoryException e) {
            log.error("error initialising connection to Sesame in-memory repository",e);
        }

    }



    /**
     * Return a map that can be used to store caching metadata about resources. The LDCacheProvider should take care
     * of persisting the metadata if desired.
     *
     * @return a map for storing caching metadata
     */
    @Override
    public Map<String,CacheEntry> getMetadataRepository() {
        return cacheEntries;
    }

}
TOP

Related Classes of at.newmedialab.ldpath.backend.linkeddata.LDMemoryBackend

TOP
Copyright © 2018 www.massapi.com. 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.