Package fish.payara.micro.impl
Class PayaraMicroImpl
- java.lang.Object
-
- fish.payara.micro.impl.PayaraMicroImpl
-
- All Implemented Interfaces:
PayaraMicroBoot
public class PayaraMicroImpl extends Object implements PayaraMicroBoot
Main class for Bootstrapping Payara Micro Edition This class is used from applications to create a full JavaEE runtime environment and deploy war files. This class is used to configure and bootstrap a Payara Micro Runtime.- Author:
- steve
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PayaraMicroImpladdDeployFromGAV(String GAV)Adds a Maven GAV coordinate to the list of archives to be deployed at boot.PayaraMicroImpladdDeployment(String pathToWar)Adds an archive to the list of archives to be deployed at boot.PayaraMicroImpladdDeploymentFile(File file)Adds an archive to the list of archives to be deployed at boot.PayaraMicroImpladdLibrary(File lib)Adds the library to the classloader and loads itPayaraMicroImpladdRepoUrl(String... URLs)Adds a Maven repository to the list of repositories to search for artifacts instatic PayaraMicroRuntimebootstrap()Bootstraps the PayaraMicroRuntime with all defaults and no additional configuration.PayaraMicroRuntimebootStrap()Boots the Payara Micro Server.static PayaraMicroBootcreate(String[] args)FilegetAlternateDomainXML()The path to an alternative domain.xml for PayaraMicro to use at bootintgetAutoBindRange()Gets the maximum number of ports to check if free for autobinding purposesStringgetClusterMulticastGroup()Gets the cluster groupintgetClusterPort()Gets the cluster multicast port used for cluster communicationsintgetClusterStartPort()Gets the instance listen port number used by clustering.FilegetDeploymentDir()A directory which will be scanned for archives to deploybooleangetHttpAutoBind()Indicates whether autobinding of the HTTP port is enabledintgetHttpPort()The configured port Payara Micro will use for HTTP requests.StringgetHzClusterName()Gets the name of the Hazelcast cluster group.static PayaraMicroImplgetInstance()Obtains the static singleton instance of the Payara Micro Server.static PayaraMicroImplgetInstance(boolean create)StringgetInstanceGroup()Gets the name of the instance groupStringgetInstanceName()Gets the logical name for this PayaraMicro Server within the server clusterintgetMaxHttpThreads()The maximum threads in the HTTP(S) threadpool processing HTTP(S) requests.intgetMinHttpThreads()The minimum number of threads in the HTTP(S) threadpool Default value is 10FilegetRootDir()The File path to a directory that PayaraMicro should use for storing its configuration filesPayaraMicroRuntimeImplgetRuntime()Get a handle on the running Payara instance to manipulate the server once runningbooleangetSslAutoBind()Indicates whether autobinding of the HTTPS port is enabledStringgetSslCert()The name of the SSL certificate to use in the keystoreintgetSslPort()The configured port for HTTPS requestsFilegetUberJar()The UberJar to createbooleanisLite()Indicates whether this is a lite cluster member which means it stores no cluster data although it participates fully in the cluster.booleanisNoCluster()Indicated whether clustering is enabledbooleanisNoHazelcast()Indicated whether distributed data grid is enabledstatic voidmain(String[] args)Runs a Payara Micro server used via java -jar payara-micro.jarPayaraMicroBootsetAccessLogDir(String filePath)Set user defined file directory for the access logPayaraMicroBootsetAccessLogFormat(String format)Set user defined formatting for the access logPayaraMicroBootsetAccessLogInterval(int interval)Set user defined interval for the access logPayaraMicroImplsetAlternateDomainXML(File alternateDomainXML)Sets the path to a domain.xml file PayaraMicro should use to boot.PayaraMicroImplsetApplicationDomainXML(String domainXml)Sets an application specific domain.xml file that is embedded on the classpath of your application.PayaraMicroImplsetAutoBindRange(int autoBindRange)Sets the maximum number of ports to check if free for autobinding purposesPayaraMicroImplsetClusterMulticastGroup(String hzMulticastGroup)Sets the cluster group used for Payara Micro clustering used for cluster communications and discovery.PayaraMicroImplsetClusterPort(int hzPort)Sets the multicast group used for Payara Micro clustering used for cluster communication and discovery.PayaraMicroImplsetClusterStartPort(int hzStartPort)Sets the start port number for the Payara Micro to listen on for cluster communications.PayaraMicroImplsetDeploymentDir(File deploymentRoot)Sets a directory to scan for archives to deploy on boot.PayaraMicroImplsetHttpAutoBind(boolean httpAutoBind)Enables or disables autobinding of the HTTP portPayaraMicroImplsetHttpPort(int httpPort)Sets the port used for HTTP requestsPayaraMicroImplsetHzClusterName(String hzClusterName)Sets the name of the Hazelcast cluster groupPayaraMicroImplsetInstanceGroup(String instanceGroup)Sets the instance group namePayaraMicroImplsetInstanceName(String instanceName)Sets the logical instance name for this PayaraMicro server within the server cluster If this is not set a name is generatedPayaraMicroImplsetLite(boolean liteMember)Sets the lite status of this cluster member.PayaraMicroImplsetLogoFile(String filePath)Sets the path to the logo file printed at boot.PayaraMicroImplsetLogPropertiesFile(File fileName)Set user defined properties file for loggingPayaraMicroImplsetMaxHttpThreads(int maxHttpThreads)The maximum threads in the HTTP(S) threadpool processing HTTP(S) requests.PayaraMicroImplsetMinHttpThreads(int minHttpThreads)The minimum number of threads in the HTTP(S) threadpool Default value is 10PayaraMicroImplsetNoCluster(boolean noCluster)Enables or disables clustering before bootstrapPayaraMicroImplsetNoHazelcast(boolean noHazelcast)Enables or disables clustering before bootstrapPayaraMicroBootsetPostBootHandler(Consumer<AdminCommandRunner> handler)Register a handler for executing admin commands at post-boot time.PayaraMicroBootsetPreBootHandler(Consumer<AdminCommandRunner> handler)Register a handler for executing admin commands at pre-boot time.PayaraMicroImplsetPrintLogo(boolean generate)Set whether the logo should be generated on bootPayaraMicroImplsetRootDir(File rootDir)Sets the File path to a directory PayaraMicro should use to install its configuration files.PayaraMicroImplsetSniEnabled(boolean value)Sets whether SNI enabled for SSLPayaraMicroImplsetSslAutoBind(boolean sslAutoBind)Enables or disables autobinding of the HTTPS portPayaraMicroImplsetSslCert(String alias)Set the certificate alias in the keystore to use for the server certPayaraMicroImplsetSslPort(int sslPort)Sets the configured port for HTTPS requests.PayaraMicroImplsetUserLogFile(String fileName)Set user defined file for the Log entriesvoidshutdown()Stops and then shutsdown the Payara Micro Server
-
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Runs a Payara Micro server used via java -jar payara-micro.jar- Parameters:
args- Command line arguments for PayaraMicro Usage: --help to see all the options
--help Shows this message and exits\n- Throws:
BootstrapException- If there is a problem booting the serverException
-
create
public static PayaraMicroBoot create(String[] args) throws Exception
- Throws:
Exception
-
getInstance
public static PayaraMicroImpl getInstance()
Obtains the static singleton instance of the Payara Micro Server. If it does not exist it will be create.- Returns:
- The singleton instance
-
bootstrap
public static PayaraMicroRuntime bootstrap() throws BootstrapException
Bootstraps the PayaraMicroRuntime with all defaults and no additional configuration. Functionally equivalent to PayaraMicro.getInstance().bootstrap();- Returns:
- Throws:
BootstrapException
-
getInstance
public static PayaraMicroImpl getInstance(boolean create)
- Parameters:
create- If false the instance won't be created if it has not been initialised- Returns:
- null if no instance exists and create is false. Otherwise returns the singleton instance
-
getClusterMulticastGroup
public String getClusterMulticastGroup()
Gets the cluster group- Specified by:
getClusterMulticastGroupin interfacePayaraMicroBoot- Returns:
- The Multicast Group that will beused for the Hazelcast clustering
-
setClusterMulticastGroup
public PayaraMicroImpl setClusterMulticastGroup(String hzMulticastGroup)
Sets the cluster group used for Payara Micro clustering used for cluster communications and discovery. Each Payara Micro cluster should have different values for the MulticastGroup- Specified by:
setClusterMulticastGroupin interfacePayaraMicroBoot- Parameters:
hzMulticastGroup- String representation of the multicast group- Returns:
-
setLogoFile
public PayaraMicroImpl setLogoFile(String filePath)
Sets the path to the logo file printed at boot. This can be on the classpath of the server or an absolute URL- Specified by:
setLogoFilein interfacePayaraMicroBoot- Parameters:
filePath-- Returns:
-
setPrintLogo
public PayaraMicroImpl setPrintLogo(boolean generate)
Set whether the logo should be generated on boot- Specified by:
setPrintLogoin interfacePayaraMicroBoot- Parameters:
generate-- Returns:
-
setUserLogFile
public PayaraMicroImpl setUserLogFile(String fileName)
Set user defined file for the Log entries- Specified by:
setUserLogFilein interfacePayaraMicroBoot- Parameters:
fileName-- Returns:
-
setLogPropertiesFile
public PayaraMicroImpl setLogPropertiesFile(File fileName)
Set user defined properties file for logging- Specified by:
setLogPropertiesFilein interfacePayaraMicroBoot- Parameters:
fileName-- Returns:
-
setAccessLogDir
public PayaraMicroBoot setAccessLogDir(String filePath)
Set user defined file directory for the access log- Specified by:
setAccessLogDirin interfacePayaraMicroBoot- Parameters:
filePath-- Returns:
-
setAccessLogFormat
public PayaraMicroBoot setAccessLogFormat(String format)
Set user defined formatting for the access log- Specified by:
setAccessLogFormatin interfacePayaraMicroBoot- Parameters:
format-- Returns:
-
setAccessLogInterval
public PayaraMicroBoot setAccessLogInterval(int interval)
Set user defined interval for the access log- Parameters:
interval-- Returns:
-
getClusterPort
public int getClusterPort()
Gets the cluster multicast port used for cluster communications- Specified by:
getClusterPortin interfacePayaraMicroBoot- Returns:
- The configured cluster port
-
setClusterPort
public PayaraMicroImpl setClusterPort(int hzPort)
Sets the multicast group used for Payara Micro clustering used for cluster communication and discovery. Each Payara Micro cluster should have different values for the cluster port- Specified by:
setClusterPortin interfacePayaraMicroBoot- Parameters:
hzPort- The port number- Returns:
-
getClusterStartPort
public int getClusterStartPort()
Gets the instance listen port number used by clustering. This number will be incremented automatically if the port is unavailable due to another instance running on the same host,- Specified by:
getClusterStartPortin interfacePayaraMicroBoot- Returns:
- The start port number
-
setClusterStartPort
public PayaraMicroImpl setClusterStartPort(int hzStartPort)
Sets the start port number for the Payara Micro to listen on for cluster communications.- Specified by:
setClusterStartPortin interfacePayaraMicroBoot- Parameters:
hzStartPort- Start port number- Returns:
-
getHttpPort
public int getHttpPort()
The configured port Payara Micro will use for HTTP requests.- Specified by:
getHttpPortin interfacePayaraMicroBoot- Returns:
- The HTTP port
-
setHttpPort
public PayaraMicroImpl setHttpPort(int httpPort)
Sets the port used for HTTP requests- Specified by:
setHttpPortin interfacePayaraMicroBoot- Parameters:
httpPort- The port number- Returns:
-
getUberJar
public File getUberJar()
The UberJar to create- Specified by:
getUberJarin interfacePayaraMicroBoot- Returns:
-
getSslPort
public int getSslPort()
The configured port for HTTPS requests- Specified by:
getSslPortin interfacePayaraMicroBoot- Returns:
- The HTTPS port
-
setSslPort
public PayaraMicroImpl setSslPort(int sslPort)
Sets the configured port for HTTPS requests. If this is not set HTTPS is disabled- Specified by:
setSslPortin interfacePayaraMicroBoot- Parameters:
sslPort- The HTTPS port- Returns:
-
setSniEnabled
public PayaraMicroImpl setSniEnabled(boolean value)
Description copied from interface:PayaraMicroBootSets whether SNI enabled for SSL- Specified by:
setSniEnabledin interfacePayaraMicroBoot- Parameters:
value- true to enable SNI- Returns:
-
setSslCert
public PayaraMicroImpl setSslCert(String alias)
Set the certificate alias in the keystore to use for the server cert- Specified by:
setSslCertin interfacePayaraMicroBoot- Parameters:
alias- name of the certificate in the keystore- Returns:
-
getSslCert
public String getSslCert()
Description copied from interface:PayaraMicroBootThe name of the SSL certificate to use in the keystore- Specified by:
getSslCertin interfacePayaraMicroBoot- Returns:
-
getInstanceName
public String getInstanceName()
Gets the logical name for this PayaraMicro Server within the server cluster- Specified by:
getInstanceNamein interfacePayaraMicroBoot- Returns:
- The configured instance name
-
setInstanceName
public PayaraMicroImpl setInstanceName(String instanceName)
Sets the logical instance name for this PayaraMicro server within the server cluster If this is not set a name is generated- Specified by:
setInstanceNamein interfacePayaraMicroBoot- Parameters:
instanceName- The logical server name- Returns:
-
getDeploymentDir
public File getDeploymentDir()
A directory which will be scanned for archives to deploy- Specified by:
getDeploymentDirin interfacePayaraMicroBoot- Returns:
-
setDeploymentDir
public PayaraMicroImpl setDeploymentDir(File deploymentRoot)
Sets a directory to scan for archives to deploy on boot. This directory is not monitored while running for changes. Therefore archives in this directory will NOT be redeployed during runtime.- Specified by:
setDeploymentDirin interfacePayaraMicroBoot- Parameters:
deploymentRoot- File path to the directory- Returns:
-
getAlternateDomainXML
public File getAlternateDomainXML()
The path to an alternative domain.xml for PayaraMicro to use at boot- Specified by:
getAlternateDomainXMLin interfacePayaraMicroBoot- Returns:
- The path to the domain.xml
-
setApplicationDomainXML
public PayaraMicroImpl setApplicationDomainXML(String domainXml)
Sets an application specific domain.xml file that is embedded on the classpath of your application.- Specified by:
setApplicationDomainXMLin interfacePayaraMicroBoot- Parameters:
domainXml- This is a resource string for your domain.xml- Returns:
-
setAlternateDomainXML
public PayaraMicroImpl setAlternateDomainXML(File alternateDomainXML)
Sets the path to a domain.xml file PayaraMicro should use to boot. If this is not set PayaraMicro will use an appropriate domain.xml from within its jar file- Specified by:
setAlternateDomainXMLin interfacePayaraMicroBoot- Parameters:
alternateDomainXML-- Returns:
-
addDeployment
public PayaraMicroImpl addDeployment(String pathToWar)
Adds an archive to the list of archives to be deployed at boot. These archives are not monitored for changes during running so are not redeployed without restarting the server- Specified by:
addDeploymentin interfacePayaraMicroBoot- Parameters:
pathToWar- File path to the deployment archive- Returns:
-
addDeploymentFile
public PayaraMicroImpl addDeploymentFile(File file)
Adds an archive to the list of archives to be deployed at boot. These archives are not monitored for changes during running so are not redeployed without restarting the server- Specified by:
addDeploymentFilein interfacePayaraMicroBoot- Parameters:
file- File path to the deployment archive- Returns:
-
addDeployFromGAV
public PayaraMicroImpl addDeployFromGAV(String GAV)
Adds a Maven GAV coordinate to the list of archives to be deployed at boot.- Specified by:
addDeployFromGAVin interfacePayaraMicroBoot- Parameters:
GAV- GAV coordinate- Returns:
-
addRepoUrl
public PayaraMicroImpl addRepoUrl(String... URLs)
Adds a Maven repository to the list of repositories to search for artifacts in- Specified by:
addRepoUrlin interfacePayaraMicroBoot- Parameters:
URLs- URL to Maven repository- Returns:
-
isNoCluster
public boolean isNoCluster()
Indicated whether clustering is enabled- Specified by:
isNoClusterin interfacePayaraMicroBoot- Returns:
-
isNoHazelcast
public boolean isNoHazelcast()
Indicated whether distributed data grid is enabled- Specified by:
isNoHazelcastin interfacePayaraMicroBoot- Returns:
-
setNoCluster
public PayaraMicroImpl setNoCluster(boolean noCluster)
Enables or disables clustering before bootstrap- Specified by:
setNoClusterin interfacePayaraMicroBoot- Parameters:
noCluster- set to true to disable clustering- Returns:
-
setNoHazelcast
public PayaraMicroImpl setNoHazelcast(boolean noHazelcast)
Enables or disables clustering before bootstrap- Specified by:
setNoHazelcastin interfacePayaraMicroBoot- Parameters:
noHazelcast- set to true to disable clustering- Returns:
-
isLite
public boolean isLite()
Indicates whether this is a lite cluster member which means it stores no cluster data although it participates fully in the cluster.- Specified by:
isLitein interfacePayaraMicroBoot- Returns:
-
setLite
public PayaraMicroImpl setLite(boolean liteMember)
Sets the lite status of this cluster member. If true the Payara Micro is a lite cluster member which means it stores no cluster data.- Specified by:
setLitein interfacePayaraMicroBoot- Parameters:
liteMember- set to true to set as a lite cluster member with no data storage- Returns:
-
getMaxHttpThreads
public int getMaxHttpThreads()
The maximum threads in the HTTP(S) threadpool processing HTTP(S) requests. Setting this will determine how many concurrent HTTP requests can be processed. The default value is 200. This value is shared by both HTTP and HTTP(S) requests.- Specified by:
getMaxHttpThreadsin interfacePayaraMicroBoot- Returns:
-
setMaxHttpThreads
public PayaraMicroImpl setMaxHttpThreads(int maxHttpThreads)
The maximum threads in the HTTP(S) threadpool processing HTTP(S) requests. Setting this will determine how many concurrent HTTP requests can be processed. The default value is 200- Specified by:
setMaxHttpThreadsin interfacePayaraMicroBoot- Parameters:
maxHttpThreads- Maximum threads in the HTTP(S) threadpool- Returns:
-
getMinHttpThreads
public int getMinHttpThreads()
The minimum number of threads in the HTTP(S) threadpool Default value is 10- Specified by:
getMinHttpThreadsin interfacePayaraMicroBoot- Returns:
- The minimum threads to be created in the threadpool
-
setMinHttpThreads
public PayaraMicroImpl setMinHttpThreads(int minHttpThreads)
The minimum number of threads in the HTTP(S) threadpool Default value is 10- Specified by:
setMinHttpThreadsin interfacePayaraMicroBoot- Parameters:
minHttpThreads-- Returns:
-
getRootDir
public File getRootDir()
The File path to a directory that PayaraMicro should use for storing its configuration files- Specified by:
getRootDirin interfacePayaraMicroBoot- Returns:
-
setRootDir
public PayaraMicroImpl setRootDir(File rootDir)
Sets the File path to a directory PayaraMicro should use to install its configuration files. If this is set the PayaraMicro configuration files will be stored in the directory and persist across server restarts. If this is not set the configuration files are created in a temporary location and not persisted across server restarts.- Specified by:
setRootDirin interfacePayaraMicroBoot- Parameters:
rootDir- Path to a valid directory- Returns:
- Returns the PayaraMicro instance
-
getHttpAutoBind
public boolean getHttpAutoBind()
Indicates whether autobinding of the HTTP port is enabled- Specified by:
getHttpAutoBindin interfacePayaraMicroBoot- Returns:
-
setHttpAutoBind
public PayaraMicroImpl setHttpAutoBind(boolean httpAutoBind)
Enables or disables autobinding of the HTTP port- Specified by:
setHttpAutoBindin interfacePayaraMicroBoot- Parameters:
httpAutoBind- The true or false value to enable or disable HTTP autobinding- Returns:
-
getSslAutoBind
public boolean getSslAutoBind()
Indicates whether autobinding of the HTTPS port is enabled- Specified by:
getSslAutoBindin interfacePayaraMicroBoot- Returns:
-
setSslAutoBind
public PayaraMicroImpl setSslAutoBind(boolean sslAutoBind)
Enables or disables autobinding of the HTTPS port- Specified by:
setSslAutoBindin interfacePayaraMicroBoot- Parameters:
sslAutoBind- The true or false value to enable or disable HTTPS autobinding- Returns:
-
getAutoBindRange
public int getAutoBindRange()
Gets the maximum number of ports to check if free for autobinding purposes- Specified by:
getAutoBindRangein interfacePayaraMicroBoot- Returns:
- The number of ports to check if free
-
setAutoBindRange
public PayaraMicroImpl setAutoBindRange(int autoBindRange)
Sets the maximum number of ports to check if free for autobinding purposes- Specified by:
setAutoBindRangein interfacePayaraMicroBoot- Parameters:
autoBindRange- The maximum number of ports to increment the port value by- Returns:
-
getHzClusterName
public String getHzClusterName()
Gets the name of the Hazelcast cluster group. Clusters with different names do not interact- Specified by:
getHzClusterNamein interfacePayaraMicroBoot- Returns:
- The current Cluster Name
-
setHzClusterName
public PayaraMicroImpl setHzClusterName(String hzClusterName)
Sets the name of the Hazelcast cluster group- Specified by:
setHzClusterNamein interfacePayaraMicroBoot- Parameters:
hzClusterName- The name of the hazelcast cluster- Returns:
-
getInstanceGroup
public String getInstanceGroup()
Gets the name of the instance group- Specified by:
getInstanceGroupin interfacePayaraMicroBoot- Returns:
- The name of the instance group
-
setInstanceGroup
public PayaraMicroImpl setInstanceGroup(String instanceGroup)
Sets the instance group name- Specified by:
setInstanceGroupin interfacePayaraMicroBoot- Parameters:
instanceGroup- The instance group name- Returns:
-
bootStrap
public PayaraMicroRuntime bootStrap() throws BootstrapException
Boots the Payara Micro Server. All parameters are checked at this point- Specified by:
bootStrapin interfacePayaraMicroBoot- Returns:
- An instance of PayaraMicroRuntime that can be used to access the running server
- Throws:
BootstrapException
-
getRuntime
public PayaraMicroRuntimeImpl getRuntime() throws IllegalStateException
Get a handle on the running Payara instance to manipulate the server once running- Specified by:
getRuntimein interfacePayaraMicroBoot- Returns:
- Throws:
IllegalStateException
-
shutdown
public void shutdown() throws BootstrapExceptionStops and then shutsdown the Payara Micro Server- Specified by:
shutdownin interfacePayaraMicroBoot- Throws:
BootstrapException
-
addLibrary
public PayaraMicroImpl addLibrary(File lib)
Description copied from interface:PayaraMicroBootAdds the library to the classloader and loads it- Specified by:
addLibraryin interfacePayaraMicroBoot- Parameters:
lib- The library to add- Returns:
-
setPreBootHandler
public PayaraMicroBoot setPreBootHandler(Consumer<AdminCommandRunner> handler)
Description copied from interface:PayaraMicroBootRegister a handler for executing admin commands at pre-boot time. Handler will be called with reference toAdminCommandRunnerbefore instance starts. It offers way of changing domain configuration by means of running commandset. The commands will be only executed on the instance that is booted. Only single handler can be registered.- Specified by:
setPreBootHandlerin interfacePayaraMicroBoot- Returns:
-
setPostBootHandler
public PayaraMicroBoot setPostBootHandler(Consumer<AdminCommandRunner> handler)
Description copied from interface:PayaraMicroBootRegister a handler for executing admin commands at post-boot time. Handler will be called with reference toAdminCommandRunnerafter all services start, but before deployment starts. All commands available overasadmincommand are valid in this phase. The commands will be only executed on the instance starting up, not in any cluster it may have formed. Only single handler can be registered- Specified by:
setPostBootHandlerin interfacePayaraMicroBoot- Returns:
-
-