E4AP provides two levels of lifecycles, for contributions and for the application.

Component Lifecycle

Components (UI or non-UI) very often manage resources that need to be initialized when the component is instantiated, or disposed when the component itself is disposed. This is a long-winded way of saying that a container should call a method after a component is instantiated and ready to go, and call another method just before disposing the component.

Clients can use the @PostConstruct and @PreDestroy JSR-250 annotations to mark methods that should be called by the framework.

Initialization

@PostConstruct
private void init() {
// do stuff
}

Disposal

@PersistState
private void persitState() {
// do stuff
} @PreDestroy
private void dispose() {
// do stuff
}

Application Lifecycle

The E4AP provides a few mechanisms for hooking into the application lifecycle.

The Lifecycle Manager

A product can provide a lifecycle manager object. An instance of this object will be created and called into by E4AP using a set of annotated methods. The lifecycle manager class is provided as a URI either using the "lifeCycleURI" product property or from the "-lifeCycleURI" command-line argument; only a single lifecycle manager is supported at present. The lifecycle manager is created on the application context.

Currently supported annotations are those in org.eclipse.e4.ui.workbench.lifecycle:

  • PostContextCreate: called after the application context has been created, but prior to the model having been loaded
  • ProcessAdditions: called once the application model is loaded.
  • ProcessRemovals: called after ProcessAdditions
  • PreSave: called before the model is persisted

Model Processors

Model processors are provided an opportunity to manipulate the model after load. A model processor may be invoked either before or after any fragments have been loaded. Processors are typically used for one-time model transformations; model addons are used for providing model-based services.

Model processors are specified using the org.eclipse.e4.workbench.model extension point. The processor is created with a context hooked from the application context, and is triggered with the org.eclipse.e4.core.di.annotations.Execute-annotated method.

Model Addons

Model addons are typically used for associating model-based services, i.e., services that react to changes in the model over the course of the application lifetime. An addon is specified by adding a reference to the MApplication's addon list, either through a model processor or via a fragment.

Addons,like any model contribution, are triggered by @PostConstruct and @PreDestroy. Any execution for an addon must be started from its @PostConstruct and those listeners should be removed in @PreDestroy. Addons are created after @ProcessRemovals, and disposed as part of the application context being destroyed.

An addon can use model changes to react at events that are meaningful within the application lifetime. For example, an addon could install an event listener for a widget-set on a window to detect when the first window is shown.

[JAVA][RCP] Eclipse4/RCP/Lifecycle的更多相关文章

  1. Eclipse RCP应用开发(概念)

    学习Eclipse RCP应用开发,对其中一些相关的概念需要了解. 让我们在讲解概念前先思考两个问题. 问题一.什么是Eclipse 大部分同学会回答eclipse是IBM公司开发的java集成开发环 ...

  2. rcp命令

    rcp命令 rcp代表“remote file copy”(远程文件拷贝).该命令用于在计算机之间拷贝文件.rcp命令有两种格式.第一种格式用于文件到文件的拷贝:第二种格式用于把文件或目录拷贝到另一个 ...

  3. 让普通 Java 类自动感知 Activity Lifecycle

    背景 在 Android 开发中,我们都很熟悉 Activity 的 Lifecycle,并且会在特定的 Lifecycle 下执行特定的操作.当然,我们清楚 Lifecycle 本身是带有 Andr ...

  4. java攻城狮之路(Android篇)--Activity生命

    一:Activity的激活 1.写一个类 extends Activity Activity是android的四大组件之一.Activity的激活分为显式意图激活和隐式意图激活.如果一个activit ...

  5. 《Java从入门到精通》学习总结1

    1. Java既是编译型语音,也是解释型语言:先将源代码编译成Java字节码,然后Java虚拟机对Java字节码进行解释运行 2. 使用命令行编译Java源代码时,如果代码中有中文,在编译时需要指定编 ...

  6. 【高软作业4】:Tomcat 观察者模式解析 之 Lifecycle

    一. 预备 如果你是Windows用户,使用Eclipse,并且想自行导入源码进行分析,你可能需要:Eclipse 导入 Tomcat 源码 如果你已遗忘 观察者模式,那么你可以通过该文章回顾:设计模 ...

  7. Mybatis入门 digest

    http://www.mybatis.org/mybatis-3/zh/configuration.html userDao-mapping.xml相当于是UserDao的实现, 同时也将User实体 ...

  8. 25个最佳最闪亮的Eclipse开发项目

    http://blog.csdn.net/howareyoutodayyhz/article/details/8264599 25个最佳最闪亮的Eclipse开发项目 标签: eclipseEclip ...

  9. client交互技术简单介绍

    随着网络应用的不断丰富,client交互技术也如雨后春笋一般,遍地开花. 正是这些技术的支持,我们的互联网世界变得更加丰富多彩.一个浏览器上.不用说是简单的动画效果,就是一个Office应用也能顺畅的 ...

随机推荐

  1. 翻译「C++ Rvalue References Explained」C++右值引用详解 Part5:右值引用就是右值吗?

    本文为第五部分,目录请参阅概述部分:http://www.cnblogs.com/harrywong/p/cpp-rvalue-references-explained-introduction.ht ...

  2. Android ROM 备书

    1. Android ROM 目录接口 我们经常说的刷ROM是刷系统的意思,但是ROM的原意并不是这样,ROM的全称是read only memory只读储存器,正因为它是“只读”的,而且系统文件通常 ...

  3. WPF学习系列之六 (元素绑定)

    元素绑定 简单地说,数据绑定是一种关系,该关系告诉WPF从一个源对象提取一些信息,并使用这些信息设置目标对象的属性.目标属性总是依赖属性,并且通常位于WPF元素中. 一.将元素绑定到一起 <Wi ...

  4. CHARINDEX用法

    CHARINDEX返回字符串中指定表达式的起始位置. 语法CHARINDEX ( e­xpression1 , e­xpression2 [ , start_location ] ) 参数e­xpre ...

  5. 改变ListCtrl某行的背景色或者字体颜色

    大家也许熟悉WM_NOTIFY,控件通过WM_NOTIFY向父窗口发送消息.在WM_NOTIFY消息体中,部分控件会发送NM_CUSTOMDRAW告诉父窗口自己需要绘图. 也可以反射NM_CUSTOM ...

  6. C#基础知识点

    一.方法(结构.数组.冒泡排序.3个参数重载) 1将string转换为int类型 Convert.ToInt32(); int.Parse() ; int.TryParse()三种方式. 2 结构:可 ...

  7. Compass是什么

    Compass是一个强大的Sass框架,他的设计目标是顺畅.搞笑地装扮互联网,使用它的人可以写出可维护性更高的样式表. Compass由三个主要部分组成:混混合器和实用工具类库,能够集成到应用开发环境 ...

  8. Sass基础语法

    Sass是CSS3语言的扩展,在CSS的基础之上添加了新特性和语法,能省事地写出更好的样式表.Sass引擎是基于Ruby的. 导入Sass文件: @import "colors" ...

  9. JS常用的设计模式(15)—— 职责链模式

    职责链模式是一个对象A向另一个对象B发起请求,如果B不处理,可以把请求转给C,如果C不处理,又可以把请求转给D.一直到有一个对象愿意处理这个请求为止. 打个比方,客户让老板写个php程序.老板肯定不写 ...

  10. Spring与Quartz的整合实现定时任务调度

    摘自: http://kevin19900306.iteye.com/blog/1397744 最近在研究Spring中的定时任务功能,最好的办法当然是使用Quartz来实现.对于一个新手来说,花了我 ...