org.commonjava.indy.setback.conf.SetbackConfig Maven / Gradle / Ivy
/**
* Copyright (C) 2011-2018 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* 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 org.commonjava.indy.setback.conf;
import org.commonjava.indy.conf.IndyConfigInfo;
import org.commonjava.web.config.annotation.ConfigName;
import org.commonjava.web.config.annotation.SectionName;
import javax.enterprise.context.ApplicationScoped;
import java.io.File;
import java.io.InputStream;
@SectionName( "setback" )
@ApplicationScoped
public class SetbackConfig
implements IndyConfigInfo
{
private static final boolean DEFAULT_ENABLED = false;
private Boolean enabled;
public SetbackConfig(){}
public SetbackConfig( boolean enabled )
{
this.enabled = enabled;
}
public boolean isEnabled()
{
return enabled == null ? DEFAULT_ENABLED : enabled;
}
@ConfigName( "enabled" )
public void setEnabled( final Boolean enabled )
{
this.enabled = enabled;
}
@Override
public String getDefaultConfigFileName()
{
return new File( IndyConfigInfo.CONF_INCLUDES_DIR, "setback.conf" ).getPath();
}
@Override
public InputStream getDefaultConfig()
{
return Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream( "default-setback.conf" );
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy