001    /**
002     * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
003     * Licensed under the Apache License, Version 2.0 (the "License");
004     * you may not use this file except in compliance with the License.
005     * You may obtain a copy of the License at
006     *
007     *   http://www.apache.org/licenses/LICENSE-2.0
008     *
009     *  Unless required by applicable law or agreed to in writing, software
010     *  distributed under the License is distributed on an "AS IS" BASIS,
011     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012     *  See the License for the specific language governing permissions and
013     *  limitations under the License. See accompanying LICENSE file.
014     */
015    package org.apache.oozie.service;
016    
017    import org.apache.oozie.CoordinatorEngine;
018    import org.apache.oozie.service.Service;
019    import org.apache.oozie.service.Services;
020    
021    /**
022     * Service that return a coordinator engine for a user.
023     */
024    public class CoordinatorEngineService implements Service {
025    
026        /**
027         * Initialize the service.
028         *
029         * @param services services instance.
030         */
031        public void init(Services services) {
032        }
033    
034        /**
035         * Destroy the service.
036         */
037        public void destroy() {
038        }
039    
040        /**
041         * Return the public interface of the Coordinator engine service.
042         *
043         * @return {@link CoordinatorEngineService}.
044         */
045        public Class<? extends Service> getInterface() {
046            return CoordinatorEngineService.class;
047        }
048    
049        /**
050         * Return a Coordinator engine.
051         *
052         * @param user user for the coordinator engine.
053         * @param authToken the authentication token.
054         * @return the coordinator engine for the specified user.
055         */
056        public CoordinatorEngine getCoordinatorEngine(String user, String authToken) {
057            return new CoordinatorEngine(user, authToken);
058        }
059    
060        /**
061         * Return a Coordinator engine for a system user (no user, no group).
062         *
063         * @return a system Coordinator engine.
064         */
065        public CoordinatorEngine getSystemCoordinatorEngine() {
066            return new CoordinatorEngine();
067        }
068    
069    }