Package org.apache.karaf.instance.core

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


        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

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

    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);
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;
        }
    }
View Full Code Here

    public void startInstance(String name, String opts) throws Exception {
        getExistingInstance(name).start(opts);
    }

    public void startInstance(String name, String opts, boolean wait, boolean debug) throws Exception {
        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);
        }
    }
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

        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

        String javaOpts = settings.getJavaOpts();
        if (javaOpts == null || javaOpts.length() == 0) {
            javaOpts = "-server -Xmx512M -Dcom.sun.management.jmxremote";
        }
        Instance instance = new InstanceImpl(this, name, karafBase.toString(), settings.getJavaOpts());
        instances.put(name, instance);
        saveState();
        return instance;
    }
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.