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

com.impetus.kundera.persistence.ReaderResolver Maven / Gradle / Ivy

There is a newer version: 2.9
Show newest version
/*******************************************************************************
 * * Copyright 2012 Impetus Infotech.
 *  *
 *  * 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 com.impetus.kundera.persistence;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.impetus.kundera.client.DBType;

/**
 * The Class ReaderResolver.
 * 
 * @author vivek.mishra
 */
final class ReaderResolver
{

    /** The reader col. */
    static Map readerCol = new ConcurrentHashMap();

    static
    {
        try
        {
            readerCol.put(DBType.CASSANDRA,
                    (EntityReader) Class.forName("com.impetus.client.cassandra.query.CassandraEntityReader")
                            .newInstance());
            readerCol.put(DBType.RDBMS, (EntityReader) Class
                    .forName("com.impetus.client.rdbms.query.RDBMSEntityReader").newInstance());
        }
        catch (InstantiationException e)
        {
            throw new ReaderResolverException(e);
        }
        catch (IllegalAccessException e)
        {
            throw new ReaderResolverException(e);
        }
        catch (ClassNotFoundException e)
        {
            throw new ReaderResolverException(e);
        }
    }

    /**
     * Gets the reader.
     * 
     * @param dbType
     *            the db type
     * @return the reader
     */
    static EntityReader getReader(DBType dbType)
    {
        return readerCol.get(dbType);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy