Class JettyMicroservice.Builder
- Enclosing class:
- JettyMicroservice
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedBuilder()Constructor.protectedBuilder(JettyMicroservice.Builder copyFrom) Copy constructor.
- 
Method SummaryModifier and TypeMethodDescriptionSpecifies the command-line arguments passed into the Java command.Specifies the command-line arguments passed into the Java command.build()Instantiate a new microservice using the settings defined on this builder.Specifies the config for initializing this microservice.configName(String configName) Specifies the config name for initializing this microservice.configStore(ConfigStore configStore) Specifies the config store to use for storing and retrieving configurations.console(Scanner consoleReader, PrintWriter consoleWriter) Specifies the console input and output.consoleCommands(ConsoleCommand... consoleCommands) Specifies console commands to make available on the Java console.consoleEnabled(boolean consoleEnabled) Specifies that the Java console is enabled for this microservice.copy()Creates a copy of this builder.Specifies the factory to use for creating the JettyServerinstance.Specifies the contents or location of thejetty.xml file used by the Jetty server.listener(JettyMicroserviceListener listener) Registers an event listener for this microservice.Specifies the logger used by the microservice and returned by theMicroservice.getLogger()method.Specifies the manifest file of the jar file this microservice is contained within.ports(int... ports) Specifies the ports to use for the web server.Adds a servlet instance to the servlet container.Adds a servlet to the servlet container.servlet(Class<? extends RestServlet> c) Adds a servlet to the servlet container.servletAttribute(String name, Object value) Adds a servlet attribute to the servlet container.servletAttribute(Map<String, Object> values) Adds a set of servlet attributes to the servlet container.Adds a set of servlets to the servlet container.Adds a bean for vars defined in the var resolver.Augments the set of variables defined in the configuration and var resolver.workingDir(File path) Specifies the directory to use to resolve the config file and other paths defined with the config file.workingDir(String path) Specifies the directory to use to resolve the config file and other paths defined with the config file.Methods inherited from class org.apache.juneau.microservice.Microservice.BuilderconsoleCommands, listener, logConfig, resolveFile
- 
Constructor Details- 
Builderprotected Builder()Constructor.
- 
BuilderCopy constructor.- Parameters:
- copyFrom- The builder to copy settings from.
 
 
- 
- 
Method Details- 
copyDescription copied from class:Microservice.BuilderCreates a copy of this builder.- Overrides:
- copyin class- Microservice.Builder
- Returns:
- A new copy of this builder.
 
- 
jettyXmlSpecifies the contents or location of thejetty.xml file used by the Jetty server.If you do not specify this value, it is pulled from the following in the specified order: - 
         Jetty/config setting in the config file.Jetty-Config setting in the manifest file.
 By default, we look for the jetty.xml file in the following locations:- jetty.xml in home directory.
- files/jetty.xml in home directory.
- /jetty.xml in classpath.
- /files/jetty.xml in classpath.
 - Parameters:
- jettyXml- The contents or location of the file.
 Can be any of the following:- String- Relative path to file on file system or classpath.
- File- File on file system.
- Path- Path on file system.
- InputStream- Raw contents as- UTF-8 encoded stream.
- Reader- Raw contents.
 
- resolveVars- If- true , SVL variables in the file will automatically be resolved.
- Returns:
- This object.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
         
- 
portsSpecifies the ports to use for the web server.You can specify multiple ports. The first available will be used. '0' indicates to try a random port. The resulting available port gets set as the system property"availablePort" which can be referenced in thejetty.xml file as"$S{availablePort}" (assuming resolveVars is enabled).If you do not specify this value, it is pulled from the following in the specified order: - 
      Jetty/port setting in the config file.
- 
      Jetty-Port setting in the manifest file.
- 
      8000 
 - Parameters:
- ports- The ports to use for the web server.
- Returns:
- This object.
 
- 
      
- 
servletAdds a servlet to the servlet container.This method can only be used with servlets with no-arg constructors. 
 The path is pulled from theRest.path()annotation.- Parameters:
- c- The servlet to add to the servlet container.
- Returns:
- This object.
- Throws:
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
servletpublic JettyMicroservice.Builder servlet(Class<? extends jakarta.servlet.Servlet> c, String path) throws ExecutableException Adds a servlet to the servlet container.This method can only be used with servlets with no-arg constructors. - Parameters:
- c- The servlet to add to the servlet container.
- path- The servlet path spec.
- Returns:
- This object.
- Throws:
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
servletAdds a servlet instance to the servlet container.- Parameters:
- servlet- The servlet to add to the servlet container.
- path- The servlet path spec.
- Returns:
- This object.
 
- 
servletsAdds a set of servlets to the servlet container.- Parameters:
- servlets- A map of servlets to add to the servlet container.
 Keys are path specs for the servlet.
- Returns:
- This object.
 
- 
servletAttributeAdds a servlet attribute to the servlet container.- Parameters:
- name- The attribute name.
- value- The attribute value.
- Returns:
- This object.
 
- 
servletAttributeAdds a set of servlet attributes to the servlet container.- Parameters:
- values- The map of attributes.
- Returns:
- This object.
 
- 
jettyServerFactorySpecifies the factory to use for creating the JettyServerinstance.If not specified, uses BasicJettyServerFactory.- Parameters:
- value- The new value for this property.
- Returns:
- This object.
 
- 
buildDescription copied from class:Microservice.BuilderInstantiate a new microservice using the settings defined on this builder.- Overrides:
- buildin class- Microservice.Builder
- Returns:
- A new microservice.
- Throws:
- Exception- Error occurred.
 
- 
argsDescription copied from class:Microservice.BuilderSpecifies the command-line arguments passed into the Java command.This is required if you use Microservice.getArgs()or$A string variables.- Overrides:
- argsin class- Microservice.Builder
- Parameters:
- args- The command-line arguments passed into the Java command as a pre-parsed- Argsobject.
- Returns:
- This object.
 
- 
argsDescription copied from class:Microservice.BuilderSpecifies the command-line arguments passed into the Java command.This is required if you use Microservice.getArgs()or$A string variables.- Overrides:
- argsin class- Microservice.Builder
- Parameters:
- args- The command-line arguments passed into the Java command as the raw command-line arguments.
- Returns:
- This object.
 
- 
manifestDescription copied from class:Microservice.BuilderSpecifies the manifest file of the jar file this microservice is contained within.This is required if you use Microservice.getManifest(). It's also used to locate initialization values such asMain-Config .If you do not specify the manifest file, we attempt to resolve it through the following methods: - 
      Looking on the file system for a file at "META-INF/MANIFEST.MF" . This is primarily to allow for running microservices from within eclipse workspaces where the manifest file is located in the project root.
- 
      Using the class loader for this class to find the file at the URL "META-INF/MANIFEST.MF" .
 - Overrides:
- manifestin class- Microservice.Builder
- Parameters:
- manifest- The manifest file of this microservice.
 Can be any of the following types:- ManifestFile
- Manifest
- Reader- Containing the raw contents of the manifest. Note that the input must end with a newline.
- InputStream- Containing the raw contents of the manifest. Note that the input must end with a newline.
- File- File containing the raw contents of the manifest.
- String- Path to file containing the raw contents of the manifest.
- Class- Finds and loads the manifest file of the jar file that the specified class is contained within.
 
- Returns:
- This object.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
      Looking on the file system for a file at 
- 
loggerDescription copied from class:Microservice.BuilderSpecifies the logger used by the microservice and returned by theMicroservice.getLogger()method.Calling this method overrides the default logging mechanism controlled by the Microservice.Builder.logConfig(LogConfig)method.- Overrides:
- loggerin class- Microservice.Builder
- Parameters:
- logger- The logger to use for logging microservice messages.
- Returns:
- This object.
 
- 
configDescription copied from class:Microservice.BuilderSpecifies the config for initializing this microservice.Calling this method overrides the default configuration controlled by the Microservice.Builder.configName(String)andMicroservice.Builder.configStore(ConfigStore)methods.- Overrides:
- configin class- Microservice.Builder
- Parameters:
- config- The configuration.
- Returns:
- This object.
 
- 
configNameDescription copied from class:Microservice.BuilderSpecifies the config name for initializing this microservice.If you do not specify the config file location, we attempt to resolve it through the following methods: - 
      Resolve file first in working directory, then in classpath, using the following names:
      - 
            The "configFile" argument in the command line arguments passed in through the constructor.
- 
            The value of the Main-Config entry in the manifest file.
- 
            A config file in the same location and with the same name as the executable jar file.
            (e.g. "java -jar myjar.jar" will look for"myjar.cfg" ).
 
- 
            The 
- 
      Resolve any "*.cfg" file that can be found in the working directory.
- 
      Resolve any of the following files in the classpath:  "juneau.cfg" ,"system.cfg" 
 If no configuration file is found, and empty in-memory configuration is used. - Overrides:
- configNamein class- Microservice.Builder
- Parameters:
- configName- The configuration name.
- Returns:
- This object.
 
- 
      Resolve file first in working directory, then in classpath, using the following names:
      
- 
configStoreDescription copied from class:Microservice.BuilderSpecifies the config store to use for storing and retrieving configurations.By default, we use a FileStorestore for configuration files.- Overrides:
- configStorein class- Microservice.Builder
- Parameters:
- configStore- The configuration name.
- Returns:
- This object.
 
- 
consoleEnabledDescription copied from class:Microservice.BuilderSpecifies that the Java console is enabled for this microservice.If not specified, this value is taken from the "Console/enabled" configuration setting. If not specified in the configuration, defaults tofalse .- Overrides:
- consoleEnabledin class- Microservice.Builder
- Parameters:
- consoleEnabled-- true if the Java console is enabled for this microservice.
- Returns:
- This object.
 
- 
consoleCommandsDescription copied from class:Microservice.BuilderSpecifies console commands to make available on the Java console.Note that these are ignored if the console is not enabled via Microservice.Builder.consoleEnabled(boolean).This list augments the commands defined via the "Console/commands" configuration setting.- Overrides:
- consoleCommandsin class- Microservice.Builder
- Parameters:
- consoleCommands- The list of console commands to append to the list of available commands.
- Returns:
- This object.
 
- 
consoleDescription copied from class:Microservice.BuilderSpecifies the console input and output.If not specified, uses the console returned by System.console(). If that is not available, usesSystem.inandSystem.out.Note that these are ignored if the console is not enabled via Microservice.Builder.consoleEnabled(boolean).- Overrides:
- consolein class- Microservice.Builder
- Parameters:
- consoleReader- The console input.
- consoleWriter- The console output.
- Returns:
- This object.
 
- 
varsDescription copied from class:Microservice.BuilderAugments the set of variables defined in the configuration and var resolver.This calls VarResolver.Builder.vars(Class[])on the var resolver used to construct the configuration object returned byMicroservice.getConfig()and the var resolver returned byMicroservice.getVarResolver().- Overrides:
- varsin class- Microservice.Builder
- Parameters:
- vars- The set of variables to append to the var resolver builder.
- Returns:
- This object.
 
- 
varBeanDescription copied from class:Microservice.BuilderAdds a bean for vars defined in the var resolver.This calls VarResolver.Builder.bean(Class,Object)on the var resolver used to construct the configuration object returned byMicroservice.getConfig()and the var resolver returned byMicroservice.getVarResolver().- Overrides:
- varBeanin class- Microservice.Builder
- Type Parameters:
- T- The bean type.
- Parameters:
- c- The bean type.
- value- The bean.
- Returns:
- This object.
 
- 
workingDirDescription copied from class:Microservice.BuilderSpecifies the directory to use to resolve the config file and other paths defined with the config file.- Overrides:
- workingDirin class- Microservice.Builder
- Parameters:
- path- The working directory, or- null to use the underlying working directory.
- Returns:
- This object.
 
- 
workingDirDescription copied from class:Microservice.BuilderSpecifies the directory to use to resolve the config file and other paths defined with the config file.- Overrides:
- workingDirin class- Microservice.Builder
- Parameters:
- path- The working directory, or- null to use the underlying working directory.
- Returns:
- This object.
 
- 
listenerRegisters an event listener for this microservice.- Parameters:
- listener- An event listener for this microservice.
- Returns:
- This object.
 
 
-