Custom-field types are created with this entry in atlassian-plugin.xml:
<customfield-type name="New Custom Field Type" i18n-name-key="new-custom-field-type.name" key="new-custom-field-type" class="hk.com.epictechnology.plugins.newCustomFieldType">
<description key="new-custom-field-type.description">The new Custom Field Plugin</description>
<resource name="view" type="velocity" location="/templates/customfields/new-custom-field-type/view.vm"/>
<resource name="edit" type="velocity" location="/templates/customfields/new-custom-field-type/edit.vm"/>
</customfield-type>
The implementing class is not a component, it just gets scanned (@Scanned) by spring and then instantiated by some Jira service some time after the plugin is enabled.
@Scanned
public class NewCustomFieldTypeextends AbstractSingleFieldType<BigDecimal> {
private static final Logger log = LoggerFactory.getLogger(WsjfCustomField.class);
public NewCustomFieldType(@JiraImport CustomFieldValuePersister customFieldValuePersister, @JiraImport GenericConfigManager genericConfigManager) {
super(customFieldValuePersister, genericConfigManager);
}
@Override
public String getStringFromSingularObject(final BigDecimal singularObject) {
if (singularObject == null)
return null;
else
return singularObject.toString();
}
...
The How does another module know when it is safe to use the new custom-field type? Right now I am running into null pointer exceptions in the other module because it is trying to use the custom field type too early. Attempts to to inject custom-field type class as a dependency have failed.