Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerUtils.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerUtils.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerUtils.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerUtils.java Fri Dec 12 04:06:29 2008 @@ -1,57 +1,57 @@ -/* +/* * 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.page.impl; - -import java.util.Collection; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ojb.broker.util.collections.RemovalAwareCollection; -import org.apache.ojb.broker.util.collections.RemovalAwareList; - - -/** - * DatabasePageManagerUtils - * - * @author David Sean Taylor - * @version $Id: $ - */ -public class DatabasePageManagerUtils -{ - protected static Log log = LogFactory.getLog(DatabasePageManagerUtils.class); - - /** - * OJB 1.0.3 requires collections to be removal aware. - * Thus we can't seem to get away with just creating ArrayLists - * This issue on occurs when persisting newly create object collections - * When persisting objects retrieved with OJB, this issue does not occur - * - * @see JS2-590 - * @return - */ - public static final Collection createCollection() - { - return java.util.Collections.synchronizedCollection(new RemovalAwareCollection()); - } - - public static final List createList() - { - return java.util.Collections.synchronizedList(new RemovalAwareList()); - } - -} + * 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.page.impl; + +import java.util.Collection; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ojb.broker.util.collections.RemovalAwareCollection; +import org.apache.ojb.broker.util.collections.RemovalAwareList; + + +/** + * DatabasePageManagerUtils + * + * @author David Sean Taylor + * @version $Id: $ + */ +public class DatabasePageManagerUtils +{ + protected static Log log = LogFactory.getLog(DatabasePageManagerUtils.class); + + /** + * OJB 1.0.3 requires collections to be removal aware. + * Thus we can't seem to get away with just creating ArrayLists + * This issue on occurs when persisting newly create object collections + * When persisting objects retrieved with OJB, this issue does not occur + * + * @see JS2-590 + * @return + */ + public static final Collection createCollection() + { + return java.util.Collections.synchronizedCollection(new RemovalAwareCollection()); + } + + public static final List createList() + { + return java.util.Collections.synchronizedList(new RemovalAwareList()); + } + +} Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerUtils.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/TransactionedOperation.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/TransactionedOperation.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/TransactionedOperation.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/TransactionedOperation.java Fri Dec 12 04:06:29 2008 @@ -1,65 +1,65 @@ -/* +/* * 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.page.impl; - - -/** - * A transactioned operation is a single Page Manager DML operation that was applied - * to the OJB cache. Im finding that OJB is not properly synchronizing its cache - * upon rollback of database transactions. This code may not be needed in future - * versions of OJB which have fixed this bug. - * - * @author David Sean Taylor - * @version $Id: $ - */ -public class TransactionedOperation -{ - public static final int ADD_OPERATION = 0; - public static final int UPDATE_OPERATION = 1; - private String path; - private int transactionType; - - public TransactionedOperation(String path, int type) - { - this.path = path; - this.transactionType = type; - } - - - public String getPath() - { - return path; - } - - - public void setPath(String path) - { - this.path = path; - } - - - public int getTransactionType() - { - return transactionType; - } - - - public void setTransactionType(int transactionType) - { - this.transactionType = transactionType; - } + * 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.page.impl; + + +/** + * A transactioned operation is a single Page Manager DML operation that was applied + * to the OJB cache. Im finding that OJB is not properly synchronizing its cache + * upon rollback of database transactions. This code may not be needed in future + * versions of OJB which have fixed this bug. + * + * @author David Sean Taylor + * @version $Id: $ + */ +public class TransactionedOperation +{ + public static final int ADD_OPERATION = 0; + public static final int UPDATE_OPERATION = 1; + private String path; + private int transactionType; + + public TransactionedOperation(String path, int type) + { + this.path = path; + this.transactionType = type; + } + + + public String getPath() + { + return path; + } + + + public void setPath(String path) + { + this.path = path; + } + + + public int getTransactionType() + { + return transactionType; + } + + + public void setTransactionType(int transactionType) + { + this.transactionType = transactionType; + } } \ No newline at end of file Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/TransactionedOperation.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayDecisionMaker.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayDecisionMaker.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayDecisionMaker.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayDecisionMaker.java Fri Dec 12 04:06:29 2008 @@ -1,40 +1,40 @@ -/* +/* * 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.interceptors; - -import org.aopalliance.intercept.MethodInvocation; - -/** - * A interface which is akin to a gateway in BPMN notation. Concrete - * implementations can make a decision as to whether or not a method invocation - * should be replayed. - * - * @author a336317 - */ -public interface MethodReplayDecisionMaker -{ - /** - * - * @param invocation - * The MethodInvocation object - * @param exception - * Exception thrown on previous invocation attempt - * @return True if we should replay the method, false otherwise - */ - public boolean shouldReplay(MethodInvocation invocation, Exception exception); - -} + * 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.interceptors; + +import org.aopalliance.intercept.MethodInvocation; + +/** + * A interface which is akin to a gateway in BPMN notation. Concrete + * implementations can make a decision as to whether or not a method invocation + * should be replayed. + * + * @author a336317 + */ +public interface MethodReplayDecisionMaker +{ + /** + * + * @param invocation + * The MethodInvocation object + * @param exception + * Exception thrown on previous invocation attempt + * @return True if we should replay the method, false otherwise + */ + public boolean shouldReplay(MethodInvocation invocation, Exception exception); + +} Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayDecisionMaker.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayInterceptor.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayInterceptor.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayInterceptor.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayInterceptor.java Fri Dec 12 04:06:29 2008 @@ -1,179 +1,179 @@ -/* +/* * 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.interceptors; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Generic aspect that will attempt to replay a method invocation if one of a - * set of specified exceptions is thrown from its execution. - * - * @author a336317 - */ -public class MethodReplayInterceptor implements MethodInterceptor -{ - - /** Log reference */ - private Log log = LogFactory.getLog(MethodReplayInterceptor.class); - - /** Serialization version identifier */ - private static final long serialVersionUID = -1316279974504594833L; - - /** - * How many times we should attempt to retry the method invocation if it - * fails - */ - private int retryCount; - - /** How long we should wait before retrying - specified in milliseconds * */ - private int retryInterval; - - /** - * Object which decides whether or not a method invocation should be - * replayed - */ - private TransactionalMethodReplayDecisionMaker replayDecisionMaker; - - /** - * Encloses super.invoke() in a try/catch block, where the - * catch block contains additional retry logic. - */ - public Object invoke(MethodInvocation invocation) throws Throwable - { - // TODO Make this more elegant - this logic can be simpler - try - { - return invocation.proceed(); - } catch (Exception exp) - { - - // determine whether to retry or just throw the exception back up - if (!this.isReplayable(invocation, exp)) { throw exp; } - - // TODO should this be at level WARN/ERROR? - if (log.isDebugEnabled()) - { - log - .debug("Invocation for method [" - + invocation.getMethod().toString() - + "] failed. Will attempt to replay method invocation [" - + retryCount + "] times with an interval of [" - + retryInterval + "] milliseconds"); - } - - int retryCounter = 1; - Exception lastExp = null; - - while ((retryCounter < retryCount)) - { - - try - { - if (log.isDebugEnabled()) - { - log - .debug("Sleeping for [" - + retryInterval - + "] milliseconds before replaying invocation for method [" - + invocation.getMethod().toString() - + "]."); - } - Thread.sleep(this.retryInterval); - - if (log.isDebugEnabled()) - { - log.debug("Attempt invocation [" + retryCounter - + "] for method [" - + invocation.getMethod().toString() + "]."); - } - // returning from a finally block will discard the - // exception - return invocation.proceed(); - } catch (Exception exp2) - { - // determine whether to retry or just throw the exception - // back up - if (!this.isReplayable(invocation, exp)) { throw exp; } - - if (log.isDebugEnabled()) - { - log.debug("Attempt [" + retryCounter - + "] to replay invocation for method [" - + invocation.getMethod().toString() - + "] failed. [" + (retryCount - retryCounter) - + "] attempts left."); - } - - lastExp = exp2; - retryCounter++; - } - } - if (log.isDebugEnabled()) - { - log.debug("[" + retryCounter - + "] attempts to replay invocation for method [" - + invocation.getMethod().toString() - + "] failed. Throwing exception [" - + lastExp.getClass().getName() + "]"); - } - throw lastExp; - } - - } - - public int getRetryCount() - { - return retryCount; - } - - public void setRetryCount(int retryCount) - { - this.retryCount = retryCount; - } - - public int getRetryInterval() - { - return retryInterval; - } - - public void setRetryInterval(int retryInterval) - { - this.retryInterval = retryInterval; - } - - /** - * Determine if we should attempt to replay the method given that the - * previous invocation returned the passed exception. - * - * @param exp - * @return True if we should replay the method. - */ - private boolean isReplayable(MethodInvocation invocation, Exception exp) - { - return replayDecisionMaker.shouldReplay(invocation, exp); - } - - public void setReplayDecisionMaker( - TransactionalMethodReplayDecisionMaker replayDecisionMaker) - { - this.replayDecisionMaker = replayDecisionMaker; - } - -} + * 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.interceptors; + +import org.aopalliance.intercept.MethodInterceptor; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Generic aspect that will attempt to replay a method invocation if one of a + * set of specified exceptions is thrown from its execution. + * + * @author a336317 + */ +public class MethodReplayInterceptor implements MethodInterceptor +{ + + /** Log reference */ + private Log log = LogFactory.getLog(MethodReplayInterceptor.class); + + /** Serialization version identifier */ + private static final long serialVersionUID = -1316279974504594833L; + + /** + * How many times we should attempt to retry the method invocation if it + * fails + */ + private int retryCount; + + /** How long we should wait before retrying - specified in milliseconds * */ + private int retryInterval; + + /** + * Object which decides whether or not a method invocation should be + * replayed + */ + private TransactionalMethodReplayDecisionMaker replayDecisionMaker; + + /** + * Encloses super.invoke() in a try/catch block, where the + * catch block contains additional retry logic. + */ + public Object invoke(MethodInvocation invocation) throws Throwable + { + // TODO Make this more elegant - this logic can be simpler + try + { + return invocation.proceed(); + } catch (Exception exp) + { + + // determine whether to retry or just throw the exception back up + if (!this.isReplayable(invocation, exp)) { throw exp; } + + // TODO should this be at level WARN/ERROR? + if (log.isDebugEnabled()) + { + log + .debug("Invocation for method [" + + invocation.getMethod().toString() + + "] failed. Will attempt to replay method invocation [" + + retryCount + "] times with an interval of [" + + retryInterval + "] milliseconds"); + } + + int retryCounter = 1; + Exception lastExp = null; + + while ((retryCounter < retryCount)) + { + + try + { + if (log.isDebugEnabled()) + { + log + .debug("Sleeping for [" + + retryInterval + + "] milliseconds before replaying invocation for method [" + + invocation.getMethod().toString() + + "]."); + } + Thread.sleep(this.retryInterval); + + if (log.isDebugEnabled()) + { + log.debug("Attempt invocation [" + retryCounter + + "] for method [" + + invocation.getMethod().toString() + "]."); + } + // returning from a finally block will discard the + // exception + return invocation.proceed(); + } catch (Exception exp2) + { + // determine whether to retry or just throw the exception + // back up + if (!this.isReplayable(invocation, exp)) { throw exp; } + + if (log.isDebugEnabled()) + { + log.debug("Attempt [" + retryCounter + + "] to replay invocation for method [" + + invocation.getMethod().toString() + + "] failed. [" + (retryCount - retryCounter) + + "] attempts left."); + } + + lastExp = exp2; + retryCounter++; + } + } + if (log.isDebugEnabled()) + { + log.debug("[" + retryCounter + + "] attempts to replay invocation for method [" + + invocation.getMethod().toString() + + "] failed. Throwing exception [" + + lastExp.getClass().getName() + "]"); + } + throw lastExp; + } + + } + + public int getRetryCount() + { + return retryCount; + } + + public void setRetryCount(int retryCount) + { + this.retryCount = retryCount; + } + + public int getRetryInterval() + { + return retryInterval; + } + + public void setRetryInterval(int retryInterval) + { + this.retryInterval = retryInterval; + } + + /** + * Determine if we should attempt to replay the method given that the + * previous invocation returned the passed exception. + * + * @param exp + * @return True if we should replay the method. + */ + private boolean isReplayable(MethodInvocation invocation, Exception exp) + { + return replayDecisionMaker.shouldReplay(invocation, exp); + } + + public void setReplayDecisionMaker( + TransactionalMethodReplayDecisionMaker replayDecisionMaker) + { + this.replayDecisionMaker = replayDecisionMaker; + } + +} Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/MethodReplayInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java Fri Dec 12 04:06:29 2008 @@ -1,55 +1,55 @@ -/* +/* * 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.interceptors; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.jetspeed.page.impl.DatabasePageManagerCache; - -/** - * Aspect that will attempt to rollback cache entries upon Page Manager failures - * - * @author David Sean Taylor - */ -public class PageManagerInterceptor implements MethodInterceptor -{ - - /** Serialization version identifier */ - private static final long serialVersionUID = -1316279974504594833L; - - /** - * Encloses super.invoke() in a try/catch block, where the - * catch block contains additional retry logic. - */ - public Object invoke(MethodInvocation invocation) throws Throwable - { - try - { - return invocation.proceed(); - } - catch (Exception exp) - { - DatabasePageManagerCache.rollbackTransactions(); - throw exp; - } - finally - { - DatabasePageManagerCache.clearTransactions(); - } - } - -} + * 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.interceptors; + +import org.aopalliance.intercept.MethodInterceptor; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.jetspeed.page.impl.DatabasePageManagerCache; + +/** + * Aspect that will attempt to rollback cache entries upon Page Manager failures + * + * @author David Sean Taylor + */ +public class PageManagerInterceptor implements MethodInterceptor +{ + + /** Serialization version identifier */ + private static final long serialVersionUID = -1316279974504594833L; + + /** + * Encloses super.invoke() in a try/catch block, where the + * catch block contains additional retry logic. + */ + public Object invoke(MethodInvocation invocation) throws Throwable + { + try + { + return invocation.proceed(); + } + catch (Exception exp) + { + DatabasePageManagerCache.rollbackTransactions(); + throw exp; + } + finally + { + DatabasePageManagerCache.clearTransactions(); + } + } + +} Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/TransactionalMethodReplayDecisionMaker.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/TransactionalMethodReplayDecisionMaker.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/TransactionalMethodReplayDecisionMaker.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/TransactionalMethodReplayDecisionMaker.java Fri Dec 12 04:06:29 2008 @@ -1,98 +1,98 @@ -/* +/* * 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.interceptors; - -import java.sql.SQLException; -import java.util.StringTokenizer; - -import org.aopalliance.intercept.MethodInvocation; - -/** - * MethodReplayDecisionMaker intended for use with methods marked as - * transactional, where the decision to replay the method is based on the - * content of the underlying exception from the resource. - * - * @author a336317 - * @author a202225 - */ -public class TransactionalMethodReplayDecisionMaker implements - MethodReplayDecisionMaker -{ - - private int[] sqlErrorCodes; - - public boolean shouldReplay(MethodInvocation invocation, Exception exception) - { - SQLException sqlException = findSQLException(exception); - if (sqlException != null) - { - int errorCode = sqlException.getErrorCode(); - - if (errorCode != 0) { return isErrorCodeListed(errorCode); } - } - - return false; - } - - // Recursively search the exception tree looking for the first SQLException - protected SQLException findSQLException(Exception exception) - { - SQLException foundException = null; - if (exception != null) - { - if (exception instanceof SQLException) - { - foundException = (SQLException) exception; - } - else - { - // Look at the cause - Throwable throwable = exception.getCause(); - if (throwable != null && throwable instanceof Exception) - { - foundException = findSQLException((Exception) throwable); - } - } - } - - return foundException; - } - - public void setSqlErrorCodes(String sqlErrorCodesString) - { - StringTokenizer tokenizer = new StringTokenizer(sqlErrorCodesString, - ","); - - this.sqlErrorCodes = new int[tokenizer.countTokens()]; - - for (int i = 0; tokenizer.hasMoreTokens(); i++) - { - this.sqlErrorCodes[i] = new Integer(tokenizer.nextToken()) - .intValue(); - } - } - - private boolean isErrorCodeListed(int errorCode) - { - for (int i = 0; i < this.sqlErrorCodes.length; i++) - { - if (this.sqlErrorCodes[i] == errorCode) return true; - } - - return false; - } + * 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.interceptors; + +import java.sql.SQLException; +import java.util.StringTokenizer; + +import org.aopalliance.intercept.MethodInvocation; + +/** + * MethodReplayDecisionMaker intended for use with methods marked as + * transactional, where the decision to replay the method is based on the + * content of the underlying exception from the resource. + * + * @author a336317 + * @author a202225 + */ +public class TransactionalMethodReplayDecisionMaker implements + MethodReplayDecisionMaker +{ + + private int[] sqlErrorCodes; + + public boolean shouldReplay(MethodInvocation invocation, Exception exception) + { + SQLException sqlException = findSQLException(exception); + if (sqlException != null) + { + int errorCode = sqlException.getErrorCode(); + + if (errorCode != 0) { return isErrorCodeListed(errorCode); } + } + + return false; + } + + // Recursively search the exception tree looking for the first SQLException + protected SQLException findSQLException(Exception exception) + { + SQLException foundException = null; + if (exception != null) + { + if (exception instanceof SQLException) + { + foundException = (SQLException) exception; + } + else + { + // Look at the cause + Throwable throwable = exception.getCause(); + if (throwable != null && throwable instanceof Exception) + { + foundException = findSQLException((Exception) throwable); + } + } + } + + return foundException; + } + + public void setSqlErrorCodes(String sqlErrorCodesString) + { + StringTokenizer tokenizer = new StringTokenizer(sqlErrorCodesString, + ","); + + this.sqlErrorCodes = new int[tokenizer.countTokens()]; + + for (int i = 0; tokenizer.hasMoreTokens(); i++) + { + this.sqlErrorCodes[i] = new Integer(tokenizer.nextToken()) + .intValue(); + } + } + + private boolean isErrorCodeListed(int errorCode) + { + for (int i = 0; i < this.sqlErrorCodes.length; i++) + { + if (this.sqlErrorCodes[i] == errorCode) return true; + } + + return false; + } } \ No newline at end of file Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/TransactionalMethodReplayDecisionMaker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/DirectoryXMLTransform.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCreateUserHomePagesFromRoles.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCreateUserHomePagesFromRoles.java?rev=725977&r1=725976&r2=725977&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCreateUserHomePagesFromRoles.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCreateUserHomePagesFromRoles.java Fri Dec 12 04:06:29 2008 @@ -1,135 +1,135 @@ -/* +/* * 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.page; - -import java.util.HashSet; -import java.util.Set; - -import javax.security.auth.Subject; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.jetspeed.om.folder.Folder; -import org.apache.jetspeed.page.psml.CastorXmlPageManager; -import org.apache.jetspeed.test.JetspeedTestCase; - -/** - * TestSecureCastorXmlPageManager - * - * @author Randy Watler - * @version $Id$ - */ -public class TestCreateUserHomePagesFromRoles extends JetspeedTestCase implements PageManagerTestShared -{ - protected CastorXmlPageManager pageManager; - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - pageManager = Shared.makeCastorXMLPageManager(getBaseDir(), "pages", false, false); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown - */ - protected void tearDown() throws Exception - { - super.tearDown(); - Shared.shutdownCastorXMLPageManager(pageManager); - } - - /** - * Defines the testcase name for JUnit. - * - * @param name - * the testcase's name. - */ - public TestCreateUserHomePagesFromRoles( String name ) - { - super(name); - } - - /** - * Start the tests. - * - * @param args - * the arguments. Not used - */ - public static void main( String args[] ) - { - junit.awtui.TestRunner.main(new String[]{TestCreateUserHomePagesFromRoles.class.getName()}); - } - - /** - * Creates the test suite. - * - * @return a test suite (TestSuite) that includes all - * methods starting with "test" - */ - public static Test suite() - { - // All methods starting with "test" will be executed in the test suite. - return new TestSuite(TestCreateUserHomePagesFromRoles.class); - } - - - static final String FOLDER1 = Folder.ROLE_FOLDER + "role1"; - static final String FOLDER2 = Folder.ROLE_FOLDER + "role2"; - static final String FOLDER3 = Folder.ROLE_FOLDER + "role3"; - - static final String DEFAULT_PAGE = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "default-page.psml"; - static final String ROLE_PAGE_1 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role1-default-page.psml"; - static final String ROLE_PAGE_2 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role2-default-page.psml"; - static final String ROLE_PAGE_3 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role3-default-page.psml"; - static final String SUB_PAGE = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR + "default-page.psml"; - static final String SUB_LINK = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR + "apache_portals.link"; - - public void testCreateUserHomePagesFromRoles() throws Exception - { - assertTrue("folder1 failed to create", pageManager.folderExists(FOLDER1)); - assertTrue("folder2 failed to create", pageManager.folderExists(FOLDER2)); - assertTrue("folder3 failed to create", pageManager.folderExists(FOLDER3)); - - Set principals = new HashSet(); - - // create the role principals - principals.add(new TestRole("role1")); - principals.add(new TestRole("role2")); - principals.add(new TestRole("role3")); - - // create the user principal - principals.add(new TestUser("david")); - - // create the subject - Subject subject = new Subject(true, principals, new HashSet(), new HashSet()); - - pageManager.createUserHomePagesFromRoles(subject); - - assertTrue("failed to create default page", pageManager.pageExists(DEFAULT_PAGE)); - assertTrue("failed to create sub page", pageManager.pageExists(SUB_PAGE)); - assertTrue("failed to create sub link", pageManager.linkExists(SUB_LINK)); - } - -} + * 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.page; + +import java.util.HashSet; +import java.util.Set; + +import javax.security.auth.Subject; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.jetspeed.om.folder.Folder; +import org.apache.jetspeed.page.psml.CastorXmlPageManager; +import org.apache.jetspeed.test.JetspeedTestCase; + +/** + * TestSecureCastorXmlPageManager + * + * @author Randy Watler + * @version $Id$ + */ +public class TestCreateUserHomePagesFromRoles extends JetspeedTestCase implements PageManagerTestShared +{ + protected CastorXmlPageManager pageManager; + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + pageManager = Shared.makeCastorXMLPageManager(getBaseDir(), "pages", false, false); + } + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#tearDown + */ + protected void tearDown() throws Exception + { + super.tearDown(); + Shared.shutdownCastorXMLPageManager(pageManager); + } + + /** + * Defines the testcase name for JUnit. + * + * @param name + * the testcase's name. + */ + public TestCreateUserHomePagesFromRoles( String name ) + { + super(name); + } + + /** + * Start the tests. + * + * @param args + * the arguments. Not used + */ + public static void main( String args[] ) + { + junit.awtui.TestRunner.main(new String[]{TestCreateUserHomePagesFromRoles.class.getName()}); + } + + /** + * Creates the test suite. + * + * @return a test suite (TestSuite) that includes all + * methods starting with "test" + */ + public static Test suite() + { + // All methods starting with "test" will be executed in the test suite. + return new TestSuite(TestCreateUserHomePagesFromRoles.class); + } + + + static final String FOLDER1 = Folder.ROLE_FOLDER + "role1"; + static final String FOLDER2 = Folder.ROLE_FOLDER + "role2"; + static final String FOLDER3 = Folder.ROLE_FOLDER + "role3"; + + static final String DEFAULT_PAGE = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "default-page.psml"; + static final String ROLE_PAGE_1 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role1-default-page.psml"; + static final String ROLE_PAGE_2 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role2-default-page.psml"; + static final String ROLE_PAGE_3 = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "role3-default-page.psml"; + static final String SUB_PAGE = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR + "default-page.psml"; + static final String SUB_LINK = Folder.USER_FOLDER + "david" + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR + "apache_portals.link"; + + public void testCreateUserHomePagesFromRoles() throws Exception + { + assertTrue("folder1 failed to create", pageManager.folderExists(FOLDER1)); + assertTrue("folder2 failed to create", pageManager.folderExists(FOLDER2)); + assertTrue("folder3 failed to create", pageManager.folderExists(FOLDER3)); + + Set principals = new HashSet(); + + // create the role principals + principals.add(new TestRole("role1")); + principals.add(new TestRole("role2")); + principals.add(new TestRole("role3")); + + // create the user principal + principals.add(new TestUser("david")); + + // create the subject + Subject subject = new Subject(true, principals, new HashSet(), new HashSet()); + + pageManager.createUserHomePagesFromRoles(subject); + + assertTrue("failed to create default page", pageManager.pageExists(DEFAULT_PAGE)); + assertTrue("failed to create sub page", pageManager.pageExists(SUB_PAGE)); + assertTrue("failed to create sub link", pageManager.linkExists(SUB_LINK)); + } + +} Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCreateUserHomePagesFromRoles.java ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org For additional commands, e-mail: jetspeed-dev-help@portals.apache.org