Example usage for org.apache.wicket.application CompoundClassResolver add

List of usage examples for org.apache.wicket.application CompoundClassResolver add

Introduction

In this page you can find the example usage for org.apache.wicket.application CompoundClassResolver add.

Prototype

public CompoundClassResolver add(final IClassResolver resolver) 

Source Link

Document

Adds a resolver

Usage

From source file:org.efaps.ui.wicket.EFapsApplication.java

License:Apache License

/**
 * @see org.apache.wicket.protocol.http.WebApplication#init()
 *///from  w w  w .jav  a2s . c o m
@Override
protected void init() {
    super.init();

    final String appKey = getInitParameter(AbstractFilter.INITPARAM_APP_KEY);
    final String loginRolesTmp = getInitParameter(AbstractFilter.INITPARAM_LOGIN_ROLES);
    final Set<UUID> temp = new HashSet<>();
    if (loginRolesTmp != null) {
        final String[] loginRolesAr = loginRolesTmp.split(",");
        for (final String loginRole : loginRolesAr) {
            temp.add(UUID.fromString(loginRole));
        }
    }
    AppAccessHandler.init(appKey, temp);

    final Map<String, String> map = new HashMap<>();
    for (final AppConfigHandler.Parameter param : AppConfigHandler.Parameter.values()) {
        final String configTmp = getInitParameter(param.getKey());
        if (configTmp != null) {
            map.put(param.getKey(), configTmp);
        }
    }
    if (!map.containsKey(AppConfigHandler.Parameter.TEMPFOLDER.getKey())) {
        map.put(AppConfigHandler.Parameter.TEMPFOLDER.getKey(),
                getStoreSettings().getFileStoreFolder().toURI().toString());
    }
    AppConfigHandler.init(map);

    getJavaScriptLibrarySettings().setJQueryReference(new DynamicJQueryResourceReference());

    getApplicationSettings().setPageExpiredErrorPage(LoginPage.class);
    getApplicationSettings().setInternalErrorPage(UnexpectedErrorPage.class);

    final CompoundClassResolver resolver = new CompoundClassResolver();
    resolver.add(new DefaultClassResolver());
    resolver.add(new AbstractClassResolver() {
        @Override
        public ClassLoader getClassLoader() {
            return EFapsClassLoader.getInstance();
        }

    });
    getApplicationSettings().setClassResolver(resolver);

    getApplicationSettings().setUploadProgressUpdatesEnabled(true);

    getDebugSettings().setAjaxDebugModeEnabled(false);
    getDebugSettings().setDevelopmentUtilitiesEnabled(false);

    setPageManagerProvider(new EFapsPageManagerProvider(this));
    getStoreSettings().setMaxSizePerSession(
            Bytes.megabytes(Configuration.getAttributeAsInteger(ConfigAttribute.STORE_MAXSIZEPERSESSION)));
    getStoreSettings()
            .setInmemoryCacheSize(Configuration.getAttributeAsInteger(ConfigAttribute.STORE_INMEMORYCACHE));

    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setStripComments(true);
    getMarkupSettings().setCompressWhitespace(true);
    getMarkupSettings().setAutomaticLinking(false);

    getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
    getRequestCycleListeners().add(new EFapsRequestCycleListener());
    getRequestLoggerSettings().setRequestLoggerEnabled(false);

    getSecuritySettings().setAuthorizationStrategy(new EFapsFormBasedAuthorizationStartegy());

    getResourceSettings().setJavaScriptCompressor(new DefaultJavaScriptCompressor());

    // allow svg resources
    final IPackageResourceGuard guard = getResourceSettings().getPackageResourceGuard();
    if (guard instanceof SecurePackageResourceGuard) {
        ((SecurePackageResourceGuard) guard).addPattern("+*.svg");
    }

    setHeaderResponseDecorator(new IHeaderResponseDecorator() {

        @Override
        public IHeaderResponse decorate(final IHeaderResponse _response) {
            return new EFapsResourceAggregator(_response);
        }
    });
    getRequestCycleSettings().addResponseFilter(new IResponseFilter() {
        @Override
        public AppendingStringBuffer filter(final AppendingStringBuffer _responseBuffer) {
            final AppendingStringBuffer ret;
            if (RequestCycle.get().getActiveRequestHandler() instanceof ACAjaxRequestTarget) {
                ret = new AppendingStringBuffer().append(_responseBuffer.subSequence(0,
                        _responseBuffer.length() - XmlPartialPageUpdate.END_ROOT_ELEMENT.length()));
            } else {
                ret = _responseBuffer;
            }
            return ret;
        }
    });
}

From source file:ro.fortsoft.wicket.plugin.PluginManagerInitializer.java

License:Apache License

@Override
public void init(Application application) {
    pluginManager = createPluginManager(application);
    if (pluginManager == null) {
        throw new WicketRuntimeException("Plugin manager cannot be null");
    }//  w w  w .j  a  va2s.c o  m

    log.debug("Created plugin manager {}", pluginManager);

    // load plugins        
    pluginManager.loadPlugins();

    // init plugins
    List<PluginWrapper> resolvedPlugins = pluginManager.getResolvedPlugins();
    for (PluginWrapper plugin : resolvedPlugins) {
        if (plugin.getPlugin() instanceof WicketPlugin) {
            ((WicketPlugin) plugin.getPlugin()).init(application);
        }
    }

    // start plugins
    pluginManager.startPlugins();

    // set class resolver
    CompoundClassResolver classResolver = new CompoundClassResolver();
    List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
    for (PluginWrapper plugin : startedPlugins) {
        classResolver.add(new PluginClassResolver(plugin));
    }
    application.getApplicationSettings().setClassResolver(classResolver);

    // store plugin manager in application
    application.setMetaData(PLUGIN_MANAGER_KEY, pluginManager);

    // add PluginComponentInjector
    application.getComponentInstantiationListeners().add(new PluginComponentInjector(application));
}