Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7A48610ABA for ; Fri, 6 Mar 2015 21:56:46 +0000 (UTC) Received: (qmail 95432 invoked by uid 500); 6 Mar 2015 21:48:42 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 95362 invoked by uid 500); 6 Mar 2015 21:48:42 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 95349 invoked by uid 99); 6 Mar 2015 21:48:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Mar 2015 21:48:42 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of karl.kilden@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-wg0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Mar 2015 21:48:16 +0000 Received: by wgha1 with SMTP id a1so12072517wgh.1 for ; Fri, 06 Mar 2015 13:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=yUb4oW+/NqwfSyluRKYieTPrH0K4uZoCZjz12Cbva4Q=; b=KLkwE3HQF8koFnRzYnc4sLUw6f5vMG5CqlG0TcWxIVudC3OnQL2A0ywKyVXJKsFq5C /elcYNjPbDkRbI5GlDjXXqaR5a9UmNx871dh3QeKOMsVvnMTuTZm27WkDJd/nvoeD1E4 Da9uku78+YhmHmSp5n9xzHJYumqpNV2yRBMI6mwExG8ogDqFgx6liQhKUUnWHHj6qUJY zPXmIl5WFRi4ZSju5GeZ2lykBEEJJ566O23UmRzlUdHpi1KTShTr3VrJzjEAS1g6ToQS 5r9+hVVqpp+otJKgIO324ZjE5fto+Db1hd+QM4+fH5cV9yJKrm+8ORuRsXmGaPRpg3YC 6xIw== MIME-Version: 1.0 X-Received: by 10.194.94.1 with SMTP id cy1mr32710505wjb.127.1425678495018; Fri, 06 Mar 2015 13:48:15 -0800 (PST) Received: by 10.27.135.67 with HTTP; Fri, 6 Mar 2015 13:48:14 -0800 (PST) Date: Fri, 6 Mar 2015 22:48:14 +0100 Message-ID: Subject: PostBind method for DocumentObjectBinder? From: =?UTF-8?B?S2FybCBLaWxkw6lu?= To: solr-user@lucene.apache.org Content-Type: multipart/alternative; boundary=047d7bf0c39a4275280510a5a40a X-Virus-Checked: Checked by ClamAV on apache.org --047d7bf0c39a4275280510a5a40a Content-Type: text/plain; charset=UTF-8 Hello, DocumentObjectBinder would benefit from a post bind call imo. Something like: public List getBeans(Class clazz, SolrDocumentList solrDocList, boolean postBind) { List fields = getDocFields(clazz); List result = new ArrayList<>(solrDocList.size()); for (SolrDocument sdoc : solrDocList) { T bean = getBean(clazz, fields, sdoc); if (postBind) { runAnnotatedMethod(bean, PostBind.class); } result.add(bean); } return result; } private void runAnnotatedMethod(final Object instance, Class annotation) { for (Method m : instance.getClass().getDeclaredMethods()) { if (m.isAnnotationPresent(annotation)) { m.setAccessible(true); try { m.invoke(instance, new Object[] {}); } catch (Exception e) { throw new BindingException("Could not run postbind " + instance.getClass(), e); } } } } Can probably take some thinking on how to do the API pretty staying backwards compatible and the found annotated method should be cached. WDYT? --047d7bf0c39a4275280510a5a40a--