You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by br...@apache.org on 2011/12/22 06:54:53 UTC

svn commit: r1222072 [2/13] - in /incubator/npanday/trunk: ./ components/dotnet-executable/src/main/java/npanday/executable/ components/dotnet-executable/src/main/java/npanday/executable/compiler/ components/dotnet-executable/src/main/java/npanday/exec...

Modified: incubator/npanday/trunk/components/dotnet-model/settings/src/test/resources/sample-settings.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-model/settings/src/test/resources/sample-settings.xml?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-model/settings/src/test/resources/sample-settings.xml (original)
+++ incubator/npanday/trunk/components/dotnet-model/settings/src/test/resources/sample-settings.xml Thu Dec 22 06:54:49 2011
@@ -1,42 +1,42 @@
-<!--
-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.
--->
-<npandaySettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-  <operatingSystem>Microsoft Windows NT 6.1.7600.0</operatingSystem>
-  <defaultSetup>
-    <vendorName>MICROSOFT</vendorName>
-    <vendorVersion>2.0.50727</vendorVersion>
-    <frameworkVersion>2.0.50727</frameworkVersion>
-  </defaultSetup>
-  <vendors>
-    <vendor>
-      <vendorName>MICROSOFT</vendorName>
-      <vendorVersion>2.0.50727</vendorVersion>
-      <frameworks>
-        <framework>
-          <frameworkVersion>2.0.50727</frameworkVersion>
-          <installRoot>C:\Windows\Microsoft.NET\Framework64\v2.0.50727</installRoot>
-          <sdkInstallRoot>C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\</sdkInstallRoot>
-          <executablePaths>
-            <executablePath>C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\bin</executablePath>
-          </executablePaths>
-        </framework>
-      </frameworks>
-    </vendor>
-  </vendors>
-</npandaySettings>
+<!--
+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.
+-->
+<npandaySettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <operatingSystem>Microsoft Windows NT 6.1.7600.0</operatingSystem>
+  <defaultSetup>
+    <vendorName>MICROSOFT</vendorName>
+    <vendorVersion>2.0.50727</vendorVersion>
+    <frameworkVersion>2.0.50727</frameworkVersion>
+  </defaultSetup>
+  <vendors>
+    <vendor>
+      <vendorName>MICROSOFT</vendorName>
+      <vendorVersion>2.0.50727</vendorVersion>
+      <frameworks>
+        <framework>
+          <frameworkVersion>2.0.50727</frameworkVersion>
+          <installRoot>C:\Windows\Microsoft.NET\Framework64\v2.0.50727</installRoot>
+          <sdkInstallRoot>C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\</sdkInstallRoot>
+          <executablePaths>
+            <executablePath>C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\bin</executablePath>
+          </executablePaths>
+        </framework>
+      </frameworks>
+    </vendor>
+  </vendors>
+</npandaySettings>

Propchange: incubator/npanday/trunk/components/dotnet-model/settings/src/test/resources/sample-settings.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ModelInterpolator.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ModelInterpolator.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ModelInterpolator.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ModelInterpolator.java Thu Dec 22 06:54:49 2011
@@ -1,13 +1,13 @@
-package npanday.registry;
-
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.interpolation.InterpolationException;
-
-/**
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- */
-public interface ModelInterpolator
-{
-    <T> T interpolate( T model, MavenProject project )
-        throws InterpolationException;
-}
+package npanday.registry;
+
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.interpolation.InterpolationException;
+
+/**
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public interface ModelInterpolator
+{
+    <T> T interpolate( T model, MavenProject project )
+        throws InterpolationException;
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/ModelInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessException.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessException.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessException.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessException.java Thu Dec 22 06:54:49 2011
@@ -1,50 +1,50 @@
-package npanday.registry;
-
-/**
- * Thrown to indicate an error while accessing the windows registry.
- *
- * @author Shane Isbell
- */
-public class WindowsRegistryAccessException
-    extends Exception
-{
-
-    /**
-     * Constructs an <code>WindowsRegistryAccessException</code>  with no exception message.
-     */
-    public WindowsRegistryAccessException()
-    {
-        super();
-    }
-
-    /**
-     * Constructs an <code>WindowsRegistryAccessException</code> with the specified exception message.
-     *
-     * @param message the exception message
-     */
-    public WindowsRegistryAccessException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Constructs an <code>WindowsRegistryAccessException</code> with the specified exception message and cause of the exception.
-     *
-     * @param message the exception message
-     * @param cause   the cause of the exception
-     */
-    public WindowsRegistryAccessException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    /**
-     * Constructs an <code>WindowsRegistryAccessException</code> with the cause of the exception.
-     *
-     * @param cause the cause of the exception
-     */
-    public WindowsRegistryAccessException( Throwable cause )
-    {
-        super( cause );
-    }
-}
+package npanday.registry;
+
+/**
+ * Thrown to indicate an error while accessing the windows registry.
+ *
+ * @author Shane Isbell
+ */
+public class WindowsRegistryAccessException
+    extends Exception
+{
+
+    /**
+     * Constructs an <code>WindowsRegistryAccessException</code>  with no exception message.
+     */
+    public WindowsRegistryAccessException()
+    {
+        super();
+    }
+
+    /**
+     * Constructs an <code>WindowsRegistryAccessException</code> with the specified exception message.
+     *
+     * @param message the exception message
+     */
+    public WindowsRegistryAccessException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Constructs an <code>WindowsRegistryAccessException</code> with the specified exception message and cause of the exception.
+     *
+     * @param message the exception message
+     * @param cause   the cause of the exception
+     */
+    public WindowsRegistryAccessException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    /**
+     * Constructs an <code>WindowsRegistryAccessException</code> with the cause of the exception.
+     *
+     * @param cause the cause of the exception
+     */
+    public WindowsRegistryAccessException( Throwable cause )
+    {
+        super( cause );
+    }
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessProvider.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessProvider.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessProvider.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessProvider.java Thu Dec 22 06:54:49 2011
@@ -1,56 +1,56 @@
-package npanday.registry;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- */
-public interface WindowsRegistryAccessProvider
-{
-   /**
-     * Tries to get a registry value from the Windows registry.
-     * @param registryHKey
-     * @param key
-     * @param valueName
-     * @return The value of the key or null.
-     */
-    String getValue( RegistryHKey registryHKey, String key, String valueName ) throws
-        WindowsRegistryAccessException;
-
-    public static enum RegistryHKey
-    {
-        HKLM( "HKEY_LOCAL_MACHINE", 0x80000002 ),
-        HKCU( "HKEY_CURRENT_USER",  0x80000001 );
-
-        private String longName;
-        private int hkey;
-
-        RegistryHKey( String longName, int hkey )
-        {
-            this.longName = longName;
-            this.hkey = hkey;
-        }
-
-        public String getLongName()
-        {
-            return longName;
-        }
-
-        public int getHKey()
-        {
-            return hkey;
-        }
-
-        public static RegistryHKey tryGetFromName(String name){
-            checkArgument( name != null, "Name must not be null");
-
-            if (name.equals("HKLM") || name.equals(HKLM.getLongName()))
-                return HKLM;
-            if (name.equals("HKCU") || name.equals(HKCU.getLongName()))
-                return HKCU;
-
-            return null;
-        }
-    }
-}
-
+package npanday.registry;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public interface WindowsRegistryAccessProvider
+{
+   /**
+     * Tries to get a registry value from the Windows registry.
+     * @param registryHKey
+     * @param key
+     * @param valueName
+     * @return The value of the key or null.
+     */
+    String getValue( RegistryHKey registryHKey, String key, String valueName ) throws
+        WindowsRegistryAccessException;
+
+    public static enum RegistryHKey
+    {
+        HKLM( "HKEY_LOCAL_MACHINE", 0x80000002 ),
+        HKCU( "HKEY_CURRENT_USER",  0x80000001 );
+
+        private String longName;
+        private int hkey;
+
+        RegistryHKey( String longName, int hkey )
+        {
+            this.longName = longName;
+            this.hkey = hkey;
+        }
+
+        public String getLongName()
+        {
+            return longName;
+        }
+
+        public int getHKey()
+        {
+            return hkey;
+        }
+
+        public static RegistryHKey tryGetFromName(String name){
+            checkArgument( name != null, "Name must not be null");
+
+            if (name.equals("HKLM") || name.equals(HKLM.getLongName()))
+                return HKLM;
+            if (name.equals("HKCU") || name.equals(HKCU.getLongName()))
+                return HKCU;
+
+            return null;
+        }
+    }
+}
+

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/WindowsRegistryAccessProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java Thu Dec 22 06:54:49 2011
@@ -1,167 +1,167 @@
-package npanday.registry.impl;
-
-import npanday.registry.ModelInterpolator;
-import npanday.registry.NPandayRepositoryException;
-import npanday.registry.Repository;
-import org.codehaus.plexus.interpolation.InterpolationException;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-
-import javax.naming.OperationNotSupportedException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- * Provides base functionality for configuration repositories that read
- * from both resources and files. It supports multiple sources, clear, reload
- * and content versioning.
- *
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- * @param <T>
- */
-public abstract class AbstractMultisourceRepository<T>
-    extends AbstractLogEnabled
-    implements Repository
-{
-    private Hashtable properties;
-
-    /**
-     * The list of sources loaded into the repository.
-     */
-    private List<URL> sources = new ArrayList<URL>();
-
-    private int contentVersion = 0;
-
-    public void load( URL sourceUrl )
-        throws NPandayRepositoryException
-    {
-        loadAndMerge( sourceUrl );
-        sources.add( sourceUrl );
-    }
-
-    public void clearAll()
-        throws OperationNotSupportedException
-    {
-        sources.clear();
-        clear();
-    }
-
-    private void loadAndMerge( URL sourceUrl )
-        throws NPandayRepositoryException
-    {
-        T model;
-        try
-        {
-            Reader reader = new InputStreamReader( sourceUrl.openStream() );
-            model = loadFromReader( reader, properties );
-        }
-        catch ( IOException e )
-        {
-            throw new NPandayRepositoryException(
-                "NPANDAY-111-000: An error occurred while reading " + sourceUrl + " into " + getClass().getSimpleName(),
-                e );
-        }
-        catch ( org.codehaus.plexus.util.xml.pull.XmlPullParserException e )
-        {
-            throw new NPandayRepositoryException(
-                "NPANDAY-111-001: Could not read " + sourceUrl + " into " + getClass().getSimpleName(), e );
-        }
-
-        try
-        {
-            interpolateModel( model );
-        }
-        catch ( InterpolationException e )
-        {
-            throw new NPandayRepositoryException(
-                "NPANDAY-111-001: Error on interpolating model from " + sourceUrl, e );
-        }
-
-        normalizeInterpolatedModelNodes( model );
-
-        mergeLoadedModel( model );
-        incrementContentVersion();
-    }
-
-    protected void normalizeInterpolatedModelNodes( T model ){
-
-    }
-
-    /**
-     * Filters in properties from windows registry, environment variables, and (hopefully soon)
-     * the running mojos Maven project.
-     *
-     * @param model
-     * @throws InterpolationException
-     */
-    private void interpolateModel( T model )
-        throws InterpolationException
-    {
-       // TODO: somehow we have to get the MavenProject here in order to filter it in
-       getInterpolator().interpolate( model, null );
-    }
-
-    /**
-     * @return The (probably injected) interpolator.
-     */
-    protected abstract ModelInterpolator getInterpolator();
-
-    protected abstract T loadFromReader( Reader reader, Hashtable properties )
-        throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-    protected abstract void mergeLoadedModel( T model )
-        throws NPandayRepositoryException;
-
-    /**
-     * The properties configured in the registry.
-     */
-    public void setProperties( Hashtable props )
-    {
-        properties = props;
-    }
-
-    /**
-     * Reloads this repository based on all provided sources.
-     */
-    public void reloadAll()
-        throws IOException, NPandayRepositoryException
-    {
-        clear();
-        for ( URL source : sources )
-        {
-            // TODO: throw better exception
-            loadAndMerge( source );
-        }
-    }
-
-    /**
-     * Remove all stored values in preparation for a reload.
-     */
-    protected abstract void clear();
-
-    /**
-     * @return The current version of the content. Will be increased, every time new content is loaded
-     *         into the same instance. This is useful, if you built a cache upon the values provided by this repository.
-     */
-    public int getContentVersion()
-    {
-        return this.contentVersion;
-    }
-
-    protected void incrementContentVersion()
-    {
-        this.contentVersion++;
-    }
-
-    /**
-     * @return The properties, the repository was initialized with.
-     */
-    public Hashtable getProperties()
-    {
-        return properties;
-    }
-}
+package npanday.registry.impl;
+
+import npanday.registry.ModelInterpolator;
+import npanday.registry.NPandayRepositoryException;
+import npanday.registry.Repository;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import javax.naming.OperationNotSupportedException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Provides base functionality for configuration repositories that read
+ * from both resources and files. It supports multiple sources, clear, reload
+ * and content versioning.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ * @param <T>
+ */
+public abstract class AbstractMultisourceRepository<T>
+    extends AbstractLogEnabled
+    implements Repository
+{
+    private Hashtable properties;
+
+    /**
+     * The list of sources loaded into the repository.
+     */
+    private List<URL> sources = new ArrayList<URL>();
+
+    private int contentVersion = 0;
+
+    public void load( URL sourceUrl )
+        throws NPandayRepositoryException
+    {
+        loadAndMerge( sourceUrl );
+        sources.add( sourceUrl );
+    }
+
+    public void clearAll()
+        throws OperationNotSupportedException
+    {
+        sources.clear();
+        clear();
+    }
+
+    private void loadAndMerge( URL sourceUrl )
+        throws NPandayRepositoryException
+    {
+        T model;
+        try
+        {
+            Reader reader = new InputStreamReader( sourceUrl.openStream() );
+            model = loadFromReader( reader, properties );
+        }
+        catch ( IOException e )
+        {
+            throw new NPandayRepositoryException(
+                "NPANDAY-111-000: An error occurred while reading " + sourceUrl + " into " + getClass().getSimpleName(),
+                e );
+        }
+        catch ( org.codehaus.plexus.util.xml.pull.XmlPullParserException e )
+        {
+            throw new NPandayRepositoryException(
+                "NPANDAY-111-001: Could not read " + sourceUrl + " into " + getClass().getSimpleName(), e );
+        }
+
+        try
+        {
+            interpolateModel( model );
+        }
+        catch ( InterpolationException e )
+        {
+            throw new NPandayRepositoryException(
+                "NPANDAY-111-001: Error on interpolating model from " + sourceUrl, e );
+        }
+
+        normalizeInterpolatedModelNodes( model );
+
+        mergeLoadedModel( model );
+        incrementContentVersion();
+    }
+
+    protected void normalizeInterpolatedModelNodes( T model ){
+
+    }
+
+    /**
+     * Filters in properties from windows registry, environment variables, and (hopefully soon)
+     * the running mojos Maven project.
+     *
+     * @param model
+     * @throws InterpolationException
+     */
+    private void interpolateModel( T model )
+        throws InterpolationException
+    {
+       // TODO: somehow we have to get the MavenProject here in order to filter it in
+       getInterpolator().interpolate( model, null );
+    }
+
+    /**
+     * @return The (probably injected) interpolator.
+     */
+    protected abstract ModelInterpolator getInterpolator();
+
+    protected abstract T loadFromReader( Reader reader, Hashtable properties )
+        throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+    protected abstract void mergeLoadedModel( T model )
+        throws NPandayRepositoryException;
+
+    /**
+     * The properties configured in the registry.
+     */
+    public void setProperties( Hashtable props )
+    {
+        properties = props;
+    }
+
+    /**
+     * Reloads this repository based on all provided sources.
+     */
+    public void reloadAll()
+        throws IOException, NPandayRepositoryException
+    {
+        clear();
+        for ( URL source : sources )
+        {
+            // TODO: throw better exception
+            loadAndMerge( source );
+        }
+    }
+
+    /**
+     * Remove all stored values in preparation for a reload.
+     */
+    protected abstract void clear();
+
+    /**
+     * @return The current version of the content. Will be increased, every time new content is loaded
+     *         into the same instance. This is useful, if you built a cache upon the values provided by this repository.
+     */
+    public int getContentVersion()
+    {
+        return this.contentVersion;
+    }
+
+    protected void incrementContentVersion()
+    {
+        this.contentVersion++;
+    }
+
+    /**
+     * @return The properties, the repository was initialized with.
+     */
+    public Hashtable getProperties()
+    {
+        return properties;
+    }
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/AbstractMultisourceRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java Thu Dec 22 06:54:49 2011
@@ -1,196 +1,196 @@
-package npanday.registry.impl;
-
-/*
- * 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.
- */
-
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.interpolation.InterpolationException;
-import org.codehaus.plexus.interpolation.Interpolator;
-import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
-import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
-import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
-import org.codehaus.plexus.interpolation.RecursionInterceptor;
-import org.codehaus.plexus.interpolation.StringSearchInterpolator;
-import org.codehaus.plexus.interpolation.object.FieldBasedObjectInterpolator;
-import org.codehaus.plexus.interpolation.object.ObjectInterpolationWarning;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * Interpolates Maven Project expressions and registry lookups.
- *
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- * @plexus.component role="npanday.registry.ModelInterpolator"
- */
-public class ContextAwareModelInterpolator
-    extends AbstractLogEnabled
-    implements npanday.registry.ModelInterpolator
-{
-    private static final Properties ENVIRONMENT_VARIABLES;
-
-    public static final List<String> PROJECT_PREFIXES;
-
-    public static final List<String> PROJECT_PROPERTIES_PREFIXES;
-
-    public static final String SETTINGS_PREFIX = "settings.";
-
-    static
-    {
-        final List<String> projectPrefixes = new ArrayList<String>();
-        projectPrefixes.add( "pom." );
-        projectPrefixes.add( "project." );
-
-        PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
-
-        final List<String> projectPropertiesPrefixes = new ArrayList<String>();
-
-        projectPropertiesPrefixes.add( "pom.properties." );
-        projectPropertiesPrefixes.add( "project.properties." );
-
-        PROJECT_PROPERTIES_PREFIXES = Collections.unmodifiableList( projectPropertiesPrefixes );
-
-        Properties environmentVariables;
-        try
-        {
-            environmentVariables = CommandLineUtils.getSystemEnvVars( false );
-        }
-        catch ( final IOException e )
-        {
-            environmentVariables = new Properties();
-        }
-
-        ENVIRONMENT_VARIABLES = environmentVariables;
-    }
-
-    public <T> T interpolate( final T model, final MavenProject project ) throws InterpolationException
-    {
-        @SuppressWarnings( "unchecked" )
-        final Set<String> blacklistFields = new HashSet<String>(
-            FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES
-        );
-
-        @SuppressWarnings( "unchecked" )
-        final Set<String> blacklistPkgs = FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_PACKAGE_PREFIXES;
-
-        final FieldBasedObjectInterpolator objectInterpolator = new FieldBasedObjectInterpolator(
-            blacklistFields, blacklistPkgs
-        );
-        final Interpolator interpolator = buildInterpolator( project );
-
-        // TODO: Will this adequately detect cycles between prefixed property references and prefixed project
-        // references??
-        final RecursionInterceptor interceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES, true );
-
-        try
-        {
-            objectInterpolator.interpolate( model, interpolator, interceptor );
-        }
-        finally
-        {
-            interpolator.clearAnswers();
-        }
-
-        if ( objectInterpolator.hasWarnings() && getLogger().isDebugEnabled() )
-        {
-            final StringBuffer sb = new StringBuffer();
-
-            sb.append( "NPANDAY-116-000: One or more minor errors occurred while interpolating the model: \n" );
-
-            @SuppressWarnings( "unchecked" )
-            final List<ObjectInterpolationWarning> warnings = objectInterpolator.getWarnings();
-            for ( final Iterator<ObjectInterpolationWarning> it = warnings.iterator(); it.hasNext(); )
-            {
-                final ObjectInterpolationWarning warning = it.next();
-
-                sb.append( '\n' ).append( warning );
-            }
-
-            sb.append( "\n\nThese values were SKIPPED, but the assembly process will continue.\n" );
-
-            getLogger().debug( sb.toString() );
-        }
-
-        return model;
-    }
-
-    public static Interpolator buildInterpolator( final MavenProject project )
-    {
-        final StringSearchInterpolator interpolator = new StringSearchInterpolator();
-        interpolator.setCacheAnswers( true );
-
-        if ( project != null )
-        {
-            interpolator.addValueSource(
-                new PrefixedPropertiesValueSource(
-                    PROJECT_PROPERTIES_PREFIXES, project.getProperties(), true
-                )
-            );
-
-            interpolator.addValueSource(
-                new PrefixedObjectValueSource(
-                    PROJECT_PREFIXES, project, true
-                )
-            );
-        }
-
-        /*final Properties settingsProperties = new Properties();
-        if ( session != null && session.getSettings() != null )
-        {
-            settingsProperties.setProperty( "localRepository", session.getSettings().getLocalRepository() );
-            settingsProperties.setProperty( "settings.localRepository", configSource.getLocalRepository().getBasedir
-            () );
-        }
-        interpolator.addValueSource( new PropertiesBasedValueSource( settingsProperties ) );
-
-        Properties commandLineProperties = System.getProperties();
-        if ( session != null )
-        {
-            commandLineProperties = new Properties();
-            if ( session.getExecutionProperties() != null )
-            {
-                commandLineProperties.putAll( session.getExecutionProperties() );
-            }
-            
-            if ( session.getUserProperties() != null )
-            {
-                commandLineProperties.putAll( session.getUserProperties() );
-            }
-        }
-        interpolator.addValueSource( new PropertiesBasedValueSource( commandLineProperties ) );
-        */
-
-        interpolator.addValueSource(
-            new PrefixedPropertiesValueSource(
-                Collections.singletonList( "env." ), ENVIRONMENT_VARIABLES, true
-            )
-        );
-        interpolator.addValueSource( new WindowsRegistryValueSource( new WinRegistry() ) );
-
-        return interpolator;
-    }
-}
+package npanday.registry.impl;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
+import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
+import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
+import org.codehaus.plexus.interpolation.RecursionInterceptor;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.interpolation.object.FieldBasedObjectInterpolator;
+import org.codehaus.plexus.interpolation.object.ObjectInterpolationWarning;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Interpolates Maven Project expressions and registry lookups.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ * @plexus.component role="npanday.registry.ModelInterpolator"
+ */
+public class ContextAwareModelInterpolator
+    extends AbstractLogEnabled
+    implements npanday.registry.ModelInterpolator
+{
+    private static final Properties ENVIRONMENT_VARIABLES;
+
+    public static final List<String> PROJECT_PREFIXES;
+
+    public static final List<String> PROJECT_PROPERTIES_PREFIXES;
+
+    public static final String SETTINGS_PREFIX = "settings.";
+
+    static
+    {
+        final List<String> projectPrefixes = new ArrayList<String>();
+        projectPrefixes.add( "pom." );
+        projectPrefixes.add( "project." );
+
+        PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
+
+        final List<String> projectPropertiesPrefixes = new ArrayList<String>();
+
+        projectPropertiesPrefixes.add( "pom.properties." );
+        projectPropertiesPrefixes.add( "project.properties." );
+
+        PROJECT_PROPERTIES_PREFIXES = Collections.unmodifiableList( projectPropertiesPrefixes );
+
+        Properties environmentVariables;
+        try
+        {
+            environmentVariables = CommandLineUtils.getSystemEnvVars( false );
+        }
+        catch ( final IOException e )
+        {
+            environmentVariables = new Properties();
+        }
+
+        ENVIRONMENT_VARIABLES = environmentVariables;
+    }
+
+    public <T> T interpolate( final T model, final MavenProject project ) throws InterpolationException
+    {
+        @SuppressWarnings( "unchecked" )
+        final Set<String> blacklistFields = new HashSet<String>(
+            FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES
+        );
+
+        @SuppressWarnings( "unchecked" )
+        final Set<String> blacklistPkgs = FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_PACKAGE_PREFIXES;
+
+        final FieldBasedObjectInterpolator objectInterpolator = new FieldBasedObjectInterpolator(
+            blacklistFields, blacklistPkgs
+        );
+        final Interpolator interpolator = buildInterpolator( project );
+
+        // TODO: Will this adequately detect cycles between prefixed property references and prefixed project
+        // references??
+        final RecursionInterceptor interceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES, true );
+
+        try
+        {
+            objectInterpolator.interpolate( model, interpolator, interceptor );
+        }
+        finally
+        {
+            interpolator.clearAnswers();
+        }
+
+        if ( objectInterpolator.hasWarnings() && getLogger().isDebugEnabled() )
+        {
+            final StringBuffer sb = new StringBuffer();
+
+            sb.append( "NPANDAY-116-000: One or more minor errors occurred while interpolating the model: \n" );
+
+            @SuppressWarnings( "unchecked" )
+            final List<ObjectInterpolationWarning> warnings = objectInterpolator.getWarnings();
+            for ( final Iterator<ObjectInterpolationWarning> it = warnings.iterator(); it.hasNext(); )
+            {
+                final ObjectInterpolationWarning warning = it.next();
+
+                sb.append( '\n' ).append( warning );
+            }
+
+            sb.append( "\n\nThese values were SKIPPED, but the assembly process will continue.\n" );
+
+            getLogger().debug( sb.toString() );
+        }
+
+        return model;
+    }
+
+    public static Interpolator buildInterpolator( final MavenProject project )
+    {
+        final StringSearchInterpolator interpolator = new StringSearchInterpolator();
+        interpolator.setCacheAnswers( true );
+
+        if ( project != null )
+        {
+            interpolator.addValueSource(
+                new PrefixedPropertiesValueSource(
+                    PROJECT_PROPERTIES_PREFIXES, project.getProperties(), true
+                )
+            );
+
+            interpolator.addValueSource(
+                new PrefixedObjectValueSource(
+                    PROJECT_PREFIXES, project, true
+                )
+            );
+        }
+
+        /*final Properties settingsProperties = new Properties();
+        if ( session != null && session.getSettings() != null )
+        {
+            settingsProperties.setProperty( "localRepository", session.getSettings().getLocalRepository() );
+            settingsProperties.setProperty( "settings.localRepository", configSource.getLocalRepository().getBasedir
+            () );
+        }
+        interpolator.addValueSource( new PropertiesBasedValueSource( settingsProperties ) );
+
+        Properties commandLineProperties = System.getProperties();
+        if ( session != null )
+        {
+            commandLineProperties = new Properties();
+            if ( session.getExecutionProperties() != null )
+            {
+                commandLineProperties.putAll( session.getExecutionProperties() );
+            }
+            
+            if ( session.getUserProperties() != null )
+            {
+                commandLineProperties.putAll( session.getUserProperties() );
+            }
+        }
+        interpolator.addValueSource( new PropertiesBasedValueSource( commandLineProperties ) );
+        */
+
+        interpolator.addValueSource(
+            new PrefixedPropertiesValueSource(
+                Collections.singletonList( "env." ), ENVIRONMENT_VARIABLES, true
+            )
+        );
+        interpolator.addValueSource( new WindowsRegistryValueSource( new WinRegistry() ) );
+
+        return interpolator;
+    }
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java Thu Dec 22 06:54:49 2011
@@ -1,510 +1,510 @@
-package npanday.registry.impl;
-
-import npanday.registry.WindowsRegistryAccessException;
-import npanday.registry.WindowsRegistryAccessProvider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.prefs.Preferences;
-
-public class WinRegistry
-    implements WindowsRegistryAccessProvider
-{
-    public static final int HKEY_CURRENT_USER = 0x80000001;
-
-    public static final int HKEY_LOCAL_MACHINE = 0x80000002;
-
-    public static final int REG_SUCCESS = 0;
-
-    private static final int KEY_ALL_ACCESS = 0xf003f;
-
-    private static final int KEY_READ = 0x20019;
-
-    private static Preferences userRoot = Preferences.userRoot();
-
-    private static Preferences systemRoot = Preferences.systemRoot();
-
-    private static Class<? extends Preferences> userClass = userRoot.getClass();
-
-    private static Method regOpenKey = null;
-
-    private static Method regCloseKey = null;
-
-    private static Method regQueryValueEx = null;
-
-    private static Method regEnumValue = null;
-
-    private static Method regQueryInfoKey = null;
-
-    private static Method regEnumKeyEx = null;
-
-    private static Method regCreateKeyEx = null;
-
-    private static Method regSetValueEx = null;
-
-    private static Method regDeleteKey = null;
-
-    private static Method regDeleteValue = null;
-
-    static
-    {
-        try
-        {
-            regOpenKey = userClass.getDeclaredMethod(
-                "WindowsRegOpenKey", new Class[]{ int.class, byte[].class, int.class }
-            );
-            regOpenKey.setAccessible( true );
-            regCloseKey = userClass.getDeclaredMethod( "WindowsRegCloseKey", new Class[]{ int.class } );
-            regCloseKey.setAccessible( true );
-            regQueryValueEx = userClass.getDeclaredMethod(
-                "WindowsRegQueryValueEx", new Class[]{ int.class, byte[].class }
-            );
-            regQueryValueEx.setAccessible( true );
-            regEnumValue = userClass.getDeclaredMethod(
-                "WindowsRegEnumValue", new Class[]{ int.class, int.class, int.class }
-            );
-            regEnumValue.setAccessible( true );
-            regQueryInfoKey = userClass.getDeclaredMethod( "WindowsRegQueryInfoKey1", new Class[]{ int.class } );
-            regQueryInfoKey.setAccessible( true );
-            regEnumKeyEx = userClass.getDeclaredMethod(
-                "WindowsRegEnumKeyEx", new Class[]{ int.class, int.class, int.class }
-            );
-            regEnumKeyEx.setAccessible( true );
-            regCreateKeyEx = userClass.getDeclaredMethod(
-                "WindowsRegCreateKeyEx", new Class[]{ int.class, byte[].class }
-            );
-            regCreateKeyEx.setAccessible( true );
-            regSetValueEx = userClass.getDeclaredMethod(
-                "WindowsRegSetValueEx", new Class[]{ int.class, byte[].class, byte[].class }
-            );
-            regSetValueEx.setAccessible( true );
-            regDeleteValue = userClass.getDeclaredMethod(
-                "WindowsRegDeleteValue", new Class[]{ int.class, byte[].class }
-            );
-            regDeleteValue.setAccessible( true );
-            regDeleteKey = userClass.getDeclaredMethod(
-                "WindowsRegDeleteKey", new Class[]{
-                int.class, byte[].class
-            }
-            );
-            regDeleteKey.setAccessible( true );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-    }
-
-    public WinRegistry()
-    {
-    }
-
-    /**
-     * Read a value from key and value name
-     *
-     * @param hkey      HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
-     * @param key
-     * @param valueName
-     * @return the value
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static String readString( int hkey, String key, String valueName ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            return readString( systemRoot, hkey, key, valueName );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            return readString( userRoot, hkey, key, valueName );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "hkey=" + hkey );
-        }
-    }
-
-    /**
-     * Read value(s) and value name(s) form given key
-     *
-     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
-     * @param key
-     * @return the value name(s) plus the value(s)
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static Map<String, String> readStringValues( int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            return readStringValues( systemRoot, hkey, key );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            return readStringValues( userRoot, hkey, key );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "hkey=" + hkey );
-        }
-    }
-
-    /**
-     * Read the value name(s) from a given key
-     *
-     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
-     * @param key
-     * @return the value name(s)
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static List<String> readStringSubKeys( int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            return readStringSubKeys( systemRoot, hkey, key );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            return readStringSubKeys( userRoot, hkey, key );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "hkey=" + hkey );
-        }
-    }
-
-    /**
-     * Create a key
-     *
-     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
-     * @param key
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static void createKey( int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int[] ret;
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            ret = createKey( systemRoot, hkey, key );
-            regCloseKey.invoke( systemRoot, new Object[]{ new Integer( ret[0] ) } );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            ret = createKey( userRoot, hkey, key );
-            regCloseKey.invoke( userRoot, new Object[]{ new Integer( ret[0] ) } );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "hkey=" + hkey );
-        }
-        if ( ret[1] != REG_SUCCESS )
-        {
-            throw new IllegalArgumentException( "rc=" + ret[1] + "  key=" + key );
-        }
-    }
-
-    /**
-     * Write a value in a given key/value name
-     *
-     * @param hkey
-     * @param key
-     * @param valueName
-     * @param value
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static void writeStringValue( int hkey, String key, String valueName, String value ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            writeStringValue( systemRoot, hkey, key, valueName, value );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            writeStringValue( userRoot, hkey, key, valueName, value );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "hkey=" + hkey );
-        }
-    }
-
-    /**
-     * Delete a given key
-     *
-     * @param hkey
-     * @param key
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static void deleteKey( int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int rc = -1;
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            rc = deleteKey( systemRoot, hkey, key );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            rc = deleteKey( userRoot, hkey, key );
-        }
-        if ( rc != REG_SUCCESS )
-        {
-            throw new IllegalArgumentException( "rc=" + rc + "  key=" + key );
-        }
-    }
-
-    /**
-     * delete a value from a given key/value name
-     *
-     * @param hkey
-     * @param key
-     * @param value
-     * @throws IllegalArgumentException
-     * @throws IllegalAccessException
-     * @throws java.lang.reflect.InvocationTargetException
-     *
-     */
-    public static void deleteValue( int hkey, String key, String value ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int rc = -1;
-        if ( hkey == HKEY_LOCAL_MACHINE )
-        {
-            rc = deleteValue( systemRoot, hkey, key, value );
-        }
-        else if ( hkey == HKEY_CURRENT_USER )
-        {
-            rc = deleteValue( userRoot, hkey, key, value );
-        }
-        if ( rc != REG_SUCCESS )
-        {
-            throw new IllegalArgumentException( "rc=" + rc + "  key=" + key + "  value=" + value );
-        }
-    }
-
-    // =====================
-
-    private static int deleteValue( Preferences root, int hkey, String key, String value ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int[] handles = (int[]) regOpenKey.invoke(
-            root, new Object[]{
-            new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
-        }
-        );
-        if ( handles[1] != REG_SUCCESS )
-        {
-            return handles[1];  // can be REG_NOTFOUND, REG_ACCESSDENIED
-        }
-        int rc = (
-            (Integer) regDeleteValue.invoke(
-                root, new Object[]{
-                new Integer( handles[0] ), toCstr( value )
-            }
-            )
-        ).intValue();
-        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-        return rc;
-    }
-
-    private static int deleteKey( Preferences root, int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int rc = (
-            (Integer) regDeleteKey.invoke(
-                root, new Object[]{ new Integer( hkey ), toCstr( key ) }
-            )
-        ).intValue();
-        return rc;  // can REG_NOTFOUND, REG_ACCESSDENIED, REG_SUCCESS
-    }
-
-    private static String readString( Preferences root, int hkey, String key, String value ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int[] handles = (int[]) regOpenKey.invoke(
-            root, new Object[]{
-            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
-        }
-        );
-        if ( handles[1] != REG_SUCCESS )
-        {
-            return null;
-        }
-        byte[] valb = (byte[]) regQueryValueEx.invoke(
-            root, new Object[]{ new Integer( handles[0] ), toCstr( value ) }
-        );
-        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-        return ( valb != null ? new String( valb ).trim() : null );
-    }
-
-    private static Map<String, String> readStringValues( Preferences root, int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        HashMap<String, String> results = new HashMap<String, String>();
-        int[] handles = (int[]) regOpenKey.invoke(
-            root, new Object[]{
-            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
-        }
-        );
-        if ( handles[1] != REG_SUCCESS )
-        {
-            return null;
-        }
-        int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-
-        int count = info[2]; // count
-        int maxlen = info[3]; // value length max
-        for ( int index = 0; index < count; index++ )
-        {
-            byte[] name = (byte[]) regEnumValue.invoke(
-                root, new Object[]{
-                new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
-            }
-            );
-            String value = readString( hkey, key, new String( name ) );
-            results.put( new String( name ).trim(), value );
-        }
-        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-        return results;
-    }
-
-    private static List<String> readStringSubKeys( Preferences root, int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        List<String> results = new ArrayList<String>();
-        int[] handles = (int[]) regOpenKey.invoke(
-            root, new Object[]{
-            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
-        }
-        );
-        if ( handles[1] != REG_SUCCESS )
-        {
-            return null;
-        }
-        int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-
-        int count = info[2]; // count
-        int maxlen = info[3]; // value length max
-        for ( int index = 0; index < count; index++ )
-        {
-            byte[] name = (byte[]) regEnumKeyEx.invoke(
-                root, new Object[]{
-                new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
-            }
-            );
-            results.add( new String( name ).trim() );
-        }
-        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-        return results;
-    }
-
-    private static int[] createKey( Preferences root, int hkey, String key ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        return (int[]) regCreateKeyEx.invoke( root, new Object[]{ new Integer( hkey ), toCstr( key ) } );
-    }
-
-    private static void writeStringValue(
-        Preferences root, int hkey, String key, String valueName, String value ) throws
-        IllegalArgumentException,
-        IllegalAccessException,
-        InvocationTargetException
-    {
-        int[] handles = (int[]) regOpenKey.invoke(
-            root, new Object[]{
-            new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
-        }
-        );
-
-        regSetValueEx.invoke( root, new Object[]{ new Integer( handles[0] ), toCstr( valueName ), toCstr( value ) } );
-        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
-    }
-
-    // utility
-    private static byte[] toCstr( String str )
-    {
-        byte[] result = new byte[str.length() + 1];
-
-        for ( int i = 0; i < str.length(); i++ )
-        {
-            result[i] = (byte) str.charAt( i );
-        }
-        result[str.length()] = 0;
-        return result;
-    }
-
-    public String getValue(
-        RegistryHKey registryHKey, String key, String valueName ) throws WindowsRegistryAccessException
-    {
-        try
-        {
-            return WinRegistry.readString(
-                registryHKey.getHKey(), key, valueName
-            );
-        }
-        catch ( InvocationTargetException e )
-        {
-            throw new WindowsRegistryAccessException(
-                "NPANDAY-117-000: Error while retrieving a windows registry value", e
-            );
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new WindowsRegistryAccessException(
-                "NPANDAY-117-001: Error while retrieving a windows registry value", e
-            );
-        }
-    }
-}
+package npanday.registry.impl;
+
+import npanday.registry.WindowsRegistryAccessException;
+import npanday.registry.WindowsRegistryAccessProvider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.prefs.Preferences;
+
+public class WinRegistry
+    implements WindowsRegistryAccessProvider
+{
+    public static final int HKEY_CURRENT_USER = 0x80000001;
+
+    public static final int HKEY_LOCAL_MACHINE = 0x80000002;
+
+    public static final int REG_SUCCESS = 0;
+
+    private static final int KEY_ALL_ACCESS = 0xf003f;
+
+    private static final int KEY_READ = 0x20019;
+
+    private static Preferences userRoot = Preferences.userRoot();
+
+    private static Preferences systemRoot = Preferences.systemRoot();
+
+    private static Class<? extends Preferences> userClass = userRoot.getClass();
+
+    private static Method regOpenKey = null;
+
+    private static Method regCloseKey = null;
+
+    private static Method regQueryValueEx = null;
+
+    private static Method regEnumValue = null;
+
+    private static Method regQueryInfoKey = null;
+
+    private static Method regEnumKeyEx = null;
+
+    private static Method regCreateKeyEx = null;
+
+    private static Method regSetValueEx = null;
+
+    private static Method regDeleteKey = null;
+
+    private static Method regDeleteValue = null;
+
+    static
+    {
+        try
+        {
+            regOpenKey = userClass.getDeclaredMethod(
+                "WindowsRegOpenKey", new Class[]{ int.class, byte[].class, int.class }
+            );
+            regOpenKey.setAccessible( true );
+            regCloseKey = userClass.getDeclaredMethod( "WindowsRegCloseKey", new Class[]{ int.class } );
+            regCloseKey.setAccessible( true );
+            regQueryValueEx = userClass.getDeclaredMethod(
+                "WindowsRegQueryValueEx", new Class[]{ int.class, byte[].class }
+            );
+            regQueryValueEx.setAccessible( true );
+            regEnumValue = userClass.getDeclaredMethod(
+                "WindowsRegEnumValue", new Class[]{ int.class, int.class, int.class }
+            );
+            regEnumValue.setAccessible( true );
+            regQueryInfoKey = userClass.getDeclaredMethod( "WindowsRegQueryInfoKey1", new Class[]{ int.class } );
+            regQueryInfoKey.setAccessible( true );
+            regEnumKeyEx = userClass.getDeclaredMethod(
+                "WindowsRegEnumKeyEx", new Class[]{ int.class, int.class, int.class }
+            );
+            regEnumKeyEx.setAccessible( true );
+            regCreateKeyEx = userClass.getDeclaredMethod(
+                "WindowsRegCreateKeyEx", new Class[]{ int.class, byte[].class }
+            );
+            regCreateKeyEx.setAccessible( true );
+            regSetValueEx = userClass.getDeclaredMethod(
+                "WindowsRegSetValueEx", new Class[]{ int.class, byte[].class, byte[].class }
+            );
+            regSetValueEx.setAccessible( true );
+            regDeleteValue = userClass.getDeclaredMethod(
+                "WindowsRegDeleteValue", new Class[]{ int.class, byte[].class }
+            );
+            regDeleteValue.setAccessible( true );
+            regDeleteKey = userClass.getDeclaredMethod(
+                "WindowsRegDeleteKey", new Class[]{
+                int.class, byte[].class
+            }
+            );
+            regDeleteKey.setAccessible( true );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public WinRegistry()
+    {
+    }
+
+    /**
+     * Read a value from key and value name
+     *
+     * @param hkey      HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+     * @param key
+     * @param valueName
+     * @return the value
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static String readString( int hkey, String key, String valueName ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            return readString( systemRoot, hkey, key, valueName );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            return readString( userRoot, hkey, key, valueName );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "hkey=" + hkey );
+        }
+    }
+
+    /**
+     * Read value(s) and value name(s) form given key
+     *
+     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+     * @param key
+     * @return the value name(s) plus the value(s)
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static Map<String, String> readStringValues( int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            return readStringValues( systemRoot, hkey, key );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            return readStringValues( userRoot, hkey, key );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "hkey=" + hkey );
+        }
+    }
+
+    /**
+     * Read the value name(s) from a given key
+     *
+     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+     * @param key
+     * @return the value name(s)
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static List<String> readStringSubKeys( int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            return readStringSubKeys( systemRoot, hkey, key );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            return readStringSubKeys( userRoot, hkey, key );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "hkey=" + hkey );
+        }
+    }
+
+    /**
+     * Create a key
+     *
+     * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+     * @param key
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static void createKey( int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int[] ret;
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            ret = createKey( systemRoot, hkey, key );
+            regCloseKey.invoke( systemRoot, new Object[]{ new Integer( ret[0] ) } );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            ret = createKey( userRoot, hkey, key );
+            regCloseKey.invoke( userRoot, new Object[]{ new Integer( ret[0] ) } );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "hkey=" + hkey );
+        }
+        if ( ret[1] != REG_SUCCESS )
+        {
+            throw new IllegalArgumentException( "rc=" + ret[1] + "  key=" + key );
+        }
+    }
+
+    /**
+     * Write a value in a given key/value name
+     *
+     * @param hkey
+     * @param key
+     * @param valueName
+     * @param value
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static void writeStringValue( int hkey, String key, String valueName, String value ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            writeStringValue( systemRoot, hkey, key, valueName, value );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            writeStringValue( userRoot, hkey, key, valueName, value );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "hkey=" + hkey );
+        }
+    }
+
+    /**
+     * Delete a given key
+     *
+     * @param hkey
+     * @param key
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static void deleteKey( int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int rc = -1;
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            rc = deleteKey( systemRoot, hkey, key );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            rc = deleteKey( userRoot, hkey, key );
+        }
+        if ( rc != REG_SUCCESS )
+        {
+            throw new IllegalArgumentException( "rc=" + rc + "  key=" + key );
+        }
+    }
+
+    /**
+     * delete a value from a given key/value name
+     *
+     * @param hkey
+     * @param key
+     * @param value
+     * @throws IllegalArgumentException
+     * @throws IllegalAccessException
+     * @throws java.lang.reflect.InvocationTargetException
+     *
+     */
+    public static void deleteValue( int hkey, String key, String value ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int rc = -1;
+        if ( hkey == HKEY_LOCAL_MACHINE )
+        {
+            rc = deleteValue( systemRoot, hkey, key, value );
+        }
+        else if ( hkey == HKEY_CURRENT_USER )
+        {
+            rc = deleteValue( userRoot, hkey, key, value );
+        }
+        if ( rc != REG_SUCCESS )
+        {
+            throw new IllegalArgumentException( "rc=" + rc + "  key=" + key + "  value=" + value );
+        }
+    }
+
+    // =====================
+
+    private static int deleteValue( Preferences root, int hkey, String key, String value ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int[] handles = (int[]) regOpenKey.invoke(
+            root, new Object[]{
+            new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
+        }
+        );
+        if ( handles[1] != REG_SUCCESS )
+        {
+            return handles[1];  // can be REG_NOTFOUND, REG_ACCESSDENIED
+        }
+        int rc = (
+            (Integer) regDeleteValue.invoke(
+                root, new Object[]{
+                new Integer( handles[0] ), toCstr( value )
+            }
+            )
+        ).intValue();
+        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+        return rc;
+    }
+
+    private static int deleteKey( Preferences root, int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int rc = (
+            (Integer) regDeleteKey.invoke(
+                root, new Object[]{ new Integer( hkey ), toCstr( key ) }
+            )
+        ).intValue();
+        return rc;  // can REG_NOTFOUND, REG_ACCESSDENIED, REG_SUCCESS
+    }
+
+    private static String readString( Preferences root, int hkey, String key, String value ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int[] handles = (int[]) regOpenKey.invoke(
+            root, new Object[]{
+            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+        }
+        );
+        if ( handles[1] != REG_SUCCESS )
+        {
+            return null;
+        }
+        byte[] valb = (byte[]) regQueryValueEx.invoke(
+            root, new Object[]{ new Integer( handles[0] ), toCstr( value ) }
+        );
+        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+        return ( valb != null ? new String( valb ).trim() : null );
+    }
+
+    private static Map<String, String> readStringValues( Preferences root, int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        HashMap<String, String> results = new HashMap<String, String>();
+        int[] handles = (int[]) regOpenKey.invoke(
+            root, new Object[]{
+            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+        }
+        );
+        if ( handles[1] != REG_SUCCESS )
+        {
+            return null;
+        }
+        int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+
+        int count = info[2]; // count
+        int maxlen = info[3]; // value length max
+        for ( int index = 0; index < count; index++ )
+        {
+            byte[] name = (byte[]) regEnumValue.invoke(
+                root, new Object[]{
+                new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
+            }
+            );
+            String value = readString( hkey, key, new String( name ) );
+            results.put( new String( name ).trim(), value );
+        }
+        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+        return results;
+    }
+
+    private static List<String> readStringSubKeys( Preferences root, int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        List<String> results = new ArrayList<String>();
+        int[] handles = (int[]) regOpenKey.invoke(
+            root, new Object[]{
+            new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+        }
+        );
+        if ( handles[1] != REG_SUCCESS )
+        {
+            return null;
+        }
+        int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+
+        int count = info[2]; // count
+        int maxlen = info[3]; // value length max
+        for ( int index = 0; index < count; index++ )
+        {
+            byte[] name = (byte[]) regEnumKeyEx.invoke(
+                root, new Object[]{
+                new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
+            }
+            );
+            results.add( new String( name ).trim() );
+        }
+        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+        return results;
+    }
+
+    private static int[] createKey( Preferences root, int hkey, String key ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        return (int[]) regCreateKeyEx.invoke( root, new Object[]{ new Integer( hkey ), toCstr( key ) } );
+    }
+
+    private static void writeStringValue(
+        Preferences root, int hkey, String key, String valueName, String value ) throws
+        IllegalArgumentException,
+        IllegalAccessException,
+        InvocationTargetException
+    {
+        int[] handles = (int[]) regOpenKey.invoke(
+            root, new Object[]{
+            new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
+        }
+        );
+
+        regSetValueEx.invoke( root, new Object[]{ new Integer( handles[0] ), toCstr( valueName ), toCstr( value ) } );
+        regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+    }
+
+    // utility
+    private static byte[] toCstr( String str )
+    {
+        byte[] result = new byte[str.length() + 1];
+
+        for ( int i = 0; i < str.length(); i++ )
+        {
+            result[i] = (byte) str.charAt( i );
+        }
+        result[str.length()] = 0;
+        return result;
+    }
+
+    public String getValue(
+        RegistryHKey registryHKey, String key, String valueName ) throws WindowsRegistryAccessException
+    {
+        try
+        {
+            return WinRegistry.readString(
+                registryHKey.getHKey(), key, valueName
+            );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new WindowsRegistryAccessException(
+                "NPANDAY-117-000: Error while retrieving a windows registry value", e
+            );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new WindowsRegistryAccessException(
+                "NPANDAY-117-001: Error while retrieving a windows registry value", e
+            );
+        }
+    }
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java Thu Dec 22 06:54:49 2011
@@ -1,63 +1,63 @@
-package npanday.registry.impl;
-
-import hidden.org.codehaus.plexus.interpolation.AbstractValueSource;
-import npanday.registry.WindowsRegistryAccessException;
-import npanday.registry.WindowsRegistryAccessProvider;
-import org.codehaus.plexus.interpolation.ValueSource;
-
-/**
- * Tries to find registry settings for all expressions starting with HKLM or HKCU.
- *
- * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
- */
-public class WindowsRegistryValueSource
-    extends AbstractValueSource
-    implements ValueSource
-{
-   private WindowsRegistryAccessProvider registry;
-
-    public WindowsRegistryValueSource( WindowsRegistryAccessProvider registry )
-    {
-        super( true );
-        this.registry = registry;
-    }
-
-    public Object getValue( String expression )
-    {
-        int indexOfBackslash = expression.indexOf( "\\" );
-        if (indexOfBackslash == -1)
-            return null;
-
-        String hkeyExpression = expression.substring( 0, indexOfBackslash );
-
-        final WindowsRegistryAccessProvider.RegistryHKey registryHKey = WindowsRegistryAccessProvider.RegistryHKey
-            .tryGetFromName(
-                hkeyExpression
-            );
-
-        if (registryHKey == null)
-            return null;
-
-        if (expression.length() < indexOfBackslash || !expression.contains( "@" ))
-            return null;
-
-        String keyAndValueNamePart = expression.substring( indexOfBackslash +1 );
-        int indexOfAt = keyAndValueNamePart.indexOf( '@' );
-
-        String key = keyAndValueNamePart.substring( 0, indexOfAt );
-        String valueName = keyAndValueNamePart.substring( indexOfAt+1 );
-
-        try
-        {
-            final String value = registry.getValue( registryHKey, key, valueName );
-            addFeedback( "NPANDAY-118-001: Retrieved the registry value for " + expression + ": " + value);
-            return value == null ? "" : value;
-        }
-        catch ( WindowsRegistryAccessException e )
-        {
-            addFeedback( "NPANDAY-118-000: Could not retrieve the registry value for " + expression, e );
-            return "";
-        }
-    }
-}
-
+package npanday.registry.impl;
+
+import hidden.org.codehaus.plexus.interpolation.AbstractValueSource;
+import npanday.registry.WindowsRegistryAccessException;
+import npanday.registry.WindowsRegistryAccessProvider;
+import org.codehaus.plexus.interpolation.ValueSource;
+
+/**
+ * Tries to find registry settings for all expressions starting with HKLM or HKCU.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public class WindowsRegistryValueSource
+    extends AbstractValueSource
+    implements ValueSource
+{
+   private WindowsRegistryAccessProvider registry;
+
+    public WindowsRegistryValueSource( WindowsRegistryAccessProvider registry )
+    {
+        super( true );
+        this.registry = registry;
+    }
+
+    public Object getValue( String expression )
+    {
+        int indexOfBackslash = expression.indexOf( "\\" );
+        if (indexOfBackslash == -1)
+            return null;
+
+        String hkeyExpression = expression.substring( 0, indexOfBackslash );
+
+        final WindowsRegistryAccessProvider.RegistryHKey registryHKey = WindowsRegistryAccessProvider.RegistryHKey
+            .tryGetFromName(
+                hkeyExpression
+            );
+
+        if (registryHKey == null)
+            return null;
+
+        if (expression.length() < indexOfBackslash || !expression.contains( "@" ))
+            return null;
+
+        String keyAndValueNamePart = expression.substring( indexOfBackslash +1 );
+        int indexOfAt = keyAndValueNamePart.indexOf( '@' );
+
+        String key = keyAndValueNamePart.substring( 0, indexOfAt );
+        String valueName = keyAndValueNamePart.substring( indexOfAt+1 );
+
+        try
+        {
+            final String value = registry.getValue( registryHKey, key, valueName );
+            addFeedback( "NPANDAY-118-001: Retrieved the registry value for " + expression + ": " + value);
+            return value == null ? "" : value;
+        }
+        catch ( WindowsRegistryAccessException e )
+        {
+            addFeedback( "NPANDAY-118-000: Could not retrieve the registry value for " + expression, e );
+            return "";
+        }
+    }
+}
+

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/npanday/trunk/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy?rev=1222072&r1=1222071&r2=1222072&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy (original)
+++ incubator/npanday/trunk/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy Thu Dec 22 06:54:49 2011
@@ -1,107 +1,107 @@
-/* Copyright 2010 NPanday
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * 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 npanday.registry.impl
-
-import npanday.registry.WindowsRegistryAccessException
-import npanday.registry.WindowsRegistryAccessProvider
-import npanday.registry.WindowsRegistryAccessProvider.RegistryHKey
-import org.gmock.GMockTestCase
-import org.junit.Test
-
-class WindowsRegistryValueSourceTest extends GMockTestCase
-{
-  @Test
-  void testExceptionIsCaught()
-  {
-    def provider = mock(WindowsRegistryAccessProvider);
-
-    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").raises(new WindowsRegistryAccessException("Trouble here!!"))
-
-    play{
-      def source = new WindowsRegistryValueSource(provider)
-
-      assert source.getValue("HKLM\\Key@ValueName") == ""
-    }
-  }
-
-  @Test
-  void testWrongKeysAreNull()
-  {
-    def provider = mock(WindowsRegistryAccessProvider);
-
-    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName")
-      .raises(new WindowsRegistryAccessException("Trouble here!!"))
-      .stub()
-
-    play {
-      def source = new WindowsRegistryValueSource(provider)
-
-      assert source.getValue("ABC\\Key@ValueName") == null
-      assert source.getValue("HKLM\\Key?ValueName") == null
-      assert source.getValue("HKLM") == null
-    }
-  }
-
-  @Test
-  void testExpressionParsing()
-  {
-    def provider = mock(WindowsRegistryAccessProvider);
-
-    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").returns("value")
-
-    play{
-      def source = new WindowsRegistryValueSource(provider)
-
-      assert source.getValue("HKLM\\Key@ValueName") == "value"
-    }
-  }
-
-  @Test
-  void testHKLMLongAndShortNames()
-  {
-    def provider = mock(WindowsRegistryAccessProvider);
-
-    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName")
-      .returns("value")
-      .times(2)
-
-    play{
-      def source = new WindowsRegistryValueSource(provider)
-
-      assert source.getValue("HKLM\\Key@ValueName") == "value"
-      assert source.getValue("HKEY_LOCAL_MACHINE\\Key@ValueName") == "value"
-    }
-  }
-
-  @Test
-  void testHKCULongAndShortNames()
-  {
-    def provider = mock(WindowsRegistryAccessProvider);
-
-    provider.getValue(RegistryHKey.HKCU, "Key", "ValueName")
-      .returns("value")
-      .times(2)
-
-    play{
-      def source = new WindowsRegistryValueSource(provider)
-
-      assert source.getValue("HKCU\\Key@ValueName") == "value"
-      assert source.getValue("HKEY_CURRENT_USER\\Key@ValueName") == "value"
-    }
-  }
-}
+/* Copyright 2010 NPanday
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * 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 npanday.registry.impl
+
+import npanday.registry.WindowsRegistryAccessException
+import npanday.registry.WindowsRegistryAccessProvider
+import npanday.registry.WindowsRegistryAccessProvider.RegistryHKey
+import org.gmock.GMockTestCase
+import org.junit.Test
+
+class WindowsRegistryValueSourceTest extends GMockTestCase
+{
+  @Test
+  void testExceptionIsCaught()
+  {
+    def provider = mock(WindowsRegistryAccessProvider);
+
+    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").raises(new WindowsRegistryAccessException("Trouble here!!"))
+
+    play{
+      def source = new WindowsRegistryValueSource(provider)
+
+      assert source.getValue("HKLM\\Key@ValueName") == ""
+    }
+  }
+
+  @Test
+  void testWrongKeysAreNull()
+  {
+    def provider = mock(WindowsRegistryAccessProvider);
+
+    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName")
+      .raises(new WindowsRegistryAccessException("Trouble here!!"))
+      .stub()
+
+    play {
+      def source = new WindowsRegistryValueSource(provider)
+
+      assert source.getValue("ABC\\Key@ValueName") == null
+      assert source.getValue("HKLM\\Key?ValueName") == null
+      assert source.getValue("HKLM") == null
+    }
+  }
+
+  @Test
+  void testExpressionParsing()
+  {
+    def provider = mock(WindowsRegistryAccessProvider);
+
+    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").returns("value")
+
+    play{
+      def source = new WindowsRegistryValueSource(provider)
+
+      assert source.getValue("HKLM\\Key@ValueName") == "value"
+    }
+  }
+
+  @Test
+  void testHKLMLongAndShortNames()
+  {
+    def provider = mock(WindowsRegistryAccessProvider);
+
+    provider.getValue(RegistryHKey.HKLM, "Key", "ValueName")
+      .returns("value")
+      .times(2)
+
+    play{
+      def source = new WindowsRegistryValueSource(provider)
+
+      assert source.getValue("HKLM\\Key@ValueName") == "value"
+      assert source.getValue("HKEY_LOCAL_MACHINE\\Key@ValueName") == "value"
+    }
+  }
+
+  @Test
+  void testHKCULongAndShortNames()
+  {
+    def provider = mock(WindowsRegistryAccessProvider);
+
+    provider.getValue(RegistryHKey.HKCU, "Key", "ValueName")
+      .returns("value")
+      .times(2)
+
+    play{
+      def source = new WindowsRegistryValueSource(provider)
+
+      assert source.getValue("HKCU\\Key@ValueName") == "value"
+      assert source.getValue("HKEY_CURRENT_USER\\Key@ValueName") == "value"
+    }
+  }
+}

Propchange: incubator/npanday/trunk/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy
------------------------------------------------------------------------------
    svn:eol-style = native