Package me.friwi.jcefmaven
Class CefAppBuilder
java.lang.Object
me.friwi.jcefmaven.CefAppBuilder
Class used to configure the JCef environment. Specify
an installation directory, arguments to be passed to JCef
and configure the embedded
CefSettings to
your needs. When done, call build()
to create an CefApp instance.
Example use:
//Create a new CefAppBuilder instance
CefAppBuilder builder = new CefAppBuilder();
//Configure the builder instance
builder.setInstallDir(new File("jcef-bundle")); //Default
builder.setProgressHandler(new ConsoleProgressHandler()); //Default
builder.addJCefArgs("--disable-gpu"); //Just an example
builder.getCefSettings().windowless_rendering_enabled = true; //Default - select OSR mode
//Set an app handler. Do not use CefApp.addAppHandler(...), it will break your code on MacOSX!
builder.setAppHandler(new MavenCefAppHandlerAdapter(){...});
//Build a CefApp instance using the configuration above
CefApp app = builder.build();
- Author:
- Fritz Windisch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddJcefArgs(String... args) Add one or multiple arguments to pass to the JCef library.org.cef.CefAppbuild()Builds aCefAppinstance.org.cef.CefSettingsRetrieve the embeddedCefSettingsinstance to change configuration parameters.Retrieves a mutable list of arguments to pass to the JCef library.Get a copy of all mirrors that are currently in use.booleanIf installation skipping is enabled, no checks against the installation directory will be performed and the download, installation and verification of the jcef natives has to be performed by the individual developer.install()Helper method to install the native libraries/resources.voidsetAppHandler(MavenCefAppHandlerAdapter handlerAdapter) Attach your own adapter to handle certain events in CEF.voidsetInstallDir(File installDir) Sets the install directory to use.voidsetMirrors(Collection<String> mirrors) Set mirror urls that should be used when downloading jcef.voidsetProgressHandler(IProgressHandler progressHandler) Specify a progress handler to receive install progress updates.voidsetSkipInstallation(boolean skipInstallation) If installation skipping is enabled, no checks against the installation directory will be performed and the download, installation and verification of the jcef natives has to be performed by the individual developer.
-
Constructor Details
-
CefAppBuilder
public CefAppBuilder()Constructs a new CefAppBuilder instance.
-
-
Method Details
-
setInstallDir
Sets the install directory to use. Defaults to "./jcef-bundle".- Parameters:
installDir- the directory to install to
-
setProgressHandler
Specify a progress handler to receive install progress updates. Defaults to "new ConsoleProgressHandler()".- Parameters:
progressHandler- a progress handler to use
-
getJcefArgs
Retrieves a mutable list of arguments to pass to the JCef library. Arguments may contain spaces.Due to installation using maven some arguments may be overwritten again depending on your platform. Make sure to not specify arguments that break the installation process (e.g. subprocess path, resources path...)!
- Returns:
- A mutable list of arguments to pass to the JCef library
-
addJcefArgs
Add one or multiple arguments to pass to the JCef library. Arguments may contain spaces.Due to installation using maven some arguments may be overwritten again depending on your platform. Make sure to not specify arguments that break the installation process (e.g. subprocess path, resources path...)!
- Parameters:
args- the arguments to add
-
getCefSettings
public org.cef.CefSettings getCefSettings()Retrieve the embeddedCefSettingsinstance to change configuration parameters.Due to installation using maven some settings may be overwritten again depending on your platform.
- Returns:
- the embedded
CefSettingsinstance
-
setAppHandler
Attach your own adapter to handle certain events in CEF.- Parameters:
handlerAdapter- the adapter to attach
-
getMirrors
Get a copy of all mirrors that are currently in use. To add another mirror, use the setter. Mirror urls can contain placeholders that are replaced when a fetch is attempted:
{mvn_version}: The version of jcefmaven (e.g. 100.0.14.3)
{platform}: The desired platform for the download (e.g. linux-amd64)
{tag}: The desired version tag for the download (e.g. jcef-08efede+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75)- Returns:
- A copy of all mirrors that are currently in use. First element will be attempted first.
-
setMirrors
Set mirror urls that should be used when downloading jcef. First element will be attempted first. Mirror urls can contain placeholders that are replaced when a fetch is attempted:
{mvn_version}: The version of jcefmaven (e.g. 100.0.14.3)
{platform}: The desired platform for the download (e.g. linux-amd64)
{tag}: The desired version tag for the download (e.g. jcef-08efede+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75) -
setSkipInstallation
public void setSkipInstallation(boolean skipInstallation) If installation skipping is enabled, no checks against the installation directory will be performed and the download, installation and verification of the jcef natives has to be performed by the individual developer.- Parameters:
skipInstallation- true if the installation process should be skipped, false otherwise
-
getSkipInstallation
public boolean getSkipInstallation()If installation skipping is enabled, no checks against the installation directory will be performed and the download, installation and verification of the jcef natives has to be performed by the individual developer.- Returns:
- true if the installation process should be skipped, false otherwise
-
install
Helper method to install the native libraries/resources. Useful for triggering an install ahead of actually needing to create a CEF app instance. This method is NOT thread safe and the caller must ensure only one thread will call this method at a time.- Returns:
- This builder instance
- Throws:
IOException- if an artifact could not be fetched or IO-actions on disk failedUnsupportedPlatformException- if the platform is not supported
-
build
public org.cef.CefApp build() throws IOException, UnsupportedPlatformException, InterruptedException, CefInitializationExceptionBuilds aCefAppinstance. When called multiple times, will return the previously built instance. This method is thread-safe.- Returns:
- a built
CefAppinstance - Throws:
IOException- if an artifact could not be fetched or IO-actions on disk failedUnsupportedPlatformException- if the platform is not supportedInterruptedException- if the installation process got interruptedCefInitializationException- if the initialization of JCef failed
-