Package org.hyperic.sigar.win32

Examples of org.hyperic.sigar.win32.Service


    public void testDeleteService() throws Exception {
        if (!TEST_DELETE) {
            return;
        }
        Service service = new Service(TEST_NAME);
        service.delete();
    }
View Full Code Here


public class ServiceStatus {

    private static void printStatus(String name)
        throws Win32Exception {

        Service service = new Service(name);
        System.out.println(name + ": " +
                           service.getStatusString());
        service.close();
    }
View Full Code Here

            return null;
        }
    }

    public void output(String[] args) throws SigarException {
        Service service = null;
        String name = args[0];
        String cmd = null;

        if (args.length == 2) {
            cmd = args[1];
        }
       
        try {
            service = new Service(name);
       
            if ((cmd == null) || cmd.equals("state")) {
                service.list(this.out);
            }
            else if (cmd.equals("start")) {
                service.start();
            }
            else if (cmd.equals("stop")) {
                service.stop();
            }
            else if (cmd.equals("pause")) {
                service.pause();
            }
            else if (cmd.equals("resume")) {
                service.resume();
            }
            else if (cmd.equals("delete")) {
                service.delete();
            }
            else if (cmd.equals("restart")) {
                service.stop(0);
                service.start();
            }
            else {
                println("Unsupported service command: " + args[1]);
                println("Valid commands: " + COMMANDS);
            }
        } finally {
            if (service != null) {
                service.close();
            }
        }
    }
View Full Code Here

    public TestService(String name) {
        super(name);
    }

    public void testServiceOpen() throws Exception {
        Service service = new Service("Eventlog");
        service.getConfig();
        service.close();
       
        String dummyName = "DOESNOTEXIST";
        try {
            new Service(dummyName);
            assertTrue(false);
        } catch (Win32Exception e) {
            traceln(dummyName + ": " + e.getMessage());
            assertTrue(true);
        }
View Full Code Here

    public void testDeleteService() throws Exception {
        if (!TEST_DELETE) {
            return;
        }
        Service service = new Service(TEST_NAME);
        service.delete();
    }
View Full Code Here

                    Service s = null;

                    try {
                        s = new Service(serviceName);

                        ServiceConfig sc = s.getConfig();
                        ServiceInfo si = new ServiceInfo(sc.getName(), sc.getDisplayName(), sc.getDescription(), sc
                            .getPath(), sc.getDependencies());
                        services.add(si);
                    } catch (Win32Exception e) {
                        ; // Ignore these, it means Sigar was rejected by Windows for the particular Service.
                    } finally {
                        if (null != s) {
View Full Code Here

    public void testServiceCreateDelete() throws Exception {
        if (!TEST_CREATE) {
            return;
        }
        ServiceConfig config = new ServiceConfig(TEST_NAME);
        config.setStartType(ServiceConfig.START_MANUAL);
        config.setDisplayName("My Test Service");
        config.setDescription("A Description of " + config.getDisplayName());
        config.setPath("C:\\Program Files\\My Test 1.0\\mytest.exe");

        Service.create(config);
    }
View Full Code Here

    public void testServiceCreateDelete() throws Exception {
        if (!TEST_CREATE) {
            return;
        }
        ServiceConfig config = new ServiceConfig(TEST_NAME);
        config.setStartType(ServiceConfig.START_MANUAL);
        config.setDisplayName("My Test Service");
        config.setDescription("A Description of " + config.getDisplayName());
        config.setPath("C:\\Program Files\\My Test 1.0\\mytest.exe");

        Service.create(config);
    }
View Full Code Here

    public void testServiceCreateDelete() throws Exception {
        if (!TEST_CREATE) {
            return;
        }
        ServiceConfig config = new ServiceConfig(TEST_NAME);
        config.setStartType(ServiceConfig.START_MANUAL);
        config.setDisplayName("My Test Service");
        config.setDescription("A Description of " + config.getDisplayName());
        config.setPath("C:\\Program Files\\My Test 1.0\\mytest.exe");

        Service.create(config);
    }
View Full Code Here

    BuilderIssues issues = this.allService.getIssues();
    assertTrue( issues.toString(), issues.isValid());
    assertTrue( issues.toString(), issues.isEmpty());

    // Build
    Service s = this.allService.build();

    assertNotNull( s);
    assertTrue( this.allService.isBuilt() );

    assertEquals( allName, s.getName() );
    assertEquals( allType, s.getType() );
    assertEquals( allBaseUri, s.getBaseUri() );

    assertEquals( odapService, s.getServiceByName( odapName ) );
    assertEquals( wcsService, s.getServiceByName( wcsName ) );
    assertEquals( wmsService, s.getServiceByName( wmsName ) );

    assertEquals( odapService, s.findServiceByNameGlobally( odapName ) );
    assertEquals( wcsService, s.findServiceByNameGlobally( wcsName ) );
    assertEquals( wmsService, s.findServiceByNameGlobally( wmsName ) );

    List<Service> services = s.getServices();
    assertFalse( services.isEmpty() );
    assertEquals( 3, services.size() );

    assertEquals( odapService, services.get( 0 ) );
    assertEquals( wcsService, services.get( 1 ) );
    assertEquals( wmsService, services.get( 2 ) );

    // Test that Service methods succeed after build.
    List<Property> propList = s.getProperties();
    assertEquals( 2, propList.size() );
    Property prop1 = propList.get( 0 );
    Property prop2 = propList.get( 1 );

    assertEquals( "propName1", prop1.getName() );
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.win32.Service

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.