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