/** * Adds an AU extension and associates it with the specified prefix. * * <p>If there was an AU extension associated with the same name, the the old AU extension will be * replaced. * * <p>If you want to add an Au extension, even before DHtmlUpdateServlet is started, use {@link * #addAuExtension(WebApp, String, AuExtension)} instead. * * @param prefix the prefix. It must start with "/", but it cannot be "/" nor "/web" (which are * reserved). * @param extension the AU extension (never null). * @return the previous AU extension associated with the specified prefix, or null if the prefix * was not associated before. * @see #addAuExtension(WebApp,String,AuExtension) * @since 5.0.0 */ public AuExtension addAuExtension(String prefix, AuExtension extension) throws ServletException { checkAuExtension(prefix, extension); if (_aues.get(prefix) == extension) // speed up to avoid sync return extension; // nothing changed extension.init(this); // To avoid using sync in doGet(), we make a copy here final AuExtension old; synchronized (this) { final Map ps = new HashMap(_aues); old = (AuExtension) ps.put(prefix, extension); _aues = ps; } if (old != null) try { old.destroy(); } catch (Throwable ex) { log.warningBriefly("Unable to stop " + old, ex); } return old; }