Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to access settings from config.ini
How to access settings from config.ini [message #1053719] Tue, 07 May 2013 11:36 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I've tried to access some of the settings defined in the config.ini file of the server product (say org.eclipse.scout.rt.server.services.common.file.RemoteFileService#rootPath) but not found out how to do that.

How would I go about accessing those settings?
Re: How to access settings from config.ini [message #1053728 is a reply to message #1053719] Tue, 07 May 2013 12:04 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I am not sure what you mean.

This line in config ini:
org.eclipse.scout.rt.server.services.common.file.RemoteFileService#rootPath=SomeValue


Correspond to:
service.setRootPath("SomeValue");
//where service is the instance of org.eclipse.scout.rt.server.services.common.file.RemoteFileService

(of course it is dynamic, but I think you get the idea)

I am not sure when the properties are set:
* 1. during scout server start.
* 2. during Service initialization.
(I think it is the second solution, but I didn't check).

You can access the value with:
SERVICES.getService(RemoteFileService.class).getRootPath();


I hope it helps.
Re: How to access settings from config.ini [message #1053882 is a reply to message #1053728] Wed, 08 May 2013 06:16 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks, this works perfectly for rootPath.

What if I wanted to add arbitrary application specific configuration settings to the config.ini file that I would want to access?
Re: How to access settings from config.ini [message #1056875 is a reply to message #1053728] Wed, 08 May 2013 12:03 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Quote:
I am not sure what you mean.


SERVICES.getService(RemoteFileService.class).getRootPath();


Thanks, this was part of what I wanted and it works perfectly for rootPath.

What if I wanted to add arbitrary application specific configuration settings to the config.ini file that I would want to access?
Re: How to access settings from config.ini [message #1057723 is a reply to message #1053728] Wed, 08 May 2013 13:09 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Urs Beeli wrote on Wed, 08 May 2013 14:04
What if I wanted to add arbitrary application specific configuration settings to the config.ini file that I would want to access?


In this case, you do not need the special pattern:
<Class>#<property>=<value>

I think that this pattern is specific to Eclipse Scout. It is a good practice when you want to configure some parameter on a generic service (RemoteFileSerivce, SQL Service...). The advantage of having a such configuration in a config.ini file is that you can modify it during your deployment process (if you need to deploy for test and for production)

If you want a normal property: just use the pattern (like in any *.properties file)
<property>=<value>


For example:
my.property=lorem


You can access the value with:
Activator.getDefault().getBundle().getBundleContext().getProperty("my.property");

Re: How to access settings from config.ini [message #1057737 is a reply to message #1057723] Wed, 08 May 2013 13:57 Go to previous messageGo to next message
Arthur vD is currently offline Arthur vDFriend
Messages: 52
Registered: March 2010
Member
Hi

If you extend an org.eclipse.scout.service.AbstractService and add a field with a setter and a getter you can use the myPackage.MyService#myFieldName=myValue style lines in the config.ini. For your own classes not extending AbstractService you can use ServiceUtility.injectConfigProperties(this) to inject the properties. You'd still have to have a field following the bean conventions.

Have fun.

EDIT: Or use the free style properties as Jeremie has explained.

[Updated on: Wed, 08 May 2013 13:59]

Report message to a moderator

Re: How to access settings from config.ini [message #1058182 is a reply to message #1057737] Mon, 13 May 2013 06:25 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks Jeremie and Arthur, this is exactly what I had been looking for.
Previous Topic:Authorization/Permissions: resource-level access
Next Topic:Missing Oracle bundle with Maven Tycho
Goto Forum:
  


Current Time: Sat Apr 20 00:21:42 GMT 2024

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

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

Back to the top