Forum Discussion
omatzura
17 years agoSuper Contributor
Hi Ali,
ok.. how about the following:
1) Create a project-level property containing the endpoint with a default value
2) Use that property with property-expansion in your endpoints:
${#Project#mainEndpoint}
3) Create a load-script for the project (which is run every time the project gets loaded) in the project editor. The script needs to check some external source for an alternative value and set the property if available. For example:
def filename = context.expand( '${projectDir}\\endpoint.properties' )
def file = new java.io.File( filename )
if( file.exists() )
{
def props = new java.util.Properties()
props.load( new java.io.FileReader( file ))
def endpoint = props.get( "mainEndpoint" )
if( endpoint != null && endpoint.trim().length() > 0 )
{
project.setPropertyValue( "mainEndpoint", endpoint )
log.info( "Changed mainEndpoint to [" + endpoint + "]" )
}
}
else log.info( "Missing [" + filename + "]" )
This script checks for a endpoint.properties file in the same folder as the project file, if found it reads the properties and assigns the mainEndpoint property to the corresponding project-property. The file should be in "standard" property-format, ie:
mainEndpoint=....
Then just make sure there is a corresponding file available in your different environments.
Hope this works ok for you, let me know!
regards,
/Ole
eviware.com
ok.. how about the following:
1) Create a project-level property containing the endpoint with a default value
2) Use that property with property-expansion in your endpoints:
${#Project#mainEndpoint}
3) Create a load-script for the project (which is run every time the project gets loaded) in the project editor. The script needs to check some external source for an alternative value and set the property if available. For example:
def filename = context.expand( '${projectDir}\\endpoint.properties' )
def file = new java.io.File( filename )
if( file.exists() )
{
def props = new java.util.Properties()
props.load( new java.io.FileReader( file ))
def endpoint = props.get( "mainEndpoint" )
if( endpoint != null && endpoint.trim().length() > 0 )
{
project.setPropertyValue( "mainEndpoint", endpoint )
log.info( "Changed mainEndpoint to [" + endpoint + "]" )
}
}
else log.info( "Missing [" + filename + "]" )
This script checks for a endpoint.properties file in the same folder as the project file, if found it reads the properties and assigns the mainEndpoint property to the corresponding project-property. The file should be in "standard" property-format, ie:
mainEndpoint=....
Then just make sure there is a corresponding file available in your different environments.
Hope this works ok for you, let me know!
regards,
/Ole
eviware.com
Related Content
- 7 years agoroyd
- 3 years agoCata
- 8 months agomengbinhao
- 5 years agoManijem
- 12 months agoMadhuLambu