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 * 058 * @since 5.5 059 * @see #reloadProperties() 060 */ 061 void reload(); 062 063 /** 064 * Reloads the Nuxeo repository configuration 065 */ 066 void reloadRepository(); 067 068 /** 069 * Reloads runtime framework properties 070 */ 071 void reloadProperties() throws IOException; 072 073 /** 074 * Sends a runtime event with id {@link #RELOAD_SEAM_EVENT_ID} 075 * 076 * @since 5.5 077 */ 078 void reloadSeamComponents(); 079 080 /** 081 * Sends a runtime event with id {@link #FLUSH_EVENT_ID} so that listeners can be notified that a flush is needed 082 * (after a reload for instance). 083 * <p> 084 * Also calls {@link #flushJaasCache()} by default, but not other flush methods as they could alter the running 085 * application behaviour. 086 * 087 * @see {@link #flushJaasCache()} 088 * @since 5.5 089 */ 090 void flush(); 091 092 /** 093 * Returns the last time one of the flush commands where called on this service instance ({@link #flush()} or 094 * {@link #flushJaasCache()} or {@link #flushSeamComponents()}, or null if never called 095 * 096 * @since 5.6 097 */ 098 Long lastFlushed(); 099 100 /** 101 * Sends an event that can trigger reset of JaasCache 102 */ 103 void flushJaasCache(); 104 105 /** 106 * Sends a runtime event with id {@link #FLUSH_SEAM_EVENT_ID} 107 * 108 * @since 5.6 109 */ 110 void flushSeamComponents(); 111 112 /** 113 * Deploys bundle to the runtime, without reloading resources 114 * 115 * @since 5.5 116 * @see #deployBundle(File, boolean) 117 */ 118 String deployBundle(File file) throws BundleException; 119 120 /** 121 * Deploys bundle to the runtime, gives possibility to control resources reloading. 122 * 123 * @since 5.5 124 */ 125 String deployBundle(File file, boolean reloadResources) throws BundleException; 126 127 /** 128 * Undeploys bundle from the runtime, given the bundle resource, gives possibility to control resources reloading 129 * 130 * @since 5.6 131 */ 132 void undeployBundle(File file, boolean reloadResources) throws BundleException; 133 134 /** 135 * Undeploys bundle from the runtime, given the bundle filename 136 * 137 * @since 5.6 138 */ 139 void undeployBundle(String bundleName) throws BundleException; 140 141 /** 142 * Runs the deployment preprocessor 143 * 144 * @since 5.6 145 * @See {@link DeploymentPreprocessor} 146 */ 147 public void runDeploymentPreprocessor() throws IOException; 148 149 /** 150 * Copies the bundle web resources into the nuxeo WAR directory. 151 * 152 * @since 5.5 153 * @deprecated since 5.6: {@link #runDeploymentPreprocessor()} method now re-deploys all jars so that the nuxeo.war 154 * holds the same content than it would at startup. 155 */ 156 @Deprecated 157 void installWebResources(File file) throws IOException; 158 159 /*** 160 * Returns the OSGI bundle name if given file can be identified as an OSGI bundle, or null. The OSGI bundle can be a 161 * jar or an exploded jar on file system. 162 * 163 * @since 5.6 164 */ 165 String getOSGIBundleName(File file); 166 167}