Ejemplo n.º 1
0
 @Override
 public void start() throws Exception {
   if (serviceDefinitions != null && !serviceDefinitions.isEmpty()) {
     LOG.debug(
         "Configuring "
             + serviceDefinitions.size()
             + " services for application id "
             + CoreConfigHelper.getApplicationId()
             + " using config for classloader "
             + ClassLoaderUtils.getDefaultClassLoader());
     KsbApiServiceLocator.getServiceBus().publishServices(serviceDefinitions, true);
     super.start();
   }
 }
Ejemplo n.º 2
0
 public Thread newThread(Runnable runnable) {
   threadSequence++;
   Thread thread = this.defaultThreadFactory.newThread(runnable);
   // if the thread ends up getting spawned by an action inside of a workflow plugin or something
   // along those lines, it will inherit the plugin's
   // classloader as it's ContextClassLoader.  Let's make sure it's set to the same ClassLoader
   // that loaded the KSBConfigurer
   thread.setContextClassLoader(contextClassLoader);
   thread.setName(
       CoreConfigHelper.getApplicationId()
           + "/KSB-pool-"
           + factorySequence
           + "-thread-"
           + threadSequence);
   return thread;
 }
Ejemplo n.º 3
0
 public ServerPluginRegistry() {
   super(
       new QName(CoreConfigHelper.getApplicationId(), ResourceLoader.PLUGIN_REGISTRY_LOADER_NAME));
 }
Ejemplo n.º 4
0
  @Test
  public void testHotDeploy() throws Exception {
    // Grab the ServerPluginRegistry
    PluginRegistry theRegistry = PluginUtils.getPluginRegistry();
    assertNotNull("PluginRegistry should exist.", theRegistry);
    assertTrue(theRegistry instanceof ServerPluginRegistry);
    ServerPluginRegistry registry = (ServerPluginRegistry) theRegistry;

    // Let's shut down the asynchronous reloader and hot deployer because we want to do this
    // synchronously.
    HotDeployer hotDeployer = registry.getHotDeployer();
    Reloader reloader = registry.getReloader();
    registry.stopHotDeployer();
    registry.stopReloader();

    // Assert that there are currently no plugins
    assertEquals("There should be no plugins.", 0, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have no children.", 0, registry.getResourceLoaders().size());

    // query the hot deployer directly about it's added and removed plugins
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());
    hotDeployer.run();
    assertEquals("There should still be no plugins.", 0, registry.getPluginEnvironments().size());

    // now let's copy a plugin over and run the hot deployer
    String pluginZipFileLocation =
        getBaseDir() + "/src/test/resources/org/kuali/rice/kew/plugin/ziptest.zip";
    File pluginZipFile = new File(pluginZipFileLocation);
    assertTrue("Plugin file '" + pluginZipFileLocation + "' should exist", pluginZipFile.exists());
    assertTrue(
        "Plugin file '" + pluginZipFileLocation + "' should be a file", pluginZipFile.isFile());
    FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);

    assertEquals("There should be one plugin added.", 1, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

    hotDeployer.run();

    // the plugin should have been hot deployed
    assertEquals(
        "Plugin should have been hot deployed.", 1, registry.getPluginEnvironments().size());

    // check added plugins again, it should now indicate no new added plugins
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

    // verify that the resource loading and the registry are sane and properly set up with the new
    // plugin
    assertEquals(
        "Resource loader should have 1 plugin child.", 1, registry.getResourceLoaders().size());
    Plugin plugin = (Plugin) registry.getResourceLoaders().get(0);
    assertEquals(
        "Plugin has wrong name.",
        new QName(CoreConfigHelper.getApplicationId(), "ziptest"),
        plugin.getName());
    assertTrue("Plugin should be started.", plugin.isStarted());
    assertEquals(
        "Plugin in resource loader and environment should be the same.",
        plugin,
        registry.getPluginEnvironment(plugin.getName().getLocalPart()).getPlugin());

    // The reloader should have a reference to the environment
    assertEquals(
        "Reloader should have a reference to environment.", 1, reloader.getReloadables().size());

    // now remove the plugin and ensure that it goes away
    FileUtils.forceDelete(new File(pluginDir, "ziptest.zip"));
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be one plugin removed.", 1, hotDeployer.getRemovedPlugins().size());
    hotDeployer.run();

    // verify that the resource loading and the registry no longer contain the plugin
    assertEquals("No plugins should be deployed.", 0, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have 0 plugin children.", 0, registry.getResourceLoaders().size());

    // also assert that the reloader no longer has a reference to the environment
    assertEquals(
        "Reloader should no longer have reference to environment.",
        0,
        reloader.getReloadables().size());
  }