io.datakernel.launchers.crdt.CrdtNodeLauncher Maven / Gradle / Ivy
/*
* Copyright (C) 2015-2018 SoftIndex LLC.
*
* 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 io.datakernel.launchers.crdt;
import io.datakernel.config.Config;
import io.datakernel.config.ConfigModule;
import io.datakernel.crdt.CrdtServer;
import io.datakernel.di.annotation.Inject;
import io.datakernel.di.annotation.Provides;
import io.datakernel.di.core.Key;
import io.datakernel.di.module.Module;
import io.datakernel.jmx.JmxModule;
import io.datakernel.launcher.Launcher;
import io.datakernel.launcher.OnStart;
import io.datakernel.launchers.crdt.CrdtNodeLogicModule.Cluster;
import io.datakernel.service.ServiceGraphModule;
import io.datakernel.trigger.TriggersModule;
import java.util.concurrent.CompletionStage;
import static io.datakernel.config.Config.ofClassPathProperties;
import static io.datakernel.config.Config.ofProperties;
import static io.datakernel.di.module.Modules.combine;
public abstract class CrdtNodeLauncher, S> extends Launcher {
public static final String PROPERTIES_FILE = "crdt-node.properties";
@Inject
@Cluster
CrdtServer clusterServer;
@Inject
CrdtServer crdtServer;
@Provides
Config config() {
return Config.create()
.overrideWith(ofClassPathProperties(PROPERTIES_FILE, true))
.overrideWith(ofProperties(System.getProperties()).getChild("config"));
}
@Override
protected Module getModule() {
return combine(
ServiceGraphModule.create(),
JmxModule.create(),
TriggersModule.create(),
ConfigModule.create()
.printEffectiveConfig()
.rebindImport(new Key>() {}, new Key>(OnStart.class) {}),
getBusinessLogicModule());
}
protected abstract CrdtNodeLogicModule getBusinessLogicModule();
@Override
protected void run() throws Exception {
awaitShutdown();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy