View Javadoc

1   /*
2    * $Id: ActionContextImpl.java 471756 2006-11-06 15:01:43Z husted $
3    *
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
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  // Copyright 2006 Google Inc. All Rights Reserved.
22  
23  package org.apache.struts2.impl;
24  
25  import java.lang.reflect.Method;
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  import org.apache.struts2.spi.ActionContext;
30  import org.apache.struts2.spi.Result;
31  
32  import com.opensymphony.xwork2.ActionInvocation;
33  
34  public class ActionContextImpl implements ActionContext {
35  
36      final ActionInvocation invocation;
37  
38      public ActionContextImpl(ActionInvocation invocation) {
39          this.invocation = invocation;
40      }
41  
42      public Object getAction() {
43          return invocation.getAction();
44      }
45  
46      public Method getMethod() {
47          String methodName = invocation.getProxy().getMethod();
48          try {
49              return getAction().getClass().getMethod(methodName);
50          } catch (NoSuchMethodException e) {
51              throw new RuntimeException(e);
52          }
53      }
54  
55      public String getActionName() {
56          return invocation.getProxy().getActionName();
57      }
58  
59      public String getNamespacePath() {
60          return invocation.getProxy().getNamespace();
61      }
62  
63      // TODO: Do something with these.
64      List<Result> resultInterceptors = new ArrayList<Result>();
65  
66      public void addResultInterceptor(Result interceptor) {
67          resultInterceptors.add(interceptor);
68      }
69  
70      public Result getResult() {
71          // TODO
72          throw new UnsupportedOperationException();
73      }
74  
75      public ActionContext getPrevious() {
76          // TODO
77          throw new UnsupportedOperationException();
78      }
79  
80      public ActionContext getNext() {
81          // TODO
82          throw new UnsupportedOperationException();
83      }
84  }