Package org.apache.felix.karaf.admin

Examples of org.apache.felix.karaf.admin.Instance


            chmod(new File(karafBase, "bin/stop"), "a+x");
        }
       
        handleFeatures(new File(karafBase, FEATURES_CFG), settings);
       
        Instance instance = new InstanceImpl(this, name, karafBase.toString());
        instances.put(name, instance);
        saveState();
        return instance;
    }
View Full Code Here


        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

    public void setAdminService(AdminService adminService) {
        this.adminService = adminService;
    }

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

    public void testConfigurationFiles() throws Exception {
        AdminServiceImpl service = new AdminServiceImpl();
        service.setStorageLocation(new File("target/instances/" + System.currentTimeMillis()));

        InstanceSettings settings = new InstanceSettings(8122, getName(), null, null);
        Instance instance = service.createInstance(getName(), settings);

        assertFileExists(instance.getLocation(), "etc/config.properties");
        assertFileExists(instance.getLocation(), "etc/users.properties");
        assertFileExists(instance.getLocation(), "etc/startup.properties");

        assertFileExists(instance.getLocation(), "etc/java.util.logging.properties");
        assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.features.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.felix.fileinstall-deploy.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.log.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.felix.karaf.management.cfg");
        assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.logging.cfg");
        assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.url.mvn.cfg");
    }
View Full Code Here

        }

        InstanceSettings settings = new InstanceSettings(port, location,
                parseStringList(featureURLs), parseStringList(features));

        Instance inst = adminService.createInstance(name, settings);
        if (inst != null) {
            return inst.getPid();
        } else {
            return -1;
        }
    }
View Full Code Here

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

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

        TabularType tt = JmxInstance.INSTANCE_TABLE;
        Assert.assertEquals("Instances", tt.getTypeName());
    }

    public void testJMXInstance() throws Exception {
        Instance i = EasyMock.createMock(Instance.class);
        EasyMock.expect(i.getPid()).andReturn(1712);
        EasyMock.expect(i.getName()).andReturn("MyInstance");
        EasyMock.expect(i.isRoot()).andReturn(false);
        EasyMock.expect(i.getPort()).andReturn(0);
        EasyMock.expect(i.getState()).andThrow(new Exception("gotcha"));
        EasyMock.expect(i.getLocation()).andReturn("somewhere");
        EasyMock.replay(i);
       
        JmxInstance ji = new JmxInstance(i);
        TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));       
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
View Full Code Here

        Assert.assertEquals("Error", cd.get("State"));
        Assert.assertEquals("somewhere", cd.get("Location"));
    }

    public void testJMXInstance2() throws Exception {
        Instance i = EasyMock.createMock(Instance.class);
        EasyMock.expect(i.getPid()).andReturn(1712);
        EasyMock.expect(i.getName()).andReturn("MyInstance");
        EasyMock.expect(i.isRoot()).andReturn(true);
        EasyMock.expect(i.getPort()).andReturn(0);
        EasyMock.expect(i.getState()).andReturn("Started");
        EasyMock.expect(i.getLocation()).andReturn(null);
        EasyMock.replay(i);
       
        JmxInstance ji = new JmxInstance(i);
        TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));       
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
View Full Code Here

TOP

Related Classes of org.apache.felix.karaf.admin.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.