on 07-23-2007 1:10 PM
Hi,
I need to adapt a application to its particular environment on which it should be deployed. Therefor it would be great to be able to define a parameter which the application can read when it is deployed and adapts itself according to the parameter value.
The use case is as follows:
Deploying via SDMGUI on a WebAS 6.40, Windows Server 2003
Is the scenario mentioned above possible or do I have to reconfigure the application for every single deployment target?
Thanks,
Tino
Hi!
Have you already noticed the Configuration Adapter Service in Visual Administrator? Under tree node 'apps' you will find any of your deployed applications, each with a node appcfg. The data you store at this place can be accessed using Configuration Adapter interface:
ApplicationConfigurationHandler configHandler;
ApplicationConfigHandlerFactory appCfgHdlFctry;
Configuration config;
appCfgHdlFctry =
(ApplicationConfigHandlerFactory) ctx.lookup(
"ApplicationConfiguration");
configHandler = appCfgHdlFctry.getApplicationConfigurationHandler();
config = configHandler.openRootConfiguration(
ApplicationConfigurationHandler.READ_ACCESS);
Parameters you set using Visual Admin will not be changed by deployments, so you only have to do the configuration work once for each systems you will use. Really awesome is the possibilty to register a listerner to the configuration, so your application can automatically reconfigure itself without a restart - handy in a productive environment if used carefully.
Best regards,
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
having a look at my source, you will have to import at least these:
import com.sap.engine.frame.core.configuration.*;
import com.sap.engine.services.configuration.appconfiguration.ApplicationConfigHandlerFactory;
import com.sap.engine.services.configuration.appconfiguration.ApplicationConfigurationHandler;
The classes needed should be available in DC configuration and maybe kernel.sda.
If there is still something missing, let me know. My class does a bit more, so there are a couple of imports you will not need. I'm not sure if I missed something important.
Best regards,
Frank
Frank, this is really useful information. However, do you know if this is a published API from Sap? The Java docs published by SAP contain no mention of the API's you list above. I'm concerned that SAP will remove customer access to one or more of the required DC's (excluding com.sap.exception) in the future, which would prevent any DC that uses these now inaccessible DC's from compiling.
I do consider this unlikely, since this is a base function. I'll have to check my CE installation to see if these DC's are still available.
So, with 7.0, I was able to quickly put together a test application that could query the configuration store, once I had added the com.sap.engine.client.lib, configuration, and com.sap.exception DC's to my project. It works very well.
And, an FYI for other folks out there regarding listeners: when you register a listener, it must be registered at the folder level - any items changed in the folder will cause a callback....
Hi Tino,
If you have never heard about "DC configuration", you will most likely not need it. You have to deal with this stuff if you use the NetWeaver Developer Infrastructure (NWDI). The DC configuration defines which external components your application will use, basically to allow the NWDIs Component Build Server to work.
However, I guess you use the Developer Studio. So, all you have to do to get the libraries needed is a right click on your project: "Set additional libraries". The dialog shows basically what is provided as DCs when using NWDI. Selecting them (configuration, com.sap.exception, ...) will add everything needed to your project.
Besten regards,
Frank
Hello,
Do you know what could cause in this code that the getApplicationProperties() call returns a null? I looked for the configuration settings on the server with the config tool, and everthing looked fine. I use a CE SP1 server.
ctx = new InitialContext();
ApplicationConfigHandlerFactory cfgFactory = (ApplicationConfigHandlerFactory)ctx.lookup(JNDI_NAME_APPLICATION_CONFIGURATION);
this.properties = cfgFactory.getApplicationProperties();
loadIndexedProperties();
Hi,
I have just the same problem. I'm developing a DC under CE and cannot find the class ApplicationConfigHandlerFactory. Any idea, which Public Part I have to use in order to get access to this class? All PPs that look appropriate do not allow me to use them (no grant). SAP-Docs do not give any hints.
Regards,
Christoph
You can have a singleton class and your parameters as attributes in the class.
If your application have any InitServlet, you can always initialize your singleton class
in the init() method of your Initservlet. This method will be called during Start of your application. So your parameters will get initialized now.
This is one way of doing it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
would be great if you can elaborate as in where exactly you want to achieve this..
in a web application?
in an ejb application?
in case of web app, you could make use of the ContextListener interfaces which uses callback mechanism and the methods are called only once during startup / shutdown of the web app.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.