http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6e2bf9e/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystemFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystemFactory.java 
b/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystemFactory.java
deleted file mode 100644
index 04d0239..0000000
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystemFactory.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.sshd.server.sftp;
-
-import java.util.concurrent.ExecutorService;
-
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.sftp.SftpConstants;
-import org.apache.sshd.common.util.ObjectBuilder;
-import org.apache.sshd.common.util.threads.ExecutorServiceConfigurer;
-import org.apache.sshd.server.Command;
-
-/**
- * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
- */
-public class SftpSubsystemFactory implements NamedFactory<Command>, Cloneable, 
ExecutorServiceConfigurer {
-    public static final String NAME = SftpConstants.SFTP_SUBSYSTEM_NAME;
-    public static final UnsupportedAttributePolicy DEFAULT_POLICY = 
UnsupportedAttributePolicy.Warn;
-
-    public static class Builder implements ObjectBuilder<SftpSubsystemFactory> 
{
-        private final SftpSubsystemFactory factory = new 
SftpSubsystemFactory();
-
-        public Builder() {
-            super();
-        }
-
-        public Builder withExecutorService(ExecutorService service) {
-            factory.setExecutorService(service);
-            return this;
-        }
-
-        public Builder withShutdownOnExit(boolean shutdown) {
-            factory.setShutdownOnExit(shutdown);
-            return this;
-        }
-
-        public Builder 
withUnsupportedAttributePolicy(UnsupportedAttributePolicy p) {
-            factory.setUnsupportedAttributePolicy(p);
-            return this;
-        }
-
-        @Override
-        public SftpSubsystemFactory build() {
-            // return a clone so that each invocation returns a different 
instance - avoid shared instances
-            return factory.clone();
-        }
-    }
-
-    private ExecutorService executors;
-    private boolean shutdownExecutor;
-    private UnsupportedAttributePolicy policy = DEFAULT_POLICY;
-
-    public SftpSubsystemFactory() {
-        super();
-    }
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ExecutorService getExecutorService() {
-        return executors;
-    }
-
-    /**
-     * @param service The {@link ExecutorService} to be used by the {@link 
SftpSubsystem}
-     *                command when starting execution. If {@code null} then a 
single-threaded ad-hoc service is used.
-     */
-    @Override
-    public void setExecutorService(ExecutorService service) {
-        executors = service;
-    }
-
-    @Override
-    public boolean isShutdownOnExit() {
-        return shutdownExecutor;
-    }
-
-    /**
-     * @param shutdownOnExit If {@code true} the {@link 
ExecutorService#shutdownNow()}
-     *                       will be called when subsystem terminates - unless 
it is the ad-hoc service, which
-     *                       will be shutdown regardless
-     */
-    @Override
-    public void setShutdownOnExit(boolean shutdownOnExit) {
-        shutdownExecutor = shutdownOnExit;
-    }
-
-    public UnsupportedAttributePolicy getUnsupportedAttributePolicy() {
-        return policy;
-    }
-
-    /**
-     * @param p The {@link UnsupportedAttributePolicy} to use if failed to 
access
-     *          some local file attributes
-     */
-    public void setUnsupportedAttributePolicy(UnsupportedAttributePolicy p) {
-        if (p == null) {
-            throw new IllegalArgumentException("No policy provided");
-        }
-
-        policy = p;
-    }
-
-    @Override
-    public Command create() {
-        return new SftpSubsystem(getExecutorService(), isShutdownOnExit(), 
getUnsupportedAttributePolicy());
-    }
-
-    @Override
-    public SftpSubsystemFactory clone() {
-        try {
-            return getClass().cast(super.clone());  // shallow clone is good 
enough
-        } catch (CloneNotSupportedException e) {
-            throw new UnsupportedOperationException("Unexpected clone 
exception", e);   // unexpected since we implement cloneable
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6e2bf9e/sshd-core/src/main/java/org/apache/sshd/server/sftp/UnsupportedAttributePolicy.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/sftp/UnsupportedAttributePolicy.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/sftp/UnsupportedAttributePolicy.java
deleted file mode 100644
index f9a1472..0000000
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/sftp/UnsupportedAttributePolicy.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.sshd.server.sftp;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
- */
-public enum UnsupportedAttributePolicy {
-    Ignore,
-    Warn,
-    ThrowException;
-
-    public static final Set<UnsupportedAttributePolicy> VALUES =
-            
Collections.unmodifiableSet(EnumSet.allOf(UnsupportedAttributePolicy.class));
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6e2bf9e/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
index e46a005..98d7e40 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java
@@ -19,10 +19,6 @@
 
 package org.apache.sshd.server.shell;
 
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Set;
-
 import org.apache.sshd.common.util.OsUtils;
 
 /**
@@ -34,6 +30,10 @@ public class InteractiveProcessShellFactory extends 
ProcessShellFactory {
     private static final String[] LINUX_COMMAND = { "/bin/sh", "-i", "-l" };
     private static final String[] WINDOWS_COMMAND = { "cmd.exe" };
 
+    public static String[] resolveDefaultInteractiveCommand() {
+        return resolveInteractiveCommand(OsUtils.isWin32());
+    }
+
     public static String[] resolveInteractiveCommand(boolean isWin32) {
         // return clone(s) to avoid inadvertent modification
         if (isWin32) {
@@ -42,23 +42,10 @@ public class InteractiveProcessShellFactory extends 
ProcessShellFactory {
             return LINUX_COMMAND.clone();
         }
     }
-    
-    public static final Set<TtyOptions> LINUX_OPTIONS =
-            Collections.unmodifiableSet(EnumSet.of(TtyOptions.ONlCr));
-    public static final Set<TtyOptions> WINDOWS_OPTIONS =
-            Collections.unmodifiableSet(EnumSet.of(TtyOptions.Echo, 
TtyOptions.ICrNl, TtyOptions.ONlCr));
-
-    public static Set<TtyOptions> resolveTtyOptions(boolean isWin32) {
-        if (isWin32) {
-            return WINDOWS_OPTIONS;
-        } else {
-            return LINUX_OPTIONS;
-        }
-    }
 
     public static final InteractiveProcessShellFactory INSTANCE = new 
InteractiveProcessShellFactory();
 
     public InteractiveProcessShellFactory() {
-        super(resolveInteractiveCommand(OsUtils.isWin32()), 
resolveTtyOptions(OsUtils.isWin32()));
+        super(resolveDefaultInteractiveCommand(), 
TtyOptions.resolveDefaultTtyOptions());
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6e2bf9e/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java 
b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
index 033f476..eb7334f 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShellFactory.java
@@ -31,6 +31,7 @@ import java.util.Set;
 
 import org.apache.sshd.common.Factory;
 import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.OsUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -44,12 +45,30 @@ import org.apache.sshd.server.Command;
  */
 public class ProcessShellFactory extends AbstractLoggingBean implements 
Factory<Command> {
 
-    public enum TtyOptions {
+    public static enum TtyOptions {
         Echo,
         INlCr,
         ICrNl,
         ONlCr,
-        OCrNl
+        OCrNl;
+        
+        
+        public static final Set<TtyOptions> LINUX_OPTIONS =
+                Collections.unmodifiableSet(EnumSet.of(TtyOptions.ONlCr));
+        public static final Set<TtyOptions> WINDOWS_OPTIONS =
+                Collections.unmodifiableSet(EnumSet.of(TtyOptions.Echo, 
TtyOptions.ICrNl, TtyOptions.ONlCr));
+
+        public static Set<TtyOptions> resolveDefaultTtyOptions() {
+            return resolveTtyOptions(OsUtils.isWin32());
+        }
+
+        public static Set<TtyOptions> resolveTtyOptions(boolean isWin32) {
+            if (isWin32) {
+                return WINDOWS_OPTIONS;
+            } else {
+                return LINUX_OPTIONS;
+            }
+        }
     }
 
     private String[] command;
@@ -60,7 +79,7 @@ public class ProcessShellFactory extends AbstractLoggingBean 
implements Factory<
     }
 
     public ProcessShellFactory(String[] command) {
-        this(command, EnumSet.noneOf(TtyOptions.class));
+        this(command, TtyOptions.resolveDefaultTtyOptions());
     }
 
     public ProcessShellFactory(String[] command, Collection<TtyOptions> 
ttyOptions) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6e2bf9e/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
new file mode 100644
index 0000000..2a888e3
--- /dev/null
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
@@ -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.sshd.server.subsystem;
+
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.Transformer;
+import org.apache.sshd.server.Command;
+
+/**
+ * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
+ */
+public interface SubsystemFactory extends NamedFactory<Command> {
+    // required because of generics issues
+    Transformer<SubsystemFactory,NamedFactory<Command>> FAC2NAMED=new 
Transformer<SubsystemFactory,NamedFactory<Command>>() {
+        @Override
+        public NamedFactory<Command> transform(SubsystemFactory input) {
+            return input;
+        }
+    };
+
+}

Reply via email to