Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 52616 invoked from network); 3 Feb 2009 21:38:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Feb 2009 21:38:38 -0000 Received: (qmail 69131 invoked by uid 500); 3 Feb 2009 21:38:37 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 69120 invoked by uid 500); 3 Feb 2009 21:38:37 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 69109 invoked by uid 99); 3 Feb 2009 21:38:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 13:38:37 -0800 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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 21:38:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4B5F3238898E; Tue, 3 Feb 2009 21:38:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r740461 - in /portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE: commons/src/java/org/apache/jetspeed/util/ components/page-manager/ components/prefs/ components/prefs/src/java/org/apache/jetspeed/prefs/impl/ src/webapp/WEB-INF/... Date: Tue, 03 Feb 2009 21:38:03 -0000 To: jetspeed-dev@portals.apache.org From: taylor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090203213805.4B5F3238898E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: taylor Date: Tue Feb 3 21:38:02 2009 New Revision: 740461 URL: http://svn.apache.org/viewvc?rev=740461&view=rev Log: Backport of preferences fix: when redeploying Jetspeed, the Java Preferences would hold on (via a static) to the old Preferences Spring component, not allowing the newly created Preferences Spring component to replace it. Fixed this by wrappering the Spring Preferences component and always intercepting calls to userRoot and systemRoot Added: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java (with props) portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesProviderWrapper.java (with props) Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/page-manager/project.xml portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/pom.xml portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/src/webapp/WEB-INF/assembly/prefs.xml Added: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java?rev=740461&view=auto ============================================================================== --- portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java (added) +++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java Tue Feb 3 21:38:02 2009 @@ -0,0 +1,234 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jetspeed.util; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Observable; +import java.util.Observer; +import java.util.prefs.BackingStoreException; +import java.util.prefs.NodeChangeListener; +import java.util.prefs.PreferenceChangeListener; +import java.util.prefs.Preferences; + +/** + * PreferencesRootWrapper is a lightweight wrapper around the Jetspeed persistent PreferencesImpl to allow + * restarting the Jetspeed Portal. + *

+ * As the (Sun) Java Preferences implementation only creates a PreferencesFactory instance *once* per JVM + * (as static final), reloading the Jetspeed Portal (using a new classloader) requires a wrapper solution + * to prevent ClassCastExceptions and/or out-of-sync kept proxies and caches. + *

+ *

+ * As a newly created Jetspeed Portal classloader can no longer cast a previous Preferences root to its + * own PreferencesImpl, a "trick" is used by also implementing the Observer interface (which is provided by + * the Java system classloader). The Observer interface is used because it is very lightweight and allows + * passing an Object instance through its update method. That update method is used to "inject" the newly + * created Preferences root instance. + *

+ * @author Ate Douma + * @version $Id$ + */ +public class PreferencesRootWrapper extends Preferences implements Observer +{ + private Preferences root; + + public String absolutePath() + { + return root.absolutePath(); + } + + public void addNodeChangeListener(NodeChangeListener ncl) + { + root.addNodeChangeListener(ncl); + } + + public void addPreferenceChangeListener(PreferenceChangeListener pcl) + { + root.addPreferenceChangeListener(pcl); + } + + public String[] childrenNames() throws BackingStoreException + { + return root.childrenNames(); + } + + public void clear() throws BackingStoreException + { + root.clear(); + } + + public boolean equals(Object obj) + { + return root.equals(obj); + } + + public void exportNode(OutputStream os) throws IOException, BackingStoreException + { + root.exportNode(os); + } + + public void exportSubtree(OutputStream os) throws IOException, BackingStoreException + { + root.exportSubtree(os); + } + + public void flush() throws BackingStoreException + { + root.flush(); + } + + public String get(String key, String def) + { + return root.get(key, def); + } + + public boolean getBoolean(String key, boolean def) + { + return root.getBoolean(key, def); + } + + public byte[] getByteArray(String key, byte[] def) + { + return root.getByteArray(key, def); + } + + public double getDouble(String key, double def) + { + return root.getDouble(key, def); + } + + public float getFloat(String key, float def) + { + return root.getFloat(key, def); + } + + public int getInt(String key, int def) + { + return root.getInt(key, def); + } + + public long getLong(String key, long def) + { + return root.getLong(key, def); + } + + public int hashCode() + { + return root.hashCode(); + } + + public boolean isUserNode() + { + return root.isUserNode(); + } + + public String[] keys() throws BackingStoreException + { + return root.keys(); + } + + public String name() + { + return root.name(); + } + + public Preferences node(String pathName) + { + return root.node(pathName); + } + + public boolean nodeExists(String pathName) throws BackingStoreException + { + return root.nodeExists(pathName); + } + + public Preferences parent() + { + return root.parent(); + } + + public void put(String key, String value) + { + root.put(key, value); + } + + public void putBoolean(String key, boolean value) + { + root.putBoolean(key, value); + } + + public void putByteArray(String key, byte[] value) + { + root.putByteArray(key, value); + } + + public void putDouble(String key, double value) + { + root.putDouble(key, value); + } + + public void putFloat(String key, float value) + { + root.putFloat(key, value); + } + + public void putInt(String key, int value) + { + root.putInt(key, value); + } + + public void putLong(String key, long value) + { + root.putLong(key, value); + } + + public void remove(String key) + { + root.remove(key); + } + + public void removeNode() throws BackingStoreException + { + root.removeNode(); + } + + public void removeNodeChangeListener(NodeChangeListener ncl) + { + root.removeNodeChangeListener(ncl); + } + + public void removePreferenceChangeListener(PreferenceChangeListener pcl) + { + root.removePreferenceChangeListener(pcl); + } + + public void sync() throws BackingStoreException + { + root.sync(); + } + + public String toString() + { + return root.toString(); + } + + public void update(Observable o, Object arg) + { + root = (Preferences)arg; + } +} Propchange: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java ------------------------------------------------------------------------------ svn:keywords = Id Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/page-manager/project.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/page-manager/project.xml?rev=740461&r1=740460&r2=740461&view=diff ============================================================================== --- portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/page-manager/project.xml (original) +++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/page-manager/project.xml Tue Feb 3 21:38:02 2009 @@ -90,6 +90,7 @@ **/PageManagerTestShared.java **/DirectoryXMLTransform.java + **/TestTransactions.java Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/pom.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/pom.xml?rev=740461&r1=740460&r2=740461&view=diff ============================================================================== --- portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/pom.xml (original) +++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.2-POSTRELEASE/components/prefs/pom.xml Tue Feb 3 21:38:02 2009 @@ -50,6 +50,11 @@ ${pom.groupId} jetspeed-rdbms + + ${pom.groupId} + jetspeed-commons + provided + - + JETSPEED-INF/ojb/prefs_repository.xml @@ -47,7 +48,10 @@ - + + + 1 --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org For additional commands, e-mail: jetspeed-dev-help@portals.apache.org