use of org.apache.karaf.instance.core.InstanceSettings in project karaf by apache.
the class InstancesMBeanImpl method cloneInstance.
public void cloneInstance(String name, String cloneName, int sshPort, int rmiRegistryPort, int rmiServerPort, String location, String javaOpts) throws MBeanException {
try {
if ("".equals(location)) {
location = null;
}
if ("".equals(javaOpts)) {
javaOpts = null;
}
InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, null, null);
instanceService.cloneInstance(name, cloneName, settings, false);
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of org.apache.karaf.instance.core.InstanceSettings in project karaf by apache.
the class InstancesMBeanImpl method createInstance.
public int createInstance(String name, int sshPort, int rmiRegistryPort, int rmiServerPort, String location, String javaOpts, String features, String featureURLs, String address) throws MBeanException {
try {
if ("".equals(location)) {
location = null;
}
if ("".equals(javaOpts)) {
javaOpts = null;
}
InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, parseStringList(featureURLs), parseStringList(features), address);
Instance inst = instanceService.createInstance(name, settings, false);
if (inst != null) {
return inst.getPid();
} else {
return -1;
}
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of org.apache.karaf.instance.core.InstanceSettings in project karaf by apache.
the class CloneCommand method doExecute.
protected Object doExecute() throws Exception {
Map<String, URL> textResources = getResources(textResourceLocation);
Map<String, URL> binaryResources = getResources(binaryResourceLocations);
InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, null, null, null, textResources, binaryResources);
getInstanceService().cloneInstance(name, cloneName, settings, verbose);
return null;
}
use of org.apache.karaf.instance.core.InstanceSettings in project karaf by apache.
the class CreateCommand method doExecute.
protected Object doExecute() throws Exception {
if (!bare) {
Properties configuration = new Properties();
File configFile = new File(System.getProperty("karaf.etc"), FEATURES_SERVICE_CONFIG_FILE);
configuration.load(configFile);
String featuresRepositories = configuration.getProperty("featuresRepositories", "");
String featuresBoot = configuration.getProperty("featuresBoot", "");
if (featureURLs == null) {
featureURLs = new ArrayList<>();
}
for (String repo : featuresRepositories.split(",")) {
repo = repo.trim();
if (!repo.isEmpty()) {
featureURLs.add(repo);
}
}
if (features == null) {
features = new ArrayList<>();
}
for (String feature : featuresBoot.split(",")) {
feature = feature.trim();
if (!feature.isEmpty()) {
features.add(feature);
}
}
}
Map<String, URL> textResources = getResources(textResourceLocation);
Map<String, URL> binaryResources = getResources(binaryResourceLocations);
InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts, featureURLs, features, address, textResources, binaryResources, profiles);
getInstanceService().createInstance(instance, settings, verbose);
return null;
}
use of org.apache.karaf.instance.core.InstanceSettings in project karaf by apache.
the class CreateCommandTest method testCreateCommandExecute.
public void testCreateCommandExecute() throws Exception {
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.replay(instanceService);
CreateCommand cc = new CreateCommand();
cc.setInstanceService(instanceService);
cc.sshPort = 9941;
cc.rmiRegistryPort = 1122;
cc.rmiServerPort = 44444;
cc.location = "top";
cc.javaOpts = "foo";
cc.features = new ArrayList<>(Arrays.asList("abc", "def"));
cc.featureURLs = new ArrayList<>(Arrays.asList("http://something"));
cc.instance = "myInstance";
cc.verbose = true;
// Create the features config file used
System.setProperty("karaf.etc", "target/etc");
File cfgFile = new File("target/etc/" + CreateCommand.FEATURES_SERVICE_CONFIG_FILE);
cfgFile.getParentFile().mkdirs();
cfgFile.createNewFile();
// check precondition
EasyMock.verify(instanceService);
EasyMock.reset(instanceService);
InstanceSettings expectedIS = new InstanceSettings(9941, 1122, 44444, "top", "foo", Collections.singletonList("http://something"), Arrays.asList("abc", "def"));
EasyMock.expect(instanceService.createInstance("myInstance", expectedIS, true)).andReturn(null);
EasyMock.replay(instanceService);
cc.doExecute();
EasyMock.verify(instanceService);
}
Aggregations