NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Include a .conf file in a plattform application

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
lanthale



Joined: 08 Dec 2009
Posts: 93
Location: Austria

PostPosted: Fri Jun 04, 2010 9:44 am    Post subject: Include a .conf file in a plattform application Reply with 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
Back to top
Geertjan Wielenga
Posted via mailing list.





PostPosted: Fri Jun 04, 2010 11:12 am    Post subject: [platform-dev] Re: Include a .conf file in a plattform application Reply with quote

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

PostPosted: Mon Jun 07, 2010 8:17 am    Post subject: Conf file Reply with 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.





PostPosted: Mon Jun 07, 2010 8:32 am    Post subject: [platform-dev] Re: Include a .conf file in a plattform application Reply with quote

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

PostPosted: Mon Jun 07, 2010 5:22 pm    Post subject: [platform-dev] Re: Include a .conf file in a plattform application Reply with quote

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.





PostPosted: Mon Jun 07, 2010 8:59 pm    Post subject: [platform-dev] Re: Include a .conf file in a plattform application Reply with quote

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

PostPosted: Wed Jun 09, 2010 10:05 am    Post subject: Solution Reply with quote

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

PostPosted: Wed Dec 01, 2010 12:41 pm    Post subject: Include a .conf file in a MAVEN plattform application Reply with quote

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

PostPosted: Wed Dec 01, 2010 5:17 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo