Results 1 to 3 of 3

Thread: How to save properties changed by application

  1. #1
    Join Date
    Aug 2004
    Posts
    1

    Default How to save properties changed by application

    After instantion of the bean via BeanFactory its properties could be changed by application. I want these properties to be saved and restored when application starts next time. Does Spring provide API that support such behavior? I understand that I could modify xml or properties file from application but is it a recommended way?

    Thanks,
    Zahar

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    You can implement org.springframework.beans.factory.InitializingBean or specify an init-method for the bean, and implement you own way of restoring persisted properties - overwriting the default values in Spring's context. For example:

    <bean id="exampleInitBean" class="examples.ExampleBean" init-method="init"/>

    public class ExampleBean {
    public void init() {
    // do some initialization work
    }
    }

    I wouldn't recommend modifying the Spring context XML (if that's what you're suggesting), as this get's out of sync. with your original source repository.

  3. #3
    Join Date
    Aug 2004
    Location
    China
    Posts
    11

    Default

    I am using spring http-invoker, the client side spring applicationContext including two cofigure file:

    remote.properties file,the content as follow:

    serverName=localhost
    httpPort=8848
    contextPath=/PMIS


    applicationContext_remote.xml file, the content as follow:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location" value="remote.properties" />
    </bean>

    <bean id="paramConfigService" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="target">
    <bean class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://${serverName}:${httpPort}${contextPath}/remoting/paramConfigService" />
    <property name="serviceInterface" value="com.nbpilot.service.charge.ParamConfigManag er" />
    <property name="httpInvokerRequestExecutor" ref="httpInvokerExecutor"/>
    </bean>
    </property>


    NOTE: the remote invoker url "http://${serverName}:${httpPort}${contextPath}"

    so when the server IP or Port has changed, how can i modify properties file.

    thanks.

Similar Threads

  1. FlowExecutionStorage in a DB
    By cacho in forum Web Flow
    Replies: 7
    Last Post: Oct 19th, 2009, 03:36 PM
  2. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  3. Replies: 0
    Last Post: May 13th, 2005, 04:18 AM
  4. Questioning the core component
    By Martin Kersten in forum Swing
    Replies: 6
    Last Post: Feb 21st, 2005, 03:45 AM
  5. Shared properties within application context
    By milosh in forum Architecture
    Replies: 5
    Last Post: Nov 16th, 2004, 08:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •