Package com.impetus.client.es

Source Code of com.impetus.client.es.ESClientPropertyReader$ESSchemaMetadata

/*******************************************************************************
* * Copyright 2013 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.client.es;

import java.util.Map;
import java.util.Properties;

import com.impetus.kundera.configure.AbstractPropertyReader;
import com.impetus.kundera.configure.ClientProperties;
import com.impetus.kundera.configure.ClientProperties.DataStore;
import com.impetus.kundera.configure.ClientProperties.DataStore.Connection;
import com.impetus.kundera.configure.PropertyReader;
import com.impetus.kundera.metadata.model.PersistenceUnitMetadata;

/**
* @author vivek.mishra
*
*/
public class ESClientPropertyReader extends AbstractPropertyReader implements PropertyReader
{

    private ESSchemaMetadata esmd;
   
    public ESClientPropertyReader(Map externalProperties, final PersistenceUnitMetadata puMetadata)
    {
        super(externalProperties, puMetadata);
        esmd = new ESSchemaMetadata();
    }

    /* (non-Javadoc)
     * @see com.impetus.kundera.configure.AbstractPropertyReader#onXml(com.impetus.kundera.configure.ClientProperties)
     */
    @Override
    protected void onXml(ClientProperties cp)
    {
        if(cp != null)
        {
            esmd.setClientProperties(cp);
        }
    }

    public Properties getConnectionProperties()
    {
        return esmd != null? esmd.getConnectionProperties():null;
    }
   
   

    private class ESSchemaMetadata extends AbstractSchemaMetadata
    {
       
        public Properties getConnectionProperties()
        {
            DataStore  ds = getDataStore("elasticsearch");
           
            if (ds != null)
            {
                Connection connection = ds.getConnection();
                if (connection != null)
                {
                    Properties properties = connection.getProperties();

                    return properties;
                }
            }      
            return null;
        }
    }
}
TOP

Related Classes of com.impetus.client.es.ESClientPropertyReader$ESSchemaMetadata

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.