Use ServiceLoader for loading DAV property factories

parent f254b6e0
......@@ -4,52 +4,19 @@ import org.xmlpull.v1.XmlPullParser;
import java.util.HashMap;
import java.util.Map;
import at.bitfire.dav4android.property.AddressData;
import at.bitfire.dav4android.property.AddressbookDescription;
import at.bitfire.dav4android.property.AddressbookHomeSet;
import at.bitfire.dav4android.property.CalendarColor;
import at.bitfire.dav4android.property.CalendarData;
import at.bitfire.dav4android.property.CalendarDescription;
import at.bitfire.dav4android.property.CalendarHomeSet;
import at.bitfire.dav4android.property.CalendarTimezone;
import at.bitfire.dav4android.property.CurrentUserPrincipal;
import at.bitfire.dav4android.property.CurrentUserPrivilegeSet;
import at.bitfire.dav4android.property.DisplayName;
import at.bitfire.dav4android.property.GetCTag;
import at.bitfire.dav4android.property.GetContentType;
import at.bitfire.dav4android.property.GetETag;
import at.bitfire.dav4android.property.ResourceType;
import at.bitfire.dav4android.property.SupportedAddressData;
import at.bitfire.dav4android.property.SupportedCalendarComponentSet;
import java.util.ServiceLoader;
public class PropertyRegistry {
protected Map<String, Map<String, PropertyFactory>> factories = new HashMap<>();
static final PropertyRegistry DEFAULT = new PropertyRegistry();
static {
DEFAULT.register(new ResourceType.Factory());
DEFAULT.register(new DisplayName.Factory());
DEFAULT.register(new GetCTag.Factory());
DEFAULT.register(new GetETag.Factory());
DEFAULT.register(new GetContentType.Factory());
DEFAULT.register(new CurrentUserPrincipal.Factory());
DEFAULT.register(new CurrentUserPrivilegeSet.Factory());
// CardDAV
DEFAULT.register(new AddressbookHomeSet.Factory());
DEFAULT.register(new AddressbookDescription.Factory());
DEFAULT.register(new SupportedAddressData.Factory());
DEFAULT.register(new AddressData.Factory());
// CalDAV
DEFAULT.register(new CalendarHomeSet.Factory());
DEFAULT.register(new CalendarColor.Factory());
DEFAULT.register(new CalendarDescription.Factory());
DEFAULT.register(new CalendarTimezone.Factory());
DEFAULT.register(new SupportedCalendarComponentSet.Factory());
DEFAULT.register(new CalendarData.Factory());
private PropertyRegistry() {
for (PropertyFactory factory : ServiceLoader.load(PropertyFactory.class)) {
Constants.log.debug("Registering DAV property factory for " + factory.getName());
register(factory);
}
}
......
at.bitfire.dav4android.property.AddressbookDescription$Factory
at.bitfire.dav4android.property.AddressbookHomeSet$Factory
at.bitfire.dav4android.property.AddressData$Factory
at.bitfire.dav4android.property.CalendarColor$Factory
at.bitfire.dav4android.property.CalendarData$Factory
at.bitfire.dav4android.property.CalendarDescription$Factory
at.bitfire.dav4android.property.CalendarHomeSet$Factory
at.bitfire.dav4android.property.CalendarTimezone$Factory
at.bitfire.dav4android.property.CurrentUserPrincipal$Factory
at.bitfire.dav4android.property.CurrentUserPrivilegeSet$Factory
at.bitfire.dav4android.property.DisplayName$Factory
at.bitfire.dav4android.property.GetContentType$Factory
at.bitfire.dav4android.property.GetCTag$Factory
at.bitfire.dav4android.property.GetETag$Factory
at.bitfire.dav4android.property.ResourceType$Factory
at.bitfire.dav4android.property.SupportedAddressData$Factory
at.bitfire.dav4android.property.SupportedCalendarComponentSet$Factory
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment