Class InfobaseApplicationBehaviourDelegate
java.lang.Object
com.e1c.g5.dt.internal.applications.infobases.ui.InfobaseApplicationBehaviourDelegate
- All Implemented Interfaces:
IApplicationBehaviourDelegate
public class InfobaseApplicationBehaviourDelegate
extends Object
implements IApplicationBehaviourDelegate
Behavior implementation for applications which are hosted on a file or server (1C cluster) infobase.
Preparing infobase application consists in
connecting project and infobase.
Symmetrically, cleaning up infobase application is
disconnecting project from infobase.
Deleting the application means disassociation
(preceeded by disconnection much like during cleanup).
InfobaseApplicationProvisionDelegate will notify IApplicationManager
through IApplicationProvisionNotifier that an application has been either
LifecycleState.CREATED or LifecycleState.STOPPED when association context is changed.
When this happens, the delegate will either prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor) or cleanup(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor) the application-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.core.runtime.IStatuscheck(IApplication application, ApplicationCheckUnknownStateTreatment whenUnknown, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Checks whether the application is ready to start.voidcleanup(IApplication application, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) Cleans up resources associated with the application.voiddelete(IApplication application, boolean unsynchronize) Deletes the specified application.voidinitialize(IApplicationProvisionNotifier notifier, IApplicationType type) Initializes the application behaviour delegate with the registered application type and provision notifier.voidonStateChanged(IApplication application, LifecycleState state) Called when application state has been changed.voidprepare(IApplication application, String launchMode, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) Prepares underlying infrastructure to be ready for interaction.publish(IApplication application, PublishKind kind, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) Publishes the application with the provided publish kind.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.e1c.g5.dt.applications.contributors.IApplicationBehaviourDelegate
launch, stop
-
Constructor Details
-
InfobaseApplicationBehaviourDelegate
public InfobaseApplicationBehaviourDelegate()
-
-
Method Details
-
initialize
Description copied from interface:IApplicationBehaviourDelegateInitializes the application behaviour delegate with the registered application type and provision notifier.- Specified by:
initializein interfaceIApplicationBehaviourDelegate- Parameters:
notifier- the application provision notifier, cannot benulltype- the application type, cannot benull
-
publish
public PublishState publish(IApplication application, PublishKind kind, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) throws ApplicationException Description copied from interface:IApplicationBehaviourDelegatePublishes the application with the provided publish kind.- Specified by:
publishin interfaceIApplicationBehaviourDelegate- Parameters:
application- the application to publish, cannot benullkind- the publish kind to use, cannot benullcontext- the execution context, cannot benullmonitor- the progress monitor to report progress to, cannot benull- Returns:
- the publication state after execution, never
null - Throws:
ApplicationException- if method call failed with some reason
-
check
public org.eclipse.core.runtime.IStatus check(IApplication application, ApplicationCheckUnknownStateTreatment whenUnknown, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws ApplicationException Description copied from interface:IApplicationBehaviourDelegateChecks whether the application is ready to start. Such readiness check might include checking that related infobase configuration has not been changed outside of EDT. If application's project has extensions then those extensions are checked as well.- Specified by:
checkin interfaceIApplicationBehaviourDelegate- Parameters:
application- the application to check, cannot benullwhenUnknown- Indicates how to treat situation when previous infobase state is not known and so cannot determine if there are changes in infobase. Must not benull.context- Context with start parameters. It must containExecutionContext.ACTIVE_SHELL_NAMEwith the shell to be used for interaction with a user. Must not benull.monitor- the progress monitor to report progress to, cannot benull- Returns:
IStatus.OKif application is ready to be started,IStatus.CANCELif user cancells operation,IStatus.ERRORif application is not ready to be started.- Throws:
ApplicationException- if thecontextdoes not specifyExecutionContext.ACTIVE_SHELL_NAMEor pulling changes from the associated infobase fails.
-
prepare
public void prepare(IApplication application, String launchMode, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) throws ApplicationException Description copied from interface:IApplicationBehaviourDelegatePrepares underlying infrastructure to be ready for interaction. Some applications might consist in more than just a client. Those type of applications might require additional set up for the interaction with them to function properly. For example, a server application might require a server to be started before a client application can beIApplicationBehaviourDelegate.publish(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.PublishKind, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor)-ed or client started. Such preparation work is performed by the method. The opposite work of undoing such preparation should be done withIApplicationBehaviourDelegate.cleanup(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor). The application preparation for regular run and for debug run might be significatly different. The caller must specify launch mode to be the same as it will specify when actually starting application in the future. However, it is up to the application if it will honor or ignore the mode and if it will re-prepare if it is already prepared for another mode or the current application state is good enough for the desired launch mode. The current thread is blocked until preparation is complete (for example, server start finishes). Since this is a long running operation, it might be inappripriate to run it from UI thread. Consider usingorg.eclipse.jface.dialogs.ProgressMonitorDialogwith fork mode enabled.- Specified by:
preparein interfaceIApplicationBehaviourDelegate- Parameters:
application- the application to prepare, cannot benulllaunchMode- Desired future application start mode. See org.eclipse.debug.core.ILaunchManager.RUN_MODE and org.eclipse.debug.core.ILaunchManager.DEBUG_MODE. Must not benull.context- Context containing parameters affecting application preparation. The context could be modified as a result of the call and should be used when starting clients. For example,ExecutionContext.DEBUG_TARGETandExecutionContext.DEBUG_URLmight be added/updated to reflect application settings when preparing for debug mode. Must not benull.monitor- the progress monitor to report progress to ornullif report is not desired- Throws:
ApplicationException- if method call failed with some reason
-
cleanup
public void cleanup(IApplication application, ExecutionContext context, org.eclipse.core.runtime.SubMonitor monitor) throws ApplicationException Description copied from interface:IApplicationBehaviourDelegateCleans up resources associated with the application. The method does not stop client application being developed. Instead, it undoes preparation work that has been previously done byIApplicationBehaviourDelegate.prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor). For example, if for a server application a server itself has been started byIApplicationBehaviourDelegate.prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.SubMonitor)and then a client application has been started then the method might stop that previously started server once it is not needed anymore. This can change lifecycle state of the application but should have no effect on application synchronization/equality/publish state. Cleanup is a temporary action and should not be as desctructive asIApplicationBehaviourDelegate.delete(com.e1c.g5.dt.applications.IApplication, boolean). The current thread is blocked until operation is finished. Since this is a long running operation, it might be inappripriate to run it from UI thread. Consider usingorg.eclipse.jface.dialogs.ProgressMonitorDialogwith fork mode enabled.- Specified by:
cleanupin interfaceIApplicationBehaviourDelegate- Parameters:
application- the application to stop, cannot benullcontext- the execution context, cannot benullmonitor- the progress monitor to report progress to, cannot benull- Throws:
ApplicationException- if method call failed with some reason
-
delete
Description copied from interface:IApplicationBehaviourDelegateDeletes the specified application.- Specified by:
deletein interfaceIApplicationBehaviourDelegate- Parameters:
application- Application to be deleted. Must not benull.unsynchronize-trueif synchronization state is to be deleted orfalseis to keep synchronization state.- Throws:
ApplicationException- If the specified application could not be deleted for whatever reason.
-
onStateChanged
Description copied from interface:IApplicationBehaviourDelegateCalled when application state has been changed.- Specified by:
onStateChangedin interfaceIApplicationBehaviourDelegate- Parameters:
application- Application whose state has changed. Nevernull.state- State in which application has been transitioned. Nevernull.
-