/*
 * ICESOFT COMMERCIAL SOURCE CODE LICENSE V 1.1
 *
 * The contents of this file are subject to the ICEsoft Commercial Source
 * Code License Agreement V1.1 (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.icesoft.com/license/commercial-source-v1.1.html
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations under
 * the License.
 *
 * Copyright 2009-2015 ICEsoft Technologies Canada, Corp. All Rights Reserved.
 */
package com.icesoft.net.messaging.jms;

import com.icesoft.net.messaging.MessageServiceConfiguration;
import com.icesoft.net.messaging.MessageServiceConfigurationProperties;
import org.icepush.Configuration;

import java.io.InputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class JMSProviderConfigurationProperties
extends MessageServiceConfigurationProperties
implements JMSProviderConfiguration, MessageServiceConfiguration {
    private static final Logger LOGGER = Logger.getLogger(JMSProviderConfigurationProperties.class.getName());

    public JMSProviderConfigurationProperties(final Configuration configuration) {
        super(configuration);
    }

    public JMSProviderConfigurationProperties(final InputStream inputStream, final Configuration configuration)
    throws IOException {
        super(inputStream, configuration);
    }

    public String getInitialContextFactory() {
        return
            configuration.getAttribute(
                INITIAL_CONTEXT_FACTORY,
                messageServiceConfigurationProperties.getProperty(INITIAL_CONTEXT_FACTORY, null));
    }

    public String getPassword() {
        return
            configuration.getAttribute(
                PASSWORD,
                messageServiceConfigurationProperties.getProperty(PASSWORD, null));
    }

    public String getProviderURL() {
        return
            configuration.getAttribute(
                PROVIDER_URL,
                messageServiceConfigurationProperties.getProperty(PROVIDER_URL, null));
    }

    public long getReceiveTimeout() {
        return
            configuration.getAttributeAsLong(
                RECEIVE_TIMEOUT,
                messageServiceConfigurationProperties.getLongProperty(RECEIVE_TIMEOUT, 1000));
    }

    public String getSecurityCredentials() {
        return
            configuration.getAttribute(
                SECURITY_CREDENTIALS,
                messageServiceConfigurationProperties.getProperty(SECURITY_CREDENTIALS, null));
    }

    public String getSecurityPrincipal() {
        return
            configuration.getAttribute(
                SECURITY_PRINCIPAL,
                messageServiceConfigurationProperties.getProperty(SECURITY_PRINCIPAL, null));
    }

    public String getTopicConnectionFactoryName() {
        return
            configuration.getAttribute(
                TOPIC_CONNECTION_FACTORY_NAME,
                messageServiceConfigurationProperties.getProperty(TOPIC_CONNECTION_FACTORY_NAME, "ConnectionFactory"));
    }

    public String getTopicNamePrefix() {
        return
            configuration.getAttribute(
                TOPIC_NAME_PREFIX,
                messageServiceConfigurationProperties.getProperty(TOPIC_NAME_PREFIX, null));
    }

    public String getURLPackagePrefixes() {
        return
            configuration.getAttribute(
                URL_PACKAGE_PREFIXES,
                messageServiceConfigurationProperties.getProperty(URL_PACKAGE_PREFIXES, null));
    }

    public String getUserName() {
        return
            configuration.getAttribute(
                USER_NAME,
                messageServiceConfigurationProperties.getProperty(USER_NAME, null));
    }
}
