The generate-schema-from-source tool may be used to generate a file containing LDAP schema definitions from a properly-annotated Java source file. The schema definitions will be represented in LDIF form as they would appear in an LDAP subschema subentry.
It is a command-line tool that may be invoked using the corresponding shell script or batch file located in the tools directory of the UnboundID LDAP SDK for Java distribution. Alternately, it may be run programmatically by invoking the main method of class com.unboundid.ldap.sdk.persist.GenerateSchemaFromSource. In either case, some of the arguments which may be used with this tool are provided below. Use the --help argument for a complete listing of all supported options.
Note that the generated schema definitions will not contain valid object identifiers, but instead will have placeholders consisting of the name of the associated attribute type or object class in all lowercase characters followed by the string "-oid" (e.g., for an attribute of "myAttr", the generated attribute type definition would have "myattr-oid" where the numeric OID would normally go). Although some directory servers allow this form instead of actual numeric OIDs, it is strongly recommended that you edit the resulting schema definitions to give them valid, unique numeric OIDs. Most of the processing performed by this tool is handled by invoking the constructAttributeTypes and constructObjectClasses methods on an LDAPPersister object, and there are variants of these methods which take an OIDAllocator instance that can be used to generate the OIDs using whatever logic you wish.