Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Wiki Markup
{scrollbar}

Tapestry Inversion of Control Container

Main article: Tapestry IoC

Contents

Table of Contents
excludeContents|Tapestry Inversion of Control Container|Related Articles
printablefalse

 

Div
stylefloat:right
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel = "ioc" and space = currentSpace()

...

This same concern applies to any long-lived resource (a thread, a database connection, a JMS queue connection) that a service may hold onto. Your code needs to know when the application has been undeployed and shutdown. This is actually quite easy, by adding some post-injection logic to your implementation class.

Code Block
controlstrue
languagejava
titleMyServiceImpl.java
linenumberstrue
public class MyServiceImpl implements MyService
{
  private boolean shuttingDown;

  private final Thread workerThread;

  public MyServiceImpl()
  {
    workerThread = new Thread(. . .);
  }

  . . .

  @PostInjection
  public void startupService(RegistryShutdownHub shutdownHub)
  {
    shutdownHub.addRegistryShutdownListener(new Runnable()
    {
      public void run() 
      {
        shuttingDown = true;

        workerThread.interrupt();
      }
    });
  }
}

...

Warning

It is not recommended that MyServiceImpl take RegistryShutdownHub as a constructor parameter and register itself as a listener inside the constructor. Doing so is an example of unsafe publishing, a remote an unlikely but potential thread safety issue.

...