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

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 ...

    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 ...

    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#...

    计算机网络第六版答案

    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 ...

    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...

    Windows Azure Succinctly(Syncfusion,2014)

    the management of what data to store and how to keep it consistent with the applicable rules is usually performed by the application code itself. Therefore, very little management activity that is ...

    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, ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    Ideally, one should check VsIsReady() using a timer or the like to wait efficiently, so that the host PC is free to do other tasks while waiting for the VariSpec. The VariSpec always processes each ...

    Xcode Treasures: Master the Tools to Design, Build, and Distribute Great Apps

    Discover how much easier and more fun iOS development is when you know the secrets of the tools. About the Pragmatic Bookshelf Contents What Readers Are Saying About Xcode Treasures Acknowledgments ...

    Expert One-on-One J2EE Design and Development

    you will learn When to use a distributed architecture When and how to use EJB How to develop an efficient data access strategy How to design a clean and maintainable web interface How to design J2EE ...

Global site tag (gtag.js) - Google Analytics