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 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
    Constructor
    Description
    Constructs a new CefAppBuilder instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add one or multiple arguments to pass to the JCef library.
    org.cef.CefApp
    Builds a CefApp instance.
    org.cef.CefSettings
    Retrieve the embedded CefSettings instance 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.
    boolean
    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.
    Helper method to install the native libraries/resources.
    void
    Attach your own adapter to handle certain events in CEF.
    void
    setInstallDir(File installDir)
    Sets the install directory to use.
    void
    Set mirror urls that should be used when downloading jcef.
    void
    Specify a progress handler to receive install progress updates.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CefAppBuilder

      public CefAppBuilder()
      Constructs a new CefAppBuilder instance.
  • Method Details

    • 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 embedded CefSettings instance to change configuration parameters.

      Due to installation using maven some settings may be overwritten again depending on your platform.

      Returns:
      the embedded CefSettings instance
    • 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)
    • 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 failed
      UnsupportedPlatformException - if the platform is not supported
    • build

      Builds a CefApp instance. When called multiple times, will return the previously built instance. This method is thread-safe.
      Returns:
      a built CefApp instance
      Throws:
      IOException - if an artifact could not be fetched or IO-actions on disk failed
      UnsupportedPlatformException - if the platform is not supported
      InterruptedException - if the installation process got interrupted
      CefInitializationException - if the initialization of JCef failed