Eclipse中创建Plug-in项目时的Target platform选项说明-osgi,三种建立区别
2014-02-14 11:17
295 查看
原来地址:http://blog.csdn.net/jsjszg/article/details/7370814
新建Plug-in项目时,需要选择Target platform:
其中有三种选择:
1、Eclipse version
2、an OSGi framework: Equinox
3、an OSGi framework: standard
什么意思呢?
Eclipse version 指的是Eclipse UI 插件这样的运行方式.
an OSGI framework 指的是运行于OSGI下的,非UI的插件.
选项: Equinox 指的是,使用Equinox(Eclipse的OSGI实现)
选项: standard 指的是,使用标准的OSGI实现
下面具体说明他们的差别:
1. 自动生成代码的区别:
选择Eclipse version, 那么默认生成的Activator就是继承与AbstractUIPlugin.
[java] view
plaincopy
package helloservive04;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "HelloServive04"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
选择Equinox或者standard,
那么默认的Activator就是实现了BundleActivator接口.
[java] view
plaincopy
package helloservice02;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}
2. MANIFEST.MF的区别:
Eclipse version,打开的MANIFEST.MF的编辑器, 它有Extensions 和 Extension
Points这两个设置页面.
Equinox或者standard,开的MANIFEST.MF的编辑器,
是没有Extensions 和 Extension Points这两个设置页面.
这也说明一个区别: Ecliopse平台不仅仅实现了OSGI, 同时, 还使用了自己的Plugin机制, 也就是Extensions和Extensions Points机制.
也就是Eclipse并不是一个完全的OSGI, 而是一个OSGI 与 自己的Plugin机制的结合体.
Equinox和standard发现一个小小的区别:
对于Equinox,MANIFEST.MF中多了一项默认设置:
Bundle-ActivationPolicy: lazy
standard的MANIFEST.MF中没有发现。
后记:
发现Eclipse的Help里面有一些相关的信息:
引用
Eclipse vs. OSGi Framework
The Eclipse vs. OSGi framework choice acts as pre-filter to determine what initial pages will be visible in the plug-in manifest editor when it opens.
Since the extension registry is Eclipse-specific content, the Extensions and Extension Points pages of the manifest editor are visible only when the Eclipse version option is chosen.
Equinox vs. Standard
When targeting an OSGi framework, you have a choice between the Equinox and standard frameworks. The Equinox OSGi framework augments the MANIFEST.MF content with Eclipse-specific headers (e.g. Eclipse-LazyStart) and directives (e.g. x-friends). If you do not
wish to use these Eclipse-specific headers and attributes, then choose the standard option.
新建Plug-in项目时,需要选择Target platform:
其中有三种选择:
1、Eclipse version
2、an OSGi framework: Equinox
3、an OSGi framework: standard
什么意思呢?
Eclipse version 指的是Eclipse UI 插件这样的运行方式.
an OSGI framework 指的是运行于OSGI下的,非UI的插件.
选项: Equinox 指的是,使用Equinox(Eclipse的OSGI实现)
选项: standard 指的是,使用标准的OSGI实现
下面具体说明他们的差别:
1. 自动生成代码的区别:
选择Eclipse version, 那么默认生成的Activator就是继承与AbstractUIPlugin.
[java] view
plaincopy
package helloservive04;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "HelloServive04"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
选择Equinox或者standard,
那么默认的Activator就是实现了BundleActivator接口.
[java] view
plaincopy
package helloservice02;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}
2. MANIFEST.MF的区别:
Eclipse version,打开的MANIFEST.MF的编辑器, 它有Extensions 和 Extension
Points这两个设置页面.
Equinox或者standard,开的MANIFEST.MF的编辑器,
是没有Extensions 和 Extension Points这两个设置页面.
这也说明一个区别: Ecliopse平台不仅仅实现了OSGI, 同时, 还使用了自己的Plugin机制, 也就是Extensions和Extensions Points机制.
也就是Eclipse并不是一个完全的OSGI, 而是一个OSGI 与 自己的Plugin机制的结合体.
Equinox和standard发现一个小小的区别:
对于Equinox,MANIFEST.MF中多了一项默认设置:
Bundle-ActivationPolicy: lazy
standard的MANIFEST.MF中没有发现。
后记:
发现Eclipse的Help里面有一些相关的信息:
引用
Eclipse vs. OSGi Framework
The Eclipse vs. OSGi framework choice acts as pre-filter to determine what initial pages will be visible in the plug-in manifest editor when it opens.
Since the extension registry is Eclipse-specific content, the Extensions and Extension Points pages of the manifest editor are visible only when the Eclipse version option is chosen.
Equinox vs. Standard
When targeting an OSGi framework, you have a choice between the Equinox and standard frameworks. The Equinox OSGi framework augments the MANIFEST.MF content with Eclipse-specific headers (e.g. Eclipse-LazyStart) and directives (e.g. x-friends). If you do not
wish to use these Eclipse-specific headers and attributes, then choose the standard option.
相关文章推荐
- 【OSGI】Eclipse中创建Plug-in项目时的Target platform选项说明
- 如何用Eclipse创建Plug-in项目
- eclipse创建android项目,无法正常预览布局文件,出现This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in...
- 8. 练习:创建一个Eclipse plug-in项目
- 创建EclipsePlug-in项目和RCP
- Myeclipse 和 Eclipse创建web项目的区别
- eclipse、lomboz、tomcat创建lomboz项目说明
- eclipse中创建的web项目从/WEB-INF/lib下复制jar包与在build path中导入jar包的区别
- 为Eclipse plug-in(插件)创建语言包
- osgi 学习系列(二)第一个plug-in项目
- Eclipse建立Java工程中的三个JRE选项的区别(Use an execution environment JRE,Use a project specific JRE,Use default JRE)
- Plug-in 创建插件项目
- Eclipse 开发plug-in 引用其它项目时 导出plug-in的方法
- OSGI实战(2)-走近OSGI-开发第一个Plug-in项目
- Plug-in 创建RCP项目
- eclipse中创建android项目时,设定minimum required SDK、TargetSDK和Compile SDK有什么要求
- Flex Flash Builder 4.5 4.6 Eclipse插件 plug-in下载安装说明
- Eclipse中创建Maven项目时,报错提示:“a pom xml file already exists in the destination folder ”
- 【OSGI】2.走近OSGI-开发第一个Plug-in项目
- eclipse创建项目