[jboss-svn-commits] JBoss Common SVN: r3909 - jboss-stdio/trunk/src/main/java/org/jboss/stdio.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jan 7 14:52:54 EST 2010


Author: david.lloyd at jboss.com
Date: 2010-01-07 14:52:54 -0500 (Thu, 07 Jan 2010)
New Revision: 3909

Added:
   jboss-stdio/trunk/src/main/java/org/jboss/stdio/SimpleStdioContextSelector.java
Modified:
   jboss-stdio/trunk/src/main/java/org/jboss/stdio/StdioContext.java
Log:
Add a simple StdioContextSelector class

Added: jboss-stdio/trunk/src/main/java/org/jboss/stdio/SimpleStdioContextSelector.java
===================================================================
--- jboss-stdio/trunk/src/main/java/org/jboss/stdio/SimpleStdioContextSelector.java	                        (rev 0)
+++ jboss-stdio/trunk/src/main/java/org/jboss/stdio/SimpleStdioContextSelector.java	2010-01-07 19:52:54 UTC (rev 3909)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stdio;
+
+/**
+ * A simple {@code org.jboss.stdio.StdioContextSelector} implementation which always selects the same context.
+ */
+public final class SimpleStdioContextSelector implements StdioContextSelector {
+    private final StdioContext context;
+
+    /**
+     * Construct a new instance.
+     *
+     * @param context the context to use (must not be {@code null})
+     */
+    public SimpleStdioContextSelector(final StdioContext context) {
+        if (context == null) {
+            throw new NullPointerException("context is null");
+        }
+        this.context = context;
+    }
+
+    /** {@inheritDoc} */
+    public StdioContext getStdioContext() {
+        return context;
+    }
+}

Modified: jboss-stdio/trunk/src/main/java/org/jboss/stdio/StdioContext.java
===================================================================
--- jboss-stdio/trunk/src/main/java/org/jboss/stdio/StdioContext.java	2010-01-07 19:46:34 UTC (rev 3908)
+++ jboss-stdio/trunk/src/main/java/org/jboss/stdio/StdioContext.java	2010-01-07 19:52:54 UTC (rev 3909)
@@ -112,11 +112,7 @@
         return err;
     }
 
-    private static volatile StdioContextSelector stdioContextSelector = new StdioContextSelector() {
-        public StdioContext getStdioContext() {
-            return SYSTEM_STDIO_CONTEXT;
-        }
-    };
+    private static volatile StdioContextSelector stdioContextSelector = new SimpleStdioContextSelector(SYSTEM_STDIO_CONTEXT);
 
     /**
      * Install the StdioContext streams.



More information about the jboss-svn-commits mailing list