View Javadoc
1 /* 2 * Local.java 3 * Created on July 24, 2003 4 * 5 * The Blues Framework - A lightweight application framework 6 * Copyright (C) 2003 Lonnie Pryor 7 * http://blues.lonniepryor.com 8 * 9 * This library is free software; you can redistribute it and/or modify it under the 10 * terms of the GNU Lesser General Public License as published by the Free Software 11 * Foundation; either version 2.1 of the License, or (at your option) any later 12 * version. 13 * 14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 16 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along 19 * with this library; if not, write to: 20 * 21 * The Free Software Foundation, Inc. 22 * 59 Temple Place, Suite 330 23 * Boston, MA 02111-1307 USA 24 * 25 */ 26 package com.lonniepryor.blues; 27 28 /*** 29 * Provides a service similiar to the ThreadLocal class, except values of blues 30 * Locals can only exist between the creation of a Session and the subsequent 31 * calling of it's dispose() method. Values of these Locals will therefore be 32 * safely disposed of without relying on garbage collection. 33 * 34 * @author Lonnie Pryor 35 * @version $Revision: 1.1 $ 36 */ 37 public class Local { 38 /*** 39 * Creates a new Local object. 40 */ 41 public Local () { 42 } 43 44 /*** 45 * Returns the value of this Local in the currently bound Session. 46 * 47 * @return The value of this Local in the currently bound Session. 48 */ 49 public final Object get () { 50 return Blues.currentSession().getLocalValue(this); 51 } 52 53 /*** 54 * Sets the value of this Local in the currently bound Session. 55 * 56 * @param value The new value of this Local in the currently bound Session. 57 */ 58 public final void set (Object value) { 59 Blues.currentSession().setLocalValue(this, value); 60 } 61 62 /* (non-Javadoc) 63 * @see java.lang.Object#equals(java.lang.Object) 64 */ 65 public final boolean equals (Object obj) { 66 return super.equals(obj); 67 } 68 69 /* (non-Javadoc) 70 * @see java.lang.Object#hashCode() 71 */ 72 public final int hashCode () { 73 return super.hashCode(); 74 } 75 76 /*** 77 * Creates the inital value of this Local, returns null by 78 * default. 79 * 80 * @return The inital value of this Local. 81 */ 82 protected Object createValue () { 83 return null; 84 } 85 86 /*** 87 * Disposed the value of this local when the Session is disposed, 88 * does nothing by default. 89 * 90 * @param value The local value to dispose. 91 */ 92 protected void disposeValue (Object value) { 93 } 94 }

This page was automatically generated by Maven