Writing HK2 components in GlassFish 4?

烈酒焚心 提交于 2019-12-13 04:42:00

问题


In version 3 there is this guide on how to write components(including HK2 components): Oracle GlassFish Server 3.0.1 Add-On Component Development Guide

This documentation is not available with GF4. Why not?

Why am I asking?

Because I want to write a custom Logging Handler, as documented in Chapter 7 of the administration guide(https://glassfish.java.net/docs/4.0/administration-guide.pdf).

"Note: The custom handler class should be packaged in an OSGi module and the JAR file placed in the as-install/modules directory."

So how exactly do I proceed to create a HK2 component for GF4? Is it the same as GF3?


回答1:


GlassFish 4 added a new handlerServices logging property that is not in GlassFish 3. If your handler is a HK2 handler you have to place it in the modules directory and install the handler under the "handlerServices" property in the logging.properties file. The Hundred-Kilobyte Kernel website contains all of the documentation to get you started. I would reference the GFFileHandler source code and Adding custom handlers to GlassFish v3 loggers when building your handler.

The GlassFish 4 Administration Guide also states on page 7-17:

To configure a custom handler that is not developed as an HK2 component, add the new handler to the logging.properties file after the developer has put the custom handler JAR file into the domain-dir/lib/ext directory

So you might be able to setup your handler without using HK2. For these handlers you have to use the standard .handlers proprty in the logging properties file.



来源:https://stackoverflow.com/questions/25268183/writing-hk2-components-in-glassfish-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!