acording上服务生命周期我应该能够实施RegistryShutdownListener和整理我的资源(在这种情况下,关闭线程池),但它是抛出一个异常,似乎是试图以执行关闭监听器重新初始化我的服务!?

2010-01-14 10:59:01,750 [main] ERROR org.apache.hivemind.impl.ShutdownCoordinatorImpl - Unable to shutdown <SingletonProxy for svc.MyService($MyService_1262a1db992)>: Unable to construct service svc.MyService: The HiveMind Registry has been shutdown.
org.apache.hivemind.ApplicationRuntimeException: Unable to construct service svc.MyService: The HiveMind Registry has been shutdown.
    at org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructNewServiceImplementation(AbstractServiceModelImpl.java:166)
    at org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructServiceImplementation(AbstractServiceModelImpl.java:140)
    at org.apache.hivemind.impl.servicemodel.SingletonServiceModel.getActualServiceImplementation(SingletonServiceModel.java:69)
    at $$MyService_1262a1db992_1262a1db994._service($$MyService_1262a1db992_1262a1db994.java)
    at $$MyService_1262a1db992_1262a1db994.registryDidShutdown($$MyService_1262a1db992_1262a1db994.java)
    at $$MyService_1262a1db992_1262a1db993.registryDidShutdown($$MyService_1262a1db992_1262a1db993.java)
    at org.apache.hivemind.impl.ShutdownCoordinatorImpl.shutdown(ShutdownCoordinatorImpl.java:97)
    at org.apache.hivemind.impl.ShutdownCoordinatorImpl.shutdown(ShutdownCoordinatorImpl.java:80)
    at org.apache.hivemind.impl.RegistryInfrastructureImpl.shutdown(RegistryInfrastructureImpl.java:379)
    at org.apache.hivemind.impl.RegistryImpl.shutdown(RegistryImpl.java:94)
    at org.apache.tapestry.ApplicationServlet.destroy(ApplicationServlet.java:322)
    at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1394)
    ...
Caused by: org.apache.hivemind.ApplicationRuntimeException: The HiveMind Registry has been shutdown.
    at org.apache.hivemind.impl.RegistryInfrastructureImpl.checkShutdown(RegistryInfrastructureImpl.java:404)
    at org.apache.hivemind.impl.RegistryInfrastructureImpl.getServicePoint(RegistryInfrastructureImpl.java:153)
    at org.apache.hivemind.impl.ModuleImpl.getServicePoint(ModuleImpl.java:169)
    at org.apache.hivemind.impl.InvokeFactoryServiceConstructor.setupFactoryAndParameters(InvokeFactoryServiceConstructor.java:78)
    at org.apache.hivemind.impl.InvokeFactoryServiceConstructor.constructCoreServiceImplementation(InvokeFactoryServiceConstructor.java:55)
    at org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructCoreServiceImplementation(AbstractServiceModelImpl.java:108)
    at org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructNewServiceImplementation(AbstractServiceModelImpl.java:158)
    ... 31 more

Hivemodule.xml:

<service-point id="MyService" interface="package.MyService">
    <invoke-factory><construct class="package.MyService" /></invoke-factory>
</service-point>

package.MyService.java:

public class MyService implements RegistryShutdownListener
{
...
    private ExecutorService executors;

    private void intitialise()
    {
...
    executors = Executors.newFixedThreadPool(3);
...
    }

...

    @Override
    public void registryDidShutdown()
    {
        if (executors.isShutdown())
            return;
        executors.shutdown();
    }
}

附言:我明白,你不能引用到其他的HiveMind服务registryDidShutdown()但执行人不是一个HiveMind的服务AFAIK,这是java.util.concurrent的一部分

有帮助吗?

解决方案

找到我可以看到,这是一个错误之后。解决方法是要使用的服务的接口(这是我有时跳过),而不是使用用于建筑和接口在hivemodule实现。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top