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 /** 018 * A service is component managed by the {@link Services} singleton. 019 */ 020 public interface Service { 021 public static final String DEFAULT_LOCK_TIMEOUT = "oozie.service.default.lock.timeout"; 022 023 /** 024 * Prefix for all services configuration properties. 025 */ 026 public static final String CONF_PREFIX = "oozie.service."; 027 028 /** 029 * Constant for XCommand 030 */ 031 public static final String USE_XCOMMAND = "oozie.useXCommand"; 032 033 /** 034 * Initialize the service. <p/> Invoked by the {@link Service} singleton at start up time. 035 * 036 * @param services services singleton initializing the service. 037 * @throws ServiceException thrown if the service could not initialize. 038 */ 039 public void init(Services services) throws ServiceException; 040 041 /** 042 * Destroy the service. <p/> Invoked by the {@link Service} singleton at shutdown time. 043 */ 044 public void destroy(); 045 046 /** 047 * Return the public interface of the service. <p/> Services are retrieved by its public interface. Specializations 048 * of services must return the public interface. 049 * 050 * @return the interface of the service. 051 */ 052 public Class<? extends Service> getInterface(); 053 054 /** 055 * Lock timeout value if service is only allowed to have one single running instance. 056 */ 057 public static long lockTimeout = Services.get().getConf().getLong(DEFAULT_LOCK_TIMEOUT, 5 * 1000); 058 059 }