Example usage for org.apache.wicket Application getResourceSettings

List of usage examples for org.apache.wicket Application getResourceSettings

Introduction

In this page you can find the example usage for org.apache.wicket Application getResourceSettings.

Prototype

public final ResourceSettings getResourceSettings() 

Source Link

Usage

From source file:com.googlecode.wicket.jquery.ui.plugins.Initializer.java

License:Apache License

@Override
public void init(Application application) {
    // Wysiwyg Plugin //
    IPackageResourceGuard packageResourceGuard = application.getResourceSettings().getPackageResourceGuard();

    if (packageResourceGuard instanceof SecurePackageResourceGuard) {
        SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;

        if (!guard.getPattern().contains(new SearchPattern("+*.eot"))) {
            guard.addPattern("+*.eot");
            guard.addPattern("+*.woff");
            guard.addPattern("+*.ttf");
        }// www .  j  ava  2 s  .c  o  m
    }
}

From source file:com.swordlord.gozer.util.ResourceLoader.java

License:Open Source License

/**
 * Loads a resource using the {@link Application}s
 * {@link IResourceStreamLocator}./*from   w w w  .  java 2  s.com*/
 * 
 * @param application
 *            The application
 * @param filename
 *            The normalized name/path of the file to load (after being
 *            passed to {@link #prepareFileName(String)})
 * @param clazz
 *            The class loader for delegating the loading of the resource
 * @return The input stream
 * @throws IOException
 *             If no such resource could be found
 */
private static InputStream loadResource0(Application application, String filename, Class clazz)
        throws IOException {
    final IResourceStreamLocator locator = application.getResourceSettings().getResourceStreamLocator();
    final IResourceStream resource = locator.locate(clazz, filename);
    if (resource == null) {
        throw new IOException("Error while loading " + filename + " from classpath - no such entry found");
    }
    try {
        return resource.getInputStream();
    } catch (ResourceStreamNotFoundException e) {
        throw new IOException("Error while loading " + filename + " from classpath", e);
    }
}

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Adds the given file patterns to package resource guard from the given application.
 *
 * @param application/*ww w.java2s  . c  om*/
 *            the application
 * @param patterns
 *            the patterns
 */
public static void addFilePatternsToPackageResourceGuard(final Application application,
        final String... patterns) {
    final IPackageResourceGuard packageResourceGuard = application.getResourceSettings()
            .getPackageResourceGuard();
    if (packageResourceGuard instanceof SecurePackageResourceGuard) {
        final SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
        for (final String pattern : patterns) {
            guard.addPattern(pattern);
        }
    }
}

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Sets the deployment settings for deployment mode for the given application.
 *
 * @param application// w w w  . j a v a2s .com
 *            the application to set the settings
 */
public static void setDeploymentModeConfiguration(final Application application) {
    application.getMarkupSettings().setStripComments(true);
    // The resources are never polled. This are properties, html,
    // css, js files.
    application.getResourceSettings().setResourcePollFrequency(null);
    application.getResourceSettings().setJavaScriptCompressor(new DefaultJavaScriptCompressor());
    // set the behavior if an missing resource is found...
    application.getResourceSettings().setThrowExceptionOnMissingResource(false);
    // debug settings...
    application.getDebugSettings().setComponentUseCheck(false);
    application.getDebugSettings().setAjaxDebugModeEnabled(false);
    application.getDebugSettings().setDevelopmentUtilitiesEnabled(false);

    application.getDebugSettings().setOutputMarkupContainerClassName(false);
    application.getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(false);
    application.getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(false);
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Sets the debug settings for deployment mode for the given application.
 *
 * @param application//  www . jav a  2s . c o  m
 *            the application to set the settings
 */
public static void setDeploymentModeConfiguration(final Application application) {
    application.getMarkupSettings().setStripComments(true);
    // The resources are never polled. This are properties, html,
    // css, js files.
    application.getResourceSettings().setResourcePollFrequency(null);
    application.getResourceSettings().setJavaScriptCompressor(new DefaultJavaScriptCompressor());
    // set the behavior if an missing resource is found...
    application.getResourceSettings().setThrowExceptionOnMissingResource(false);
    // debug settings...
    application.getDebugSettings().setComponentUseCheck(false);
    application.getDebugSettings().setAjaxDebugModeEnabled(false);
    application.getDebugSettings().setDevelopmentUtilitiesEnabled(false);

    application.getDebugSettings().setOutputComponentPath(false);
    application.getDebugSettings().setOutputMarkupContainerClassName(false);
    application.getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(false);
    application.getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(false);
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Adds the given file patterns to package resource guard from the given application.
 *
 * @param application/*from w  ww  .j av  a 2 s  . c  o  m*/
 *            the application
 * @param patterns
 *            the patterns
 */
public static void addFilePatternsToPackageResourceGuard(final Application application, String... patterns) {
    IPackageResourceGuard packageResourceGuard = application.getResourceSettings().getPackageResourceGuard();
    if (packageResourceGuard instanceof SecurePackageResourceGuard) {
        SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
        for (String pattern : patterns) {
            guard.addPattern(pattern);
        }
    }
}

From source file:org.odlabs.wiquery.core.commons.merge.WiQueryMergedJavaScriptResourceReference.java

License:Open Source License

/**
 * {@inheritDoc}/*from   www . j  ava2s  .  co m*/
 */
@Override
protected Resource newResource() {
    return new Resource() {
        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        public IResourceStream getResourceStream() {
            String temp = null;
            Application application = Application.get();
            StringBuffer buffer = new StringBuffer();
            IJavascriptCompressor compressor = application.getResourceSettings().getJavascriptCompressor();

            for (ResourceReference ref : wiQueryHeaderResponse.getJavascript()) {
                // We bind the resources into the SharedResources
                ref.bind(Application.get());

                // We insert the javascript code into the template
                try {
                    IResourceStream resource = Application.get().getResourceSettings()
                            .getResourceStreamLocator().locate(getClass(),
                                    "/" + Packages.absolutePath(ref.getScope(), "") + "/" + ref.getName());
                    if (resource != null)
                        temp = Streams.readString(resource.getInputStream());
                } catch (Exception e) {
                    temp = null;
                    e.printStackTrace();
                    LOGGER.error("error in merged processing", e);
                }

                if (compressor != null && temp != null) {
                    temp = compressor.compress(temp);
                }

                if (temp != null) {
                    buffer.append(temp).append("\r\n");
                }
            }

            Map<String, Object> genJs = new HashMap<String, Object>();
            genJs.put("wiqueryresources", buffer);
            jstemplate.interpolate(genJs);

            return new StringResourceStream(jstemplate.asString(), CONTENT_TYPE);
        }
    };
}