Home » Eclipse Projects » Eclipse Platform » how to read the extensions registry outside eclipse
| how to read the extensions registry outside eclipse [message #319418] |
Mon, 20 August 2007 14:37  |
Eclipse User |
|
|
|
Hi,
I have to write a utility that can be run from command line to read all
extension contributions to an extension point. I have looked into headless
RCP and OSGI launchers. All these require eclipse.core.runtime plugin. I
cannot be dependent on core.runtime since we are running our utils on
HP-Itanium. Hence I have to write a Java utility class that can read through
all my jar files (plug-ins) and figure out the extension contributions in
all plugin.xml files and load these classes. Can you point me to the eclipse
code that creates and loads the extension contributions to the Eclipse
registry? Is there some sample code that I can take a look at to read all
plugin.xml files from all jars and create my own registry?
I have many extension points. Is it worthy to convert all these into
Declarative Services and create an OSGI application?
Thanks,
Rashmy
|
|
| | | | | |
| Re: how to read the extensions registry outside eclipse [message #319450 is a reply to message #319442] |
Tue, 21 August 2007 11:49   |
Eclipse User |
|
|
|
Rashmy wrote:
> I found examples in the below two plugins for the creation of my own
> ExtensionsRegsitry outside of the Eclipse IDE
> org.eclipse.equinox.test.internal.standalone
> org.eclipse.core.tests.internal.registry.simple
>
> But both these require me to pass an IContributor that is defined in
> core.runtime.
No, it's in the org.eclipse.core.runtime package but it is actually
defined in the equinox.registry bundle. ContributorFactorySimple is
also in the equinox.registry bundle.
Also, check in the thread titled "Using Extension Registry without OSGi"
in eclipse.technology.equinox. It looks like you don't even need the
org.eclipse.osgi bundle, but can reduce the size needed by using the
supplemental one.
It can be done completely with the 3 jars mentioned in this thread and a
java app:
masterToken = new Object();
registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
null), masterToken, null);
Then for each plugin.xml you need to check:
InputStream pluginXmlInput = ...;
String pluginXmlId = ...;
ResourceBundle pluginXmlResources = null; // or dig out the correct one
registry.addContribution(pluginXmlInput,
ContributorFactorySimple.createContributor(pluginXmlId), false,
pluginXmlId, pluginXmlResources, masterToken);
Later,
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
|
|
|
| Re: how to read the extensions registry outside eclipse [message #319472 is a reply to message #319450] |
Wed, 22 August 2007 08:51   |
Eclipse User |
|
|
|
Hi Paul,
I had found a similar code you mentioned in eclipsezone website. But it did
not work for me. Then I tried what you mentioned below, still I have an
issue.
Here is what I did -
I have a plugin called "com.mycompany.base.ui". This contains the below
plugin.xml file-
<plugin>
<extension-point id="testcontributor" name="%ExtPoint.testcontributor"
schema="schema/testcontributor.exsd"/>
<extension
id="MyDataProjectNature"
name="%MyDataProjectNature.name"
point="org.eclipse.core.resources.natures">
<runtime>
<run
class="com.mycompany.base.ui.project.MyDataProjectNature">
</run>
</runtime>
</extension>
</plugin>
Here is the code I had to load the above xml file to the registry-
RegistryStrategy stratergy = new RegistryStrategy(null, null);
IExtensionRegistry registry = new ExtensionRegistry(stratergy, masterToken,
null);
IContributor contrib =
ContributorFactorySimple.createContributor("com.mycompany.base.ui ");
String path = "D:\com.mycompany.base.ui\plugin.xml";
InputStream is = new FileInputStream(path);
registry.addContribution( is, contrib, false, null, null, null );
I get the error -
Error: Could not parse XML contribution for "com.mycompany.base.ui/". Any
contributed extensions and extension points will be ignored.
But when I tried the below test case it worked. I think it is because the
plugin ID "RegistryTest" is in the XML file while the 3.2 plugin.xml that I
have does not have the plugin ID. This is now in the MANIFEST.MF file.
String xmlContribution = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
//$NON-NLS-1$
"<plugin id=\"RegistryTest\" version=\"1.0.0\">" + //$NON-NLS-1$
"<extension-point id=\"point1\" name=\"Test extension point\"
schema=\"schema/schema.exsd\"/>" + //$NON-NLS-1$
"<extension point=\"point1\" id=\"extension1\">" + //$NON-NLS-1$
"</extension></plugin>";
IContributor contrib =
ContributorFactorySimple.createContributor("RegistryTest");
RegistryStrategy stratergy = new RegistryStrategy(null, null);
IExtensionRegistry registry = new ExtensionRegistry(stratergy,masterToken,
null);
InputStream is = new ByteArrayInputStream(xmlContribution.getBytes());
registry.addContribution( is, contrib, false, null, null, null );
Is there anything else I have to do to get my plugin.xml file working?
Thanks.
"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:faf166$555$1@build.eclipse.org...
> Rashmy wrote:
>> I found examples in the below two plugins for the creation of my own
>> ExtensionsRegsitry outside of the Eclipse IDE
>> org.eclipse.equinox.test.internal.standalone
>> org.eclipse.core.tests.internal.registry.simple
>>
>> But both these require me to pass an IContributor that is defined in
>> core.runtime.
>
> No, it's in the org.eclipse.core.runtime package but it is actually
> defined in the equinox.registry bundle. ContributorFactorySimple is also
> in the equinox.registry bundle.
>
> Also, check in the thread titled "Using Extension Registry without OSGi"
> in eclipse.technology.equinox. It looks like you don't even need the
> org.eclipse.osgi bundle, but can reduce the size needed by using the
> supplemental one.
>
> It can be done completely with the 3 jars mentioned in this thread and a
> java app:
>
> masterToken = new Object();
> registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
> null), masterToken, null);
>
> Then for each plugin.xml you need to check:
>
> InputStream pluginXmlInput = ...;
> String pluginXmlId = ...;
> ResourceBundle pluginXmlResources = null; // or dig out the correct one
> registry.addContribution(pluginXmlInput,
> ContributorFactorySimple.createContributor(pluginXmlId), false,
> pluginXmlId, pluginXmlResources, masterToken);
>
> Later,
> PW
>
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
|
|
|
| Re: how to read the extensions registry outside eclipse [message #319476 is a reply to message #319472] |
Wed, 22 August 2007 10:21   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------070201080104090100010506
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Rashmy wrote:
>
> RegistryStrategy stratergy = new RegistryStrategy(null, null);
> IExtensionRegistry registry = new ExtensionRegistry(stratergy, masterToken,
> null);
> IContributor contrib =
> ContributorFactorySimple.createContributor("com.mycompany.base.ui ");
This probably isn't the java statement that you expect:
> String path = "D:\com.mycompany.base.ui\plugin.xml";
You probably want:
String path = "d:\\com.mycompany.base.ui\\plugin.xml";
I was kinda curious, so I took a stab at it. I've attached a java file
that accepts an eclipse/plugins directory and will try and load all of
the plugins into the registry. It tries to load the plugin id and the
localication file from the MANIFEST.MF.
It's the brute-force stupid version, but it appears to work on my
machine. It also doesn't close input streams (not necessary for
addContribution(*), but I didn't check the MANIFEST or ResourceBundle ones).
bash$ java -cp org.eclipse.equinox.registry_3.4.0.v20070820.jar\
:org.eclipse.equinox.common_3.3.0.v20070820.jar\
:org.eclipse.osgi_3.4.0.v20070820.jar\
:check.jar z.ex.registry.CheckRegistry /opt/eclipse330/plugins
This works well with the 3.3.0 jars, and it runs with the 3.2.2 jars
(but not so well).
Later,
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
--------------070201080104090100010506
Content-Type: text/x-java;
name="CheckRegistry.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CheckRegistry.java"
package z.ex.registry;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import org.eclipse.core.runtime.ContributorFactorySimple;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.spi.RegistryStrategy;
/**
* Takes an eclipse/plugins directory and loads an IExtensionRegistry
* with the plugin.xml information. It'll even try and load the
* bundle id and main localization information.
*
* To run it you need 3 jars:
* <ul>
* <li>org.eclipse.equinox.supplement or org.eclipse.osgi</li>
* <li>org.eclipse.equinox.common</li>
* <li>org.eclipse.equinox.registry</li>
* </ul>
*/
public class CheckRegistry {
private static final String LOCALIZATION_NAME = "plugin.properties";
private static final String PLUGIN_XML_NAME = "plugin.xml";
public static final String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
public final static String BUNDLE_LOCALIZATION = "Bundle-Localization";
/**
* @param args
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Need a plugins directory");
return;
}
CheckRegistry check = new CheckRegistry(args[0]);
check.validate();
}
private String dir;
private Object masterToken;
private IExtensionRegistry registry;
private static class BundleInfo {
InputStream pluginxml = null;
ResourceBundle resources = null;
IContributor contributor = null;
}
public CheckRegistry(String pluginsDir) {
dir = pluginsDir;
masterToken = new Object();
registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
null), masterToken, null);
}
public void validate() {
File directory = new File(dir);
if (!directory.exists()) {
System.out.println(dir + " does not exist");
return;
}
File[] files = directory.listFiles();
for (int i = 0; i < files.length; i++) {
try {
BundleInfo in = getPluginInfo(files[i]);
if (in != null) {
System.out.println("processing: " + files[i]);
registry.addContribution(in.pluginxml, in.contributor,
false, in.contributor.getName(), in.resources,
masterToken);
}
} catch (Exception e) {
e.printStackTrace();
}
}
IExtensionPoint[] extensionPoints = registry.getExtensionPoints();
for (int i = 0; i < extensionPoints.length; i++) {
System.out.println("ep: "
+ extensionPoints[i].getUniqueIdentifier());
}
IExtensionPoint extensionPoint = registry
.getExtensionPoint("org.eclipse.ui.commands");
IExtension[] extensions = extensionPoint.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configurationElements = extensions[i]
.getConfigurationElements();
for (int j = 0; j < configurationElements.length; j++) {
System.out.println("e: "
+ configurationElements[j].getAttribute("id") + "\n\t"
+ configurationElements[j].getAttribute("name"));
}
}
}
private BundleInfo getPluginInfo(File file) throws Exception {
String propName = LOCALIZATION_NAME;
if (file.isDirectory()) {
File xml = new File(file, PLUGIN_XML_NAME);
if (xml.exists()) {
BundleInfo b = new BundleInfo();
b.pluginxml = new FileInputStream(xml);
b.contributor = ContributorFactorySimple.createContributor(file
.getName().split("_")[0]);
File cont = new File(file, "META-INF/MANIFEST.MF");
if (cont.exists()) {
Manifest m = new Manifest(new FileInputStream(cont));
ContributorFactorySimple.createContributor(m
.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME)
.split(";")[0].trim());
String baseName = m.getMainAttributes().getValue(
BUNDLE_LOCALIZATION);
if (baseName != null) {
propName = baseName + ".properties";
}
}
File prop = new File(file, propName);
if (prop.exists()) {
b.resources = new PropertyResourceBundle(
new FileInputStream(prop));
}
return b;
}
return null;
}
if (file.getName().endsWith("jar")) {
JarFile jf = new JarFile(file);
JarEntry entry = jf.getJarEntry(PLUGIN_XML_NAME);
if (entry != null) {
BundleInfo b = new BundleInfo();
b.pluginxml = jf.getInputStream(entry);
b.contributor = ContributorFactorySimple.createContributor(jf
.getManifest().getMainAttributes().getValue(
BUNDLE_SYMBOLICNAME).split(";")[0].trim());
String baseName = jf.getManifest().getMainAttributes()
.getValue(BUNDLE_LOCALIZATION);
if (baseName != null) {
propName = baseName + ".properties";
}
JarEntry prop = jf.getJarEntry(propName);
if (prop != null) {
b.resources = new PropertyResourceBundle(jf
.getInputStream(prop));
}
return b;
}
}
return null;
}
}
--------------070201080104090100010506--
|
|
|
| Re: how to read the extensions registry outside eclipse [message #319483 is a reply to message #319472] |
Wed, 22 August 2007 13:31   |
Eclipse User |
|
|
|
I finally got it working. But only after copying the contents of the
InputStream to a string and then sending it as bytes to the
addContribution() method. Maybe there is an issue with the way I am reading
my plugin.xml file
"Rashmy" <appanera@ugs.com> wrote in message
news:fahbgj$eic$1@build.eclipse.org...
> Hi Paul,
> I had found a similar code you mentioned in eclipsezone website. But it
> did not work for me. Then I tried what you mentioned below, still I have
> an issue.
>
> Here is what I did -
> I have a plugin called "com.mycompany.base.ui". This contains the below
> plugin.xml file-
> <plugin>
> <extension-point id="testcontributor" name="%ExtPoint.testcontributor"
> schema="schema/testcontributor.exsd"/>
> <extension
> id="MyDataProjectNature"
> name="%MyDataProjectNature.name"
> point="org.eclipse.core.resources.natures">
> <runtime>
> <run
> class="com.mycompany.base.ui.project.MyDataProjectNature">
> </run>
> </runtime>
> </extension>
> </plugin>
>
> Here is the code I had to load the above xml file to the registry-
>
> RegistryStrategy stratergy = new RegistryStrategy(null, null);
> IExtensionRegistry registry = new ExtensionRegistry(stratergy,
> masterToken, null);
> IContributor contrib =
> ContributorFactorySimple.createContributor("com.mycompany.base.ui ");
> String path = "D:\com.mycompany.base.ui\plugin.xml";
> InputStream is = new FileInputStream(path);
> registry.addContribution( is, contrib, false, null, null, null );
>
> I get the error -
> Error: Could not parse XML contribution for "com.mycompany.base.ui/". Any
> contributed extensions and extension points will be ignored.
>
> But when I tried the below test case it worked. I think it is because the
> plugin ID "RegistryTest" is in the XML file while the 3.2 plugin.xml that
> I have does not have the plugin ID. This is now in the MANIFEST.MF file.
>
> String xmlContribution = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
> //$NON-NLS-1$
> "<plugin id=\"RegistryTest\" version=\"1.0.0\">" + //$NON-NLS-1$
> "<extension-point id=\"point1\" name=\"Test extension point\"
> schema=\"schema/schema.exsd\"/>" + //$NON-NLS-1$
> "<extension point=\"point1\" id=\"extension1\">" + //$NON-NLS-1$
> "</extension></plugin>";
>
> IContributor contrib =
> ContributorFactorySimple.createContributor("RegistryTest");
> RegistryStrategy stratergy = new RegistryStrategy(null, null);
> IExtensionRegistry registry = new ExtensionRegistry(stratergy,masterToken,
> null);
> InputStream is = new ByteArrayInputStream(xmlContribution.getBytes());
> registry.addContribution( is, contrib, false, null, null, null );
>
> Is there anything else I have to do to get my plugin.xml file working?
>
> Thanks.
>
>
> "Paul Webster" <pwebster@ca.ibm.com> wrote in message
> news:faf166$555$1@build.eclipse.org...
>> Rashmy wrote:
>>> I found examples in the below two plugins for the creation of my own
>>> ExtensionsRegsitry outside of the Eclipse IDE
>>> org.eclipse.equinox.test.internal.standalone
>>> org.eclipse.core.tests.internal.registry.simple
>>>
>>> But both these require me to pass an IContributor that is defined in
>>> core.runtime.
>>
>> No, it's in the org.eclipse.core.runtime package but it is actually
>> defined in the equinox.registry bundle. ContributorFactorySimple is also
>> in the equinox.registry bundle.
>>
>> Also, check in the thread titled "Using Extension Registry without OSGi"
>> in eclipse.technology.equinox. It looks like you don't even need the
>> org.eclipse.osgi bundle, but can reduce the size needed by using the
>> supplemental one.
>>
>> It can be done completely with the 3 jars mentioned in this thread and a
>> java app:
>>
>> masterToken = new Object();
>> registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
>> null), masterToken, null);
>>
>> Then for each plugin.xml you need to check:
>>
>> InputStream pluginXmlInput = ...;
>> String pluginXmlId = ...;
>> ResourceBundle pluginXmlResources = null; // or dig out the correct one
>> registry.addContribution(pluginXmlInput,
>> ContributorFactorySimple.createContributor(pluginXmlId), false,
>> pluginXmlId, pluginXmlResources, masterToken);
>>
>> Later,
>> PW
>>
>>
>> --
>> Paul Webster
>> http://wiki.eclipse.org/Platform_Command_Framework
>> http://wiki.eclipse.org/Command_Core_Expressions
>> http://wiki.eclipse.org/Menu_Contributions
>> http://wiki.eclipse.org/Menus_Extension_Mapping
>
>
|
|
|
| Re: how to read the extensions registry outside eclipse [message #319484 is a reply to message #319476] |
Wed, 22 August 2007 13:33  |
Eclipse User |
|
|
|
Thanks Paul!
Yes, I did have the string as below. But entered it wrong in the email.
> String path = "d:\\com.mycompany.base.ui\\plugin.xml";
I found that it was an issue with the InputStream I created.
I will also take a look at the sample code that you provided.
Thanks again for your inputs to get my code working!!
"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:fahgcb$fcj$1@build.eclipse.org...
> Rashmy wrote:
>
>>
>> RegistryStrategy stratergy = new RegistryStrategy(null, null);
>> IExtensionRegistry registry = new ExtensionRegistry(stratergy,
>> masterToken,
>> null);
>> IContributor contrib =
>> ContributorFactorySimple.createContributor("com.mycompany.base.ui ");
>
> This probably isn't the java statement that you expect:
>
>> String path = "D:\com.mycompany.base.ui\plugin.xml";
>
> You probably want:
>
> I was kinda curious, so I took a stab at it. I've attached a java file
> that accepts an eclipse/plugins directory and will try and load all of
> the plugins into the registry. It tries to load the plugin id and the
> localication file from the MANIFEST.MF.
>
> It's the brute-force stupid version, but it appears to work on my
> machine. It also doesn't close input streams (not necessary for
> addContribution(*), but I didn't check the MANIFEST or ResourceBundle
> ones).
>
> bash$ java -cp org.eclipse.equinox.registry_3.4.0.v20070820.jar\
> :org.eclipse.equinox.common_3.3.0.v20070820.jar\
> :org.eclipse.osgi_3.4.0.v20070820.jar\
> :check.jar z.ex.registry.CheckRegistry /opt/eclipse330/plugins
>
> This works well with the 3.3.0 jars, and it runs with the 3.2.2 jars
> (but not so well).
>
> Later,
> PW
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
>
>
------------------------------------------------------------ --------------------
> package z.ex.registry;
>
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.InputStream;
> import java.util.PropertyResourceBundle;
> import java.util.ResourceBundle;
> import java.util.jar.JarEntry;
> import java.util.jar.JarFile;
> import java.util.jar.Manifest;
>
> import org.eclipse.core.runtime.ContributorFactorySimple;
> import org.eclipse.core.runtime.IConfigurationElement;
> import org.eclipse.core.runtime.IContributor;
> import org.eclipse.core.runtime.IExtension;
> import org.eclipse.core.runtime.IExtensionPoint;
> import org.eclipse.core.runtime.IExtensionRegistry;
> import org.eclipse.core.runtime.RegistryFactory;
> import org.eclipse.core.runtime.spi.RegistryStrategy;
>
> /**
> * Takes an eclipse/plugins directory and loads an IExtensionRegistry
> * with the plugin.xml information. It'll even try and load the
> * bundle id and main localization information.
> *
> * To run it you need 3 jars:
> * <ul>
> * <li>org.eclipse.equinox.supplement or org.eclipse.osgi</li>
> * <li>org.eclipse.equinox.common</li>
> * <li>org.eclipse.equinox.registry</li>
> * </ul>
> */
> public class CheckRegistry {
>
> private static final String LOCALIZATION_NAME = "plugin.properties";
> private static final String PLUGIN_XML_NAME = "plugin.xml";
>
> public static final String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
> public final static String BUNDLE_LOCALIZATION = "Bundle-Localization";
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> if (args.length < 1) {
> System.out.println("Need a plugins directory");
> return;
> }
> CheckRegistry check = new CheckRegistry(args[0]);
> check.validate();
> }
>
> private String dir;
> private Object masterToken;
> private IExtensionRegistry registry;
>
> private static class BundleInfo {
> InputStream pluginxml = null;
> ResourceBundle resources = null;
> IContributor contributor = null;
> }
>
> public CheckRegistry(String pluginsDir) {
> dir = pluginsDir;
> masterToken = new Object();
> registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
> null), masterToken, null);
> }
>
> public void validate() {
> File directory = new File(dir);
> if (!directory.exists()) {
> System.out.println(dir + " does not exist");
> return;
> }
> File[] files = directory.listFiles();
> for (int i = 0; i < files.length; i++) {
> try {
> BundleInfo in = getPluginInfo(files[i]);
> if (in != null) {
> System.out.println("processing: " + files[i]);
> registry.addContribution(in.pluginxml, in.contributor,
> false, in.contributor.getName(), in.resources,
> masterToken);
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> IExtensionPoint[] extensionPoints = registry.getExtensionPoints();
> for (int i = 0; i < extensionPoints.length; i++) {
> System.out.println("ep: "
> + extensionPoints[i].getUniqueIdentifier());
> }
> IExtensionPoint extensionPoint = registry
> .getExtensionPoint("org.eclipse.ui.commands");
> IExtension[] extensions = extensionPoint.getExtensions();
> for (int i = 0; i < extensions.length; i++) {
> IConfigurationElement[] configurationElements = extensions[i]
> .getConfigurationElements();
> for (int j = 0; j < configurationElements.length; j++) {
> System.out.println("e: "
> + configurationElements[j].getAttribute("id") + "\n\t"
> + configurationElements[j].getAttribute("name"));
> }
> }
> }
>
> private BundleInfo getPluginInfo(File file) throws Exception {
> String propName = LOCALIZATION_NAME;
> if (file.isDirectory()) {
> File xml = new File(file, PLUGIN_XML_NAME);
> if (xml.exists()) {
> BundleInfo b = new BundleInfo();
> b.pluginxml = new FileInputStream(xml);
> b.contributor = ContributorFactorySimple.createContributor(file
> .getName().split("_")[0]);
> File cont = new File(file, "META-INF/MANIFEST.MF");
> if (cont.exists()) {
> Manifest m = new Manifest(new FileInputStream(cont));
> ContributorFactorySimple.createContributor(m
> .getMainAttributes().getValue(BUNDLE_SYMBOLICNAME)
> .split(";")[0].trim());
> String baseName = m.getMainAttributes().getValue(
> BUNDLE_LOCALIZATION);
> if (baseName != null) {
> propName = baseName + ".properties";
> }
> }
> File prop = new File(file, propName);
> if (prop.exists()) {
> b.resources = new PropertyResourceBundle(
> new FileInputStream(prop));
> }
> return b;
> }
> return null;
> }
> if (file.getName().endsWith("jar")) {
> JarFile jf = new JarFile(file);
> JarEntry entry = jf.getJarEntry(PLUGIN_XML_NAME);
> if (entry != null) {
> BundleInfo b = new BundleInfo();
> b.pluginxml = jf.getInputStream(entry);
> b.contributor = ContributorFactorySimple.createContributor(jf
> .getManifest().getMainAttributes().getValue(
> BUNDLE_SYMBOLICNAME).split(";")[0].trim());
> String baseName = jf.getManifest().getMainAttributes()
> .getValue(BUNDLE_LOCALIZATION);
> if (baseName != null) {
> propName = baseName + ".properties";
> }
> JarEntry prop = jf.getJarEntry(propName);
> if (prop != null) {
> b.resources = new PropertyResourceBundle(jf
> .getInputStream(prop));
> }
> return b;
> }
> }
> return null;
> }
> }
>
|
|
|
Goto Forum:
Current Time: Sat Nov 08 01:01:08 EST 2025
Powered by FUDForum. Page generated in 0.04612 seconds
|