cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practice for managing variables for multiple environments

Former Member
0 Kudos

I am very new to Java WebDynPro and have a question

concerning our deployments to Sandbox, Development, QA,

and Production environments.

What is the 'best practice' that people use so that if

you have information specific to each environment you

don't hard-code it in your Java WebDynPro code.

I could put the value in a properties file, but how do I

make that variant? Otherwise I'd still have to make a

change for each environment to the property file and

re-deploy. I know there are some configurations on the

Portal but am not sure if that will work in my instance.

For example, I have a URL that varies based on my

environment. I don't want to hard-code and re-compile

for each environment. I'd prefer to get that

information on the fly by knowing which environment I'm

running in and load the appropriate URL.

So far the only thing I've found that is close to

telling me where I'm running is by using a Parameter Map

but the 'key' in the map is the URL not the value and I

suspect there's a cleaner way to get something like that.

I used Eclipse's autosense in Netweaver to discover some

of the things available in my web context.

Here's the code I used to get that map:

TaskBinder.getCurrentTask().getWebContextAdapter().getRequestParameterMap();

In the forum is an example that gets the IP address of

the site you're serving from. It sounds like it is going

to be or has been deprecated (it worked on my system

right now) and I would really rather have something like

the DNS name, not something like an IP that could change.

Here's that code:

String remoteHost = TaskBinder.getCurrentTask().getWebContextAdapter().getHttpServletRequest().getRemoteHost();

Thanks in advance for any clues you can throw my way -

Greg

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Greg:

I suggest you that checks the "Software Change Managment Guide", in this guide you can find an explication of the best practices to work with a development infrastructure.

this is the link :

http://help.sap.com/saphelp_erp2005/helpdata/en/83/74c4ce0ed93b4abc6144aafaa1130f/frameset.htm

Now if you can gets the ip of your server or the name of your site you can do the next thing:

HttpServletRequest request = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();

String server_name = request.getServerName();

String remote_address = request.getRemoteAddr()

String remote_host = request.getRemoteHost()

Only you should export the servlet.jar in your project properties > Build Path > Libraries.

Good Luck

Josué Cruz