001/* 002 * (C) Copyright 2006-2017 Nuxeo (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 * Nuxeo - initial API and implementation 018 */ 019package org.nuxeo.runtime.model; 020 021import org.nuxeo.runtime.service.TimestampedService; 022 023/** 024 * A Nuxeo Runtime component. 025 * <p> 026 * Components are extensible and adaptable objects and they provide methods to respond to component life cycle events. 027 * 028 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 029 */ 030public interface Component extends Extensible, TimestampedService { 031 032 /** 033 * Sets the name for this component, as it was defined in its XML. 034 * <p> 035 * This is called once after construction by the runtime framework. 036 * 037 * @param name the name 038 * @since 10.3 039 */ 040 void setName(String name); 041 042 /** 043 * Activates the component. 044 * <p> 045 * This method is called by the runtime when a component is activated. 046 * 047 * @param context the runtime context 048 */ 049 void activate(ComponentContext context); 050 051 /** 052 * Deactivates the component. 053 * <p> 054 * This method is called by the runtime when a component is deactivated. 055 * 056 * @param context the runtime context 057 */ 058 void deactivate(ComponentContext context); 059 060 /** 061 * The component notification order for {@link #applicationStarted}. 062 * <p> 063 * Components are notified in increasing order. Order 1000 is the default order for components that don't care. 064 * Order 100 is the repository initialization. 065 * 066 * @return the order, 1000 by default 067 * @since 5.6 068 */ 069 default int getApplicationStartedOrder() { 070 return ComponentStartOrders.DEFAULT; 071 } 072 073 /** 074 * Notify the component that Nuxeo Framework finished starting all Nuxeo bundles. Implementors must migrate the code 075 * of the applicationStarted and move it to {@link Component#start(ComponentContext)} and 076 * {@link #stop(ComponentContext)} methods 077 * 078 * @deprecated since 9.2, since the introduction of {@link Component#start(ComponentContext)} and 079 * {@link #stop(ComponentContext)} methods 080 */ 081 @Deprecated 082 default void applicationStarted(ComponentContext context) { 083 // do nothing by default 084 } 085 086 /** 087 * Start the component. This method is called after all the components were resolved and activated 088 * 089 * @since 9.2 090 */ 091 void start(ComponentContext context); 092 093 /** 094 * Stop the component. 095 * 096 * @since 9.2 097 */ 098 void stop(ComponentContext context) throws InterruptedException; 099 100}