Package org.apache.karaf.instance.core

Examples of org.apache.karaf.instance.core.Instance


        return false;
    }

    private boolean destroyInstance(String name) {
        try {
            Instance instance = instanceService.getInstance(name);
            if (instance != null) {
                instance.destroy();
                return true;
            }
        } catch (Exception ex) {
            Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here


        return false;
    }

    private boolean startInstance(String name, String javaOpts) {
        try {
            Instance instance = instanceService.getInstance(name);
            if (instance != null) {
                instance.start(javaOpts);
                return true;
            }
        } catch (Exception ex) {
            Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

        return false;
    }

    private boolean stopInstance(String name) {
        try {
            Instance instance = instanceService.getInstance(name);
            if (instance != null) {
                instance.stop();
                return true;
            }
        } catch (Exception ex) {
            Logger.getLogger(InstancePlugin.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

            }

            InstanceSettings settings = new InstanceSettings(sshPort, rmiRegistryPort, rmiServerPort, location, javaOpts,
                    parseStringList(featureURLs), parseStringList(features));

            Instance inst = instanceService.createInstance(name, settings, false);
            if (inst != null) {
                return inst.getPid();
            } else {
                return -1;
            }
        } catch (Exception e) {
            throw new MBeanException(null, e.getMessage());
View Full Code Here

        }
    }

    public void startInstance(String name, String opts, boolean wait, boolean debug) throws MBeanException {
        try {
            Instance child = getExistingInstance(name);
            String options = opts;
            if (options == null) {
                options = child.getJavaOpts();
            }
            if (options == null) {
                options = DEFAULT_OPTS;
            }
            if (debug) {
                options += DEBUG_OPTS;
            }
            if (wait) {
                String state = child.getState();
                if (Instance.STOPPED.equals(state)) {
                    child.start(opts);
                }
                if (!Instance.STARTED.equals(state)) {
                    do {
                        Thread.sleep(500);
                        state = child.getState();
                    } while (Instance.STARTING.equals(state));
                }
            } else {
                child.start(opts);
            }
        } catch (Exception e) {
            throw new MBeanException(null, e.getMessage());
        }
    }
View Full Code Here

        TabularData table = InstanceToTableMapper.tableFrom(instances);
        return table;
    }

    private Instance getExistingInstance(String name) {
        Instance i = instanceService.getInstance(name);
        if (i == null) {
            throw new IllegalArgumentException("Instance '" + name + "' does not exist");
        }
        return i;
    }
View Full Code Here

        EasyMock.verify(instanceService);
        EasyMock.verify(inst);
    }

    public void testDestroyInstance() throws Exception {
        Instance inst = EasyMock.createMock(Instance.class);
        inst.destroy();
        EasyMock.expectLastCall();
        EasyMock.replay(inst);

        InstanceService instanceService = EasyMock.createMock(InstanceService.class);
        EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
View Full Code Here

        EasyMock.verify(instanceService);
        EasyMock.verify(inst);
    }

    public void testSshChangePort() throws Exception {
        Instance inst = EasyMock.createMock(Instance.class);
        inst.changeSshPort(7788);
        EasyMock.expectLastCall();
        EasyMock.replay(inst);

        InstanceService instanceService = EasyMock.createMock(InstanceService.class);
        EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
View Full Code Here

        EasyMock.verify(instanceService);
        EasyMock.verify(inst);
    }
   
    public void testRmiRegistryChangePort() throws Exception {
        Instance inst = EasyMock.createMock(Instance.class);
        inst.changeRmiRegistryPort(1123);
        EasyMock.expectLastCall();
        EasyMock.replay(inst);
       
        InstanceService instanceService = EasyMock.createMock(InstanceService.class);
        EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
View Full Code Here

        EasyMock.verify(instanceService);
        EasyMock.verify(inst);
    }

    public void testRmiServerChangePort() throws Exception {
        Instance inst = EasyMock.createMock(Instance.class);
        inst.changeRmiServerPort(44444);
        EasyMock.expectLastCall();
        EasyMock.replay(inst);

        InstanceService instanceService = EasyMock.createMock(InstanceService.class);
        EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
View Full Code Here

TOP

Related Classes of org.apache.karaf.instance.core.Instance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.