View Javadoc
1   /*
2    * Copyright 2022-2026 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.geojson.spring.boot.autoconfigure;
18  
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  import org.bremersee.geojson.GeoJsonGeometryFactory;
22  import org.springframework.boot.autoconfigure.AutoConfiguration;
23  import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24  import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
25  import org.springframework.boot.context.event.ApplicationReadyEvent;
26  import org.springframework.context.annotation.Bean;
27  import org.springframework.context.event.EventListener;
28  import org.springframework.util.ClassUtils;
29  
30  /**
31   * The GeoJSON geometry factory autoconfiguration.
32   *
33   * @author Christian Bremer
34   */
35  @ConditionalOnClass(name = {"org.bremersee.geojson.GeoJsonGeometryFactory"})
36  @AutoConfiguration
37  public class GeoJsonGeometryFactoryAutoConfiguration {
38  
39    private static final Log log = LogFactory.getLog(GeoJsonGeometryFactoryAutoConfiguration.class);
40  
41    /**
42     * Instantiates a new GeoJSON geometry factory autoconfiguration.
43     */
44    public GeoJsonGeometryFactoryAutoConfiguration() {
45      super();
46    }
47  
48    /**
49     * Init.
50     */
51    @EventListener(ApplicationReadyEvent.class)
52    public void init() {
53      log.info(String.format("""
54  
55              *********************************************************************************
56              * %s
57              *********************************************************************************""",
58          ClassUtils.getUserClass(getClass()).getSimpleName()));
59    }
60  
61    /**
62     * Creates the GeoJSON geometry factory.
63     *
64     * @return the gGeoJSON geometry factory
65     */
66    @ConditionalOnMissingBean
67    @Bean
68    public GeoJsonGeometryFactory geoJsonGeometryFactory() {
69      return new GeoJsonGeometryFactory();
70    }
71  
72  }