No BUNDLE_CLASSPATH for org.eclipse.osgi [message #283935] |
Thu, 14 April 2005 04:44  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
I ask for plugin classpath using this code:
org.osgi.framework.Bundle bundle = Platform.getBundle(pluginId);
String requires = (String)
bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_ CLASSPATH);
org.eclipse.osgi.util.ManifestElement[] elements =
org.eclipse.osgi.util.ManifestElement.parseHeader(org.osgi.f ramework.Constants.BUNDLE_CLASSPATH,
requires);
This works for all plugins except org.eclipse.osgi - there are no
such header. Is it bug or such feature?
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Re: No BUNDLE_CLASSPATH for org.eclipse.osgi [message #283940 is a reply to message #283935] |
Thu, 14 April 2005 07:58   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------000702040806000508060204
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
Konstantin,
We've run into this kind of problem too and have had to do some
significant restructuring to accommodate the changes in behavior. Below
is a method we've put in org.eclipse.emf.codegen.CodeGen to centralize
the processing. Note that when we get back a null, we treat it as being
the same as ".". Also note that later, trying to get a bundle entry for
".", which may appear literally in the manifest, we treat it the same
as "/", which isn't really quite the same thing; getting a bundle entry
for "." will return null. And finally, we do some special processing
to be sure we get the jar for the whole plugin, rather than the root
entry within that jar.
public static List getClasspathPaths(String pluginID) throws
JETException
{
List result = new ArrayList();
try
{
Bundle bundle = Platform.getBundle(pluginID);
String requires =
(String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
if (requires == null)
{
requires = ".";
}
ManifestElement[] elements =
ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
if (elements != null)
{
for (int i = 0, count = 0; i < elements.length; ++i)
{
ManifestElement element = elements[i];
String value = element.getValue();
if (".".equals(value))
{
value = "/";
}
try
{
URL url = bundle.getEntry(value);
if (url != null)
{
URL resolvedURL = Platform.resolve(url);
String resolvedURLString = resolvedURL.toString();
if (resolvedURLString.endsWith("!/"))
{
resolvedURLString = resolvedURL.getFile();
resolvedURLString =
resolvedURLString.substring(0,resolvedURLString.length() -
"!/".length());
}
if (resolvedURLString.startsWith("file:"))
{
result.add(resolvedURLString.substring("file:".length()));
}
else
{
result.add(Platform.asLocalURL(url).getFile());
}
}
}
catch (IOException exception)
{
throw new JETException(exception);
}
break;
}
}
}
catch (BundleException exception)
{
throw new JETException(exception);
}
return result;
}
Konstantin Scheglov wrote:
>
> I ask for plugin classpath using this code:
>
> org.osgi.framework.Bundle bundle = Platform.getBundle(pluginId);
> String requires = (String)
> bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_ CLASSPATH);
> org.eclipse.osgi.util.ManifestElement[] elements =
> org.eclipse.osgi.util.ManifestElement.parseHeader(org.osgi.f ramework.Constants.BUNDLE_CLASSPATH,
> requires);
>
> This works for all plugins except org.eclipse.osgi - there are no
> such header. Is it bug or such feature?
>
--------------000702040806000508060204
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=KOI8-R" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Konstantin,<br>
<br>
We've run into this kind of problem too and have had to do some
significant restructuring to accommodate the changes in behavior.
|
|
|
Re: No BUNDLE_CLASSPATH for org.eclipse.osgi [message #283948 is a reply to message #283940] |
Thu, 14 April 2005 08:46  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
Ed Merks:
Thank you.
> We've run into this kind of problem too and have had to do some
> significant restructuring to accommodate the changes in behavior. Below
> is a method we've put in org.eclipse.emf.codegen.CodeGen to centralize
> the processing. Note that when we get back a null, we treat it as being
> the same as ".". Also note that later, trying to get a bundle entry for
> ".", which may appear literally in the manifest, we treat it the same
> as "/", which isn't really quite the same thing; getting a bundle entry
> for "." will return null. And finally, we do some special processing
> to be sure we get the jar for the whole plugin, rather than the root
> entry within that jar.
>
> public static List getClasspathPaths(String pluginID) throws
> JETException
> {
> List result = new ArrayList();
> try
> {
> Bundle bundle = Platform.getBundle(pluginID);
> String requires =
> (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
> if (requires == null)
> {
> requires = ".";
> }
> ManifestElement[] elements =
> ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
> if (elements != null)
> {
> for (int i = 0, count = 0; i < elements.length; ++i)
> {
> ManifestElement element = elements[i];
> String value = element.getValue();
> if (".".equals(value))
> {
> value = "/";
> }
> try
> {
> URL url = bundle.getEntry(value);
> if (url != null)
> {
> URL resolvedURL = Platform.resolve(url);
> String resolvedURLString = resolvedURL.toString();
> if (resolvedURLString.endsWith("!/"))
> {
> resolvedURLString = resolvedURL.getFile();
> resolvedURLString =
> resolvedURLString.substring(0,resolvedURLString.length() -
> "!/".length());
> }
> if (resolvedURLString.startsWith("file:"))
> {
>
> result.add(resolvedURLString.substring("file:".length()));
> }
> else
> {
> result.add(Platform.asLocalURL(url).getFile());
> }
> }
> }
> catch (IOException exception)
> {
> throw new JETException(exception);
> }
> break;
> }
> }
> }
> catch (BundleException exception)
> {
> throw new JETException(exception);
> }
> return result;
> }
>
>
> Konstantin Scheglov wrote:
>
>>
>> I ask for plugin classpath using this code:
>>
>> org.osgi.framework.Bundle bundle = Platform.getBundle(pluginId);
>> String requires = (String)
>> bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_ CLASSPATH);
>> org.eclipse.osgi.util.ManifestElement[] elements =
>> org.eclipse.osgi.util.ManifestElement.parseHeader(org.osgi.f ramework.Constants.BUNDLE_CLASSPATH,
>> requires);
>>
>> This works for all plugins except org.eclipse.osgi - there are no
>> such header. Is it bug or such feature?
>>
>
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Powered by
FUDForum. Page generated in 0.03066 seconds