Package me.friwi.jcefmaven
Class CefAppBuilder
- java.lang.Object
-
- me.friwi.jcefmaven.CefAppBuilder
-
public class CefAppBuilder extends Object
Class used to configure the JCef environment. Specify an installation directory, arguments to be passed to JCef and configure the embeddedCefSettingsto your needs. When done, callbuild()to create anCefAppinstance.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 Constructor Description CefAppBuilder()Constructs a new CefAppBuilder instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJcefArgs(String... args)Add one or multiple arguments to pass to the JCef library.org.cef.CefAppbuild()Builds aCefAppinstance.org.cef.CefSettingsgetCefSettings()Retrieve the embeddedCefSettingsinstance to change configuration parameters.List<String>getJcefArgs()Retrieves a mutable list of arguments to pass to the JCef library.Collection<String>getMirrors()Get a copy of all mirrors that are currently in use.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.
-
-
-
Method Detail
-
setInstallDir
public void setInstallDir(File installDir)
Sets the install directory to use. Defaults to "./jcef-bundle".- Parameters:
installDir- the directory to install to
-
setProgressHandler
public void setProgressHandler(IProgressHandler progressHandler)
Specify a progress handler to receive install progress updates. Defaults to "new ConsoleProgressHandler()".- Parameters:
progressHandler- a progress handler to use
-
getJcefArgs
public List<String> 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
public void addJcefArgs(String... args)
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
public void setAppHandler(MavenCefAppHandlerAdapter handlerAdapter)
Attach your own adapter to handle certain events in CEF.- Parameters:
handlerAdapter- the adapter to attach
-
getMirrors
public Collection<String> 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
public void setMirrors(Collection<String> mirrors)
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)
-
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
-
-