| View previous topic :: View next topic |
| Author |
Message |
lanthale
Joined: 08 Dec 2009 Posts: 93 Location: Austria
|
Posted: Fri Jun 04, 2010 9:44 am Post subject: Include a .conf file in a plattform application |
|
|
I am developing a NB RCP application which interacts with Glassfish v2.1. The problem I have is that for login into glassfish I need to have a property set which points to a file (appclient.conf).
My actual code looks like:
| Code: |
System.setProperty("java.security.auth.login.config", "/Users/selfemp/resources/appclientlogin.conf");
|
The problem is the absolute path to the file and the distribution with the platform application.
My question is the following:
The ideal situation would be that the conf file is placed inside the same module where the login occurs.
But I do not know how to reference this conf file or how to set such a system property referencing a file inside a module ?
Clemens |
|
| Back to top |
|
 |
Geertjan Wielenga Posted via mailing list.
|
Posted: Fri Jun 04, 2010 11:12 am Post subject: [platform-dev] Re: Include a .conf file in a plattform application |
|
|
| Quote: | My question is the following:
The ideal situation would be that the conf file is placed inside the same module where the login occurs.
But I do not know how to reference this conf file or how to set such a system property referencing a file inside a module ?
| http://blogs.sun.com/geertjan/entry/support_for_custom_configuration_files
Gj |
|
| Back to top |
|
 |
lanthale
Joined: 08 Dec 2009 Posts: 93 Location: Austria
|
Posted: Mon Jun 07, 2010 8:17 am Post subject: Conf file |
|
|
| Thank you for the link but they are speaking how to add a conf file but not how to reference the new conf file. Adding appclient.conf is not a problem but how can I reference this conf file ? |
|
| Back to top |
|
 |
Geertjan Wielenga Posted via mailing list.
|
Posted: Mon Jun 07, 2010 8:32 am Post subject: [platform-dev] Re: Include a .conf file in a plattform application |
|
|
lanthale wrote:
| Quote: | Thank you for the link but they are speaking how to add a conf file but not how to reference the new conf file. Adding appclient.conf is not a problem but how can I reference this conf file ?
| It's stated there how to register it in one of the properties files.
Gj |
|
| Back to top |
|
 |
zigcnb
Joined: 06 Dec 2009 Posts: 52
|
Posted: Mon Jun 07, 2010 5:22 pm Post subject: [platform-dev] Re: Include a .conf file in a plattform application |
|
|
Can you use NbReference to retrieve a path relative to the NB installation directory?
Bill
On Mon, Jun 7, 2010 at 1:17 AM, lanthale <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Thank you for the link but they are speaking how to add a conf file but not how to reference the new conf file. Adding appclient.conf is not a problem but how can I reference this conf file ?
|
|
|
| Back to top |
|
 |
Geertjan Wielenga Posted via mailing list.
|
Posted: Mon Jun 07, 2010 8:59 pm Post subject: [platform-dev] Re: Include a .conf file in a plattform application |
|
|
lanthale wrote:
| Quote: | I am developing a NB RCP application which interacts with Glassfish v2.1. The problem I have is that for login into glassfish I need to have a property set which points to a file (appclient.conf).
My actual code looks like:
Code:
System.setProperty("java.security.auth.login.config", "/Users/selfemp/resources/appclientlogin.conf");
The problem is the absolute path to the file and the distribution with the platform application.
My question is the following:
The ideal situation would be that the conf file is placed inside the same module where the login occurs.
But I do not know how to reference this conf file or how to set such a system property referencing a file inside a module ?
Clemens
| Can't you simply use the JDK Preferences API for this -- i.e., set
preferences and get them when needed.
Gj |
|
| Back to top |
|
 |
lanthale
Joined: 08 Dec 2009 Posts: 93 Location: Austria
|
Posted: Wed Jun 09, 2010 10:05 am Post subject: Solution |
|
|
Thank you for your hints with which I was able to find a solution.
Solution:
1.) put the .conf file under directory "release" inside your module directory (If "release" does not exists create it).
2.) Get the reference with the following code:
| Code: |
File appClientConf = InstalledFileLocator.getDefault().locate("appclientlogin.conf", "at.itarchitects.wist.dclient.servercom", false);
|
and put now the property with the following code:
| Code: |
System.setProperty("java.security.auth.login.config", appClientConf.getAbsolutePath());
|
Now it is working and the file is placed under "build/cluster" which should be sufficient enough.
Useful links:
http://wiki.netbeans.org/DevFaqInstalledFileLocator
http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/InstalledFileLocator.html |
|
| Back to top |
|
 |
ljelonek
Joined: 30 Nov 2010 Posts: 5
|
Posted: Wed Dec 01, 2010 12:41 pm Post subject: Include a .conf file in a MAVEN plattform application |
|
|
Hi everybody,
this works fine, when I am dealing with an ant based platform project, but it seems to be different with maven based platform applications.
I have almost the same setup working with an ant based project and glassfish 3.1, but now I want to migrate to maven. I tried to include the configuration file in a module, but this does not work as it will be assembled into the module jar, instead of being copied into the applications folder.
My next idea was to create a maven artifact, that only contains the configuration file and include it as a dependency. Unfortunately I don't know how to do this and if it would work.
So I would like to ask you: Have you tried to include a configuration file in a maven based platform application and succeeded? If yes: How? If not, do you have suggestions? Do you know how to create a maven artifact, that is simply a config file?
Greetings,
Lukas |
|
| Back to top |
|
 |
ljelonek
Joined: 30 Nov 2010 Posts: 5
|
Posted: Wed Dec 01, 2010 5:17 pm Post subject: |
|
|
I have found the solution, by using the right configuration of the nbm plugin. Here is what I did:
1) Create a folder src/main/conf and put the .conf file into it
2) Add this to the configuration of the nbm plugin:
| Code: | <nbmResources>
<nbmResource>
<directory>src/main/conf</directory>
<targetPath></targetPath>
<includes>
<include>*.conf</include>
</includes>
</nbmResource>
</nbmResources> |
The rest works the same as in the previous post.
Greetings,
Lukas |
|
| Back to top |
|
 |
|