How to do some tasks when the application is initialized?

You let HiveMind inject stuff into your service that runs at startup:

public class MyStartupClass implements Runnable
{
 private MyService myService;

 public void setMyService( MyService myService )
 {
   this.myService = myService;
 }

 public void run()
 {
   myService.doSomethingThatMyServiceDoes();
 }
}



HiveMind will "autowire" the MyService object into your MyStartupClass object (unless there is more than one service point within your HiveMind registry which implements the MyService interface).  Then, declare your service point in the HiveMind module:

<service-point id="SomeIdYouChoose" interface="java.lang.Runnable">
 <invoke-factory>
   <construct class="com.myco.somepackage.MyStartupClass" />
 </invoke-factory>
</service-point>


Then, register your service with the startup configuration point:

<contribution configuration-id="hivemind.Startup">
 <startup object="service:SomeIdYouChoose" />
</contribution>

That's it!  Your Runnable class will now run upon registry startup (creation), which happens in a Tapestry application when the application servlet starts up.
                                        
From James Carman([email protected])

你可能感兴趣的:(servlet,UP,tapestry)