[Java] How to register classes when using Fury Builder?
cdxf opened this issue · comments
I couldn't find any method in the builder to register classes. How can I register classes using the Fury builder?
ThreadSafeFury fury = Fury.builder().withLanguage(Language.JAVA)
.requireClassRegistration(true)
.buildThreadSafeFury();
Secondly, I'm unsure about when to use buildThreadSafeFury
and when to instantiate ThreadLocalFury directly. The documentation doesn't provide clear guidance on this.
I couldn't find any method in the builder to register classes. How can I register classes using the Fury builder?
FuryBuilder
cannot register classes directly. You need to use Fury#register(...)
to register. However, we can make FuryBuilder
support registration. I will submit a PR to do this later.
Secondly, I'm unsure about when to use buildThreadSafeFury and when to instantiate ThreadLocalFury directly. The documentation doesn't provide clear guidance on this.
The implementation principle of buildThreadSafeFury
is also to directly instantiate the ThreadLocalFury
object(see code), and pass a lambda expression to the constructor of ThreadLocalFury
to create a Fury instance.
In the expression passed in when you instantiate ThreadLocalFury
yourself, you can do some operations on the Fury instance by default. For example, you can register the FooClass
class for each thread Fury instance, which is something buildThreadSafeFury cannot do.
Directly instantiating ThreadLocalFury
is more flexible than buildThreadSafeFury
.
There is currently no essential difference between the two implementations. In the future, we will use buildThreadSafeFuryPool
as the default implementation of buildThreadSafeFury
. #1335