001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.server.deploy;
031:
032: /**
033: * The start-mode="manual", redeploy-model="manual" controller strategy.
034: *
035: * initial state = stop
036: *
037: * <table>
038: * <tr><th>input <th>stopped <th>active <th>modified <th>error
039: * <tr><td>start <td>startImpl<td>- <td>restartImpl<td>restartImpl
040: * <tr><td>update <td>startImpl<td>- <td>restartImpl<td>restartImpl
041: * <tr><td>stop <td>- <td>stopImpl<td>stopImpl <td>stopImpl
042: * <tr><td>request<td>- <td>- <td>- <td>-
043: * <tr><td>include<td>- <td>- <td>- <td>-
044: * <tr><td>alarm <td>- <td>- <td>- <td>-
045: * </table>
046: */
047: public class StartManualRedeployManualStrategy extends
048: AbstractDeployControllerStrategy {
049: private final static StartManualRedeployManualStrategy STRATEGY = new StartManualRedeployManualStrategy();
050:
051: protected StartManualRedeployManualStrategy() {
052: }
053:
054: /**
055: * Returns the start="lazy" redeploy="automatic" strategy
056: *
057: * @return the singleton strategy
058: */
059: public static DeployControllerStrategy create() {
060: return STRATEGY;
061: }
062:
063: /**
064: * Called at initialization time for automatic start.
065: *
066: * @param controller the owning controller
067: */
068: public <I extends DeployInstance> void startOnInit(
069: DeployController<I> controller) {
070: controller.stopImpl();
071: }
072:
073: /**
074: * Checks for updates from an admin command. The target state will be the
075: * initial state, i.e. update will not start a lazy instance.
076: *
077: * @param controller the owning controller
078: */
079: public <I extends DeployInstance> void update(
080: DeployController<I> controller) {
081: if (controller.isStopped()) {
082: controller.startImpl();
083: } else if (controller.isModifiedNow()) {
084: controller.restartImpl();
085: } else if (controller.isError()) {
086: controller.restartImpl();
087: } else { /* active */
088: }
089: }
090:
091: /**
092: * Returns the current instance. This strategy does not lazily restart
093: * the instance.
094: *
095: * @param controller the owning controller
096: * @return the current deploy instance
097: */
098: /* XXX: should request always return an instance? */
099: public <I extends DeployInstance> I request(
100: DeployController<I> controller) {
101: return controller.getDeployInstance();
102: }
103:
104: /**
105: * Returns the current instance. This strategy does not lazily restart
106: * the instance.
107: *
108: * @param controller the owning controller
109: * @return the current deploy instance
110: */
111: /* XXX: should request always return an instance? */
112: public <I extends DeployInstance> I subrequest(
113: DeployController<I> controller) {
114: return controller.getDeployInstance();
115: }
116:
117: /**
118: * Returns the current instance. This strategy does not lazily restart
119: * the instance.
120: *
121: * @param controller the owning controller
122: */
123: /* XXX: should request always return an instance? */
124: public <I extends DeployInstance> void alarm(
125: DeployController<I> controller) {
126: }
127: }
|