cancel
Showing results for 
Search instead for 
Did you mean: 

How to add more properties to properties file

vince20151
Champ in-the-making
Champ in-the-making
I have a java backed webscript in alfresco (not share) that needs to connect to an external db. I like to keep the connection info (such as user, password, url) in a properties file rather than in the code. (e.g. mydb.username=admin, mydb.password=password123, etc..

1. Where and what file name should these properties be placed?
2. How to read these properties in my java file (snippet of code would be very helpful).

Updated for a change in requirement
Actually now, I have a need to share the properties among several java webscripts. Where is the appropriate place to place this file or modify an existing file and what would be the java code to read it? Thanks a bunch.
2 REPLIES 2

kaynezhang
World-Class Innovator
World-Class Innovator
You have several options
1. add a configuration document to your webscript. if your webscript's  description document is yourwebscript.get.desc.xml then you can add a configuration file called yourwebscript.config.xml.
Then your java-backed webscript you can get your yourwebscript.config.xml stream through :
            String configPath = getDescription().getId() + ".config.xml";
            InputStream input = this.getContainer().getSearchPath().getDocument(configPath);
    
2.Or you can add your config element to global or scoped Config and inject config servcie into your webscript.


I recommend the firs one

Thanks so much for the tip. This works well. I like this method than going to global or scoped config as it is self contained in my webscript.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.