You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/10/09 19:47:02 UTC

svn commit: r823634 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows: ServiceControlsAccepted.java ServiceErrorControl.java ServiceStartType.java ServiceState.java ServiceType.java

Author: mturk
Date: Fri Oct  9 17:47:01 2009
New Revision: 823634

URL: http://svn.apache.org/viewvc?rev=823634&view=rev
Log:
Add bunch of windows service enums

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java   (with props)

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java?rev=823634&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java Fri Oct  9 17:47:01 2009
@@ -0,0 +1,96 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+import java.util.EnumSet;
+
+/**
+ * ServiceControlsAccepted flags.
+ * Control codes the service accepts and processes in its handler function.
+ */
+public enum ServiceControlsAccepted
+{
+
+    /**
+     * By default, all services accept the
+     * {@link ServiceControl#INTERROGATE ServiceControl.INTERROGATE} value.
+     */
+    DEFAULT(        0x00000000),
+
+    /**
+     * The service can be stopped.
+     * This control code allows the service to receive
+     * {@link ServiceControl#STOP ServiceControl.STOP} notifications.
+     */
+    STOP(           0x00000001),
+
+    /**
+     * The service can be paused and continued.
+     * This control code allows the service to receive
+     * {@link ServiceControl#PAUSE ServiceControl.PAUSE} and
+     * {@link ServiceControl#CONTINUE ServiceControl.CONTINUE}
+     * notifications.
+     */
+    PAUSE_CONTINUE( 0x00000002),
+
+    /**
+     * The service is notified when system shutdown occurs.
+     * This control code allows the service to receive
+     * {@link ServiceControl#SHUTDOWN ServiceControl.SHUTDOWN} notifications.
+     * <BR/>
+     * Note that ControlService cannot
+     * send this notification; only the system can send it.
+     */
+    SHUTDOWN(       0x00000004);
+
+    private int value;
+    private ServiceControlsAccepted(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static int bitmapOf(EnumSet<ServiceControlsAccepted> set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (ServiceControlsAccepted a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    public static EnumSet<ServiceControlsAccepted> valueOf(int value)
+    {
+        EnumSet<ServiceControlsAccepted> set = EnumSet.noneOf(ServiceControlsAccepted.class);
+        if (value == 0) {
+            set.add(DEFAULT);
+            return set;
+        }
+        for (ServiceControlsAccepted e : values()) {
+            if (e == DEFAULT)
+                continue;
+            if ((e.value & value) == e.value)
+                set.add(e);
+        }
+        return set;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java?rev=823634&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java Fri Oct  9 17:47:01 2009
@@ -0,0 +1,71 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+/**
+ * ServiceErrorControl enumeration.
+ * Represents severity of the error, and action taken, if this
+ * service fails to start.
+ */
+public enum ServiceErrorControl
+{
+
+    /**
+     * The startup (boot) program logs the error but continues the
+     * startup operation.
+     */
+    IGNORE(     0),
+    /**
+     * The startup program logs the error and displays a message
+     * box pop-up but continues the startup operation.
+     */
+    NORMAL(     1),
+    /**
+     * The startup program logs the error. If the last-known good
+     * configuration is being started, the startup operation continues.
+     * Otherwise, the system is restarted with the last-known-good
+     * configuration.
+     */
+    SEVERE(     2),
+    /**
+     * The startup program logs the error, if possible. If the last-known
+     * good configuration is being started, the startup operation fails.
+     * Otherwise, the system is restarted with the last-known good
+     * configuration.
+     */
+    CRITICAL(   3);
+
+    private int value;
+    private ServiceErrorControl(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static ServiceErrorControl valueOf(int value)
+    {
+        for (ServiceErrorControl e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return IGNORE;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceErrorControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java?rev=823634&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java Fri Oct  9 17:47:01 2009
@@ -0,0 +1,71 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+/**
+ * ServiceStartType enumeration.
+ * Determines when to start the service.
+ */
+public enum ServiceStartType
+{
+
+    /**
+     * A device driver started by the system loader.
+     * This value is valid only for driver services.
+     */
+    BOOT(       0),
+    /**
+     * A device driver started by the IoInitSystem function.
+     * This value is valid only for driver services.
+     */
+    SYSTEM(     1),
+    /**
+     * A service started automatically by the service control manager
+     * during system startup.
+     */
+    AUTO(       2),
+    /**
+     * A service started by the service control manager when a process
+     * calls the StartService function.
+     */
+    DEMAND(     3),
+    /**
+     * A service that cannot be started. Attempts to start the service
+     * result in the error code ERROR_SERVICE_DISABLED.
+     */
+    DISABLED(   4);
+
+    private int value;
+    private ServiceStartType(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static ServiceStartType valueOf(int value)
+    {
+        for (ServiceStartType e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return BOOT;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceStartType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java?rev=823634&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java Fri Oct  9 17:47:01 2009
@@ -0,0 +1,83 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+import java.util.EnumSet;
+
+/**
+ * ServiceState enumeration.
+ */
+public enum ServiceState
+{
+
+    /**
+     * Unknown service state.
+     */
+    UNKNOWN(            0),
+    /**
+     * The service is not running.
+     */
+    STOPPED(            1),
+    /**
+     * The service is starting.
+     */
+    START_PENDING(      2),
+    /**
+     * The service is stopping.
+     */
+    STOP_PENDING(       3),
+    /**
+     * The service is running.
+     */
+    RUNNING(            4),
+    /**
+     * The service continue is pending.
+     */
+    CONTINUE_PENDING(   5),
+    /**
+     * The service pause is pending.
+     */
+    PAUSE_PENDING(      6),
+    /**
+     * The service is paused.
+     */
+    PAUSED(             7),
+    /**
+     * The service is disabled.
+     */
+    DISABLED(           8);
+
+    private int value;
+    private ServiceState(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static ServiceState valueOf(int value)
+    {
+        for (ServiceState e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return UNKNOWN;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java?rev=823634&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java Fri Oct  9 17:47:01 2009
@@ -0,0 +1,78 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+import java.util.EnumSet;
+
+/**
+ * Type of service.
+ */
+public enum ServiceType
+{
+
+    /** Default system service type.  */
+    DEFAULT(            0x00000000),
+    /** The service is a device driver.  */
+    FILE_SYSTEM_DRIVER( 0x00000002),
+     /** The service is a device driver */
+    KERNEL_DRIVER(      0x00000001),
+    /** The service runs in its own process. */
+    OWN_PROCESS(        0x00000010),
+    /** The service shares a process with other services. */
+    SHARE_PROCESS(      0x00000020),
+    /** The service can interact with the desktop. */
+    INTERACTIVE_PROCESS(0x00000100);
+
+
+    private int value;
+    private ServiceType(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static int bitmapOf(EnumSet<ServiceType> set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (ServiceType a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    public static EnumSet<ServiceType> valueOf(int value)
+    {
+        EnumSet<ServiceType> set = EnumSet.noneOf(ServiceType.class);
+        if (value == 0) {
+            set.add(DEFAULT);
+            return set;
+        }
+        for (ServiceType e : values()) {
+            if (e == DEFAULT)
+                continue;
+            if ((e.value & value) == e.value)
+                set.add(e);
+        }
+        return set;
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
------------------------------------------------------------------------------
    svn:eol-style = native