001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
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 * Contributors:
017 *     bstefanescu
018 */
019package org.nuxeo.ecm.automation;
020
021import java.util.List;
022import java.util.Map;
023
024import org.nuxeo.ecm.automation.core.impl.ChainTypeImpl;
025import org.nuxeo.ecm.automation.core.impl.InvokableMethod;
026
027/**
028 * Describe an operation class. Each registered operation will be stored in the registry as an instance of this class.
029 *
030 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
031 */
032public interface OperationType {
033
034    String getId();
035
036    /**
037     * The operation ID Aliases array.
038     *
039     * @since 7.1
040     */
041    String[] getAliases();
042
043    Class<?> getType();
044
045    /**
046     * The input type of a chain/operation. If set, the following input types {"document", "documents", "blob", "blobs"}
047     * for all 'run method(s)' will handled. Other values will be adapted as java.lang.Object. If not set, Automation
048     * will set the input type(s) as the 'run methods(s)' parameter types (by introspection).
049     *
050     * @since 7.4
051     */
052    default String getInputType() {
053        return null;
054    }
055
056    Object newInstance(OperationContext ctx, Map<String, Object> args) throws OperationException;
057
058    /**
059     * Gets the service that registered that type.
060     */
061    AutomationService getService();
062
063    OperationDocumentation getDocumentation() throws OperationException;
064
065    /**
066     * Gets the name of the component that contributed the operation
067     *
068     * @return
069     */
070    String getContributingComponent();
071
072    InvokableMethod[] getMethodsMatchingInput(Class<?> in);
073
074    /**
075     * @since 5.7.2
076     */
077    public List<InvokableMethod> getMethods();
078
079    @Override
080    int hashCode();
081
082    @Override
083    boolean equals(Object obj);
084
085    static OperationType typeof(OperationChain chain, boolean replace) {
086        return ChainTypeImpl.typeof(chain, replace);
087    }
088
089}