Javier,
I agree re registryIsShuttingDown .. that is what i'm looking for.
something that is called after new httprequests have been stopped, but
before the registry becomes broken.
there would need to be some ordered configuration to control the process
however.
i'm guessing this doesn't currently exist, should i create a jira issue?
in the mean time i have solved my problem by recording the connection
info at startup so i don't need to inject a service at shutdown:
public class DbShutdownImpl implements DbShutdown, RegistryShutdownListener
{
private Properties hibConfig;
private final static Logger LOG =
Logger.getLogger(DbShutdownImpl.class);
public DbShutdownImpl(HibernateSessionSource sessionSource)
{
hibConfig = sessionSource.getConfiguration().getProperties();
}
@PostInjection
public void startupService(RegistryShutdownHub shutdownHub)
{
shutdownHub.addRegistryShutdownListener(this);
}
@Override
public void registryDidShutdown()
{
Connection con = null;
try
{
String driver =
hibConfig.getProperty("hibernate.connection.driver_class");
String url = hibConfig.getProperty("hibernate.connection.url");
String username =
hibConfig.getProperty("hibernate.connection.username");
String password =
hibConfig.getProperty("hibernate.connection.password");
con = JdbcUs.getConnection(driver, url, username, password);
JdbcUs.executeUpdate("SHUTDOWN", con);
LOG.debug("database shutdown cleanly");
}
catch (Throwable e)
{
LOG.error("database shutdown failed", e);
}
finally
{
JdbcUs.closeQuietly(con);
}
}
}
NOTE: This won't work for everyone.
p.
On 29/11/2010 11:16 PM, Javier Molina wrote:
Overriding the filter might look ugly, but it was designed for that;
see the comments on destroy() and destroy(Registry registry).
You might find it less ugly to have a ServletContextListener and do
the cleanup in contextDestroyed.
The real solution would be to have a registryIsShuttingDown()
notification, fired before registryDidShutdown(). I haven't found it,
though.
El 29/11/10 12:53, Tom van Dijk escribió:
Which service would that be? Could you provide a stack trace?
Perhaps you could make your service contribute to RegistryStartup as
well,
to make sure the DbShutdownImpl service is realized and that the
sessionSource is realized. The "startupService" would then be the
registry
startup method.
I agree that modifying TapestryFilter is an ugly solution and should be
avoided if possible.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]