use of org.zaproxy.zap.extension.api.ApiImplementor in project zaproxy by zaproxy.
the class ExtensionLoader method removeExtension.
/**
* Removes an extension from internal list. As a result listeners added via
* the {@link ExtensionHook} object are unregistered.
*
* @param extension
* @param hook
*/
public void removeExtension(Extension extension, ExtensionHook hook) {
extensionList.remove(extension);
extensionsMap.remove(extension.getClass());
if (hook == null) {
logger.info("ExtensionHook is null for \"" + extension.getClass().getCanonicalName() + "\" the hooked objects will not be automatically removed.");
return;
}
// by removing the ExtensionHook object,
// the following listeners are no longer informed:
// * SessionListeners
// * OptionsChangedListeners
extensionHooks.values().remove(hook);
unloadOptions(hook);
removePersistentConnectionListener(hook);
removeProxyListener(hook);
removeOverrideMessageProxyListener(hook);
removeConnectRequestProxyListener(hook);
removeSiteMapListener(hook);
for (ContextDataFactory contextDataFactory : hook.getContextDataFactories()) {
try {
model.removeContextDataFactory(contextDataFactory);
} catch (Exception e) {
logger.error("Error while removing a ContextDataFactory from " + extension.getClass().getCanonicalName(), e);
}
}
for (ApiImplementor apiImplementor : hook.getApiImplementors()) {
try {
API.getInstance().removeApiImplementor(apiImplementor);
} catch (Exception e) {
logger.error("Error while removing an ApiImplementor from " + extension.getClass().getCanonicalName(), e);
}
}
removeViewInEDT(extension, hook);
}
use of org.zaproxy.zap.extension.api.ApiImplementor in project zaproxy by zaproxy.
the class ExtensionLoader method unhook.
private void unhook(Extension extension) {
ExtensionHook hook = extensionHooks.remove(extension);
if (hook == null) {
logger.error("ExtensionHook not found for: " + extension.getClass().getCanonicalName());
return;
}
unloadOptions(hook);
unhookProxies(hook);
removeSiteMapListener(hook);
for (ContextDataFactory contextDataFactory : hook.getContextDataFactories()) {
try {
model.removeContextDataFactory(contextDataFactory);
} catch (Exception e) {
logger.error("Error while removing a ContextDataFactory from " + extension.getClass().getCanonicalName(), e);
}
}
for (ApiImplementor apiImplementor : hook.getApiImplementors()) {
try {
API.getInstance().removeApiImplementor(apiImplementor);
} catch (Exception e) {
logger.error("Error while removing an ApiImplementor from " + extension.getClass().getCanonicalName(), e);
}
}
for (HttpSenderListener httpSenderListener : hook.getHttpSenderListeners()) {
try {
HttpSender.removeListener(httpSenderListener);
} catch (Exception e) {
logger.error("Error while removing an HttpSenderListener from " + extension.getClass().getCanonicalName(), e);
}
}
for (Class<? extends Variant> variant : hook.getVariants()) {
try {
model.getVariantFactory().removeVariant(variant);
} catch (Exception e) {
logger.error("Error while removing a Variant from " + extension.getClass().getCanonicalName(), e);
}
}
removeViewInEDT(extension, hook);
}
Aggregations