001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (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 * bstefanescu 018 */ 019package org.nuxeo.runtime.reload; 020 021import java.io.File; 022import java.io.IOException; 023 024import org.nuxeo.runtime.deployment.preprocessor.DeploymentPreprocessor; 025import org.nuxeo.runtime.service.TimestampedService; 026import org.osgi.framework.BundleException; 027 028/** 029 * Service tracking reload related events or commands when installing a package 030 * 031 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 032 */ 033public interface ReloadService extends TimestampedService { 034 035 public static final String RELOAD_TOPIC = "org.nuxeo.runtime.reload"; 036 037 public static final String FLUSH_EVENT_ID = "flush"; 038 039 public static final String BEFORE_RELOAD_EVENT_ID = "before-reload"; 040 041 public static final String RELOAD_EVENT_ID = "reload"; 042 043 public static final String AFTER_RELOAD_EVENT_ID = "after-reload"; 044 045 public static final String FLUSH_SEAM_EVENT_ID = FLUSH_EVENT_ID+"SeamComponents"; 046 047 public static final String RELOAD_SEAM_EVENT_ID = "reloadSeamComponents"; 048 049 public static final String RELOAD_REPOSITORIES_ID = "reloadRepositories"; 050 051 /** 052 * Sends a runtime event with id {@link #RELOAD_EVENT_ID} so that listeners can be notified that a reload has been 053 * done. 054 * <p> 055 * Also calls {@link #reloadProperties()} by default, but not other reload methods as they could alter the running 056 * application behaviour. 057 * @throws InterruptedException 058 * 059 * @since 5.5 060 * @see #reloadProperties() 061 */ 062 void reload() throws InterruptedException; 063 064 /** 065 * Reloads the Nuxeo repository configuration 066 * @throws InterruptedException 067 */ 068 void reloadRepository() throws InterruptedException; 069 070 /** 071 * Reloads runtime framework properties 072 */ 073 void reloadProperties() throws IOException; 074 075 /** 076 * Sends a runtime event with id {@link #RELOAD_SEAM_EVENT_ID} 077 * 078 * @since 5.5 079 */ 080 void reloadSeamComponents(); 081 082 /** 083 * Sends a runtime event with id {@link #FLUSH_EVENT_ID} so that listeners can be notified that a flush is needed 084 * (after a reload for instance). 085 * <p> 086 * Also calls {@link #flushJaasCache()} by default, but not other flush methods as they could alter the running 087 * application behaviour. 088 * 089 * @see {@link #flushJaasCache()} 090 * @since 5.5 091 */ 092 void flush(); 093 094 /** 095 * Returns the last time one of the flush commands where called on this service instance ({@link #flush()} or 096 * {@link #flushJaasCache()} or {@link #flushSeamComponents()}, or null if never called 097 * 098 * @since 5.6 099 */ 100 Long lastFlushed(); 101 102 /** 103 * Sends an event that can trigger reset of JaasCache 104 */ 105 void flushJaasCache(); 106 107 /** 108 * Sends a runtime event with id {@link #FLUSH_SEAM_EVENT_ID} 109 * 110 * @since 5.6 111 */ 112 void flushSeamComponents(); 113 114 /** 115 * Deploys bundle to the runtime, without reloading resources 116 * 117 * @since 5.5 118 * @see #deployBundle(File, boolean) 119 */ 120 String deployBundle(File file) throws BundleException; 121 122 /** 123 * Deploys bundle to the runtime, gives possibility to control resources reloading. 124 * 125 * @since 5.5 126 */ 127 String deployBundle(File file, boolean reloadResources) throws BundleException; 128 129 /** 130 * Undeploys bundle from the runtime, given the bundle resource, gives possibility to control resources reloading 131 * 132 * @since 5.6 133 */ 134 void undeployBundle(File file, boolean reloadResources) throws BundleException; 135 136 /** 137 * Undeploys bundle from the runtime, given the bundle filename 138 * 139 * @since 5.6 140 */ 141 void undeployBundle(String bundleName) throws BundleException; 142 143 /** 144 * Runs the deployment preprocessor 145 * 146 * @since 5.6 147 * @See {@link DeploymentPreprocessor} 148 */ 149 public void runDeploymentPreprocessor() throws IOException; 150 151 /** 152 * Copies the bundle web resources into the nuxeo WAR directory. 153 * 154 * @since 5.5 155 * @deprecated since 5.6: use {@link #runDeploymentPreprocessor()} method instead, now re-deploys all jars so that 156 * the nuxeo.war holds the same content than it would at startup. This method is called by reflection by 157 * ReloadServiceInvoker#hotDeployBundles. Keep it as compatibility code until NXP-9642 is done. 158 */ 159 @Deprecated 160 void installWebResources(File file) throws IOException; 161 162 /*** 163 * Returns the OSGI bundle name if given file can be identified as an OSGI bundle, or null. The OSGI bundle can be a 164 * jar or an exploded jar on file system. 165 * 166 * @since 5.6 167 */ 168 String getOSGIBundleName(File file); 169 170}