001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.runtime.model; 013 014import java.util.ArrayList; 015import java.util.List; 016 017import org.nuxeo.runtime.service.TimestampedService; 018 019/** 020 * A component that expose a reload method usefull to completely reload the component and preserving already registered 021 * extensions. 022 * 023 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 024 * @deprecated since 5.6: services needing a reload should listen to runtime reload events instead. They can also 025 * implement the {@link TimestampedService} interface in case they should not need to be reloaded when event 026 * is received. 027 */ 028@Deprecated 029public class ReloadableComponent extends DefaultComponent implements Reloadable { 030 031 protected List<Extension> extensions = new ArrayList<Extension>(); 032 033 @Override 034 public void registerExtension(Extension extension) { 035 super.registerExtension(extension); 036 extensions.add(extension); 037 } 038 039 @Override 040 public void unregisterExtension(Extension extension) { 041 extensions.remove(extension); 042 super.unregisterExtension(extension); 043 } 044 045 public void reload(ComponentContext context) { 046 deactivate(context); 047 activate(context); 048 for (Extension xt : extensions) { 049 super.registerExtension(xt); 050 } 051 } 052 053 public List<Extension> getExtensions() { 054 return extensions; 055 } 056 057}