commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1085784 [1/2] - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/platform/ java/org/apache/commons/runtime/platform/aix/ java/org/apache/commons/runtime/platform/bsdx/ java/org/apache/commons/runtime/platform/dar...
Date Sat, 26 Mar 2011 18:56:57 GMT
Author: mturk
Date: Sat Mar 26 18:56:55 2011
New Revision: 1085784

URL: http://svn.apache.org/viewvc?rev=1085784&view=rev
Log:
Add more of the old code with some simplifications

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/InvalidHandleException.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyAccessRights.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryValueType.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControl.java   (with props)
    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)
    commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h   (with props)
    commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h   (with props)
    commons/sandbox/runtime/trunk/src/main/native/shared/callback.c   (with props)
    commons/sandbox/runtime/trunk/src/main/native/shared/observer.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr/memory.h
    commons/sandbox/runtime/trunk/src/main/native/os/linux/misc.c
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/aix/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/bsdx/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/darwin/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/hpux/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,59 @@
+/* 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.linux;
+
+import org.apache.commons.runtime.exception.OperatingSystemException;
+import org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
+
+/**
+ * Security-Enhanced Linux support.
+ */
+public class SELinux
+{
+
+    private SELinux()
+    {
+        // No instance
+    }
+
+    /*
+     * Return 1 if we are running on a SELinux kernel, or 0 if not or -1
+     * if we get an error.
+     * @param type OS type to test.
+     */
+    private static native boolean   enabled0()
+        throws OperatingSystemException;
+
+    /**
+     * Check if we are running on {@code SELinux} kernel.
+     *
+     * @return {@code true} if kernel has {@code SELinux} support enabled.
+     * @throws OperatingSystemException if we have error
+     * @throws UnsupportedOperatingSystemException if not running on {@code Linux}
+     *         operating system.
+     */
+    public static boolean  isEnabled()
+        throws OperatingSystemException, UnsupportedOperatingSystemException
+    {
+        try {
+            return enabled0();
+        } catch (UnsatisfiedLinkError e) {
+            throw new UnsupportedOperatingSystemException();
+        }
+    }
+
+}

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/solaris/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Default.properties Sat Mar 26 18:56:55 2011
@@ -0,0 +1,27 @@
+# -----------------------------------------------------------------------------
+# 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.
+#
+# -----------------------------------------------------------------------------
+# DefaultProperties.properties
+#
+# OS Apache Commons Runtime properties file.
+# Those properties override main DefaultProperties
+#
+# -----------------------------------------------------------------------------
+
+# Windows platform needs explicit 'lib' prefix
+library.load = libacr
+library.load.ssl = libacrssl

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/InvalidHandleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/InvalidHandleException.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/InvalidHandleException.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/InvalidHandleException.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,38 @@
+/* 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.io.IOException;
+
+/**
+ * InvalidHandleException thrown when an attempt is made to
+ * invoke an operation on invalid Windows {@code HANDLE}.
+ *
+ * @since Runtime 1.0
+ */
+public class InvalidHandleException extends IOException
+{
+
+    public InvalidHandleException()
+    {
+        super();
+    }
+
+    public InvalidHandleException(String msg)
+    {
+        super(msg);
+    }
+}

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,260 @@
+/* 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.io.Closeable;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.SyncFailedException;
+import java.util.EnumSet;
+import org.apache.commons.runtime.io.Status;
+
+/**
+ * Registry key class.
+ * <p>
+ * An application can use handles to these keys as entry points to the
+ * registry. These handles are valid for all implementations of the
+ * registry, although the use of the handles may vary from platform to
+ * platform. In addition, other predefined handles have been defined
+ * for specific platforms. The following are handles to the predefined
+ * keys.
+ * </p>
+ */
+public class RegistryKey implements Closeable, Flushable
+{
+
+    /** Registry entries subordinate to this key define types (or classes)
+     * of documents and the properties associated with those types. Shell
+     * and COM applications use the information stored under this key.
+     * For more information, see {@code HKEY_CLASSES_ROOT} Key.
+     * <p>
+     * This key also provides backward compatibility with the Windows 3.1
+     * registration database by storing information for DDE and OLE support.
+     * File viewers and user interface extensions store their OLE class
+     * identifiers in {@code HKEY_CLASSES_ROOT}, and in-process servers are
+     * registered in this key.
+     * </p>
+     * This handle should not be used in a service or an application that
+     * impersonates different users.
+     */
+    public static final RegistryKey ClassesRoot     = new RegistryKey(0x80000000L, "HKEY_CLASSES_ROOT");
+
+    /** Registry entries subordinate to this key define the preferences of
+     * the current user. These preferences include the settings of
+     * environment variables, data about program groups, colors, printers,
+     * network connections, and application preferences. This key makes it
+     * easier to establish the current user's settings; the key maps to the
+     * current user's branch in {@code HKEY_USERS}.
+     */
+    public static final RegistryKey CurrentUser     = new RegistryKey(0x80000001L, "HKEY_CURRENT_USER");
+
+    /** Registry entries subordinate to this key define the physical state
+     * of the computer, including data about the bus type, system memory,
+     * and installed hardware and software. It contains subkeys that hold
+     * current configuration data, including Plug and Play information
+     * (the Enum branch, which includes a complete list of all hardware that
+     * has ever been on the system), network logon preferences, network
+     * security information, software-related information (such as server
+     * names and the location of the server), and other system information.
+     */
+    public static final RegistryKey LocalMachine    = new RegistryKey(0x80000002L, "HKEY_LOCAL_MACHINE");
+
+    /** Registry entries subordinate to this key define the default user
+     * configuration for new users on the local computer and the user
+     * configuration for the current user.
+     */
+    public static final RegistryKey Users           = new RegistryKey(0x80000003L, "HKEY_USERS");
+
+    /** Registry entries subordinate to this key allow you to access
+     * performance data. The data is not actually stored in the registry;
+     * the registry functions cause the system to collect the data from
+     * its source.
+     */
+    public static final RegistryKey PerformanceData = new RegistryKey(0x80000004L, "HKEY_PERFORMANCE_DATA");
+
+    /** Contains information about the current hardware profile of the
+     * local computer system.
+     * <p>
+     * The information under {@code HKEY_CURRENT_CONFIG}
+     * describes only the differences between the current hardware
+     * configuration and the standard configuration. Information about
+     * the standard hardware configuration is stored under the Software
+     * and System keys of {@code HKEY_LOCAL_MACHINE}.
+     * </p>
+     */
+    public static final RegistryKey CurrentConfig   = new RegistryKey(0x80000005L, "HKEY_CURRENT_CONFIG");
+
+    private String name;
+    private long   hKey;
+
+    private RegistryKey(long v, String n)
+    {
+        hKey = v;
+        name = n;
+    }
+
+    public long handle()
+    {
+        return hKey;
+    }
+
+    public String toString()
+    {
+        if (name == null)
+            return "null";
+        else
+            return name;
+    }
+
+    private static native int close0(long key);
+    /**
+     * Called by the garbage collector when the object is destroyed.
+     * The class will free internal resources allocated by the Operating system.
+     * @see Object#finalize()
+     * @throws Throwable the {@code Exception} raised by this method.
+     */
+    @Override
+    protected final void finalize()
+        throws Throwable
+    {
+        if (hKey != 0L) {
+            try {
+                close0(hKey);
+            } catch (Exception e) {
+                // Ignore
+            } finally {
+                hKey = 0L;
+            }
+        }
+    }
+
+    /**
+     * Free the allocated resource by the Operating system.
+     * <p>
+     * Note that {@code Object.finalize()} method will call
+     * this function. However if the native code can block for
+     * long time explicit {@code close()} should be called.
+     * </p>
+     * @see java.io.Closeable#close()
+     * @throws IOException if an I/O error occurs.
+     */
+    public final void close()
+        throws IOException
+    {
+        int s = Status.ENOTIMPL;
+        try {
+            s = close0(hKey);
+        } catch (Exception e) {
+            // Ignore
+        } finally {
+            hKey = 0L;
+        }
+        if (s != 0) {
+            throw new IOException(Status.describe(s));
+        }
+    }
+
+    private static native int flush0(long key);
+    /**
+     * Flushed the underlying object by writing any buffered data.
+     * <p>
+     * {@code fsync()} transfers  all  modified in-core data of the object
+     * referred to by {@code this} Descriptor to the disk device
+     * (or other permanent storage device)  where  that  object resides.
+     * The call blocks until the device reports that the transfer has
+     * completed.  It also flushes  metadata information associated with
+     * {@code this} Descriptor.
+     * </p>
+     *
+     * @throws SyncFailedException when the object cannot be flushed.
+     * @throws IOException if an I/O error occurs.
+     */
+    public final void flush()
+        throws SyncFailedException, IOException
+    {
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        else {
+            int s = flush0(hKey);
+            if (s != 0) {
+                throw new SyncFailedException(Status.describe(s));
+            }
+        }
+    }
+
+    private static native long open0(long key, String name, int sam)
+        throws IOException, SecurityException;
+    private static native long create0(long key, String name, int sam)
+        throws IOException, SecurityException;
+
+    public RegistryKey open(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SecurityException
+    {
+        if (name == null || mode == null) {
+            throw new NullPointerException();
+        }
+        if (hKey == 0L || hKey == -1L) {
+            throw new InvalidHandleException();
+        }
+        long sKey = open0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
+        if (sKey == 0L || sKey == -1L)
+            return null;
+        else
+            return new RegistryKey(sKey, name);
+    }
+
+    public RegistryKey open(String name, RegistryKeyAccessRights... mode)
+        throws NullPointerException, IOException, SecurityException
+    {
+        return open(name, RegistryKeyAccessRights.of(mode));
+    }
+
+    public RegistryKey open(String name)
+        throws NullPointerException, IOException, SecurityException
+    {
+        return open(name, RegistryKeyAccessRights.READ);
+    }
+
+    public RegistryKey create(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SecurityException
+    {
+        if (name == null || mode == null) {
+            throw new NullPointerException();
+        }
+        if (hKey == 0L || hKey == -1L) {
+            throw new InvalidHandleException();
+        }
+        long sKey = create0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
+        if (sKey == 0L || sKey == -1L)
+            return null;
+        else
+            return new RegistryKey(sKey, name);
+    }
+
+    public RegistryKey create(String name, RegistryKeyAccessRights... mode)
+        throws NullPointerException, IOException, SecurityException
+    {
+        return create(name, RegistryKeyAccessRights.of(mode));
+    }
+
+    public RegistryKey create(String name)
+        throws NullPointerException, IOException, SecurityException
+    {
+        return create(name, RegistryKeyAccessRights.ALL_ACCESS);
+    }
+
+}

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyAccessRights.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyAccessRights.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyAccessRights.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyAccessRights.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,115 @@
+/* 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;
+
+/**
+ * Registry Key Access Rights.
+ */
+public enum RegistryKeyAccessRights
+{
+
+    /**
+     * Access is not specified.
+     */
+    NONE(               0x0000),
+
+    ALL_ACCESS(         0x0001),
+    CREATE_LINK(        0x0002),
+    CREATE_SUB_KEY(     0x0004),
+    ENUMERATE_SUB_KEYS( 0x0008),
+    EXECUTE(            0x0010),
+    NOTIFY(             0x0020),
+    QUERY_VALUE(        0x0040),
+    READ(               0x0080),
+    SET_VALUE(          0x0100),
+    WOW64_64KEY(        0x0200),
+    WOW64_32KEY(        0x0400),
+    WRITE(              0x0800);
+
+    private int value;
+    private RegistryKeyAccessRights(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    /**
+     * Integer representing the sum of the integer values
+     * of the {@code KeyAccessRights} enums.
+     * @param set The {@code EnumSet} which values to get.
+     * @return sum of {@code KeyAccessRights} values
+     */
+    public static int bitmapOf(EnumSet<RegistryKeyAccessRights> set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (RegistryKeyAccessRights a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    /**
+     * Integer representing the sum of the integer values
+     * of the {@code KeyAccessRights} enums.
+     * @param set arguments of {@code KeyAccessRights} which values to get.
+     * @return sum of {@code KeyAccessRights} values
+     */
+    public static int bitmapOf(RegistryKeyAccessRights... set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (RegistryKeyAccessRights a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    /**
+     * Returns {@code EnumSet} of {@code KeyAccessRights} enums
+     * from the integer bitmap value.
+     * @param value Integer used to construct the {@code EnumSet}
+     * with {@code KeyAccessRights} values mathching the value flags.
+     * @return set of {@code KeyAccessRights} enums.
+     */
+    public static EnumSet<RegistryKeyAccessRights> valueOf(int value)
+    {
+        EnumSet<RegistryKeyAccessRights> set = EnumSet.noneOf(RegistryKeyAccessRights.class);
+        for (RegistryKeyAccessRights e : values()) {
+            if ((e.value & value) == e.value)
+                set.add(e);
+        }
+        return set;
+    }
+
+    public static EnumSet<RegistryKeyAccessRights> of(RegistryKeyAccessRights... of)
+    {
+        EnumSet<RegistryKeyAccessRights> set = EnumSet.noneOf(RegistryKeyAccessRights.class);
+        if (of != null) {
+            for (RegistryKeyAccessRights a : of)
+                set.add(a);
+        }
+        return set;
+    }
+
+}

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryValueType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryValueType.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryValueType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryValueType.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,90 @@
+/* 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;
+
+
+/**
+ * Type of the {@code Registry} value.
+ * <p>
+ * A registry value can store data in various formats. When you store data
+ * under a registry value, for instance by calling the {@code RegSetValueEx}
+ * function,
+ * you can specify one of the following values to indicate the type of data
+ * being stored. When you retrieve a registry value, functions such as
+ * {@code RegQueryValueEx} use these values to indicate the type of data
+ * retrieved.
+ *</p>
+ */
+public enum RegistryValueType
+{
+    /**
+     * Unknown or unsupported Registry value type.
+     */
+    UNKNOWN(    0),
+
+    /**
+     * Binary data in any form.
+     */
+    BINARY(     1),
+
+    /**
+     * A 32-bit number.
+     */
+    DWORD(      2),
+
+    /**
+     * Null-terminated string that contains unexpanded references to
+     * environment variables (for example, {@code %PATH%"}).
+     */
+    EXPAND_SZ(  3),
+
+    /**
+     * Array of null-terminated strings, terminated by two null characters.
+     */
+    MULTI_SZ(   4),
+
+    /**
+     * A 64-bit number.
+     */
+    QWORD(      5),
+
+    /**
+     * Null-terminated string
+     */
+    SZ(         6);
+
+    private int value;
+    private RegistryValueType(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static RegistryValueType valueOf(int value)
+    {
+        for (RegistryValueType e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return UNKNOWN;
+    }
+
+}

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControl.java?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControl.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControl.java Sat Mar 26 18:56:55 2011
@@ -0,0 +1,88 @@
+/* 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;
+
+/**
+ * ServiceControl types.
+ */
+public enum ServiceControl
+{
+
+    UNKNOWN(       -1),
+    /**
+     * Notifies a service that it should start.
+     */
+    START(          0),
+    /**
+     * Notifies a service that it should stop.<BR/>
+     * After sending the stop request to a service, you should not send
+     * other controls to the service.
+     */
+    STOP(           1),
+    /**
+     * Notifies a service that it should pause.
+     */
+    PAUSE(          2),
+    /**
+     * Notifies a paused service that it should resume.
+     */
+    CONTINUE(       3),
+    /**
+     * Notifies a service that it should report its current status
+     * information to the service control manager.
+     */
+    INTERROGATE(    4),
+    /**
+     * Notifies a service when system shutdown occurs.
+     * <BR/>
+     * Note that ControlService cannot
+     * send this notification; only the system can send it.
+     */
+    SHUTDOWN(       5),
+    /**
+     * Notifies a service that its startup parameters have changed.
+     */
+    PARAMCHANGE(    6),
+    /**
+     * The service defines the action associated with the control code.
+     * Range 128 to 255.
+     */
+    USER(         128);
+
+    private int value;
+    private ServiceControl(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static ServiceControl valueOf(int value)
+    {
+        for (ServiceControl e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        if (value > USER.value)
+            return USER;
+        else
+            return UNKNOWN;
+    }
+}

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

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=1085784&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 Sat Mar 26 18:56:55 2011
@@ -0,0 +1,118 @@
+/* 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 int bitmapOf(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;
+    }
+
+    public static EnumSet<ServiceControlsAccepted> of(ServiceControlsAccepted... of)
+    {
+        EnumSet<ServiceControlsAccepted> set = EnumSet.noneOf(ServiceControlsAccepted.class);
+        if (of != null) {
+            for (ServiceControlsAccepted a : of)
+                set.add(a);
+        }
+        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=1085784&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 Sat Mar 26 18:56:55 2011
@@ -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=1085784&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 Sat Mar 26 18:56:55 2011
@@ -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=1085784&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 Sat Mar 26 18:56:55 2011
@@ -0,0 +1,81 @@
+/* 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;
+
+/**
+ * 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=1085784&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 Sat Mar 26 18:56:55 2011
@@ -0,0 +1,98 @@
+/* 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 t : set)
+                bitmap += t.valueOf();
+        }
+        return bitmap;
+    }
+
+    public static int bitmapOf(ServiceType... set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (ServiceType t : set)
+                bitmap += t.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;
+    }
+
+    public static EnumSet<ServiceType> of(ServiceType... of)
+    {
+        EnumSet<ServiceType> set = EnumSet.noneOf(ServiceType.class);
+        if (of != null) {
+            for (ServiceType t : of)
+                set.add(t);
+        }
+        return set;
+    }
+
+}

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

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Sat Mar 26 18:56:55 2011
@@ -68,15 +68,11 @@ LINUX_SOURCES=\
 	$(TOPDIR)/os/linux/misc.c \
 	$(TOPDIR)/os/linux/os.c
 
-SOLARIS_SOURCES=
-
+AIX_SOURCES=
 BSDX_SOURCES=
-
 DARWIN_SOURCES=
-
 HPUX_SOURCES=
-
-AIX_SOURCES=
+SOLARIS_SOURCES=
 
 LIBSOURCES=\
 	$(BZIP2_SOURCES) \
@@ -90,12 +86,14 @@ LIBSOURCES=\
 	$(TOPDIR)/port/bsdstring.c \
 	$(TOPDIR)/port/bsdsys.c \
 	$(TOPDIR)/shared/bzip2.c \
+	$(TOPDIR)/shared/callback.c \
 	$(TOPDIR)/shared/clazz.c \
 	$(TOPDIR)/shared/debug.c \
 	$(TOPDIR)/shared/error.c \
 	$(TOPDIR)/shared/memory.c \
 	$(TOPDIR)/shared/native.c \
 	$(TOPDIR)/shared/object.c \
+	$(TOPDIR)/shared/observer.c \
 	$(TOPDIR)/shared/string.c \
 	$(TOPDIR)/shared/unsafe.c \
 	$(TOPDIR)/shared/version.c \

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Sat Mar 26 18:56:55 2011
@@ -94,6 +94,7 @@ includes="$INCLUDES"
 ssldflags=""
 bige=0
 so=.so
+dllext=.so
 lib=.a
 obj=o
 bits=""
@@ -113,6 +114,7 @@ has_shared=yes
 has_shared_version=no
 has_zlib_asm=yes
 has_openssl=no
+has_openssl_static=no
 has_ipv6=no
 openssl_home="$OPENSSL_HOME"
 openssl_inc=""
@@ -462,12 +464,6 @@ case "$host" in
         platform=LINUX
         platformver="`uname -r | sed 's/\.//' | sed 's/\..*//'`"
     ;;
-    windows  )
-        platform=WIN32
-        platformver="0x0501"
-        host=win32
-        test ".$cc_set" = .no && cc=cl
-    ;;
     *        )
         platform=`toupper "$host"`
     ;;
@@ -596,7 +592,8 @@ case "$host-$cctype" in
         varadds asflags -c -D$mcpu
         varadds ldflags -lpthread -ldl
         varadds ldrpath '-Wl,-rpath,??(PREFIX)/??(LIBDIR):.'
-        so=".jnilib"
+        so=.jnilib
+        sx=.dynlib
         varadds shflags -dynamiclib -flat_namespace -undefined suppress -fPIC
         if [ ".$has_shared_version" = .yes ]; then
             varadds lddname '-Wl,-compatibility_version,??(VERSION_MAJOR).0.0'
@@ -639,7 +636,10 @@ case "$host-$cctype" in
         varadds asflags -c +Z -D$mcpu
         varadds ldflags -lrt -lpthread -ldld -lm
         varadds asflags +Z
-        test ".$mach" = .parisc && so=.sl
+        if [ ".$mach" = .parisc ]; then
+            so=.sl
+            dllext=.sl
+        fi
         varadds shflags +Z -b
         if [ ".$has_shared_version" = .yes ]; then
             varadds lddname +h 'lib??(NAME)??(SO).??(VERSION_MAJOR)'
@@ -852,7 +852,7 @@ int hello() {return getchar();}
 EOF
     do_printf 'Checking for %-32s' "shared library support"
     cl="$cc -c $ccflags $ccshare $cppopts $cccsrc.c -o $cccsrc.$obj"
-    ll="$ld $lddarch $shflags $cccsrc.$obj $ldflags -o $cccsrc$so"
+    ll="$ld $lddarch $shflags $cccsrc.$obj $ldflags -o $cccsrc$dllext"
     co="`eval $cl 2>&1`"
     if [ ".$co" = "." ]; then
         co="`eval $ll 2>&1`"
@@ -1159,35 +1159,41 @@ else
     have_kstat=0
 fi
 
+have_ocsp=0
+have_openssl=0
+have_openssl_static=0
 if [ ".$has_openssl" = .yes ]; then
     test ".$openssl_inc" != . && varadds includes "-I$openssl_inc"
-    test ".$openssl_lib" != . && varadds ssllibs "-L$openssl_lib"
-    varadds ssllibs -lssl -lcrypto
+    if [ ".$has_openssl_static" = .yes ]; then
+        test ".$openssl_lib" != . && varadds ssllibs "-L$openssl_lib"
+        varadds ssllibs -lssl -lcrypto
+        have_openssl_static=1
+    fi
     have_openssl=1
     have_ocsp=`have_include openssl/ocsp`
     varadds modules '??(SSLOBJECTS)'
 else
     if [ ".$openssl_home" != . ]; then
         varadds includes "-I??(OPENSSL_HOME)"
-        if [ .bits = .64 ]; then
-            if [ -d "$openssl_home/lib64" ]; then
-                varadds ssllibs "-L??(OPENSSL_HOME)/lib64"
-            elif [ -d "$openssl_home/lib" ]; then
-                varadds ssllibs "-L??(OPENSSL_HOME)/lib"
-            fi
-        else
-            if [ -d "$openssl_home/lib" ]; then
-                varadds ssllibs "-L??(OPENSSL_HOME)/lib"
+        if [ ".$has_openssl_static" = .yes ]; then
+            if [ .bits = .64 ]; then
+                if [ -d "$openssl_home/lib64" ]; then
+                    varadds ssllibs "-L??(OPENSSL_HOME)/lib64"
+                elif [ -d "$openssl_home/lib" ]; then
+                    varadds ssllibs "-L??(OPENSSL_HOME)/lib"
+                fi
+            else
+                if [ -d "$openssl_home/lib" ]; then
+                    varadds ssllibs "-L??(OPENSSL_HOME)/lib"
+                fi
             fi
+            varadds ssllibs -lssl -lcrypto
+            have_openssl_static=1
         fi
-        varadds ssllibs -lssl -lcrypto
         has_openssl=yes
         have_openssl=1
         have_ocsp=`have_include w $openssl_home/openssl/ocsp`
         varadds modules '??(SSLOBJECTS)'
-    else
-        have_ocsp=0
-        have_openssl=0
     fi
 fi
 
@@ -1339,6 +1345,7 @@ extern "C" {
 #define HAVE_IPV6               `have_ipv6`
 
 #define HAVE_OPENSSL            $have_openssl
+#define HAVE_OPENSSL_STATIC     $have_openssl_static
 #define HAVE_OCSP               $have_ocsp
 #define HAVE_KSTAT              $have_kstat
 #define HAVE_PORT_H             $have_port_h
@@ -1352,6 +1359,8 @@ extern "C" {
 #define PACKAGE_INCDIR          "$incdir"
 #define PACKAGE_SHAREDIR        "$shrdir"
 #define PACKAGE_CONFIGURED      "`date -u`"
+#define PACKAGE_DLLEXT          "$dllext"
+#define PACKAGE_JNIEXT          "$so"
 
 #define CC_BITS                 $bits
 #define CC_SIZEOF_INT           $sizeof_int
@@ -1422,6 +1431,7 @@ CC=$cc
 CPP=$cpp
 LD=$ld
 SO=$so
+DLLEXT=$dllext
 LIB=$lib
 OBJ=$obj
 SLO=l$obj

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h Sat Mar 26 18:56:55 2011
@@ -0,0 +1,112 @@
+/* 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.
+ */
+
+#ifndef _ACR_CALLBACK_H
+#define _ACR_CALLBACK_H
+
+#include "acr/jniapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file callback.h
+ * @brief
+ *
+ * ACR Callback from Native to Java API.
+ *
+ */
+
+enum {
+    ACR_CALLBACK_NORMAL,
+    ACR_CALLBACK_SYNC       /** Define when the callback for the same object
+                             * can be called from multiple threads.
+                             */
+};
+
+typedef struct acr_callback_t acr_callback_t;
+
+/**
+ * Callback handler function prototype.
+ * The handler function must check for data validity.
+ */
+typedef int (acr_callback_handler_fn_t)(JNIEnv *, acr_callback_t *,
+                                        void **, int);
+
+struct acr_callback_t {
+    size_t                     size;       /* Length of 'this' structure      */
+    int                        type;       /* Type of this callback           */
+    acr_callback_handler_fn_t *handler;    /* Native handler callback         */
+    void                      *ctx;        /* Context data pointer            */
+    void                     **refd;       /* Generic 'reference to' pointer  */
+    jobject                    thiz;       /* Pointer to 'this' Java object   */
+    jobject                    data;       /* handler provided Java object    */
+    jint                       counter;    /* Reference or invocation counter */
+    char                       context[1]; /* Variable size context storage   */
+};
+
+ACR_CLASS_CTOR(Callback);
+ACR_CLASS_DTOR(Callback);
+
+/**
+ * Create and initialize a new Callback.
+ * @param env Current JNI environment
+ * @param refd Opaque data stored as reference inside callback.
+ * @param size Additional context size.
+ * @param type Callback type.
+ * @param handler Callback function pointer.
+ */
+acr_callback_t *
+AcrCallbackCreate(JNI_STDENV, void *refd, size_t size, int type,
+                  acr_callback_handler_fn_t *handler);
+
+/**
+ * Create and attach a new Callback to Java object.
+ * @param env Current JNI environment
+ * @param obj Java Object representing callback instance.
+ * @param refd Java Object representing additional data passed to the callback.
+ * @param size Additional context size.
+ * @param type Callback type.
+ * @param handler Callback function pointer.
+ */
+acr_callback_t *
+AcrCallbackAttach(JNI_STDARGS, jobject refd, size_t size,
+                  int type, acr_callback_handler_fn_t *handler);
+/**
+ * Free the memory associated with this Callback.
+ * @param env Current JNI environment
+ * @param cb Callback to free.
+ */
+int
+AcrCallbackFree(JNI_STDENV, acr_callback_t *cb);
+
+/**
+ * Run the callback.
+ * @param env Current JNI environment
+ * @param cb Callback to run.
+ * @param ctx Arbitrary data passed to the handler.
+ * @param val Arbitrary value to pass to callback method.
+ * @param rv Return value from the callback method.
+ */
+int
+AcrCallbackRun(JNI_STDENV, acr_callback_t *cb, void *ctx, int val, int *rv);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_CALLBACK_H */

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/callback.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h Sat Mar 26 18:56:55 2011
@@ -32,7 +32,7 @@
 
 #define ACR_JNI_EXPORT(RT, CL, MN)      \
     ACR_JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_##CL##_##MN
-#define ACR_OPT_EXPORT(RT, CP, CL, MN)  \
+#define ACR_JNX_EXPORT(RT, CP, CL, MN)  \
     ACR_JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_##CP##_##CL##_##MN
 
 #define JNI_STDARGS             JNIEnv *_E, jobject _O
@@ -53,6 +53,7 @@
 #define I2V(I)                  ((void *)(acr_intptr_t)(I))
 #define V2I(P)                  ((int)(acr_intptr_t)(P))
 #define V2U(P)                  ((unsigned int)(acr_uintptr_t)(P))
+#define V2Z(X)                  ((X) ? JNI_TRUE : JNI_FALSE)
 
 #define ACR_CLASS_CTOR(CL)                          \
     int acr_class_##CL##_load(JNI_STDENV)

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/memory.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/memory.h?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/memory.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/memory.h Sat Mar 26 18:56:55 2011
@@ -33,6 +33,8 @@
                 ((Type *)AcrDebugMalloc(_E, sizeof(Type) * (size_t)(Size), __FILE_FUNC_LINE__))
 #define ACR_CALLOC(Type, Size)      \
                 ((Type *)AcrDebugCalloc(_E, sizeof(Type) * (size_t)(Size), __FILE_FUNC_LINE__))
+#define ACR_EALLOC(Type, Size)      \
+                ((Type *)AcrDebugCalloc(_E, sizeof(Type) + (size_t)(Size), __FILE_FUNC_LINE__))
 #define ACR_TALLOC(Type)            \
                 ((Type *)AcrDebugCalloc(_E, sizeof(Type), __FILE_FUNC_LINE__))
 #define ACR_REALLOC(Type, Mem, Size)\
@@ -42,6 +44,8 @@
                 ((Type *)AcrMalloc(_E, sizeof(Type) * (size_t)(Size)))
 #define ACR_CALLOC(Type, Size)      \
                 ((Type *)AcrCalloc(_E, sizeof(Type) * (size_t)(Size)))
+#define ACR_EALLOC(Type, Size)      \
+                ((Type *)AcrCalloc(_E, sizeof(Type) + (size_t)(Size)))
 #define ACR_TALLOC(Type)            \
                 ((Type *)AcrCalloc(_E, sizeof(Type)))
 #define ACR_REALLOC(Type, Mem, Size)\

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h Sat Mar 26 18:56:55 2011
@@ -0,0 +1,53 @@
+/* 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.
+ */
+
+#ifndef _ACR_OBSERVER_H
+#define _ACR_OBSERVER_H
+
+#include "acr/jniapi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file observer.h
+ * @brief
+ *
+ * ACR java.util.Observer support.
+ *
+ */
+
+ACR_CLASS_CTOR(Observer);
+ACR_CLASS_DTOR(Observer);
+
+/**
+ * Run the callback.
+ * @param env Current JNI environment
+ * @param thiz Instance of the java.util.Observer object.
+ * @param o Instance of the java.util.Observable object.
+ * @param arg Argument passed to the notifyObservers method.
+ * @return If the update callback throws exception ACR_EGENERAL is
+ *         returned.
+*/
+int
+AcrObserverUpdate(JNI_STDARGS, jobject o, jobject arg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_OBSERVER_H */

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/observer.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/misc.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/misc.c?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/misc.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/misc.c Sat Mar 26 18:56:55 2011
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "acr/stdinc.h"
+#include "acr/jniapi.h"
 
 /* Use dynamic loading mechanism if not linked to -lselinux
  */
@@ -30,7 +30,7 @@ int IsSelinuxEnabled()
     static void                *sel = 0;
 
     if (sef == 0) {
-        sel = dlopen("libselinux.so", RTLD_LAZY);
+        sel = dlopen("libselinux" PACKAGE_DLLEXT, RTLD_LAZY);
         if (sel != 0)
             sef = (is_selinux_enabled_t)dlsym(sel, "is_selinux_enabled");
         if (sef == 0)
@@ -38,3 +38,8 @@ int IsSelinuxEnabled()
     }
     return (*sef)();
 }
+
+ACR_JNX_EXPORT(jboolean, platform_linux, Selinux, enabled0)(JNI_STDARGS)
+{
+    return V2Z(IsSelinuxEnabled());
+}
\ No newline at end of file

Added: commons/sandbox/runtime/trunk/src/main/native/shared/callback.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/callback.c?rev=1085784&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/callback.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/callback.c Sat Mar 26 18:56:55 2011
@@ -0,0 +1,192 @@
+/* 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.
+ */
+
+/*
+ *
+ * @author Mladen Turk
+ */
+
+#include "acr/callback.h"
+#include "acr/clazz.h"
+#include "acr/memory.h"
+
+J_DECLARE_CLAZZ = {
+    0,
+    0,
+    0,
+    0,
+    ACR_CLASS_PATH "Callback"
+};
+
+J_DECLARE_M_ID(0000) = {
+    NULL,
+    "handler",
+    "(Ljava/lang/Object;I)I"
+};
+
+ACR_CLASS_CTOR(Callback)
+{
+    int rv;
+
+    if ((rv = AcrLoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+        return rv;
+    J_LOAD_METHOD(0000);
+
+    return 0;
+}
+
+ACR_CLASS_DTOR(Callback)
+{
+    AcrUnloadClass(_E, &_clazzn);
+}
+
+acr_callback_t *
+AcrCallbackCreate(JNI_STDENV, void *refd,
+                  size_t size, int type, acr_callback_handler_fn_t *handler)
+{
+
+    acr_callback_t *cb = ACR_EALLOC(acr_callback_t, size);
+    if (cb == 0)
+        return 0;
+    cb->type    = type;
+    cb->handler = handler;
+    cb->size    = sizeof(acr_callback_t) + size;
+    if (size)
+        cb->ctx  = &cb->context[0];
+    if (refd)
+        cb->refd = &refd;
+    return cb;
+}
+
+acr_callback_t *
+AcrCallbackAttach(JNI_STDARGS, jobject refd, size_t size, int type,
+                  acr_callback_handler_fn_t *handler)
+{
+
+    acr_callback_t *cb = ACR_EALLOC(acr_callback_t, size);
+    if (cb == 0)
+        return 0;
+    if (IS_VALID_HANDLE(_E) && IS_VALID_HANDLE(_O)) {
+        cb->thiz = (*_E)->NewWeakGlobalRef(_E, _O);
+        if (cb->thiz == 0)
+            goto cleanup;
+        if (IS_VALID_HANDLE(refd)) {
+            cb->data = (*_E)->NewWeakGlobalRef(_E, refd);
+            if (cb->data == 0)
+                goto cleanup;
+        }
+    }
+    cb->type    = type;
+    cb->handler = handler;
+    cb->size    = sizeof(acr_callback_t) + size;
+    if (size)
+        cb->ctx = &cb->context[0];
+    return cb;
+
+cleanup:
+    if (IS_VALID_HANDLE(_E) && cb->thiz)
+        (*_E)->DeleteWeakGlobalRef(_E, cb->thiz);
+    AcrFree(cb);
+    return NULL;
+}
+
+int
+AcrCallbackFree(JNI_STDENV, acr_callback_t *cb)
+{
+
+    if (cb == 0)
+        return ACR_EISNULL;
+    if (_E == 0 && cb->thiz)
+        _E = AcrGetJNIEnv();
+    if (IS_VALID_HANDLE(_E)) {
+        if (cb->thiz)
+            (*_E)->DeleteWeakGlobalRef(_E, cb->thiz);
+    }
+    AcrFree(cb);
+    return 0;
+}
+
+int
+AcrCallbackRun(JNI_STDENV, acr_callback_t *cb, void *ctx, int val, int *rv)
+{
+    int rc = ACR_ECLASSNOTFOUND;
+
+    if (cb == 0) {
+        return ACR_EINVAL;
+    }
+    if (_E == 0 && cb->thiz) {
+        /* Get JNIEnv only if needed
+         */
+        _E = AcrGetJNIEnv();
+        if (IS_INVALID_HANDLE(_E))
+            return ACR_ENOJNIENV;
+    }
+    if (cb->handler) {
+        /* This is native callback
+         */
+        if (cb->type == ACR_CALLBACK_SYNC) {
+            /* TODO: Syncronize the access to the callback hander.
+             *       We would need the thread lock for that.
+             *       Implement if API would require such feature.
+             */
+        }
+        /* Execute the handler
+         */
+        *rv = (*cb->handler)(_E, cb, &ctx, val);
+        if (cb->type == ACR_CALLBACK_SYNC) {
+        }
+        rc = 0;
+    }
+    if (cb->thiz == NULL) {
+        /* Either invalid or already handled */
+        return rc;
+    }
+    else {
+        jobject d = 0;
+        jobject o = (*_E)->NewLocalRef(_E, cb->thiz);
+        if (o == 0) {
+            /* Object was garbage collected.
+             * TODO: Check for appropriate errno.
+             */
+            return ACR_DETACH;
+        }
+        if (ctx == 0 && cb->data)
+            d = (*_E)->NewLocalRef(_E, cb->data);
+        else
+            d = (jobject)ctx;
+        if (cb->type == ACR_CALLBACK_SYNC) {
+            /* Syncronize the access to the callback object
+             */
+            if ((*_E)->MonitorEnter(_E, o)) {
+                /* Object locking failed */
+                return ACR_ENOLOCK;
+            }
+        }
+        /* Execute the callback method
+         */
+        *rv = CALL_METHOD2(Int, 0000, o, d, val);
+        if (cb->type == ACR_CALLBACK_SYNC) {
+            /* Unlock */
+            (*_E)->MonitorExit(_E, o);
+        }
+        if (ctx == 0 && d)
+            (*_E)->DeleteLocalRef(_E, d);
+        (*_E)->DeleteLocalRef(_E, o);
+
+        return 0;
+    }
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/shared/callback.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Sat Mar 26 18:56:55 2011
@@ -15,9 +15,12 @@
  */
 
 #include "acr/clazz.h"
+/* Runtime class includes */
 #include "acr/object.h"
 #include "acr/unsafe.h"
 #include "acr/string.h"
+#include "acr/callback.h"
+#include "acr/observer.h"
 
 J_DECLARE_CLAZZ = {
     0,
@@ -233,14 +236,15 @@ AcrInitOptionalClasses(JNI_STDENV)
         }
         i++;
     }
-    /* Init some core Objects and it's methods */
-    ACR_CLASS_LOPT(Unsafe);
     return 0;
 }
 
 int
 AcrLoadRuntimeClasses(JNI_STDENV)
 {
+    ACR_CLASS_LOPT(Unsafe);
+    ACR_CLASS_LOAD(Callback);
+    ACR_CLASS_LOAD(Observer);
 
 #ifdef WIN32
 
@@ -252,6 +256,7 @@ void
 AcrUnloadRuntimeClasses(JNI_STDENV)
 {
 
+    ACR_CLASS_UNLOAD(Callback);
 #ifdef WIN32
 
 #endif

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1085784&r1=1085783&r2=1085784&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Sat Mar 26 18:56:55 2011
@@ -623,7 +623,13 @@ AcrThrow(JNI_STDENV, int cls, const char
             }
             return;
         }
-        _throw_classes[cls].clazz = (jclass)(*_E)->NewGlobalRef(_E, ec);
+        if (_throw_classes[cls].clazz == 0) {
+            /* XXX: This should be guarded by a mutex
+             * incase multiple threads throw united exception
+             * for the first time.
+             */
+            _throw_classes[cls].clazz = (jclass)(*_E)->NewGlobalRef(_E, ec);
+        }
         if (_throw_classes[cls].clazz == 0)
             return;
         (*_E)->DeleteLocalRef(_E, ec);
@@ -682,3 +688,30 @@ AcrThrowException(JNI_STDENV, int cls, i
     }
     AcrThrow(_E, cls, msg);
 }
+
+ACR_JNX_EXPORT(jstring, io, Status, describe)(JNI_STDARGS, jint err)
+{
+    char buf[ACR_MBUFF_SIZ] = "";
+
+    _cr_strerror_r(err, buf, ACR_MBUFF_SIZ);
+    return AcrNewJavaStringA(_E, buf);
+}
+
+ACR_JNX_EXPORT(jboolean, io, Status, is0)(JNI_STDARGS, jint what, jint err)
+{
+    jboolean rv = JNI_FALSE;
+    switch (what) {
+        case 0:
+            if (ACR_STATUS_IS_EACCES(err)) rv = JNI_TRUE;
+        break;
+        case 1:
+            if (ACR_STATUS_IS_EEXIST(err)) rv = JNI_TRUE;
+        break;
+        case 2:
+            if (ACR_STATUS_IS_ENOENT(err)) rv = JNI_TRUE;
+        break;
+        default:
+        break;
+    }
+    return rv;
+}



Mime
View raw message