blob: 5aecfff7114d7c4733d0607dbcc335514c8326c4 [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.io.File;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
import org.eclipse.statet.jcommons.rmi.RMIRegistryManager;
import org.eclipse.statet.jcommons.runtime.BasicAppEnvironment;
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;
import org.eclipse.statet.rj.servi.RServiUtils;
@NonNullByDefault
public class ServiTests extends BasicAppEnvironment {
private static boolean isInit= false;
public static synchronized void initEnv() {
if (!isInit) {
CommonsRuntime.init(new ServiTests());
RMIRegistryManager.INSTANCE.setEmbeddedPrivateMode(false);
RMIRegistryManager.INSTANCE.setEmbeddedPrivatePort(getRegistryPort());
isInit= true;
}
}
public static RJContext getRJContext() throws RjInitFailedException {
return new RJContext(RJContext.detectRJLibPaths()) {
@Override
public String getServerPolicyFilePath() throws RjInvalidConfigurationException {
final String path= getPropertiesDirPath() + "security.policy";
if (new File(path).exists()) {
return path;
}
return super.getServerPolicyFilePath();
}
};
}
public static int getRegistryPort() {
return 51099;
}
private ServiTests() {
initJRuntimeStoppingHandler();
}
@Override
public String getBundleId() {
return RServiUtils.RJ_SERVI_ID;
}
}