001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.cli;
018
019import java.util.ArrayList;
020import java.util.Collection;
021import java.util.Collections;
022import java.util.List;
023
024import org.springframework.boot.cli.command.Command;
025import org.springframework.boot.cli.command.CommandFactory;
026import org.springframework.boot.cli.command.archive.JarCommand;
027import org.springframework.boot.cli.command.archive.WarCommand;
028import org.springframework.boot.cli.command.core.VersionCommand;
029import org.springframework.boot.cli.command.encodepassword.EncodePasswordCommand;
030import org.springframework.boot.cli.command.grab.GrabCommand;
031import org.springframework.boot.cli.command.init.InitCommand;
032import org.springframework.boot.cli.command.install.InstallCommand;
033import org.springframework.boot.cli.command.install.UninstallCommand;
034import org.springframework.boot.cli.command.run.RunCommand;
035
036/**
037 * Default implementation of {@link CommandFactory}.
038 *
039 * @author Dave Syer
040 */
041public class DefaultCommandFactory implements CommandFactory {
042
043        private static final List<Command> DEFAULT_COMMANDS;
044
045        static {
046                List<Command> defaultCommands = new ArrayList<>();
047                defaultCommands.add(new VersionCommand());
048                defaultCommands.add(new RunCommand());
049                defaultCommands.add(new GrabCommand());
050                defaultCommands.add(new JarCommand());
051                defaultCommands.add(new WarCommand());
052                defaultCommands.add(new InstallCommand());
053                defaultCommands.add(new UninstallCommand());
054                defaultCommands.add(new InitCommand());
055                defaultCommands.add(new EncodePasswordCommand());
056                DEFAULT_COMMANDS = Collections.unmodifiableList(defaultCommands);
057        }
058
059        @Override
060        public Collection<Command> getCommands() {
061                return DEFAULT_COMMANDS;
062        }
063
064}