Exemplo n.º 1
0
  @Test
  public void testMultipleKernels() {
    assertNotNull(kernelImpl);
    kernelImpl.start();
    DSpaceKernel kernel = kernelImpl.getManagedBean();
    assertNotNull(kernel);
    assertNotNull(kernelImpl.getConfigurationService());
    assertNotNull(kernelImpl.getServiceManager());
    assertNotNull(kernel.getConfigurationService());
    assertNotNull(kernel.getServiceManager());
    assertEquals(kernel.getConfigurationService(), kernelImpl.getConfigurationService());
    assertEquals(kernel.getServiceManager(), kernelImpl.getServiceManager());

    DSpaceKernelImpl kernelImpl2 =
        DSpaceKernelInit.getKernel("AZ-kernel"); // checks for the existing kernel but does not init
    kernelImpl2.start();
    DSpaceKernel kernel2 = kernelImpl2.getManagedBean();
    assertNotNull(kernel2);
    assertNotNull(kernelImpl2.getConfigurationService());
    assertNotNull(kernelImpl2.getServiceManager());
    assertNotNull(kernel2.getConfigurationService());
    assertNotNull(kernel2.getServiceManager());
    assertEquals(kernel2.getConfigurationService(), kernelImpl2.getConfigurationService());
    assertEquals(kernel2.getServiceManager(), kernelImpl2.getServiceManager());

    assertNotSame(kernel, kernel2);
    assertNotSame(kernel.getConfigurationService(), kernel2.getConfigurationService());
    assertNotSame(kernel.getServiceManager(), kernel2.getServiceManager());

    kernelImpl2.stop();
    kernelImpl.stop();
  }
Exemplo n.º 2
0
  /* (non-Javadoc)
   * @see org.dspace.kernel.CommonLifecycle#destroy()
   */
  public void destroy() {
    if (this.destroyed) {
      return;
    }
    synchronized (lock) {
      // stop the kernel
      try {
        stop();
      } catch (Exception e) {
        // oh well
      }

      // If this was the default kernel, clear it
      if (DSpaceKernelManager.getDefaultKernel() == this) {
        DSpaceKernelManager.setDefaultKernel(null);
      }

      try {
        // remove the mbean
        DSpaceKernelManager.unregisterMBean(mBeanName);
      } finally {
        // trash the shutdown hook as we do not need it anymore
        if (this.shutdownHook != null) {
          try {
            Runtime.getRuntime().removeShutdownHook(this.shutdownHook);
            this.shutdownHook = null;
          } catch (Exception e) {
            // ok, keep going
          }
        }
      }

      this.destroyed = true;
    }
  }
Exemplo n.º 3
0
 /** Test method for {@link org.dspace.servicemanager.DSpaceKernelImpl#start()}. */
 @Test
 public void testKernel() {
   kernelImpl.start();
   assertNotNull(kernelImpl);
   DSpaceKernel kernel = kernelImpl.getManagedBean();
   assertNotNull(kernel);
   assertNotNull(kernelImpl.getConfigurationService());
   assertNotNull(kernelImpl.getServiceManager());
   assertNotNull(kernel.getConfigurationService());
   assertNotNull(kernel.getServiceManager());
   assertEquals(kernel.getConfigurationService(), kernelImpl.getConfigurationService());
   assertEquals(kernel.getServiceManager(), kernelImpl.getServiceManager());
   kernelImpl.stop();
 }