Skip to contentPackage: DefaultInitializer
DefaultInitializer
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.initializer.impl;
28:
29: import javax.annotation.PreDestroy;
30: import javax.inject.Inject;
31: import java.util.HashMap;
32: import java.util.Map;
33: import java.nio.file.Path;
34: import java.nio.file.Paths;
35: import it.tidalwave.util.Key;
36: import it.tidalwave.messagebus.MessageBus;
37: import it.tidalwave.bluemarine2.model.ModelPropertyNames;
38: import it.tidalwave.bluemarine2.message.PowerOffNotification;
39: import it.tidalwave.bluemarine2.message.PowerOnNotification;
40: import it.tidalwave.bluemarine2.downloader.DownloaderPropertyNames;
41: import it.tidalwave.bluemarine2.initializer.Initializer;
42: import it.tidalwave.bluemarine2.persistence.PersistencePropertyNames;
43: import lombok.extern.slf4j.Slf4j;
44:
45: /***********************************************************************************************************************
46: *
47: * @author Fabrizio Giudici
48: *
49: **********************************************************************************************************************/
50: @Slf4j
51: public class DefaultInitializer implements Initializer
52: {
53: @Inject
54: private MessageBus messageBus;
55:
56: /*******************************************************************************************************************
57: *
58: * {@inheritDoc}
59: *
60: ******************************************************************************************************************/
61: @Override
62: public void boot()
63: {
64: final Map<Key<?>, Object> properties = new HashMap<>();
65: final Path configPath = Paths.get(System.getProperty("blueMarine2.workspace"));
66: log.info("configPath is {}", configPath);
67: properties.put(ModelPropertyNames.ROOT_PATH, configPath);
68: properties.put(PersistencePropertyNames.STORAGE_FOLDER, configPath.resolve("storage"));
69: properties.put(PersistencePropertyNames.IMPORT_FILE, configPath.resolve("import").resolve("repository.n3"));
70: properties.put(PersistencePropertyNames.RENAME_IMPORT_FILE, true);
71: properties.put(DownloaderPropertyNames.CACHE_FOLDER_PATH, configPath.resolve("cache"));
72: messageBus.publish(new PowerOnNotification(properties));
73: }
74:
75: /*******************************************************************************************************************
76: *
77: *
78: *
79: ******************************************************************************************************************/
80: @PreDestroy
81: private void shutdown()
82: {
83: messageBus.publish(new PowerOffNotification());
84: }
85: }