`
tapestry
  • 浏览: 187033 次
社区版块
存档分类
最新评论

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(james@carmanconsulting.com)
分享到:
评论

相关推荐

    Java 7 Concurrency Cookbook

    When you work with a computer, you can do several things at once. You can hear music while you edit a document in a word processor and read your e-mail. This can be done because your operating system ...

    CakePHP 1.3 Application Development Cookbook.pdf

    In order to do so, we will go through a series of recipes that will show us how to change the way bindings are fetched, what bindings and what information from a binding is returned, how to create ...

    Web.Client.Programming.with.Perl.Automating.Tasks.on.the.Web.pdf

    It's analogous to editing a document by hand when you'd like to write a script to do the work for you. Graphical browsers require you to navigate the Web manually. In an effort to diminish the ...

    Hadoop from the beginning: The basics

    This book is written for anyone who needs to know how to analyze data using Hadoop. It is a good book for both Hadoop beginners and those in need of advancing their Hadoop skills. The author has ...

    ActionScript 3 For Adobe Flash CS4 Professional

    ActionScript 3 For Adobe Flash CS4 Professional About this guide This guide provides a quick introduction to migrating to ...Migration cookbook: Shows how to do common tasks in ActionScript 3

    How to Write a Better Thesis 3rd Edition

    Early chapters frame the tasks ahead and show you how to get started. From there, practical advice and illustrations take you through the elements of formulating research questions, working with ...

    How To Design Programs scheme入面经典

    how to develop an outline of the solution, based on the analys how to finish the program; and how to test. Each step produces a well-defined intermediate product. Second, the book comes with a novel...

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    Adding Some Media Support to Your Application 84 Adding Location-Based Services to Your Application 88 Debugging Your Application on Hardware 90 Summary 92 Quiz Questions 93 Exercises 94 References ...

    ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish

    And you'll even learn how to incorporate some popular open source tools along the way: little or no experience with ASP.NET or the MVC Framework is required. What you’ll learn How to design a REST ...

    UE(官方下载)

    The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...

    Accelerated C# 2010

    Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way from the start? * Comprehensively and concisely explains both C#...

    Wrox.Professional.Ruby.on.Rails.Feb.2008

    In either case, you don ’ t need me to tell you how to create a basic Rails application. The focus of this book is on the step that comes after just being able to make Rails work. You ’ ve ...

    Senfore_DragDrop_v4.1

    * When TDropFileTarget.GetDataOnEnter is set to True, the component doesn't work with WinZip. Although the file names are received correctly by TDropFileTarget, WinZip doesn't extract the files and...

    计算机网络第六版答案

    14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying ...

    Getting Started with Grunt: The JavaScript Task Runner

    Grunt, along with its wide range of plugins, provides a simple way of managing the large number of build tasks required to maintain a sophisticated web application. Getting Started with Grunt: The ...

    C# 2010捷径教程

    Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way from the start? Comprehensively and concisely explains both C# ...

    Foundations for Analytics with Python O-Reilly-2016-Clinton W. Brownley

    The ggplot section notes the library’s historical relationship with R and the Grammar of Graphics and illustrates how to use ggplot to build some common statistical plots. Finally, the seaborn ...

    a project model for the FreeBSD Project.7z

    The vision is “To produce the best UNIX-like operating system package possible, with due respect to the original software tools ideology as well as usability, performance and stability.” The ...

    Accelerated C# 2008

    Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start? Comprehensively and concisely explains ...

    Java邮件开发Fundamentals of the JavaMail API

    The first part of the API is the focus of this course --basically, how to send and receive messages independent of the provider/protocol. * The second part speaks the protocol-specific languages, ...

Global site tag (gtag.js) - Google Analytics