use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class StatusCommand method doExecute.
protected Object doExecute() throws Exception {
Instance instance = getExistingInstance(name);
System.out.println(instance.getState());
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class StopCommand method doExecute.
@SuppressWarnings("deprecation")
protected Object doExecute() throws Exception {
final MultiException exception = new MultiException("Error stopping instance(s)");
for (Instance instance : getMatchingInstances(instances)) {
try {
instance.stop();
} catch (Exception e) {
exception.addException(e);
}
}
exception.throwIfExceptions();
return null;
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstancePlugin method getStatusLine.
private String getStatusLine() {
final Instance[] instances = instanceService.getInstances();
int started = 0, starting = 0, stopped = 0;
for (Instance instance : instances) {
try {
if (instance.getState().equals(Instance.STARTED)) {
started++;
} else if (instance.getState().equals(Instance.STARTING)) {
starting++;
} else if (instance.getState().equals(Instance.STOPPED)) {
stopped++;
}
} catch (Exception ex) {
Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex);
}
}
final StringBuffer buffer = new StringBuffer();
buffer.append("Instance information: ");
buffer.append(instances.length);
buffer.append(" instance");
if (instances.length != 1) {
buffer.append('s');
}
buffer.append(" in total");
if (started == instances.length) {
buffer.append(" - all started");
} else {
if (started != 0) {
buffer.append(", ");
buffer.append(started);
buffer.append(" started");
}
if (starting != 0) {
buffer.append(", ");
buffer.append(starting);
buffer.append(" starting");
}
buffer.append('.');
}
return buffer.toString();
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testChangeOptions.
public void testChangeOptions() throws Exception {
Instance inst = EasyMock.createMock(Instance.class);
inst.changeJavaOpts("new opts");
EasyMock.expectLastCall();
EasyMock.replay(inst);
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBean instanceServiceMBean = new InstancesMBeanImpl(instanceService);
instanceServiceMBean.changeJavaOpts("test instance", "new opts");
EasyMock.verify(instanceService);
EasyMock.verify(inst);
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testStartInstanceWithNoJavaOpts.
public void testStartInstanceWithNoJavaOpts() throws Exception {
Instance inst = EasyMock.createMock(Instance.class);
inst.start(null);
EasyMock.expectLastCall();
EasyMock.replay(inst);
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBean instanceServiceMBean = new InstancesMBeanImpl(instanceService);
instanceServiceMBean.startInstance("test instance", null);
EasyMock.verify(instanceService);
EasyMock.verify(inst);
}
Aggregations