Class ApplicationManager
java.lang.Object
com.e1c.g5.dt.internal.applications.ApplicationManager
- All Implemented Interfaces:
IManagedService,IApplicationProvisionNotifier,IApplicationManager
@LifecycleService(name="APPLICATION_MANAGER")
public class ApplicationManager
extends Object
implements IApplicationManager, IApplicationProvisionNotifier, IManagedService
The default implementation of
IApplicationManager and IApplicationProvisionNotifier.
When starting client application (IApplicationManager.open(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)), the following metrics are recorded using
IMonitoringEventDispatcher:
- "com.e1c.g5.dt.applications/event/startApplication.LAUNCH_TYPE" where LAUNCH_TYPE is either "run" or "debug";
- "com.e1c.g5.dt.applications/event/startApplication.type:TYPE_IDENTIFIER" where TYPE_IDENTIFIER indicates application type.
addAppllicationListener(IApplicationListener) are notified the following way:
- Application has been created or stopped and its state is unknown
(
notifyLifecycleStateChange(com.e1c.g5.dt.applications.ILifecycleAware, com.e1c.g5.dt.applications.LifecycleState)+LifecycleState.UNKNOWN) : application state is unknown (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.UNKNOWN+PublishState.UNKNOWN). - Application is about to be prepared
(
notifyLifecycleStateChange(com.e1c.g5.dt.applications.ILifecycleAware, com.e1c.g5.dt.applications.LifecycleState)+LifecycleState.STARTING) : application starting (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.STARTING+PublishState.UNKNOWN). - Application has been prepared
(
notifyLifecycleStateChange(com.e1c.g5.dt.applications.ILifecycleAware, com.e1c.g5.dt.applications.LifecycleState)+LifecycleState.STARTED) : application stopped (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.STARTED+PublishState.UNKNOWN). - Application requires incremental update
(
notifyPublishStateChange(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.PublishState)+PublishState.INCREMENTAL_PUBLISH_REQUIRED) : application needs to be incrementally updated (IApplicationEvent.Kind.PUBLISH_CHANGE+LifecycleState.UNKNOWN+PublishState.INCREMENTAL_PUBLISH_REQUIRED). - Application has been synchronized
(
notifyPublishStateChange(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.PublishState)+PublishState.FULL_SYNCHRONIZED) : application needs no update (IApplicationEvent.Kind.PUBLISH_CHANGE+LifecycleState.UNKNOWN+PublishState.FULL_SYNCHRONIZED). - Application is about to be stopped
(
notifyLifecycleStateChange(com.e1c.g5.dt.applications.ILifecycleAware, com.e1c.g5.dt.applications.LifecycleState)+LifecycleState.STOPPING) : application stopped (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.STOPPING+PublishState.UNKNOWN). - Application has been stopped
(
notifyLifecycleStateChange(com.e1c.g5.dt.applications.ILifecycleAware, com.e1c.g5.dt.applications.LifecycleState)+LifecycleState.STOPPED) : application stopped (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.STOPPED+PublishState.UNKNOWN). - Application is about to be deleted
(
#delete(IApplication): starting deletion of application (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.DELETING+PublishState.UNKNOWN). - Application was deleted
(
#delete(IApplication): finished deletion of application (IApplicationEvent.Kind.LIFECYCLE_CHANGE+LifecycleState.DELETED+PublishState.UNKNOWN). - Application synchronization state is unknown
(
notifyPublishStateChange(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.PublishState)+PublishState.UNKNOWN) : application state is unknown (IApplicationEvent.Kind.PUBLISH_CHANGE+LifecycleState.UNKNOWN+PublishState.UNKNOWN). - Default application has changed
(
setDefaultApplication(org.eclipse.core.resources.IProject, com.e1c.g5.dt.applications.IApplication)) : defaults have changed (IApplicationEvent.Kind.DEFAULT_CHANGE+LifecycleState.UNKNOWN+PublishState.UNKNOWN).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()voidaddAppllicationListener(IApplicationListener listener) Adds the application listener to listen to application events.org.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.IProgressMonitor monitor) Cleans up resources associated with the application.voidvoiddelete(IApplication application, boolean unsynchronize) Deletes the specified application.findApplicationByInfobase(InfobaseReference infobase) Finds an application that uses specified infobase.findApplicationByInfobaseAndProject(InfobaseReference infobase, org.eclipse.core.resources.IProject project) Finds an application for the specified project that uses specified infobase.getApplication(org.eclipse.core.resources.IProject project, String id) Returns the project application with the provided id.getApplicationArtifacts(Object object) Returns a list of all found application artifacts for the provided application or application artifact.getApplications(org.eclipse.core.resources.IProject project) Returns a list of all registered project applications.Returns a list of all registered application types.getDefaultApplication(org.eclipse.core.resources.IProject project) Returns the default registered project application.Optional<org.eclipse.core.resources.IProject>Returns the default application owner project if there is any.getDefaultUrlAccess(IApplication application) Returns the default URL access instance for the provided application.getLifecycleState(ILifecycleAware object) Returns the application lifecycle state for the provided application or lifecycle aware artifact.getPublishState(IApplication application) Returns the application publish state for the provided application.getUrlAccesses(IApplication application) Returns a list of all found URL access instances for the provided application.voidnotifyLifecycleStateChange(ILifecycleAware object, LifecycleState state) Notifies about the provided application lifecycle aware object lifecycle state change.voidnotifyPublishStateChange(IApplication application, PublishState state) Notifies about the provided application publish state change.voidonInit(ProjectContext projectContext) voidonProjectStorageClosing(ProjectContext projectContext) Cleans up applications being closed or deleted.voidprepare(IApplication application, String launchMode, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Prepares underlying infrastructure to be ready for interaction.publish(IApplication application, PublishKind kind, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Publishes the application with the provided publish kind.voidRemoves the application listener.voidsetDefaultApplication(org.eclipse.core.resources.IProject project, IApplication newDefaultApplication) Sets the default registered project application.voidsetDefaultUrlAccess(IApplication application, IUrlAccess urlAccess) Sets the default URL access instance for the provided application.start(IApplication application, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Runs application being developed.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.IApplicationManager
launch, open, stop
-
Constructor Details
-
ApplicationManager
public ApplicationManager()
-
-
Method Details
-
activate
public void activate()- Specified by:
activatein interfaceIManagedService
-
deactivate
public void deactivate()- Specified by:
deactivatein interfaceIManagedService
-
onInit
-
onProjectStorageClosing
@LifecycleParticipant(phase=STORAGE_CLOSING, dependsOn={"BM_MODEL_MANAGER","CONFIGURATION_PROJECT_MANAGER","EXTERNAL_OBJECT_PROJECT_MANAGER","EXTENSION_PROJECT_MANAGER"}) public void onProjectStorageClosing(ProjectContext projectContext) Cleans up applications being closed or deleted. It is supposed to be called when project is closed thanks toLifecycleParticipant. If project is deleted then its applications are deleted as well. Otherwise, if project is closed, cleaned or IDE is shut down then project's applications are just cleaned without deletion.- Parameters:
projectContext- Context of project being closed or deleted. Must not benull.
-
getApplication
public Optional<IApplication> getApplication(org.eclipse.core.resources.IProject project, String id) throws ApplicationException Description copied from interface:IApplicationManagerReturns the project application with the provided id.- Specified by:
getApplicationin interfaceIApplicationManager- Parameters:
project- the project to get application for, cannot benullid- the id of the application, cannot benull- Returns:
- the optional found application
- Throws:
ApplicationException- if method call failed with some reason
-
getApplications
public List<IApplication> getApplications(org.eclipse.core.resources.IProject project) throws ApplicationException Description copied from interface:IApplicationManagerReturns a list of all registered project applications.- Specified by:
getApplicationsin interfaceIApplicationManager- Parameters:
project- the project to get applications for, cannot benull- Returns:
- a list of all registered project applications, never
null - Throws:
ApplicationException- if method call failed with some reason
-
getDefaultProject
public Optional<org.eclipse.core.resources.IProject> getDefaultProject() throws ApplicationExceptionDescription copied from interface:IApplicationManagerReturns the default application owner project if there is any.- Specified by:
getDefaultProjectin interfaceIApplicationManager- Returns:
- the default application owner project if there is any
- Throws:
ApplicationException- if method call failed with some reason
-
getDefaultApplication
public Optional<IApplication> getDefaultApplication(org.eclipse.core.resources.IProject project) throws ApplicationException Description copied from interface:IApplicationManagerReturns the default registered project application.- Specified by:
getDefaultApplicationin interfaceIApplicationManager- Parameters:
project- the project to get default application for, cannot benull- Returns:
- the optional default registered project application
- Throws:
ApplicationException- if method call failed with some reason
-
getDefaultUrlAccess
public Optional<IUrlAccess> getDefaultUrlAccess(IApplication application) throws ApplicationException Description copied from interface:IApplicationManagerReturns the default URL access instance for the provided application.- Specified by:
getDefaultUrlAccessin interfaceIApplicationManager- Parameters:
application- the application, cannot benull- Returns:
- the optional default URL access instance for the provided application
- Throws:
ApplicationException- if method call failed with some reason
-
getApplicationTypes
Description copied from interface:IApplicationManagerReturns a list of all registered application types.- Specified by:
getApplicationTypesin interfaceIApplicationManager- Returns:
- a list of all registered application types, never
null - Throws:
ApplicationException- if method call failed with some reason
-
getApplicationArtifacts
public List<IApplicationArtifact> getApplicationArtifacts(Object object) throws ApplicationException Description copied from interface:IApplicationManagerReturns a list of all found application artifacts for the provided application or application artifact.- Specified by:
getApplicationArtifactsin interfaceIApplicationManager- Parameters:
object- the object to get application artifacts for, cannot benull- Returns:
- a list of all found application artifacts, never
null - Throws:
ApplicationException- if method call failed with some reason
-
getUrlAccesses
Description copied from interface:IApplicationManagerReturns a list of all found URL access instances for the provided application. May return the application itself if it is an instance ofIUrlAccess.- Specified by:
getUrlAccessesin interfaceIApplicationManager- Returns:
- a list of all found URL access instances, never
null - Throws:
ApplicationException- if method call failed with some reason
-
getLifecycleState
Description copied from interface:IApplicationManagerReturns the application lifecycle state for the provided application or lifecycle aware artifact. May be unkown.- Specified by:
getLifecycleStatein interfaceIApplicationManager- Parameters:
object- the object to get state for, cannot benull- Returns:
- the application lifecycle state, never
null - Throws:
ApplicationException- if method call failed with some reason
-
getPublishState
Description copied from interface:IApplicationManagerReturns the application publish state for the provided application. May be unkown.- Specified by:
getPublishStatein interfaceIApplicationManager- Parameters:
application- the application to get state for, cannot benull- Returns:
- the application publish state, never
null - Throws:
ApplicationException- if method call failed with some reason
-
setDefaultApplication
public void setDefaultApplication(org.eclipse.core.resources.IProject project, IApplication newDefaultApplication) throws ApplicationException Description copied from interface:IApplicationManagerSets the default registered project application.- Specified by:
setDefaultApplicationin interfaceIApplicationManager- Parameters:
project- the project to get application for, cannot benullnewDefaultApplication- the default project application to register for the project ornullto reset- Throws:
ApplicationException- if method call failed with some reason
-
setDefaultUrlAccess
public void setDefaultUrlAccess(IApplication application, IUrlAccess urlAccess) throws ApplicationException Description copied from interface:IApplicationManagerSets the default URL access instance for the provided application.- Specified by:
setDefaultUrlAccessin interfaceIApplicationManager- Parameters:
application- the application, cannot benull- Throws:
ApplicationException- if method call failed with some reason
-
publish
public PublishState publish(IApplication application, PublishKind kind, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws ApplicationException Description copied from interface:IApplicationManagerPublishes the application with the provided publish kind.- Specified by:
publishin interfaceIApplicationManager- 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 ornullif report is not desired- 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:IApplicationManagerChecks 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 interfaceIApplicationManager- 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.IProgressMonitor monitor) throws ApplicationException Description copied from interface:IApplicationManagerPrepares underlying infrastructure to be ready for interaction. Some applications might consist in more than just a client (which can beIApplicationManager.start(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)-ed). 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 beIApplicationManager.publish(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.PublishKind, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)-ed or clientIApplicationManager.start(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)-ed. Such preparation work is performed by the method. The opposite work of undoing such preparation should be done withIApplicationManager.cleanup(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor). 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 interfaceIApplicationManager- 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.IProgressMonitor monitor) throws ApplicationException Description copied from interface:IApplicationManagerCleans 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 byIApplicationManager.prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor). For example, if for a server application a server itself has been started byIApplicationManager.prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)and then a client application has been started byIApplicationManager.start(com.e1c.g5.dt.applications.IApplication, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)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 asIApplicationManager.delete(com.e1c.g5.dt.applications.IApplication, boolean). If the application has not been previouslyIApplicationManager.prepare(com.e1c.g5.dt.applications.IApplication, java.lang.String, com.e1c.g5.dt.applications.ExecutionContext, org.eclipse.core.runtime.IProgressMonitor)d then it still can be cleaned up without generating an error. 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 interfaceIApplicationManager- Parameters:
application- the application to stop, cannot benullcontext- the execution context, cannot benullmonitor- the progress monitor to report progress to ornullif report is not desired- Throws:
ApplicationException- if method call failed with some reason
-
start
public Optional<Process> start(IApplication application, ExecutionContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws ApplicationException Description copied from interface:IApplicationManagerRuns application being developed. The method runs client application being developed and represented by the specifiedIApplication. Some application types (for example, server applications) require that preliminary preparation is performed before application being developed can be run. For this purpose,IApplicationManager.prepare(IApplication, String, ExecutionContext, IProgressMonitor)should be used beforehand.- Specified by:
startin interfaceIApplicationManager- Parameters:
application- the application to start, cannot benullcontext- the execution context, cannot benullmonitor- the progress monitor to report progress to, cannot benull- Returns:
- the optional application client system process, may be empty if application is web for example
- Throws:
ApplicationException- if method call failed with some reason
-
addAppllicationListener
Description copied from interface:IApplicationManagerAdds the application listener to listen to application events.- Specified by:
addAppllicationListenerin interfaceIApplicationManager- Parameters:
listener- the application listener, cannot benull
-
removeAppllicationListener
Description copied from interface:IApplicationManagerRemoves the application listener.- Specified by:
removeAppllicationListenerin interfaceIApplicationManager- Parameters:
listener- the application listener, cannot benull
-
notifyLifecycleStateChange
Description copied from interface:IApplicationProvisionNotifierNotifies about the provided application lifecycle aware object lifecycle state change.- Specified by:
notifyLifecycleStateChangein interfaceIApplicationProvisionNotifier- Parameters:
object- the lifecycle aware object, cannot benullstate- the new lifecycle state, cannot benull
-
notifyPublishStateChange
Description copied from interface:IApplicationProvisionNotifierNotifies about the provided application publish state change.- Specified by:
notifyPublishStateChangein interfaceIApplicationProvisionNotifier- Parameters:
application- the application, cannot benullstate- the new publish state, cannot benull
-
delete
Description copied from interface:IApplicationManagerDeletes the specified application.- Specified by:
deletein interfaceIApplicationManager- 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.
-
findApplicationByInfobase
public Optional<IApplication> findApplicationByInfobase(InfobaseReference infobase) throws ApplicationException Description copied from interface:IApplicationManagerFinds an application that uses specified infobase. If project is known then consider usingIApplicationManager.findApplicationByInfobaseAndProject(com._1c.g5.v8.dt.platform.services.model.InfobaseReference, org.eclipse.core.resources.IProject)which could much faster.- Specified by:
findApplicationByInfobasein interfaceIApplicationManager- Parameters:
infobase- Infobase for which to find application. Must not benull.- Returns:
- Application that uses specified infobase or an empty value if infobase is not used by any application.
Never
null. - Throws:
ApplicationException- If an error occured while searching for matching application.
-
findApplicationByInfobaseAndProject
public Optional<IApplication> findApplicationByInfobaseAndProject(InfobaseReference infobase, org.eclipse.core.resources.IProject project) throws ApplicationException Description copied from interface:IApplicationManagerFinds an application for the specified project that uses specified infobase. The method is similar toIApplicationManager.findApplicationByInfobase(com._1c.g5.v8.dt.platform.services.model.InfobaseReference)but could be much faster.- Specified by:
findApplicationByInfobaseAndProjectin interfaceIApplicationManager- Parameters:
infobase- Infobase for which to search application. Must not benull.project- Project for which to search application. Must not benull.- Returns:
- Application that uses specified infobase and project
or an empty value if infobase is not used by any application in the specified project.
Never
null. - Throws:
ApplicationException- If an error occured while searching for matching application.
-