001/**
002 *
003 * Copyright 2008 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.commands;
018
019import java.lang.reflect.InvocationTargetException;
020
021/**
022 * A factory for creating local commands. It's useful in cases where instantiation
023 * of a command is more complicated than just using the default constructor. For example,
024 * when arguments must be passed into the constructor or when using a dependency injection
025 * framework. When a LocalCommandFactory isn't used, you can provide the AdHocCommandManager
026 * a Class object instead. For more details, see
027 * {@link AdHocCommandManager#registerCommand(String, String, LocalCommandFactory)}.
028 *
029 * @author Matt Tucker
030 */
031public interface LocalCommandFactory {
032
033    /**
034     * Returns an instance of a LocalCommand.
035     *
036     * @return a LocalCommand instance.
037     * @throws InstantiationException if creating an instance failed.
038     * @throws IllegalAccessException if creating an instance is not allowed.
039     * @throws SecurityException if there was a security violation.
040     * @throws NoSuchMethodException if no such method is declared
041     * @throws InvocationTargetException if a reflection-based method or constructor invocation threw.
042     * @throws IllegalArgumentException if an illegal argument was given.
043     */
044    LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
045
046}