-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runnable Glassfish Embedded #25146
Runnable Glassfish Embedded #25146
Conversation
Example of running an app from command line: java -jar glassfish-embedded-all.jar "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true" "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=8080" app.war Example with root context: java -jar glassfish-embedded-all.jar "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true" "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=8080" "deploy --contextroot=/ app.war"
Deploy app if the argument is a file or dir. If it's a single app, deploy to root context. Support --option=value arguments with values that set GlassFish properties Support several special options, like --port, --properties. Support loading properties from glassfish.properties in the current directory. Revert using FallbackStartupModule, was needed only for testing
Refactoring the API, so that UberMain can be configured and executed programmatically.
Like: Refactored to the kernel module which already contains the config-api dependency. Adding config-api to the bootstrap module caused a dependency cycle that failed the Maven build.
Add some missing dependencies that are outside of the default directory. This makes Static shell equal to GF Embedded - it can be added to the classpath or used as an executable JAR instead of GF Embedded JAR. Fix WebSockets in GF Static Shell
Added missing Jakarta APIs: - Validation is part of Web Profile - XML Binding is not part of Web Profile but JobManagerService depends on it Improvements in handling exceptions and logging messages.
...ore/kernel/src/main/java/org/glassfish/runnablejar/commandline/UnknownPropertyException.java
Show resolved
Hide resolved
...ore/kernel/src/main/java/org/glassfish/runnablejar/commandline/UnknownPropertyException.java
Outdated
Show resolved
Hide resolved
...ore/kernel/src/main/java/org/glassfish/runnablejar/commandline/UnknownPropertyException.java
Outdated
Show resolved
Hide resolved
nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/commandline/WordWrapper.java
Outdated
Show resolved
Hide resolved
|
||
final int MAX_LINE_LENGTH; | ||
final String HELP_LINE_INDENT; | ||
int characterCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have it as local.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be an instance field, not a local variable. It holds the state. I refactored this class into a direct collector. That should make it clear it's a stateful class and shouldn't be reused.
nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/commandline/WordWrapper.java
Outdated
Show resolved
Hide resolved
nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/commandline/WordWrapper.java
Outdated
Show resolved
Hide resolved
Turned WordWraper into a direct collector WordWrapCollector. Moved the man page into the proper module and location. INFO level for output from admin commands
027fa29
to
a66fb8c
Compare
Logger.getAnonymousLogger().severe("Ignoring unrecognized element "+in.getLocalName() + " at " + in.getLocation()); | ||
logger.log(Level.WARNING, () -> "Ignoring unrecognized element " + in.getLocalName() + " at line #" + in.getLocation().getLineNumber()); | ||
logger.log(Level.FINE, () -> "Unrecognized element " + in.getLocalName() + " at " | ||
+ in.getLocation().toString().replace("\n", ", ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it is good to manipulate the location toString here, but ... or I will say it. It is wrong, but I have found that EventLocation
(jaxb-osgi
) really prints \n
character after every value ... perhaps we could create a PR for them ;-)
Example of running an app from command line: java -jar glassfish-embedded-all.jar "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true" "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=8080" app.war Example with root context: java -jar glassfish-embedded-all.jar "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true" "set configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=8080" "deploy --contextroot=/ app.war"
Deploy app if the argument is a file or dir. If it's a single app, deploy to root context. Support --option=value arguments with values that set GlassFish properties Support several special options, like --port, --properties. Support loading properties from glassfish.properties in the current directory. Revert using FallbackStartupModule, was needed only for testing
Refactoring the API, so that UberMain can be configured and executed programmatically.
Like: Refactored to the kernel module which already contains the config-api dependency. Adding config-api to the bootstrap module caused a dependency cycle that failed the Maven build.
Add some missing dependencies that are outside of the default directory. This makes Static shell equal to GF Embedded - it can be added to the classpath or used as an executable JAR instead of GF Embedded JAR. Fix WebSockets in GF Static Shell
Added missing Jakarta APIs: - Validation is part of Web Profile - XML Binding is not part of Web Profile but JobManagerService depends on it Improvements in handling exceptions and logging messages.
Turned WordWraper into a direct collector WordWrapCollector. Moved the man page into the proper module and location. INFO level for output from admin commands
setLogLevel(logLevel, arguments); | ||
} | ||
}, | ||
LOG_PROPERTIES("logProperties", "--logProperties=FILE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause issues, because JDK loads first and also starts using the logging configuration, the only reliable option is to use -Djava.util.logging.config.file on command line.
for (Handler handler : rootLogger.getHandlers()) { | ||
handler.setLevel(level); | ||
} | ||
LogManager.getLogManager().getLoggerNames().asIterator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem with this is that it returns just already initialized loggers. It would be better to retrieve current configuration from the logmanager, change it, and then call logManager.readConfiguration. Or just provide our own defaults generated using this parameter, set the root logger+handler level and just call logger.readConfiguration asap, even before main (in static init). It would be done just if user would not explicitly set the -Djava.util.logging.config.file
or -Djava.util.logging.config.class.
In the video it seems that currently it uses JDK defaults.
a66fb8c
to
283d261
Compare
I have rebased the branch and resolved conflicts as it was conflicting with my changes in master - finally they were just minor. |
…glassfish-embedded # Conflicts: # nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/UberMain.java
These match the configuration in the default GlassFish server domain.xml. With this it's no longer needed to specify --add-opens and --add-exports on the command line.
Allows running GlassFish Embedded from command line:
java -jar glassfish-embedded.jar
Supports configuration via command line arguments and/or config files in the current directory:
All GlassFish Embedded flavors are supported:
Includes fixes that made GlassFish Embedded Web usable. Includes fixes to the Static shell to make it equal to standalone GlassFish Embedded JAR files.
java -jar glassfish-embedded.jar --help
prints the following info: glassfish.man.txtDemo:
Runnable.GlassFish.Embedded.demo.mp4