commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DBUTILS-124) Introduce SPI to add more column, property handlers
Date Tue, 10 Oct 2017 19:48:00 GMT

    [ https://issues.apache.org/jira/browse/DBUTILS-124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16199258#comment-16199258
] 

ASF GitHub Bot commented on DBUTILS-124:
----------------------------------------

Github user hdevalke commented on a diff in the pull request:

    https://github.com/apache/commons-dbutils/pull/3#discussion_r143833029
  
    --- Diff: src/main/java/org/apache/commons/dbutils/BeanProcessor.java ---
    @@ -65,19 +65,21 @@
          */
         private static final Map<Class<?>, Object> primitiveDefaults = new HashMap<Class<?>,
Object>();
     
    -    /**
    -     * ServiceLoader to find <code>ColumnHandler</code> implementations on
the classpath.  The iterator for this is
    -     * lazy and each time <code>iterator()</code> is called.
    -     */
    -    // FIXME: I think this instantiates new handlers on each iterator() call. This might
be worth caching upfront.
    -    private static final ServiceLoader<ColumnHandler> columnHandlers = ServiceLoader.load(ColumnHandler.class);
    +    private static final List<ColumnHandler> columnHandlers = new ArrayList<ColumnHandler>();
     
    -    /**
    -     * ServiceLoader to find <code>PropertyHandler</code> implementations
on the classpath.  The iterator for this is
    -     * lazy and each time <code>iterator()</code> is called.
    -     */
    -    // FIXME: I think this instantiates new handlers on each iterator() call. This might
be worth caching upfront.
    -    private static final ServiceLoader<PropertyHandler> propertyHandlers = ServiceLoader.load(PropertyHandler.class);
    +    static{
    +        for (ColumnHandler h : ServiceLoader.load(ColumnHandler.class)) {
    +            columnHandlers.add(h);
    +        }
    +    }
    +
    +    private static final List<PropertyHandler> propertyHandlers = new ArrayList<PropertyHandler>();
    +
    +    static {
    +        for (PropertyHandler h : ServiceLoader.load(PropertyHandler.class)) {
    +            propertyHandlers.add(h);
    --- End diff --
    
    I didn't see there was already a static block initializing `primitiveDefaults`. I find
it more readable initializing each static variable in their own block. I did an update and
put all in one static block.


> Introduce SPI to add more column, property handlers
> ---------------------------------------------------
>
>                 Key: DBUTILS-124
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-124
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Carl Hall
>            Assignee: Carl Hall
>             Fix For: 1.7
>
>
> The column types and property types handled by {{BeanProcessor}} are hard coded to the
processor.  We already use a common return type, so we could add a services approach using
the spi built into the jdk.  This should also allow other types to be handled outside of {{commons-dbutils}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message