Starting from B4A v8.0 it is possible to include custom class templates inside your libraries. Note that it will also be added to B4J and B4i.
You can include multiple templates.
There are two steps:
1. Add the template files to the project. File extension must be .b4x_excluded.
For example B4J jServer library now includes the three server handlers:
2. Declare them with the new @CustomClasses annotation:
If you are using SLC to build the library then you should put the files in the 'additional' folder.
The jar structure should be:
Make sure to use BADoclet v1.07+. The updated doclet is available inside SLC.
The generated XML should end with:
See this link if you want to create a custom class template without building a library: https://www.b4x.com/android/forum/threads/custom-class-templates-in-b4a.90552/#post-572445
You can include multiple templates.
There are two steps:
1. Add the template files to the project. File extension must be .b4x_excluded.
For example B4J jServer library now includes the three server handlers:
2. Declare them with the new @CustomClasses annotation:
B4X:
@CustomClasses(values = {
@CustomClass(name = "Server Handler", fileNameWithoutExtension = "server_handler"),
@CustomClass(name = "Server Filter", fileNameWithoutExtension = "server_filter"),
@CustomClass(name = "Server WebSocket", fileNameWithoutExtension = "server_websocket")
})
@Version(2.90f)
@ShortName("Server")
@DependsOn(values={"jetty_b4j", "c3p0-0.9.5.2", "c3p0-oracle-thin-extras-0.9.5.2"
,"mchange-commons-java-0.2.11", "json"})
public class ServerWrapper {
If you are using SLC to build the library then you should put the files in the 'additional' folder.
The jar structure should be:
Make sure to use BADoclet v1.07+. The updated doclet is available inside SLC.
The generated XML should end with:
B4X:
<customClass>name:Server Handler, filenamewithoutextension:server_handler</customClass>
<customClass>name:Server Filter, filenamewithoutextension:server_filter</customClass>
<customClass>name:Server WebSocket, filenamewithoutextension:server_websocket</customClass>
</root>
See this link if you want to create a custom class template without building a library: https://www.b4x.com/android/forum/threads/custom-class-templates-in-b4a.90552/#post-572445
Last edited: