com.ptc.windchill.upgrade.ius
Class UpdateRunner

java.lang.Object
  extended bycom.ptc.windchill.upgrade.ius.UpdateRunner
All Implemented Interfaces:
Runnable

public final class UpdateRunner
extends Object
implements Runnable



Supported API: false

Extendable: false


Nested Class Summary
private  class UpdateRunner.DirectiveServicesAdapter
           
 
Field Summary
private static String ACCESS_CONTROL_PROPERTY_NAME
           
private  ApplicabilitySnapshotModel applicabilityModel_
           
private  CancellationMonitor cancellationMonitor_
           
private static String CLASSNAME
           
private static String CORE_UPDATE_RESOURCE
           
private static boolean DEBUG
           
private  UpdateRunner.DirectiveServicesAdapter directiveServices_
           
private  boolean finished_
           
private  boolean hasEnded_
           
private static String INIT_DIRECTIVE_CLASS_METHOD_NAME
           
private  boolean isPaused_
           
private  UpdateRunnerListener listener_
           
private static DebugWriter LOG
           
private  int numberOfExecutedUpdates_
           
private  int numberOfSkippedOrFailedUpdates_
           
private  boolean pauseRequested_
           
private  Object singleThreadLock_
           
private  UpgradeContext upgradeContext_
           
 
Constructor Summary
UpdateRunner(ApplicabilitySnapshotModel applicability_model)
           
 
Method Summary
 void addUpdateRunnerListener(UpdateRunnerListener new_listener)
           
private  boolean allDependedUponUpdatesHaveRun(UUID uuid)
          Confirms that all the incremental updates that this update depends upon have been applied.
private  int alterNLSDateFormat(Connection jdbc_connection)
           
private  ApplicabilitySnapshotModel applicabilityModel()
           
private  void applyUpdate(IncrementalUpdate update)
           
private  void checkForCancellation()
          If a cancel was requested, mark the state of the runner as canceled and throw the exception.
private  UpdateRunner.DirectiveServicesAdapter directiveServices()
           
private  void executeAllUpdatesIn(List update_sequence)
           
private  void executeSqlUpdate(String sql, Connection connection)
           
protected  void finalize()
           
protected  void fireLogMessageIssued(UpdateRunnerLogEvent event)
           
protected  void fireRunnerAborted(UpdateRunnerEvent event)
           
protected  void fireRunnerCanceled(UpdateRunnerEvent event)
           
protected  void fireRunnerCompleted(UpdateRunnerEvent event)
           
protected  void fireRunnerStarted(UpdateRunnerEvent event)
           
protected  void fireUpdateProcessingExecuted(IncrementalUpdateProcessingEvent event)
           
protected  void fireUpdateProcessingFailed(IncrementalUpdateProcessingEvent event)
           
protected  void fireUpdateProcessingSkippedPredecessorsNotRun(IncrementalUpdateProcessingEvent event)
           
protected  void fireUpdateProcessingStarted(IncrementalUpdateProcessingEvent event)
           
protected  void fireUpdateProcessingSucceeded(IncrementalUpdateProcessingEvent event)
           
private  InstallAndUpgradeHistory getInstallAndUpgradeHistory()
           
 boolean getOutcome()
          Answer true if a cancel was requested.
 boolean hasEnded()
          Request that the runner stop prematurely.
private  void incrementNumberOfExecutedUpdates()
           
private  void incrementNumberOfSkippedOrFailedUpdates()
           
 void initializeInstalledDirectiveClasses()
           
 int numberOfExecutedUpdates()
           
 int numberOfSkippedOrFailedUpdates()
           
private  void recompileInvalidObjects()
           
 void removeUpdateRunnerListener(UpdateRunnerListener listener_to_remove)
           
private  void resetNumberOfSkippedOrFailedUpdates()
           
 void run()
           
private  void runPostUpdateHook()
           
private  void runPreUpdateHook()
           
private  void runUpdateHook(String type)
           
 void setCancellationMonitor(CancellationMonitor cancel_monitor)
           
private  UpgradeContext upgradeContext()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

private static final String CLASSNAME

DEBUG

private static final boolean DEBUG

LOG

private static final DebugWriter LOG

INIT_DIRECTIVE_CLASS_METHOD_NAME

private static final String INIT_DIRECTIVE_CLASS_METHOD_NAME
See Also:
Constant Field Values

CORE_UPDATE_RESOURCE

private static final String CORE_UPDATE_RESOURCE

ACCESS_CONTROL_PROPERTY_NAME

private static final String ACCESS_CONTROL_PROPERTY_NAME
See Also:
Constant Field Values

upgradeContext_

private UpgradeContext upgradeContext_

applicabilityModel_

private ApplicabilitySnapshotModel applicabilityModel_

directiveServices_

private UpdateRunner.DirectiveServicesAdapter directiveServices_

singleThreadLock_

private Object singleThreadLock_

listener_

private transient UpdateRunnerListener listener_

finished_

private boolean finished_

pauseRequested_

private boolean pauseRequested_

isPaused_

private boolean isPaused_

hasEnded_

private boolean hasEnded_

cancellationMonitor_

private CancellationMonitor cancellationMonitor_

numberOfSkippedOrFailedUpdates_

private int numberOfSkippedOrFailedUpdates_

numberOfExecutedUpdates_

private int numberOfExecutedUpdates_
Constructor Detail

UpdateRunner

public UpdateRunner(ApplicabilitySnapshotModel applicability_model)
             throws InvocationTargetException,
                    IllegalAccessException,
                    NoSuchMethodException
Method Detail

finalize

protected void finalize()
                 throws Throwable
Throws:
Throwable

addUpdateRunnerListener

public void addUpdateRunnerListener(UpdateRunnerListener new_listener)

setCancellationMonitor

public void setCancellationMonitor(CancellationMonitor cancel_monitor)

removeUpdateRunnerListener

public void removeUpdateRunnerListener(UpdateRunnerListener listener_to_remove)

hasEnded

public boolean hasEnded()
Request that the runner stop prematurely. This method will return immediately.The caller can determine when the runner has finally stopped by asking hasEnded or registering as a listener and waiting for the runnerAborted, runnerCanceled, or runnerCompleted messages.

If the runner has already completed or is done with its work before the request is received, it will not reply true to wasCanceled().


run

public void run()
Specified by:
run in interface Runnable

initializeInstalledDirectiveClasses

public void initializeInstalledDirectiveClasses()
                                         throws UpdateRunnerException
Throws:
UpdateRunnerException

executeAllUpdatesIn

private void executeAllUpdatesIn(List update_sequence)
                          throws SQLException,
                                 RunnerCanceledException
Throws:
SQLException
RunnerCanceledException

alterNLSDateFormat

private int alterNLSDateFormat(Connection jdbc_connection)
                        throws Exception
Throws:
Exception

checkForCancellation

private void checkForCancellation()
                           throws RunnerCanceledException
If a cancel was requested, mark the state of the runner as canceled and throw the exception.

Throws:
CanceledException - if a cancel was requested
RunnerCanceledException

applyUpdate

private void applyUpdate(IncrementalUpdate update)
                  throws RunnerCanceledException
Throws:
CanceledException - if a cancel was requested and detected prior to the commit of the work.A cancel request that comes after the commit is not detected and handled in this method.It is the responsibility of the caller to decide what to do.
RunnerCanceledException

allDependedUponUpdatesHaveRun

private boolean allDependedUponUpdatesHaveRun(UUID uuid)
                                       throws IUHException
Confirms that all the incremental updates that this update depends upon have been applied.

Throws:
IUHException

fireLogMessageIssued

protected void fireLogMessageIssued(UpdateRunnerLogEvent event)

fireRunnerStarted

protected void fireRunnerStarted(UpdateRunnerEvent event)

fireRunnerAborted

protected void fireRunnerAborted(UpdateRunnerEvent event)

fireRunnerCanceled

protected void fireRunnerCanceled(UpdateRunnerEvent event)

fireRunnerCompleted

protected void fireRunnerCompleted(UpdateRunnerEvent event)

fireUpdateProcessingSkippedPredecessorsNotRun

protected void fireUpdateProcessingSkippedPredecessorsNotRun(IncrementalUpdateProcessingEvent event)

fireUpdateProcessingStarted

protected void fireUpdateProcessingStarted(IncrementalUpdateProcessingEvent event)

fireUpdateProcessingSucceeded

protected void fireUpdateProcessingSucceeded(IncrementalUpdateProcessingEvent event)

fireUpdateProcessingFailed

protected void fireUpdateProcessingFailed(IncrementalUpdateProcessingEvent event)

fireUpdateProcessingExecuted

protected void fireUpdateProcessingExecuted(IncrementalUpdateProcessingEvent event)

applicabilityModel

private ApplicabilitySnapshotModel applicabilityModel()

upgradeContext

private UpgradeContext upgradeContext()

getInstallAndUpgradeHistory

private InstallAndUpgradeHistory getInstallAndUpgradeHistory()

directiveServices

private UpdateRunner.DirectiveServicesAdapter directiveServices()

getOutcome

public boolean getOutcome()
Answer true if a cancel was requested. When a cancel is requested, the runner will abort the entire run after the completion of the currently running incremental update.It will not mark the current incremental as update complete.

See Also:
#cancel, #wasCanceled

numberOfSkippedOrFailedUpdates

public int numberOfSkippedOrFailedUpdates()

numberOfExecutedUpdates

public int numberOfExecutedUpdates()

incrementNumberOfSkippedOrFailedUpdates

private void incrementNumberOfSkippedOrFailedUpdates()

incrementNumberOfExecutedUpdates

private void incrementNumberOfExecutedUpdates()

resetNumberOfSkippedOrFailedUpdates

private void resetNumberOfSkippedOrFailedUpdates()

recompileInvalidObjects

private void recompileInvalidObjects()
                              throws Exception
Throws:
Exception

executeSqlUpdate

private void executeSqlUpdate(String sql,
                              Connection connection)
                       throws SQLException
Throws:
SQLException

runPreUpdateHook

private void runPreUpdateHook()

runPostUpdateHook

private void runPostUpdateHook()

runUpdateHook

private void runUpdateHook(String type)