001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.oozie.service; 019 020 /** 021 * A service is component managed by the {@link Services} singleton. 022 */ 023 public interface Service { 024 public static final String DEFAULT_LOCK_TIMEOUT = "oozie.service.default.lock.timeout"; 025 026 /** 027 * Prefix for all services configuration properties. 028 */ 029 public static final String CONF_PREFIX = "oozie.service."; 030 031 /** 032 * Constant for XCommand 033 */ 034 public static final String USE_XCOMMAND = "oozie.useXCommand"; 035 036 /** 037 * Initialize the service. <p/> Invoked by the {@link Service} singleton at start up time. 038 * 039 * @param services services singleton initializing the service. 040 * @throws ServiceException thrown if the service could not initialize. 041 */ 042 public void init(Services services) throws ServiceException; 043 044 /** 045 * Destroy the service. <p/> Invoked by the {@link Service} singleton at shutdown time. 046 */ 047 public void destroy(); 048 049 /** 050 * Return the public interface of the service. <p/> Services are retrieved by its public interface. Specializations 051 * of services must return the public interface. 052 * 053 * @return the interface of the service. 054 */ 055 public Class<? extends Service> getInterface(); 056 057 /** 058 * Lock timeout value if service is only allowed to have one single running instance. 059 */ 060 public static long lockTimeout = Services.get().getConf().getLong(DEFAULT_LOCK_TIMEOUT, 5 * 1000); 061 062 }