Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 92967 invoked from network); 25 Jan 2010 06:44:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jan 2010 06:44:57 -0000 Received: (qmail 54338 invoked by uid 500); 25 Jan 2010 06:44:56 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 53946 invoked by uid 500); 25 Jan 2010 06:44:56 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 53865 invoked by uid 99); 25 Jan 2010 06:44:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 06:44:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 06:44:54 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 89D7E234C4AA for ; Sun, 24 Jan 2010 22:44:34 -0800 (PST) Message-ID: <793719974.4651264401874563.JavaMail.jira@brutus.apache.org> Date: Mon, 25 Jan 2010 06:44:34 +0000 (UTC) From: "Henri Yandell (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (LANG-577) Add ObjectReference interface and two implementations In-Reply-To: <1556554799.1261596989554.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Henri Yandell updated LANG-577: ------------------------------- Fix Version/s: (was: 3.0) 3.1 No backwards compat issues, so moving to 3.1. If resolved before 3.0 is released please assign to 3.0. > Add ObjectReference interface and two implementations > ----------------------------------------------------- > > Key: LANG-577 > URL: https://issues.apache.org/jira/browse/LANG-577 > Project: Commons Lang > Issue Type: New Feature > Components: lang.* > Reporter: Joerg Schaible > Assignee: Joerg Schaible > Priority: Minor > Fix For: 3.1 > > Attachments: reference.diff > > > In some situations it would be helpful to use a reference to an object, e.g. for parameters by reference > {code:java} > void doSomething(ObjectReference ref) { > ref.set("Hello"); > } > {code} > or for anonymous methods > {code:java} > final ObjectReference ref = new MemoryReference(); > final Runnable r = new Runnable() { > void run() { > ref.set("Hello"); > } > } > r.run(); > {code} > Additionally it is sometimes useful to keep the reference in other places than in shared memory, e.g. in a ThreadLocal or in case of a web application in a scoped reference or even in combination with some other persistence mechanism. Basically I am proposing the interface ObjectReference: > {code:Java} > /** > * Interface to reference an object. > * > * @param the type of the referenced object > * @author Apache Software Foundation > * @since 3.0 > */ > public interface ObjectReference { > /** > * Getter for the referenced object. > * > * @return the object or null > */ > T get(); > /** > * Setter for the reference. > * > * @param object the object to reference (may be null) > */ > void set(T object); > } > {code} > and the two implementations MemoryReference and ThreadLocalReference in the new package org.apache.commons.lang3.reference. I've seen such or similar types in various libraries. > Comments? > Unit test will be provided also. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.