Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JavaServer Faces » Making jsf libraries location relative to eclipse_home?
Making jsf libraries location relative to eclipse_home? [message #472968] Wed, 20 September 2006 02:54 Go to next message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Hi all,
thanks for helping me.

I have previosly post such question(on 20060915), but it has "disapeared"
(or my firefox just do not what to show it to me) so excuse me for my
second post.

What I am tring to achieve is to specify a JSF libraries location that is
relative to the eclipse home directory (where eclipse is installed).

I noticed the RelativeToWorkspace attribute in JSFLibraryRegistry.xml but
is there an equivalent that can make the location of the library relative
to eclipse home? Or maybe there is a workaround?

Thanks.
Re: Making jsf libraries location relative to eclipse_home? [message #472970 is a reply to message #472968] Wed, 20 September 2006 13:44 Go to previous messageGo to next message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

If you need to register a JSF library goes with your runtime,
you could package your library as plugin-provided JSF library by
extending jsfLibraries extension point.

Hope this workaround addresses your need.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473463 is a reply to message #472970] Tue, 26 September 2006 02:15 Go to previous messageGo to next message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin Chen,
I will try it.

Justin Chen wrote:

> Kiril,

> If you need to register a JSF library goes with your runtime,
> you could package your library as plugin-provided JSF library by
> extending jsfLibraries extension point.

> Hope this workaround addresses your need.

> Thanks,
> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473464 is a reply to message #473463] Tue, 26 September 2006 04:44 Go to previous messageGo to next message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Hi again Justin Chen,
I could not find out how to "extend jstLibraries extension point". In fact
I just could not find such an extension point. Maybe a have not understand
you but I thought that there is an extension point which I will be able to
extend, then to implement a desired interface that will provide the jsf
libraries to the platform. Is this the case?

Thanks again,
kiril

kiril mitov wrote:

> Thanks Justin Chen,
> I will try it.

> Justin Chen wrote:

>> Kiril,

>> If you need to register a JSF library goes with your runtime,
>> you could package your library as plugin-provided JSF library by
>> extending jsfLibraries extension point.

>> Hope this workaround addresses your need.

>> Thanks,
>> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473466 is a reply to message #473464] Fri, 29 September 2006 18:39 Go to previous messageGo to next message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
kiril,

That was what I meant. There is an extension point that you can extend.

Once your extension is installed, your JSF library should be seen in JSF
library registry.

BTW, you won't be able to modify the JAR collection from preference
page.
On top of that, you *cannot* distribute your extension as a JAR. This is
a limitation that we plan to address in next JSF 1.0.

Hope that you have already found the information on jsfLibraries
extension
point already.

If not, you should be able to find the following from Help Contents
assuming that you are using WTP 1.5 + JSF 0.5 SDK.

A tutorial, Creating Plugin-Provided JSF Libraries, in the programmer's
guide under JavaServer Faces Tooling Develop Guide.

You should also find the jsfLibraries document under Reference of the
same developer guide.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473470 is a reply to message #473466] Tue, 03 October 2006 04:53 Go to previous messageGo to next message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin Chen.

I have found the jsflibraries extension point and I have extended it.
I have some problems with the ArchiveFile attributes.

Is this the right way to create an Archive file?

public Collection getArchiveFiles() {
org.eclipse.jst.jsf.core.internal.jsflibraryregistry.Archive File file1
= JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
file1.setRelativeToWorkspace(false);
file1 .setSourceLocation(" file://D:\\work\\workspace_jsf\\org.eclipse.jst.tld.editor\\ lib\\commons-logging-1.0.4.jar");
return Collections.singleton(file1);
}

If this is the right way, than way do
ArchiveFileImpl.getResolvedSourceLocation returns null for fileURL when
this call is made:
URL fileURL = Platform.find(bundle, srcPath);
with a srcPath equal to
file://D:\\work\\workspace_jsf\\org.eclipse.jst.tld.editor\\ lib\\commons-logging-1.0.4.jar

I have also tried to remove the "file://" segment but this did not help.
Could you please give me some basic guidlines on how to properly create
the ArchiveFile.

And another question that arised. The ArchiveFile is in internal package.
Both the interface and the implementation. Is it plan for this class to be
made a public api?

Thanks again.

Justin Chen wrote:

> kiril,

> That was what I meant. There is an extension point that you can extend.

> Once your extension is installed, your JSF library should be seen in JSF
> library registry.

> BTW, you won't be able to modify the JAR collection from preference
> page.
> On top of that, you *cannot* distribute your extension as a JAR. This is
> a limitation that we plan to address in next JSF 1.0.

> Hope that you have already found the information on jsfLibraries
> extension
> point already.

> If not, you should be able to find the following from Help Contents
> assuming that you are using WTP 1.5 + JSF 0.5 SDK.

> A tutorial, Creating Plugin-Provided JSF Libraries, in the programmer's
> guide under JavaServer Faces Tooling Develop Guide.

> You should also find the jsfLibraries document under Reference of the
> same developer guide.

> Thanks,
> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473472 is a reply to message #473470] Tue, 03 October 2006 16:58 Go to previous messageGo to next message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

You can construct an ArchiveFiles collection by the following if the JARs
are inside your jsfLibraries extension. You can find the complete
tutorial from help.

public Collection getArchiveFiles() {
Collection archiveFiles = new ArrayList();
setRelativeDestinationLocation("WEB-INF/lib");
archiveFiles.add(createArchiveFile("lib/commons-beanutils.jar "));
...
return archiveFiles;
}

You can also construct a collection as the following if JARs are from a
different bundle. It is actually similar to what you have.

...
Bundle bundle = Platform.getBundle("org.eclipse.jst.tld.editor");
URL fileURL = Platform.find(bundle, new
Path("lib/commons-logging-1.0.4.jar"));
...
ArchiveFile af =
JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
af.setSourceLocation(fileURL.getPath());
...
archiveFiles.add(af);
...

Not sure why Platform.find(bundle, srcPath) return null for you. What is
your bundle?

Yes, to promote some internal APIs (some may be changed and some new ones)
to public is in JSF tooling 1.0 plan.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473473 is a reply to message #473472] Wed, 04 October 2006 04:34 Go to previous messageGo to next message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin.

In the moment I have two plugins:
com.jsftest.libraries
and
com.jsftest.librariesProvider.

The com.jsftest.libraries plugin has the following structure
com.jsftest.libraries
- lib
- lib1.jar
- lib2.jar
- plugin.xml

The second plugin is com.jsftest.librariesProvider an this plugin extends
the org.eclipse.jst.jsf.core.jsflibraries extension point using the
following getArchiveFile() method:

public Collection getArchiveFiles() {
ArchiveFile file1 =
JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
Bundle bundle = Platform.getBundle("com.jsftest.libraries");
URL archiveUrl = FileLocator.find(bundle, new Path(
"lib/lib1.jar"), Collections.EMPTY_MAP);
file1.setSourceLocation(archiveUrl.getPath());
return Collections.singleton(file1);
}

The idea is that the com.jsftest.libraries bundle holds the libraries and
the librariesProvider contributes those libraries to the jsflibraries
preference page.

Now i come to the JSFCorePlugin.isJSFLibinExpandedFolder() that calls
ArchiveFile.getResolvedSourceLocation().
The getResolvedSourceLocation() has the following lines of code:

1 if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) {
2 Bundle bundle = getBundle();
3 if (bundle != null) {
4 try {
5 Path srcPath = new Path(sourceLocation);
6 URL fileURL = Platform.find(bundle, srcPath);
7 URL url = Platform.resolve(fileURL);
8 resolvedSourceLocation = url.getPath();
9 } catch (IOException e) {
10 resolvedSourceLocation = sourceLocation;
11 }
12 } else {
...
}
But here on line 2 the bundle that is returned is
com.jsftest.librariesProvider. When the code tries to find lib1.jar in
this plugin it gets a null fileURL on line 6(because lib1.jar is located
in the com.jsttest.libraries not in librariesProvider plugin).

Why do I need to separed the libraries from the extension point and put
them in different plugins?
Because the com.jsftest.libraries plugin must be contributable to builds
that do not have jsf installed. And if com.jsftest.libraries depends on
jsf.core this can never happen.

So may idea is:
In the getArchiveMethod() I can find out everything about every bundle,
their locations and resources, I know the location of the Platfrom and the
workspace.
I know everything that is needed to construct a valid path to my file. I
can even do a check to see if my file is there. This path to the file can
be absolute or relative where relative might be relative to the
eclipse_home location.

Would this be a convinient and easy to handle change for the ArchiveFile?
Does this breaks the idea ArchiveFile and the way it is used? Is is
appropriate to add this as s feature reguest or there is a workaround.
One possible change in the ArchiveFileImpl.getResolvedSourceLocation is to
add

if (fileURL == null) {
String bundleName = srcPath.segments()[0];
bundle = Platform.getBundle(bundleName);
fileURL = FileLocator.find(bundle, srcPath
.removeFirstSegments(1), Collections.EMPTY_MAP);
}
between lines 6 and 7. In the getArchiveFiles() I set the srcPath as
file1.setSourceLocation(new Path("com.jfstest.libraries").append(
archiveUrl.getPath()).toPortableString());
where archiveUrl=/lib/lib1.jar
This way if the first segment of the srcPath can be mapped to a bundle I
try to locate the library in the mapped bundle. I think that this change
wont break the way ArchiveFile is used because it will only be valide if
the srcPath first segment is a bundle.

Best regards
kiril mitov
Re: Making jsf libraries location relative to eclipse_home? [message #473656 is a reply to message #473473] Thu, 05 October 2006 17:47 Go to previous messageGo to next message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

Thank you for the detail description on your approach.

Could you log an enhancement request including the following?
1. Use case(s) for this enhancement request.
2. Proposed solution (with code if possible)

We could capture communications for this request in bugzilla.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #473657 is a reply to message #473656] Fri, 06 October 2006 02:30 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
The reguest is added:
Bug number 159971:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=159971

Thanks for the help

kiril
Re: Making jsf libraries location relative to eclipse_home? [message #607637 is a reply to message #472968] Wed, 20 September 2006 13:44 Go to previous message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

If you need to register a JSF library goes with your runtime,
you could package your library as plugin-provided JSF library by
extending jsfLibraries extension point.

Hope this workaround addresses your need.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #607998 is a reply to message #472970] Tue, 26 September 2006 02:15 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin Chen,
I will try it.

Justin Chen wrote:

> Kiril,

> If you need to register a JSF library goes with your runtime,
> you could package your library as plugin-provided JSF library by
> extending jsfLibraries extension point.

> Hope this workaround addresses your need.

> Thanks,
> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608000 is a reply to message #473463] Tue, 26 September 2006 04:44 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Hi again Justin Chen,
I could not find out how to "extend jstLibraries extension point". In fact
I just could not find such an extension point. Maybe a have not understand
you but I thought that there is an extension point which I will be able to
extend, then to implement a desired interface that will provide the jsf
libraries to the platform. Is this the case?

Thanks again,
kiril

kiril mitov wrote:

> Thanks Justin Chen,
> I will try it.

> Justin Chen wrote:

>> Kiril,

>> If you need to register a JSF library goes with your runtime,
>> you could package your library as plugin-provided JSF library by
>> extending jsfLibraries extension point.

>> Hope this workaround addresses your need.

>> Thanks,
>> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608004 is a reply to message #473464] Fri, 29 September 2006 18:39 Go to previous message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
kiril,

That was what I meant. There is an extension point that you can extend.

Once your extension is installed, your JSF library should be seen in JSF
library registry.

BTW, you won't be able to modify the JAR collection from preference
page.
On top of that, you *cannot* distribute your extension as a JAR. This is
a limitation that we plan to address in next JSF 1.0.

Hope that you have already found the information on jsfLibraries
extension
point already.

If not, you should be able to find the following from Help Contents
assuming that you are using WTP 1.5 + JSF 0.5 SDK.

A tutorial, Creating Plugin-Provided JSF Libraries, in the programmer's
guide under JavaServer Faces Tooling Develop Guide.

You should also find the jsfLibraries document under Reference of the
same developer guide.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608012 is a reply to message #473466] Tue, 03 October 2006 04:53 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin Chen.

I have found the jsflibraries extension point and I have extended it.
I have some problems with the ArchiveFile attributes.

Is this the right way to create an Archive file?

public Collection getArchiveFiles() {
org.eclipse.jst.jsf.core.internal.jsflibraryregistry.Archive File file1
= JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
file1.setRelativeToWorkspace(false);
file1 .setSourceLocation(" file://D:\\work\\workspace_jsf\\org.eclipse.jst.tld.editor\\ lib\\commons-logging-1.0.4.jar");
return Collections.singleton(file1);
}

If this is the right way, than way do
ArchiveFileImpl.getResolvedSourceLocation returns null for fileURL when
this call is made:
URL fileURL = Platform.find(bundle, srcPath);
with a srcPath equal to
file://D:\\work\\workspace_jsf\\org.eclipse.jst.tld.editor\\ lib\\commons-logging-1.0.4.jar

I have also tried to remove the "file://" segment but this did not help.
Could you please give me some basic guidlines on how to properly create
the ArchiveFile.

And another question that arised. The ArchiveFile is in internal package.
Both the interface and the implementation. Is it plan for this class to be
made a public api?

Thanks again.

Justin Chen wrote:

> kiril,

> That was what I meant. There is an extension point that you can extend.

> Once your extension is installed, your JSF library should be seen in JSF
> library registry.

> BTW, you won't be able to modify the JAR collection from preference
> page.
> On top of that, you *cannot* distribute your extension as a JAR. This is
> a limitation that we plan to address in next JSF 1.0.

> Hope that you have already found the information on jsfLibraries
> extension
> point already.

> If not, you should be able to find the following from Help Contents
> assuming that you are using WTP 1.5 + JSF 0.5 SDK.

> A tutorial, Creating Plugin-Provided JSF Libraries, in the programmer's
> guide under JavaServer Faces Tooling Develop Guide.

> You should also find the jsfLibraries document under Reference of the
> same developer guide.

> Thanks,
> Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608017 is a reply to message #473470] Tue, 03 October 2006 16:58 Go to previous message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

You can construct an ArchiveFiles collection by the following if the JARs
are inside your jsfLibraries extension. You can find the complete
tutorial from help.

public Collection getArchiveFiles() {
Collection archiveFiles = new ArrayList();
setRelativeDestinationLocation("WEB-INF/lib");
archiveFiles.add(createArchiveFile("lib/commons-beanutils.jar "));
...
return archiveFiles;
}

You can also construct a collection as the following if JARs are from a
different bundle. It is actually similar to what you have.

...
Bundle bundle = Platform.getBundle("org.eclipse.jst.tld.editor");
URL fileURL = Platform.find(bundle, new
Path("lib/commons-logging-1.0.4.jar"));
...
ArchiveFile af =
JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
af.setSourceLocation(fileURL.getPath());
...
archiveFiles.add(af);
...

Not sure why Platform.find(bundle, srcPath) return null for you. What is
your bundle?

Yes, to promote some internal APIs (some may be changed and some new ones)
to public is in JSF tooling 1.0 plan.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608018 is a reply to message #473472] Wed, 04 October 2006 04:34 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
Thanks Justin.

In the moment I have two plugins:
com.jsftest.libraries
and
com.jsftest.librariesProvider.

The com.jsftest.libraries plugin has the following structure
com.jsftest.libraries
- lib
- lib1.jar
- lib2.jar
- plugin.xml

The second plugin is com.jsftest.librariesProvider an this plugin extends
the org.eclipse.jst.jsf.core.jsflibraries extension point using the
following getArchiveFile() method:

public Collection getArchiveFiles() {
ArchiveFile file1 =
JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
Bundle bundle = Platform.getBundle("com.jsftest.libraries");
URL archiveUrl = FileLocator.find(bundle, new Path(
"lib/lib1.jar"), Collections.EMPTY_MAP);
file1.setSourceLocation(archiveUrl.getPath());
return Collections.singleton(file1);
}

The idea is that the com.jsftest.libraries bundle holds the libraries and
the librariesProvider contributes those libraries to the jsflibraries
preference page.

Now i come to the JSFCorePlugin.isJSFLibinExpandedFolder() that calls
ArchiveFile.getResolvedSourceLocation().
The getResolvedSourceLocation() has the following lines of code:

1 if (getJSFLibrary() instanceof PluginProvidedJSFLibrary) {
2 Bundle bundle = getBundle();
3 if (bundle != null) {
4 try {
5 Path srcPath = new Path(sourceLocation);
6 URL fileURL = Platform.find(bundle, srcPath);
7 URL url = Platform.resolve(fileURL);
8 resolvedSourceLocation = url.getPath();
9 } catch (IOException e) {
10 resolvedSourceLocation = sourceLocation;
11 }
12 } else {
...
}
But here on line 2 the bundle that is returned is
com.jsftest.librariesProvider. When the code tries to find lib1.jar in
this plugin it gets a null fileURL on line 6(because lib1.jar is located
in the com.jsttest.libraries not in librariesProvider plugin).

Why do I need to separed the libraries from the extension point and put
them in different plugins?
Because the com.jsftest.libraries plugin must be contributable to builds
that do not have jsf installed. And if com.jsftest.libraries depends on
jsf.core this can never happen.

So may idea is:
In the getArchiveMethod() I can find out everything about every bundle,
their locations and resources, I know the location of the Platfrom and the
workspace.
I know everything that is needed to construct a valid path to my file. I
can even do a check to see if my file is there. This path to the file can
be absolute or relative where relative might be relative to the
eclipse_home location.

Would this be a convinient and easy to handle change for the ArchiveFile?
Does this breaks the idea ArchiveFile and the way it is used? Is is
appropriate to add this as s feature reguest or there is a workaround.
One possible change in the ArchiveFileImpl.getResolvedSourceLocation is to
add

if (fileURL == null) {
String bundleName = srcPath.segments()[0];
bundle = Platform.getBundle(bundleName);
fileURL = FileLocator.find(bundle, srcPath
.removeFirstSegments(1), Collections.EMPTY_MAP);
}
between lines 6 and 7. In the getArchiveFiles() I set the srcPath as
file1.setSourceLocation(new Path("com.jfstest.libraries").append(
archiveUrl.getPath()).toPortableString());
where archiveUrl=/lib/lib1.jar
This way if the first segment of the srcPath can be mapped to a bundle I
try to locate the library in the mapped bundle. I think that this change
wont break the way ArchiveFile is used because it will only be valide if
the srcPath first segment is a bundle.

Best regards
kiril mitov
Re: Making jsf libraries location relative to eclipse_home? [message #608324 is a reply to message #473473] Thu, 05 October 2006 17:47 Go to previous message
Justin Chen is currently offline Justin Chen
Messages: 39
Registered: July 2009
Member
Kiril,

Thank you for the detail description on your approach.

Could you log an enhancement request including the following?
1. Use case(s) for this enhancement request.
2. Proposed solution (with code if possible)

We could capture communications for this request in bugzilla.

Thanks,
Justin
Re: Making jsf libraries location relative to eclipse_home? [message #608325 is a reply to message #473656] Fri, 06 October 2006 02:30 Go to previous message
kiril mitov is currently offline kiril mitov
Messages: 128
Registered: July 2009
Senior Member
The reguest is added:
Bug number 159971:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=159971

Thanks for the help

kiril
Previous Topic:Is the 1.5.1 release of the JSF platform going to be available from the update site?
Next Topic:Is the 1.5.1 release of the JSF platform going to be available from the update site?
Goto Forum:
  


Current Time: Wed Apr 16 03:34:41 EDT 2014

Powered by FUDForum. Page generated in 0.04713 seconds