Deployers's AbstractDeploymentClassLoaderPolicyModule is not removing alias if one was
added at AbstractDeploymentClassLoaderPolicyModule construction.
I've added the following code:
| public abstract class AbstractDeploymentClassLoaderPolicyModule extends
ClassLoaderPolicyModule
| @@ -64,12 +66,14 @@
| * Determine the classloading metadata for the deployment unit
| *
| * @param unit the deployment unit
| + * @param addAlias should we add alias or remove
| * @return the classloading metadata
| */
| - private static String determineContextName(DeploymentUnit unit)
| + private static String determineContextName(DeploymentUnit unit, boolean addAlias)
| {
| if (unit == null)
| throw new IllegalArgumentException("Null unit");
| +
| ControllerContext context =
unit.getTopLevel().getAttachment(ControllerContext.class);
| if (context == null)
| throw new IllegalStateException("Deployment has no controller
context");
| @@ -83,13 +87,21 @@
| Set<Object> aliases = context.getAliases();
| if (aliases != null && aliases.contains(contextName) == false)
| {
| - try
| + Controller controller = context.getController();
| + if (addAlias)
| {
| - context.getController().addAlias(contextName, context.getName());
| + try
| + {
| + controller.addAlias(contextName, context.getName());
| + }
| + catch (Throwable t)
| + {
| + throw new RuntimeException("Error adding deployment alias
" + contextName + " to " + context, t);
| + }
| }
| - catch (Throwable t)
| + else
| {
| - throw new RuntimeException("Error adding deployment alias "
+ contextName + " to " + context, t);
| + controller.removeAlias(contextName);
| }
| }
| }
| @@ -105,7 +117,7 @@
| */
| public AbstractDeploymentClassLoaderPolicyModule(DeploymentUnit unit)
| {
| - super(determineClassLoadingMetaData(unit), determineContextName(unit));
| + super(determineClassLoadingMetaData(unit), determineContextName(unit, true));
| this.unit = unit;
| ControllerContext context =
unit.getTopLevel().getAttachment(ControllerContext.class);
| setControllerContext(context);
| @@ -126,4 +138,11 @@
| {
| return CLASSLOADER_STATE;
| }
| +
| + @Override
| + public void reset()
| + {
| + super.reset();
| + determineContextName(unit, false);
| + }
| }
|
Should this be part of new release for JBoss5 GA?
I still need to write some tests, checking if it was successfully removed from Controller
(in case it was added).
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193129#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...