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.

On 10/28/06, KEGan <[EMAIL PROTECTED]> wrote:

Hi,

I have tried both approches. However, inside my code, I am trying to
access
Hivemind services, and it didnt work.

Example, in my custom "ApplicationInitializer", I use:

Registry registry = RegistryBuilder.constructDefaultRegistry();
MyService myservice = (MyService)registry.getService("
com.project.myService",
MyService.class);

And all I get is a null.

I suspect using the "RegistryBuilder.constructDefaultRegistry()" is not
the
correct way to get access into Hivemind registry, when Tapestry is
starting
up.

So, how do I get access to Hivemind registry ... whether it is from inside
"
hivemind.Startup" or "tapestry.init.ApplicationInitializers".



On 10/24/06, James Carman <[EMAIL PROTECTED]> wrote:
>
> There is a configuration point called "hivemind.Startup" where you can
> register Runnable objects to be run at HM registry startup time (which
is
> the same as Tapestry startup time).
>
> On 10/22/06, KEGan <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I need to do some tasks when my Servlet web application is
initialized.
> In
> > this, I can use ServletContextListener.
> >
> > Now, I am using Tapestry ... and I want to achieve the same thing. Of
> > course, I can still use ServletContextListener, but with this, I
cannot
> > use
> > all the TapestryAnnotation+Hivemind goodness (autowiring, etc) that
> comes
> > with Tapestry. So is there a ServletContextListener equivalent in
> > Tapestry?
> > The idea is that I can run some tasks (only once) when Tapestry is
first
> > initialized, and I want to do this with all the Tapestry Annontation
and
> > Hivemind goodness.
> >
> > Thanks.
> >
> > ~KEGan
> >
> >
>
>


Reply via email to