blob: ebbbbb1bd9614732b48c830b45695f19527a721a [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2019, 2020 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.rj.servi.pool;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
import org.eclipse.statet.jcommons.rmi.RMIRegistryManager;
import org.eclipse.statet.jcommons.runtime.CommonsRuntime;
import org.eclipse.statet.rj.RjInitFailedException;
import org.eclipse.statet.rj.RjInvalidConfigurationException;
import org.eclipse.statet.rj.server.util.RJContext;
@NonNullByDefault
public class ServiTests {
private static boolean isInit= false;
public static synchronized void initEnv() throws Exception {
if (!isInit) {
CommonsRuntime.check(true);
RMIRegistryManager.INSTANCE.setEmbeddedPrivateMode(false);
RMIRegistryManager.INSTANCE.setEmbeddedPrivatePort(getRegistryPort());
isInit= true;
}
}
public static RJContext getRJContext() throws RjInitFailedException {
return new RJContext() {
@Override
public String getServerPolicyFilePath() throws RjInvalidConfigurationException {
final String path= getPropertiesDirPath() + "security.policy";
if (Files.isRegularFile(Path.of(path))) {
return path;
}
return super.getServerPolicyFilePath();
}
};
}
public static int getRegistryPort() {
return 8099;
}
}