Commits

mrdon  committed 16615a9

Finished removing external reference resolver
XW-434

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1212e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits fb3ee6e

Comments (0)

Files changed (6)

File src/java/com/opensymphony/xwork2/config/entities/ActionConfig.java

  */
 public class ActionConfig extends Located implements InterceptorListHolder, Parameterizable, Serializable {
 
-    protected List<ExternalReference> externalRefs;
     protected List<InterceptorMapping> interceptors;
     protected Map<String, Object> params;
     protected Map<String, ResultConfig> results;
         params = new LinkedHashMap<String, Object>();
         results = new LinkedHashMap<String, ResultConfig>();
         interceptors = new ArrayList<InterceptorMapping>();
-        externalRefs = new ArrayList<ExternalReference>();
         exceptionMappings = new ArrayList<ExceptionMappingConfig>();
     }
 
     }
 
     public ActionConfig(String methodName, String className, Map<String, Object> parameters, Map<String, ResultConfig> results, List<InterceptorMapping> interceptors, List<ExceptionMappingConfig> exceptionMappings) {
-        this(methodName, className, "", parameters, results, interceptors, Collections.EMPTY_LIST, exceptionMappings);
+        this(methodName, className, "", parameters, results, interceptors, exceptionMappings);
     }
 
-    public ActionConfig(String methodName, String className, String packageName, Map<String, Object> parameters, Map<String, ResultConfig> results, List<InterceptorMapping> interceptors, List<ExternalReference> externalRefs) {
-        this(methodName, className, packageName, parameters, results, interceptors, externalRefs, Collections.EMPTY_LIST);
+    public ActionConfig(String methodName, String className, String packageName, Map<String, Object> parameters, Map<String, ResultConfig> results, List<InterceptorMapping> interceptors) {
+        this(methodName, className, packageName, parameters, results, interceptors, Collections.EMPTY_LIST);
     }
 
     public ActionConfig(String methodName, String className, String packageName, Map<String, Object> parameters,
-                        Map<String, ResultConfig> results, List<InterceptorMapping> interceptors,
-                        List<ExternalReference> externalRefs, List<ExceptionMappingConfig> exceptionMappings) {
+                        Map<String, ResultConfig> results, List<InterceptorMapping> interceptors, List<ExceptionMappingConfig> exceptionMappings) {
         this.methodName = methodName;
         this.interceptors = interceptors;
         this.params = parameters;
         this.results = results;
         this.className = className;
-        this.externalRefs = externalRefs;
         this.exceptionMappings = exceptionMappings;
         this.packageName = packageName;
     }
         return className;
     }
 
-    public List<ExternalReference> getExternalRefs() {
-        return externalRefs;
-    }
-
     public List<ExceptionMappingConfig> getExceptionMappings() {
         return exceptionMappings;
     }
         return results;
     }
 
-    public void addExternalRef(ExternalReference reference) {
-        getExternalRefs().add(reference);
-    }
-
-    public void addExternalRefs(List<ExternalReference> refs) {
-        getExternalRefs().addAll(refs);
-    }
-
     public void addExceptionMapping(ExceptionMappingConfig exceptionMapping) {
         getExceptionMappings().add(exceptionMapping);
     }

File src/java/com/opensymphony/xwork2/config/entities/ExternalReference.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork2.config.entities;
-
-import java.io.Serializable;
-
-
-/**
- * Encapsulates an external reference in the xwork configuration.
- *
- * @author Ross
- * @author Rainer Hermanns
- */
-public class ExternalReference implements Serializable {
-
-    private String externalRef;
-    private String name;
-    private boolean required = true;
-
-
-    /**
-     * default constructor
-     */
-    public ExternalReference() {
-    }
-
-    /**
-     * @param name        the name of the attribute the external reference refers to
-     * @param externalRef the name used to query the external source
-     * @param required    determines whether an exception should be thrown if the reference is not resolved
-     */
-    public ExternalReference(String name, String externalRef, boolean required) {
-        this.name = name;
-        this.externalRef = externalRef;
-        this.required = required;
-    }
-
-
-    /**
-     * @param externalRef The externalRef to set.
-     */
-    public void setExternalRef(String externalRef) {
-        this.externalRef = externalRef;
-    }
-
-    /**
-     * @return Returns the externalRef.
-     */
-    public String getExternalRef() {
-        return externalRef;
-    }
-
-    /**
-     * @param name The name to set.
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * @return Returns the name.
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * @param required The required to set.
-     */
-    public void setRequired(boolean required) {
-        this.required = required;
-    }
-
-    /**
-     * @return Returns the required.
-     */
-    public boolean isRequired() {
-        return required;
-    }
-}

File src/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java

 import com.opensymphony.xwork2.util.WildcardHelper;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
-import com.opensymphony.xwork2.config.entities.ExternalReference;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
 
 import java.io.Serializable;
             exs.add(e);
         }
         
-        List<ExternalReference> refs = new ArrayList<ExternalReference>();
-        for (ExternalReference ex : orig.getExternalRefs()) {
-            String name = convertParam(ex.getName(), vars);
-            String refName = convertParam(ex.getExternalRef(), vars);
-            ExternalReference e = new ExternalReference(name, refName, ex.isRequired());
-            refs.add(e);
-        }
-        
-        
         ActionConfig config = new ActionConfig(methodName, className, pkgName, 
-                params, results, orig.getInterceptors(), refs, exs);
+                params, results, orig.getInterceptors(), exs);
         config.setLocation(orig.getLocation());
         
         return config;

File src/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java

             }
         }
 
-        List<ExternalReference> externalRefs = baseConfig.getExternalRefs();
-
         List<ExceptionMappingConfig> exceptionMappings = baseConfig.getExceptionMappings();
         exceptionMappings.addAll(packageContext.getAllExceptionMappingConfigs());
 
         ActionConfig config = new ActionConfig(baseConfig.getMethodName(), baseConfig.getClassName(), packageContext.getName(), params, results,
-                interceptors, externalRefs, exceptionMappings);
+                interceptors, exceptionMappings);
         config.setLocation(baseConfig.getLocation());
         return config;
     }

File src/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java

 
         List interceptorList = buildInterceptorList(actionElement, packageContext);
 
-        List externalrefs = buildExternalRefs(actionElement, packageContext);
-
         List exceptionMappings = buildExceptionMappings(actionElement, packageContext);
 
-        ActionConfig actionConfig = new ActionConfig(methodName, className, packageContext.getName(), actionParams, results, interceptorList, externalrefs,
+        ActionConfig actionConfig = new ActionConfig(methodName, className, packageContext.getName(), actionParams, results, interceptorList, 
                 exceptionMappings);
         actionConfig.setLocation(location);
         packageContext.addActionConfig(name, actionConfig);
         return null;
     }
 
-    protected List buildExternalRefs(Element element, PackageConfig context) throws ConfigurationException {
-        List refs = new ArrayList();
-        NodeList externalRefList = element.getElementsByTagName("external-ref");
-
-        String refName;
-        String refValue = null;
-        String requiredTemp;
-        boolean required;
-
-        for (int i = 0; i < externalRefList.getLength(); i++) {
-            Element refElement = (Element) externalRefList.item(i);
-
-            if (refElement.getParentNode().equals(element)) {
-                refName = refElement.getAttribute("name");
-
-                //If the external ref is not declared explicitly, we can introspect the
-                //reference type using it's name and try resolving the reference using it's class type
-                if (refElement.getChildNodes().getLength() > 0) {
-                    refValue = refElement.getChildNodes().item(0).getNodeValue();
-                }
-
-                requiredTemp = refElement.getAttribute("required");
-
-                if ((requiredTemp == null) || "".equals(requiredTemp)) {
-                    required = true;
-                } else {
-                    required = Boolean.valueOf(requiredTemp).booleanValue();
-                }
-
-                refs.add(new ExternalReference(refName, refValue, required));
-            }
-        }
-
-        return refs;
-    }
-
     protected List buildInterceptorList(Element element, PackageConfig context) throws ConfigurationException {
         List interceptorList = new ArrayList();
         NodeList interceptorRefList = element.getElementsByTagName("interceptor-ref");

File src/test/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java

 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
-import com.opensymphony.xwork2.config.entities.ExternalReference;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.ResultConfig;
 
         assertTrue("First param isn't correct", "class".equals(result.getParams().get("first")));
         assertTrue("Second param isn't correct", "method".equals(result.getParams().get("second")));
         
-        ExternalReference ref = m.getExternalRefs().get(0);
-        assertTrue("Wrong name", "fooclass".equals(ref.getName()));
-        assertTrue("Wrong ref", "barmethod".equals(ref.getExternalRef()));
-        assertTrue("Wrong required", ref.isRequired());
     }
 
     public void testCheckMultipleSubstitutions() {
         config.addExceptionMapping(new ExceptionMappingConfig(
                 "foo{1}", "java.lang.{2}Exception", "success{1}", new HashMap(params)));
         
-        config.addExternalRef(new ExternalReference("foo{1}", "bar{2}", true));
-        
         config.addInterceptor(new InterceptorMapping());
         
         config.addResultConfig(new ResultConfig("success{1}", "foo.{2}", new HashMap(params)));