001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet;
016    
017    import java.io.Serializable;
018    
019    /**
020     * @author Igor Spasic
021     * @see    com.liferay.portal.kernel.util.TransientValue
022     */
023    public final class NonSerializableObjectHandler implements Serializable {
024    
025            public static Object getValue(Object value) {
026                    if (value instanceof NonSerializableObjectHandler) {
027                            NonSerializableObjectHandler nonSerializableObjectHandler =
028                                    (NonSerializableObjectHandler)value;
029    
030                            value = nonSerializableObjectHandler.getValue();
031                    }
032    
033                    return value;
034            }
035    
036            public NonSerializableObjectHandler(Object value) {
037                    while (value instanceof NonSerializableObjectHandler) {
038                            NonSerializableObjectHandler nonSerializableObjectHandler =
039                                    (NonSerializableObjectHandler)value;
040    
041                            value = nonSerializableObjectHandler.getValue();
042                    }
043    
044                    _value = value;
045            }
046    
047            public Object getValue() {
048                    return _value;
049            }
050    
051            private transient Object _value;
052    
053    }