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 * bstefanescu, jcarsique 018 */ 019package org.nuxeo.connect.update.live; 020 021import java.io.IOException; 022 023import org.nuxeo.common.Environment; 024import org.nuxeo.connect.update.PackageException; 025import org.nuxeo.connect.update.PackageUpdateService; 026import org.nuxeo.connect.update.standalone.StandaloneUpdateService; 027import org.nuxeo.connect.update.task.live.LiveInstallTask; 028import org.nuxeo.connect.update.task.live.LiveUninstallTask; 029import org.nuxeo.connect.update.task.live.commands.Deploy; 030import org.nuxeo.connect.update.task.live.commands.DeployConfig; 031import org.nuxeo.connect.update.task.live.commands.Flush; 032import org.nuxeo.connect.update.task.live.commands.FlushJaasCache; 033import org.nuxeo.connect.update.task.live.commands.ReloadProperties; 034import org.nuxeo.connect.update.task.live.commands.RollbackAndUndeploy; 035import org.nuxeo.connect.update.task.live.commands.Undeploy; 036import org.nuxeo.connect.update.task.live.commands.UndeployConfig; 037import org.nuxeo.connect.update.task.live.commands.UpdateAndDeploy; 038import org.nuxeo.connect.update.task.update.Rollback; 039import org.nuxeo.connect.update.task.update.Update; 040import org.nuxeo.runtime.reload.NuxeoRestart; 041 042/** 043 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 044 */ 045public class UpdateServiceImpl extends StandaloneUpdateService implements PackageUpdateService { 046 047 public UpdateServiceImpl() throws IOException { 048 super(Environment.getDefault()); 049 } 050 051 @Override 052 protected void addCommands() { 053 super.addCommands(); 054 addCommand(FlushJaasCache.ID, FlushJaasCache.class); 055 addCommand(Flush.ID, Flush.class); 056 057 addCommand(ReloadProperties.ID, ReloadProperties.class); 058 059 addCommand(Deploy.ID, Deploy.class); 060 addCommand(Undeploy.ID, Undeploy.class); 061 062 addCommand(DeployConfig.ID, DeployConfig.class); 063 addCommand(UndeployConfig.ID, UndeployConfig.class); 064 065 // override the update command to add hot reload support 066 addCommand(Update.ID, UpdateAndDeploy.class); 067 addCommand(Rollback.ID, RollbackAndUndeploy.class); 068 } 069 070 /** 071 * @deprecated since 9.10 - use {@code org.nuxeo.ecm.admin.NuxeoCtlManager#restart()} instead. 072 */ 073 @Override 074 @Deprecated 075 public void restart() throws PackageException { 076 try { 077 NuxeoRestart.restart(); 078 } catch (IOException e) { 079 throw new PackageException("Failed to restart Nuxeo", e); 080 } 081 } 082 083 @Override 084 public String getDefaultInstallTaskType() { 085 return LiveInstallTask.class.getName(); 086 } 087 088 @Override 089 public String getDefaultUninstallTaskType() { 090 return LiveUninstallTask.class.getName(); 091 } 092 093}