Author: mladen.turk(a)jboss.com
Date: 2007-09-26 11:25:54 -0400 (Wed, 26 Sep 2007)
New Revision: 1045
Added:
trunk/sight/java/org/jboss/sight/platform/linux/Services.properties
trunk/sight/java/org/jboss/sight/platform/solaris/Services.properties
Modified:
trunk/sight/java/org/jboss/sight/Service.java
trunk/sight/native/os/linux/service.c
Log:
Use properties files for common services
Modified: trunk/sight/java/org/jboss/sight/Service.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Service.java 2007-09-26 11:57:11 UTC (rev 1044)
+++ trunk/sight/java/org/jboss/sight/Service.java 2007-09-26 15:25:54 UTC (rev 1045)
@@ -25,7 +25,10 @@
package org.jboss.sight;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.EnumSet;
+import java.util.Properties;
/**
* Service
@@ -47,6 +50,42 @@
IProgressNotificationCallback progress,
long timeout, int state);
+ private static Properties serviceProperties = null;
+ private static boolean servicePropertiesLoaded = false;
+
+ private static void setupKnownService(Service service)
+ {
+ if (serviceProperties == null) {
+ serviceProperties = new Properties();
+ if (OS.IS_LINUX) {
+ try {
+ InputStream is = LibraryLoader.class.getResourceAsStream
+
("/org/jboss/sight/platform/linux/Services.properties");
+ serviceProperties.load(is);
+ is.close();
+ }
+ catch (Throwable t) {
+ // Nothing
+ }
+ }
+ else if (OS.IS_SOLARIS) {
+ try {
+ InputStream is = LibraryLoader.class.getResourceAsStream
+
("/org/jboss/sight/platform/solaris/Services.properties");
+ serviceProperties.load(is);
+ is.close();
+ }
+ catch (Throwable t) {
+ // Nothing
+ }
+ }
+ }
+ if (OS.IS_LINUX || OS.IS_SOLARIS) {
+ service.DisplayName = serviceProperties.getProperty(service.Name +
".0", service.DisplayName);
+ service.Description = serviceProperties.getProperty(service.Name +
".1");
+ }
+ }
+
private Service()
{
super(0);
@@ -72,6 +111,7 @@
throw new OperatingSystemException(Error.getError(e));
}
Name = name;
+ setupKnownService(this);
}
protected Service(ServiceControlManager scm, String name,
@@ -85,6 +125,7 @@
throw new OperatingSystemException(Error.getError(e));
}
Name = name;
+ setupKnownService(this);
}
/**
Added: trunk/sight/java/org/jboss/sight/platform/linux/Services.properties
===================================================================
--- trunk/sight/java/org/jboss/sight/platform/linux/Services.properties
(rev 0)
+++ trunk/sight/java/org/jboss/sight/platform/linux/Services.properties 2007-09-26
15:25:54 UTC (rev 1045)
@@ -0,0 +1,114 @@
+# Copyright(c) 2007 Red Hat Middleware, LLC,
+# and individual contributors as indicated by the @authors tag.
+# See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library in the file COPYING.LIB;
+# if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+#
+# @author Mladen Turk
+#
+# Services.properties
+# List the commonly known Linux services
+#
+
+acpid.0=Power Management
+acpid.1=Listen and dispatch ACPI events from the kernel
+
+anacron.0=Actions scheduler
+anacron.1=Run cron jobs that were left out due to downtime
+
+atd.0=Actions scheduler
+atd.1=Runs commands scheduled by the at command at the time \
+ specified when at was run, and runs batch commands when the load \
+ average is low enough.
+
+auditd.0=Auditing System Daemon
+auditd.1=Linux Auditing System Daemon
+
+autofs.0=Automount
+autofs.1=Automounts filesystems on demand
+
+avahi-daemon.0=Avahi Daemon
+avahi-daemon.1=This is a daemon which runs on client machines to perform \
+ Zeroconf service discovery on a network. avahi-daemon must be \
+ running on systems that use Avahi for service discovery. \
+ Avahi-daemon should not be running otherwise.
+
+avahi-dnsconfd.0=Avahi dns configuration daemon
+avahi-dnsconfd.1=Connects to a running avahi-daemon and runs the script \
+ /etc/avahi/dnsconf.action for each unicast DNS server that is announced
\
+ on the local LAN. This is useful for configuring unicast DNS servers in
\
+ a DHCP-like fashion with mDNS.
+
+bluetooth.0=Bluetooth services
+bluetooth.1=Bluetooth services for service discovery, authentication, \
+ Human Interface Devices, etc.
+
+capi.0=Capi services
+capi.1=Start and stop capi services for passiv ISDN cards
+
+conman.0=ConMan
+conman.1=The ConMan daemon is used for console management.
+
+cpuspeed.0=CPU speed
+cpuspeed.1=Run dynamic CPU speed daemon and/or load appropriate \
+ cpu frequency scaling kernel modules and governors.
+
+crond.0=Cron clock daemon
+crond.1=Cron is a standard UNIX program that runs user-specified \
+ programs at periodic scheduled times. vixie cron adds a \
+ number of features to the basic UNIX cron, including better \
+ security and more powerful configuration options.
+
+cups.0=Common UNIX Printing System
+cups.1=Startup/shutdown script for the Common UNIX \
+ Printing System (CUPS).
+
+cups-config-daemon.0=CUPS configuration daemon (obsolete)
+cups-config-daemon.1=cups-config-daemon is obsolete. \
+ This script just avoids that the postun script \
+ of hal-cups-utils < 0.6.0 fails.
+
+dc_client.0=Distcache Client Proxy
+dc_client.1=Distributed SSL Session Cache Client Proxy.
+
+dc_server.0=Distcache Server
+dc_server.1=Distributed SSL Session Cache server.
+
+dhcdbd.0=DHcp Client D-Bus Daemon
+dhcdbd.1=dhcdbd provides D-BUS control of the ISC DHCP client, \
+ dhclient, and D-BUS access to the DHCP options obtained by \
+ dhclient for each IPv4 interface.
+
+dund.0=Bluetooth Dial-Up-Networking Daemon
+dund.1=Bluetooth Dial-Up-Networking Daemon. Provides PPP over RFCOMM \
+ services.
+
+firstboot.0=Firstboot druid
+firstboot.1=Firstboot is a druid style program that runs on the first time \
+ a machine is booted after install. It checks for the existence \
+ of an /etc/sysconfig/firstboot file. If it doesn't find the file, \
+ then the firstboot program needs to run. If it finds the file, \
+ firstboot will not be run. \
+ If /etc/reconfigSys exists, run the reconfiguration \
+ program and remove /etc/reconfigSys when done. \
+ Also will run if 'reconfig' is on the kernel cmdline.
+
+gpm.0=GPM Mouse support
+gpm.1=GPM adds mouse support to text-based Linux applications such \
+ as the Midnight Commander. It also allows mouse-based console \
+ cut-and-paste operations, and includes support for pop-up \
+ menus on the console.
Property changes on: trunk/sight/java/org/jboss/sight/platform/linux/Services.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/sight/java/org/jboss/sight/platform/solaris/Services.properties
===================================================================
--- trunk/sight/java/org/jboss/sight/platform/solaris/Services.properties
(rev 0)
+++ trunk/sight/java/org/jboss/sight/platform/solaris/Services.properties 2007-09-26
15:25:54 UTC (rev 1045)
@@ -0,0 +1,25 @@
+# Copyright(c) 2007 Red Hat Middleware, LLC,
+# and individual contributors as indicated by the @authors tag.
+# See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library in the file COPYING.LIB;
+# if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+#
+# @author Mladen Turk
+#
+# Services.properties
+# List the commonly known Solaris services
+#
Property changes on:
trunk/sight/java/org/jboss/sight/platform/solaris/Services.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/sight/native/os/linux/service.c
===================================================================
--- trunk/sight/native/os/linux/service.c 2007-09-26 11:57:11 UTC (rev 1044)
+++ trunk/sight/native/os/linux/service.c 2007-09-26 15:25:54 UTC (rev 1045)
@@ -131,68 +131,7 @@
sight_unload_class(_E, &_clazzn);
}
-static const struct {
- const char *script;
- const char *name;
- const char *description;
-} known_services[] = {
- { "acpid"
- "Power Management",
- "Listen and dispatch ACPI events from the kernel"
- },
- { "anacron"
- "Actions scheduler",
- "Run cron jobs that were left out due to downtime"
- },
- { "atd"
- "Actions scheduler",
- "Runs commands scheduled by the at command at the time "
- "specified when at was run, and runs batch commands when the load "
- "average is low enough."
- },
- { "auditd"
- "Auditing System Daemon",
- "Linux Auditing System Daemon"
- },
- { "autofs"
- "Automount",
- "Automounts filesystems on demand"
- },
- { "avahi-daemon"
- "Avahi Daemon",
- "This is a daemon which runs on client machines to perform "
- "Zeroconf service discovery on a network. avahi-daemon must be "
- "running on systems that use Avahi for service discovery. "
- "Avahi-daemon should not be running otherwise."
- },
- { "avahi-dnsconfd"
- "Avahi dns configuration daemon",
- "Connects to a running avahi-daemon and runs the script "
- "/etc/avahi/dnsconf.action for each unicast DNS server that is announced
"
- "on the local LAN. This is useful for configuring unicast DNS servers in
"
- "a DHCP-like fashion with mDNS."
- },
-
- { NULL,
- NULL,
- NULL
- }
-};
-
-int find_service_desc(const char *name)
-{
- int i = 0;
- while (known_services[i].script) {
- if (!strcmp(known_services[i].script, name)) {
- return i;
- }
- i++;
- }
- return -1;
-}
-
-
SIGHT_EXPORT_DECLARE(jint, Service, open0)(SIGHT_STDARGS,
jobject thiz,
jlong instance,
@@ -238,16 +177,8 @@
strcat(smatch, J2S(name));
/* Match the SnnName */
if (!sight_wmatch(sname, smatch)) {
- int snix = find_service_desc(J2S(name));
-
SET_IFIELD_S(0001, thiz, sname);
- if (snix >= 0) {
- SET_IFIELD_S(0004, thiz, known_services[snix].name);
- SET_IFIELD_S(0005, thiz, known_services[snix].description);
- }
- else {
- SET_IFIELD_S(0004, thiz, sent->d_name);
- }
+ SET_IFIELD_S(0004, thiz, sent->d_name);
/* TODO: Launch script with status param
* to figure out the state.