Packaging for configuration files in Web Apps

Source: Internet
Author: User

<bean id= "Placeholderconfig" class= "Com.shz.utils.AdvancedPlaceholderConfigurer" >
<property name= "Locations" >
<list>
<value>classpath:init.properties</value>
<value>classpath:api.properties</value>
</list>
</property>
</bean>

<bean id= "systemproperties" class= "Java.util.HashMap"/>

public class Advancedplaceholderconfigurer extends propertyplaceholderconfigurer{

@SuppressWarnings ({"Unchecked", "Rawtypes"})
@Override
protected void Processproperties (
Configurablelistablebeanfactory beanfactorytoprocess,
Properties props) throws Beansexception {

Super.processproperties (beanfactorytoprocess, props);

/******** Set the properties to InitProperties object ********/
hashmap<string, string> systemproperties = (hashmap<string, string>) Beanfactorytoprocess.getbean (" Systemproperties ");
Logger.info ("Starting to load Configs into Systemproperties object ...");
Enumeration E = Props.propertynames ();
while (E.hasmoreelements ()) {
String key = (string) e.nextelement ();
Systemproperties.put (Key, Props.getproperty (key));
}
Logger.info ("Finished to load Configs into Systemproperties object");
}

}

Public String openagent (Agentinfoparams forexagentinfoparams) {
        init ();
        try {
             ApplicationContext context = Mycontextloaderlistener.getapplicationcontext ();
            map<string, string> systemproperties = (map< String, string>) Context.getbean ("Systemproperties");
            string to = Systemproperties.get ("Constantnz.forex_cs_ Agent ");
        } catch (Exception e) {
             logger.error ("error", e);
            return "ERROR:" + e.getmessage ();
        }

        return "OK";
    }


Packaging for configuration files in Web Apps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.