Solved

Properties between two applications

Posted on 2004-03-29
9
174 Views
Last Modified: 2010-03-31
Hi

I will be dividing my application into two domains. The first is the core.jar that will have some core classes. It will have its own properties file from which it will read the properties for various actions.

Now my second jar, applications.jar will be built upon core.jar. I will use only the jar of the core.
I want to modify the properties which get set in the core.jar file. How should i go about doing it.

One way is i can have a properties file outside my core.jar in a fixed path which the core.jar reads to set the propertoes. But this gives a very tight coupling between the jar and the loation of the file.

Is there any other way to go about doing it ?? I hope that i have made myself clear.

Thanks
Mrigank
0
Comment
Question by:mrigank
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10702504
If both of the jars are going to be used within a JVM you can really split the things into two parts.

All your core things in a jar (utilities).  The domain stuffs in another Jar.  That way, you will be using a single properties file.
So all your update calls will goto a single place.

If it is two different JVM's just let me know how are you sharing a single property file across two different JVM's when both are at different (remote) locations.


Regards,
Muruga
0
 
LVL 5

Author Comment

by:mrigank
ID: 10702708
actually my core.jar will be used by various applications. So the core will have its own properties file inside the jar but the applications should be able to change those properties using a separate file.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10702735
But having the properties file which might be updated within a Jar is not a good idea.

In those scenerios, you can prefer DB to hold the updatable values.
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 5

Author Comment

by:mrigank
ID: 10703036
yeah thats the point. I should not update the properties inside the jar. but can i have a file outsude the jar which overrides the properties inside the jar ????

i suggsted the use of a db but people do not like it :(
0
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 70 total points
ID: 10703071
You can have the properties inside your Jar.  May be u can have the perperties identifier (say in numeric).  On each update the count should be increased by one.

You can load the properties outside the jar first and take the count.
Then load the properties inside jar and compare the count value.

That way you can decide the latest properties file.

Otherwise,
If any outside properties is available, then consider that as a latest properties.
Always check the existance of the outside properties file.
If that fould load it, otherwise load the jar properties file.


Regards,
Muruga
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 10703299
Ya, u can have the properties files outside of the jar but the folder structure should be maintained. If u have the properties in the exact folder outside of the jar, that will be used and the properties inside the jar will be discarded.

Regards,
Siva
0
 
LVL 5

Author Comment

by:mrigank
ID: 10703312
that is the problem ..  having to maintain the folder structure ... which is a pain at times .. because my code will then search for that structure .. not in a generic format ...

though another way is to have the file in the classpath ..
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10703381
don't keep it in the classpath.  Better would be give the complete path as system property then.

-Dapp.properties=/usr/muruga/hello.properties

0
 
LVL 26

Expert Comment

by:ksivananth
ID: 10703431
>>that is the problem ..  having to maintain the folder structure ... which is a pain at times .. because my code will then search for that structure .. not in a generic format ...
>>

    I don't understant. What do you mean "which is a pain at times .. because my code will then search for that structure"?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question