-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in AddonManager that was causing addons not to be removed fro…
…m repositories
- Loading branch information
1 parent
2a122c3
commit 3e31519
Showing
7 changed files
with
228 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
addon-manager/api/src/main/java/org/jboss/forge/addon/manager/DisableRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addon.manager; | ||
|
||
import org.jboss.forge.container.addons.Addon; | ||
import org.jboss.forge.container.addons.AddonId; | ||
import org.jboss.forge.container.repositories.AddonRepository; | ||
import org.jboss.forge.container.repositories.MutableAddonRepository; | ||
|
||
/** | ||
* This object is responsible for disabling an {@link Addon}. | ||
* | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
public interface DisableRequest | ||
{ | ||
/** | ||
* The {@link AddonId} to disable. | ||
*/ | ||
public abstract AddonId getAddonIdToDisable(); | ||
|
||
/** | ||
* This will disable the {@link AddonId} in all registered {@link MutableAddonRepository} instances. | ||
*/ | ||
public abstract void perform(); | ||
|
||
/** | ||
* This will disable the {@link AddonId} in the given {@link MutableAddonRepository} instances. | ||
*/ | ||
public abstract void perform(AddonRepository target); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
addon-manager/api/src/main/java/org/jboss/forge/addon/manager/RemoveRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addon.manager; | ||
|
||
import org.jboss.forge.container.addons.Addon; | ||
import org.jboss.forge.container.addons.AddonId; | ||
import org.jboss.forge.container.repositories.AddonRepository; | ||
import org.jboss.forge.container.repositories.MutableAddonRepository; | ||
|
||
/** | ||
* This object is responsible for removing an {@link Addon}. | ||
* | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
public interface RemoveRequest | ||
{ | ||
/** | ||
* The {@link AddonId} to remove. | ||
*/ | ||
public abstract AddonId getAddonIdToRemove(); | ||
|
||
/** | ||
* This will remove the {@link AddonId} from all registered {@link MutableAddonRepository} instances. | ||
*/ | ||
public abstract void perform(); | ||
|
||
/** | ||
* This will remove the {@link AddonId} from the given {@link MutableAddonRepository} instances. | ||
*/ | ||
public abstract void perform(AddonRepository target); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
addon-manager/impl/src/main/java/org/jboss/forge/addon/manager/impl/DisableRequestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.addon.manager.impl; | ||
|
||
import org.jboss.forge.addon.manager.AddonManager; | ||
import org.jboss.forge.addon.manager.DisableRequest; | ||
import org.jboss.forge.container.Forge; | ||
import org.jboss.forge.container.addons.AddonId; | ||
import org.jboss.forge.container.repositories.AddonRepository; | ||
import org.jboss.forge.container.repositories.MutableAddonRepository; | ||
import org.jboss.forge.container.util.Assert; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class DisableRequestImpl implements DisableRequest | ||
{ | ||
@SuppressWarnings("unused") | ||
private AddonManager manager; | ||
|
||
private Forge forge; | ||
private AddonId id; | ||
|
||
public DisableRequestImpl(AddonManager manager, Forge forge, AddonId id) | ||
{ | ||
Assert.notNull(manager, "AddonManager must not be null."); | ||
Assert.notNull(forge, "Forge must not be null."); | ||
Assert.notNull(id, "AddonId must not be null."); | ||
this.manager = manager; | ||
this.forge = forge; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public AddonId getAddonIdToDisable() | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public void perform() | ||
{ | ||
for (AddonRepository repository : forge.getRepositories()) | ||
{ | ||
if (repository instanceof MutableAddonRepository && repository.isEnabled(id)) | ||
((MutableAddonRepository) repository).disable(id); | ||
} | ||
} | ||
|
||
@Override | ||
public void perform(AddonRepository repository) | ||
{ | ||
if (repository instanceof MutableAddonRepository) | ||
((MutableAddonRepository) repository).disable(id); | ||
else | ||
throw new IllegalArgumentException( | ||
"Cannot remove addons from an immutable AddonRepository (must implement MutableAddonRepository."); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
addon-manager/impl/src/main/java/org/jboss/forge/addon/manager/impl/RemoveRequestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2013 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.addon.manager.impl; | ||
|
||
import org.jboss.forge.addon.manager.AddonManager; | ||
import org.jboss.forge.addon.manager.RemoveRequest; | ||
import org.jboss.forge.container.Forge; | ||
import org.jboss.forge.container.addons.AddonId; | ||
import org.jboss.forge.container.repositories.AddonRepository; | ||
import org.jboss.forge.container.repositories.MutableAddonRepository; | ||
import org.jboss.forge.container.util.Assert; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class RemoveRequestImpl implements RemoveRequest | ||
{ | ||
@SuppressWarnings("unused") | ||
private AddonManager manager; | ||
|
||
private Forge forge; | ||
private AddonId id; | ||
|
||
public RemoveRequestImpl(AddonManager manager, Forge forge, AddonId id) | ||
{ | ||
Assert.notNull(manager, "AddonManager must not be null."); | ||
Assert.notNull(forge, "Forge must not be null."); | ||
Assert.notNull(id, "AddonId must not be null."); | ||
this.manager = manager; | ||
this.forge = forge; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public AddonId getAddonIdToRemove() | ||
{ | ||
return id; | ||
} | ||
|
||
@Override | ||
public void perform() | ||
{ | ||
for (AddonRepository repository : forge.getRepositories()) | ||
{ | ||
if (repository instanceof MutableAddonRepository && repository.isEnabled(id)) | ||
((MutableAddonRepository) repository).undeploy(id); | ||
} | ||
} | ||
|
||
@Override | ||
public void perform(AddonRepository repository) | ||
{ | ||
if (repository instanceof MutableAddonRepository) | ||
((MutableAddonRepository) repository).undeploy(id); | ||
else | ||
throw new IllegalArgumentException("Cannot remove addons from an immutable AddonRepository (must implement MutableAddonRepository."); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters