Half way there...

Using Hiveutils I managed to write this, but in the Manager ASO constructor the config is null. The setter for the config is never called. The Manager is instantiated by a Border component when method ping() is called. I can use spring provided config in Border component just fine. What did I miss?


### hivemodule.xml ###

   <contribution configuration-id="tapestry.state.ApplicationObjects">
       <state-object name="manager" scope="application">
           <invoke-factory object="object:Manager" />
       </state-object>
   </contribution>

   <contribution configuration-id="hiveutils.ObjectBuilderObjects">
       <object name="Manager" cached="true"
           class="com.acme.application.Manager">
           <inject name="config" object="spring:configuration" />
       </object>
   </contribution>

and
### Manager.java ###

public class Manager implements StateObjectFactory {
   // Commons Configuration
   private Configuration config;
/**
    * Manager is an application scope ASO (Application State Object). This
    * class is instantiated lazily - when first page injects it.
    */
   public Manager() {
       logger.info("config: " + config); // <<<<<< THIS IS NULL
       String address = config.getString("person.address");
   }

   public Object createStateObject() {
       return this;
   }

   public String ping() {
       return "pong";
   }

   public Configuration getConfig() {
       return config;
   }

public void setConfig(Configuration config) { // <<<<<<< never gets called
       logger.info("SETTING CONFIG: " + config);
       this.config = config;
   }
}

### applicationContext.xml ###
<!-- Apache Commons Configuration Composite configuration -->
   <bean id="configurations"
class="org.springmodules.commons.configuration.CommonsConfigurationFactoryBean">
       <property name="configurations">
           <list>
<bean class="org.apache.commons.configuration.XMLConfiguration">
                   <constructor-arg type="java.net.URL"
value="classpath:posting-config.xml" /> <property name="reloadingStrategy"> <bean class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
                   </property>
</bean> </list>
       </property>

       <!-- define configuration as a set of spring resources -->
       <property name="locations"
           value="classpath*:META-INF/default.properties" />
   </bean>

<bean id="configuration" factory-bean="&amp;configurations" factory-method="getConfiguration"/>

### Border.java ###
public abstract class Border extends BaseComponent {
   @InjectState("manager")
   abstract public Manager getManager();
@InjectObject("spring:configuration")
   public abstract Configuration getConfig();

public void finishLoad()
{
logger.info("person.address: " + getConfig().getString("person.address")); // correctly print the value
   logger.info("manager.ping:" + getManager().ping()); // invokes Manager
}


On 15.3.2007 20:25, Borut Bolčina wrote:
Hello,

can someone provide some code hints to Hivemind and Spring newb - that would
be me - on how to inject

  1. Hivemind service into application scope ASO
  2. Spring service into application scope ASO

I want to cache some long term objects in the global ASO, but want (if it is
at all reasonable?) those objects provided by Hivemind and/or Spring
services. I am at the very beginning of learning of the SOA. I know how to
inject services from both frameworks into Tapestry pages.

Cheers,
Borut


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to