alibaba / transmittable-thread-local

📌 a missing Java std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
https://github.com/alibaba/transmittable-thread-local
Apache License 2.0
7.59k stars 1.69k forks source link

新增功能:在启动参数中不再需要配置java参数-xbootclasspath #99

Closed xwshiustc closed 6 years ago

xwshiustc commented 6 years ago

根据本人使用经验

未来我将努力贡献一部分代码争取不再配置需要配置-xbootclasspath

oldratlee commented 6 years ago

@xwshiustc 能否说明一下: JBoss设置-xbootclasspath 且生效,需要的哪些具体操作 及相关的资料?

原因:

xwshiustc commented 6 years ago

目前我只有用过JBoss 6tomcat 6

JBoss

JBoss 6.x的大部分版本中 配置方式为:

-javaagent:/opt/xxxxxx/transmittable-thread-local-2.x.x.jar
-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager,com.alibaba.ttl,
-Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Xbootclasspath/p:/opt/xxxxxx/transmittable-thread-local-2.x.x.jar

tomcat

tomcat 6开发环境中使用很简单,不需要配置任何其他参数。

只要 -javaagent:/opt/xxxxxx/transmittable-thread-local-2.x.x.jar 即可

其他容器未知

oldratlee commented 6 years ago

Some related reources

baifan commented 6 years ago

建议不要使用MANIFEST.MF中的Boot-Class-Path代替-Xbootclasspath/a,否则修改了ttl的jar包名称,仍然需要指定参数-Xbootclasspath/a

附上Boot-Class-Path的说明:

A list of paths to be searched by the bootstrap class loader. Paths represent directories or libraries (commonly referred to as JAR or zip libraries on many platforms). These paths are searched by the bootstrap class loader after the platform specific mechanisms of locating a class have failed. Paths are searched in the order listed. Paths in the list are separated by one or more spaces. A path takes the syntax of the path component of a hierarchical URI. The path is absolute if it begins with a slash character ('/'), otherwise it is relative. A relative path is resolved against the absolute path of the agent JAR file. Malformed and non-existent paths are ignored. When an agent is started sometime after the VM has started then paths that do not represent a JAR file are ignored. This attribute is optional.

oldratlee commented 6 years ago

@baifan

  1. 通过Boot-Class-Path 简化 -Xbootclasspath的配置是Agent的最佳实践。
  2. 多数情况下,大家是不会修改下载的Jar文件名。
  3. 如果真修改了文件名,仍然可以用-Xbootclasspath的配置,就像之前的版本一样。

另外,你提的注意点在文档中已经加上明确说明了 ❤️ 👍

关于boot class path设置 - READMEimage