在GlassFish 4中编写HK2组件? [英] Writing HK2 components in GlassFish 4?

查看:138
本文介绍了在GlassFish 4中编写HK2组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在版本3中,有关如何编写组件(包括HK2组件)的指南:
Oracle GlassFish Server 3.0.1附加组件开发指南

<本文档不适用于GF4。为什么不能?



为什么要问?



因为我想编写一个自定义的Logging Handler,在管理指南的第7章中( https://glassfish.java.net/docs /4.0/administration-guide.pdf )。



注意:自定义处理程序类应该打包在OSGi
模块中,并且JAR文件放置在as-install / modules目录中。



那么我怎样才能为GF4创建一个HK2组件呢?是否与GF3相同?

解决方案

GlassFish 4增加了一个新的 handlerServices 记录GlassFish 3中没有的属性。如果您的处理程序是HK2处理程序,则必须将其放入modules目录并安装处理程序在logging.properties文件的handlerServices属性下。 百Kilobyte内核网站包含了所有的文档以帮助您入门。我会参考 GFFileHandler 源代码和在构建处理程序时向GlassFish v3记录器添加自定义处理程序。


$ b GlassFish 4管理指南在第7-17页:


要配置一个不是作为HK2组件开发的自定义处理程序,请添加
new处理程序在开发人员将自定义
处理程序JAR文件放入域-dir / lib / ext目录中之后,将其添加到logging.properties文件中



所以你可以在不使用HK2的情况下设置你的处理程序。对于这些处理程序,您必须在日志记录属性文件中使用标准.handlers属性。


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?

解决方案

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.

这篇关于在GlassFish 4中编写HK2组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆