插件和外部jar文件之间的区别

插件和外部jar文件之间的区别

本文介绍了插件和外部jar文件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java上下文中,插件"和外部jar/第三方库/外部依赖关系等"在概念上有什么区别吗?

In the context of java, is tehre any difference conceptually between 'plugin' and 'external jar/third party library/ external dependency etc?

这个问题的一个推论是:当您在Eclipse中下载并安装"插件时,除了在.plugin目录中复制jar以外,它还能做其他事情吗?

A corollary to the question is: When in eclipse you download and 'install' a plugin, does it do anything else except copy a jar in the .plugin directory?

推荐答案

Eclipse插件必须在MANIFEST.MF中包含许多条目才能被识别为插件.这些提供了插件的名称和版本以及所需的其他插件的列表以及许多其他值.

An Eclipse plugin must contain a number of entries in the MANIFEST.MF to be recognized as a plugin. These give the name and version of the plugin along with lists of other plugins that are required and numerous other values.

该插件还可能包含plugin.xml,它定义了插件使用的Eclipse扩展点,并且还可以声明新的扩展点.

The plugin may also contain a plugin.xml which defines the Eclipse extension points the plugin uses and may also declare new extension points.

Eclipse插件不必是jar文件,也可以使用等效的目录结构.

Eclipse plugins do not have to be jar files, the equivalent directory structure is also acceptable.

当Eclipse安装插件时,它将从MANIFEST.MF和plugin.xml中获取信息来更新内部表,例如扩展点贡献,每个插件的类路径等等.

When Eclipse installs a plugin it takes information from the MANIFEST.MF and plugin.xml to update internal tables of things like extension point contributions, class paths for the each plugin and so on.

示例plugin.xml,它声明一个新的扩展点并使用现有的扩展点:

Example plugin.xml which declares a new extension point and uses an existing one:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension-point id="editor" name="%extension-point.name" schema="schema/editor.exsd"/>
   <extension
         id="coreFragment"
         point="org.eclipse.e4.workbench.model">
      <fragment
            uri="fragment.e4xmi">
      </fragment>
   </extension>
</plugin>

MANIFEST.MF示例

Example MANIFEST.MF

Manifest-Version: 1.0
Export-Package: greg.music.core.common,greg.music.core.e4util,greg.mus
 ic.core.editor,greg.music.core.preferences,greg.music.core.progress,g
 reg.music.core.services,greg.music.core.showin,greg.music.core.util,g
 reg.music.core.views,greg.music.core.xml
Service-Component: OSGI-INF/playerStateService.xml,OSGI-INF/preference
 Settings.xml,OSGI-INF/extensionFactory.xml
Bundle-ActivationPolicy: lazy
Bundle-Name: %Bundle-Name
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.core.runtime,greg.music.forms;bundle-versi
 on="1.0.0",greg.music.parts;bundle-version="1.0.0",greg.music.annotat
 ions;bundle-version="1.0.0",javazoom.jlgui.basicplayer;bundle-version
 ="1.6.0",org.eclipse.jface;bundle-version="3.8.101",org.eclipse.e4.co
 re.contexts;bundle-version="1.1.0",org.eclipse.e4.core.commands;bundl
 e-version="0.10.1",org.eclipse.e4.core.di;bundle-version="1.1.0",org.
 eclipse.e4.core.services;bundle-version="1.0.0",org.eclipse.e4.ui.mod
 el.workbench;bundle-version="0.10.1",org.eclipse.e4.ui.workbench;bund
 le-version="0.11.0",org.eclipse.e4.ui.services;bundle-version="0.10.3
 ",com.ibm.icu;bundle-version="4.4.2",org.eclipse.emf.common;bundle-ve
 rsion="2.9.0",org.eclipse.emf.ecore;bundle-version="2.9.0",org.eclips
 e.e4.ui.css.swt.theme;bundle-version="0.9.100",org.eclipse.e4.ui.di;b
 undle-version="1.0.0",org.joda.time;bundle-version="2.3.0",com.google
 .guava;bundle-version="14.0.1"
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 1.0.0.201310241930
Bundle-ManifestVersion: 2
Bundle-Activator: greg.music.core.Activator
Import-Package: javax.annotation;version="1.0.0",javax.inject;version=
 "1.0.0"
Bundle-SymbolicName: greg.music.core;singleton:=true

这篇关于插件和外部jar文件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:20