Java Utils
- 8 Devlogs
- 80 Total hours
A collection of java utils, primarily focusing on an event bus framework.
A collection of java utils, primarily focusing on an event bus framework.
Make MainBus#get static instead of instance method to allow users to utilise the provided MainBus
Fix ClassLoaderServiceLoader not working in module environments by declaring Module#addUses
Add MutableServiceLayer for manual service layers and create factory method for configuring them
Add static factory methods to create MutableMappedIdRegistry and MutableKeylessRegistry instances
Add demo subproject (CC0 license) showcasing features and how to use eventbus, registry and service api
Update build workflow to publish demo artifact
Add release github workflow to automatically publish artifacts when a release is created
Promote config helpers, registry and service api from WIP to experimental
Update README with event bus demo image
Event bus:
Disallowed @Weak on static event handlers for reflection discovered methods. Static handlers do not have a listener to bound to and thus have no reason to be declared as weak listeners; this additionally improves parity with the annotation processor.
Service API:
Added factory methods to create ServiceLayer instances across different ClassLoaders and ModuleLayers.
Registry system:
The registry system was redesigned essentially from the ground up.
MutableRegistry has been detached from Registry, and extending interfaces such as MutableMappedRegistry provide additional features (e.g. key -> value mappings)
Key -> value mappings are now supported via MappedRegistry and its implementors and ID mappings have been added via the IdRegistry interface. Current implementations like SimpleMutableKeylessRegistry and SimpleMutableMappedIdRegistry provide O(1) operations for lookup and registration whilst still supporting concurrent operations via BoundedSnapshotMap and BoundedSnapshotList as each registration is immutable.
Other:
Updated build workflow
Added USAGE documentation to README showing how to add the library as a dependency in Gradle.
Remove read lock on event dispatch by providing an activeTable Supplier to pass events to if this DispatchTable is closed, allowing #dispatch to race with #close safely.
Decouple creation of DispatchTable from Flattener
Add option to disable recursion guard in EventBusBuilder
Further optimize event dispatch for guarded event buses by removing ThreadLocal#remove call. This remains safe as it is a lightweight 1 length int[] array.
Fix ClassValueDispatchTable not dispatching events
Improve internal RecursionGuard usability by accepting a Runnable instead of manual #increment and #resetTo(int) calls.
Updated unit tests where appropriate to account for refactors
Added JMH benchmarks for guarded and unguarded recursion event buses
Updated README with benchmark results.
Added support for compile time generated @Weak instance and static event processors.
Full refactor of the annotation processor to cleanup the code structure and improve safety via compile time validation.
New abstract MethodDescriptor implemented by alongside some implementations like ElementMethodDescriptor (annotation processor variant), ReflectionMethodDescriptor (runtime reflection variant) and MethodKeyDescriptor (cached reflection variant), used to compare methods cleanly.
Individual method registration has not yet been implemented. MethodDescriptor will be utilised to locate individual handlers.
Introduced compile-time generated event listeners via an Annotation Processor (AP automatically generates SPI implementations) to reduce runtime reflection which will fallback to reflection path (LambdaMetafactory + MethodHandle fallback) on failure. Currently only built for instance event listeners: static listeners and direct method registrations will be implemented in the future.
The annotation processor looks for classes annotated with @CompiledEventHandlers and generates a SubscriberInvokerFactory which holds an EventSubscriberInvoker for each method.
Refactored the reflection subscriber path (EventSubscriberCompiler and EventHandlerCompiler) to follow SOLID better and improve extensibility
Update unit tests to work with the updated code
Fixed issues with configuration caching
Repackage and add javadoc to config helpers
Improved usability by improving javadoc.
Renamed Linkable to SubscribtionAware to better fit the name.
Finalized EventBusBuilder by adding a register to global registry flag, replacing event consumers with dedicated functional interfaces, updating ErrorHandler to have throwUnchecked helper and replacing the old deprecated EventBus with the new one
Repackage and rename module to com.github.rcubedev.utils
Updated the README by adding a project description, listing components and listing requirements.
Deprecated the old EventBus god object, in favour for the new EventBus implementation which now better following SOLID, improving debugging and DX. It utilises composition, where all features are separated into different classes for testability. Migrated from a flat array dispatch table to a class value dispatch table for O(1) handler lookups after caching vs O(n) before.