1 package org.apache.archiva.redback.struts2.interceptor;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import com.opensymphony.xwork2.ActionInvocation;
23 import org.springframework.context.annotation.Scope;
24 import org.springframework.stereotype.Controller;
26 import java.util.Stack;
31 @Controller( "simple" )
33 public class SimpleActionInvocationTracker
34 implements ActionInvocationTracker
39 private int historySize = 5;
41 private boolean backTrack;
43 private Stack<SavedActionInvocation> actionInvocationStack = new Stack<SavedActionInvocation>();
45 public void setHistorySize( int size )
47 this.historySize = size;
50 public int getHistorySize()
52 return this.historySize;
55 public int getHistoryCount()
57 return actionInvocationStack.size();
61 * returns the previous actioninvocation and dropping the current one
63 public SavedActionInvocation getPrevious()
65 if ( actionInvocationStack.size() > 1 )
67 // drop the current SavedActionInvocation
68 actionInvocationStack.pop();
69 return (SavedActionInvocation) actionInvocationStack.pop();
76 * return the current action invocation
78 public SavedActionInvocation getCurrent()
80 if ( actionInvocationStack.size() > 0 )
82 return (SavedActionInvocation) actionInvocationStack.pop();
89 * returns the actioninvocation at the specified index, preserving
90 * the actioninvocation list
92 public SavedActionInvocation getActionInvocationAt( int index )
94 if ( actionInvocationStack.size() >= index )
96 return (SavedActionInvocation) actionInvocationStack.get( index );
102 public void addActionInvocation( ActionInvocation invocation )
104 actionInvocationStack.push( new SavedActionInvocation( invocation ) );
106 // remove oldest action invocation
107 if ( actionInvocationStack.size() > historySize )
109 actionInvocationStack.remove( 0 );
113 public void setBackTrack()
118 public void unsetBackTrack()
123 public boolean isBackTracked()