001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.hazelcast; 018 019import org.springframework.boot.context.properties.ConfigurationProperties; 020import org.springframework.core.io.Resource; 021import org.springframework.util.Assert; 022 023/** 024 * Configuration properties for the hazelcast integration. 025 * 026 * @author Stephane Nicoll 027 * @since 1.3.0 028 */ 029@ConfigurationProperties(prefix = "spring.hazelcast") 030public class HazelcastProperties { 031 032 /** 033 * The location of the configuration file to use to initialize Hazelcast. 034 */ 035 private Resource config; 036 037 public Resource getConfig() { 038 return this.config; 039 } 040 041 public void setConfig(Resource config) { 042 this.config = config; 043 } 044 045 /** 046 * Resolve the config location if set. 047 * @return the location or {@code null} if it is not set 048 * @throws IllegalArgumentException if the config attribute is set to an unknown 049 * location 050 */ 051 public Resource resolveConfigLocation() { 052 if (this.config == null) { 053 return null; 054 } 055 Assert.isTrue(this.config.exists(), () -> "Hazelcast configuration does not " 056 + "exist '" + this.config.getDescription() + "'"); 057 return this.config; 058 } 059 060}