Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to get install folder of the application?
How to get install folder of the application? [message #1059708] Tue, 21 May 2013 10:09 Go to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
I need to get the folder which the application was installed in.
Only one way which I know is to get ServletContext from any HttpServlet and request current path:
ServletContext.getRealPath("/")

For Tomcat it returns "tomcat_dir\webapps\app_name\" folder.

The additional problem is no active user sessions yet - plugins of the application just were loaded by osgi.

Best regards,
Yury.
Re: How to get install folder of the application? [message #1059841 is a reply to message #1059708] Tue, 21 May 2013 20:20 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Does [1] answer your question? If not, what do you need this folder for?

Regards,
Ralf

[1]
http://stackoverflow.com/questions/6584054/the-working-folder-for-a-tomcat-servlet

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to get install folder of the application? [message #1059879 is a reply to message #1059841] Wed, 22 May 2013 05:17 Go to previous messageGo to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Hello, Ralf!

The problem is that I need to obtain this ServletContext to get the path to my application folder. The folder contains some resources that supplied with the application and required for it's static initialization. But I do not know how to get the ServletContext - RWT.getRequest().getServletContext() does not work, because there are no UI threads yet.

Best regards,
Yury.
Re: How to get install folder of the application? [message #1059901 is a reply to message #1059879] Wed, 22 May 2013 07:03 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Yuri,

I see. There is no public API to obtain the ServletContext, feel free to
open an enhancement request for a getter on the ApplicationContext.

In RAP 2.1, you can cast the ApplicationContext to
ApplicationContextImpl and call getServletContext() on it.

Best regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to get install folder of the application? [message #1059912 is a reply to message #1059901] Wed, 22 May 2013 07:25 Go to previous messageGo to next message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Ralf,

How can I get the ApplicationContext? RWT.getApplicationContext() throws "Invalid thread access", because it is called from the Activator of the bundle.

Best regards,
Yury.
Re: How to get install folder of the application? [message #1060144 is a reply to message #1059912] Thu, 23 May 2013 09:58 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

> How can I get the ApplicationContext? RWT.getApplicationContext() throws
> "Invalid thread access", because it is called from the Activator of the
> bundle.

You can't do it in the Activator. When the bundle starts, there is no
application context yet. What you can do is to initialize these
resources lazily on first access.

Yes, I think a hook to initialize an application context is really
missing. See these bugs:

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=347822
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=401219

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to get install folder of the application? [message #1060146 is a reply to message #1060144] Thu, 23 May 2013 10:20 Go to previous messageGo to next message
Julia Kurde is currently offline Julia KurdeFriend
Messages: 91
Registered: November 2011
Location: Berlin, Germany
Member
Hi Yuri,

if the file you want to read is in a plugin you can use
URL rootUrl = MyPluginActivator.getDefault().getBundle().getEntry("/");

I'm reading my init files in
org.eclipse.ui.application.WorkbenchWindowAdvisor.preWindowOpen()

So they are read in for each session.
If you read them in the PluginActivator.start() they are only read when the application starts the first time.

Regards,
Julia
Re: How to get install folder of the application? [message #1060300 is a reply to message #1060146] Fri, 24 May 2013 04:07 Go to previous message
Yury Mising name is currently offline Yury Mising nameFriend
Messages: 95
Registered: May 2010
Location: Russia
Member
Hello, Ralf!

First of all - thank you for the links!
Lazy initialization is a way to resolve the problem, but in this case I have to call lazy initialization method from many places, because our application works not only with UISessions users, but with users connected by http to some our HttpServlets also that do not care about RAP Smile

Julia Kurde wrote on Thu, 23 May 2013 16:20
Hi Yuri,
If you read them in the PluginActivator.start() they are only read when the application starts the first time.

Regards,
Julia

That is what I want - read settings on application (not workbench or UISession) initialization. I suppose solution of the https://bugs.eclipse.org/bugs/show_bug.cgi?id=401219 will help me.


Best regards,
Yury.
Previous Topic:HttpOnly flag for settingStore cookie
Next Topic:How to open/download a file?
Goto Forum:
  


Current Time: Thu Apr 25 20:50:31 GMT 2024

Powered by FUDForum. Page generated in 0.02931 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top