http://mail-archives.apache.org/mod_mbox/tiles-dev/201202.mbox/%3C4F43A891.4090401%40nlebas.net%3E
git-svn-id: https://svn.apache.org/repos/asf/tiles/framework/trunk/tiles-request@1332134 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
index f74087e..ccec97b 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
@@ -69,11 +69,6 @@
return applicationContext;
}
- @Override
- public List<String> getAvailableScopes() {
- return getNativeScopes();
- }
-
/**
* Returns the application scope.
*
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/DefaultRequestWrapper.java b/tiles-request-api/src/main/java/org/apache/tiles/request/DefaultRequestWrapper.java
index 5208a49..a1ff9f1 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/DefaultRequestWrapper.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/DefaultRequestWrapper.java
@@ -125,11 +125,6 @@
}
/** {@inheritDoc} */
- public List<String> getNativeScopes() {
- return Collections.<String>emptyList();
- }
-
- /** {@inheritDoc} */
public List<String> getAvailableScopes() {
return context.getAvailableScopes();
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/DispatchRequestWrapper.java b/tiles-request-api/src/main/java/org/apache/tiles/request/DispatchRequestWrapper.java
index bbb25bd..e118f1f 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/DispatchRequestWrapper.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/DispatchRequestWrapper.java
@@ -79,11 +79,6 @@
}
/** {@inheritDoc} */
- public List<String> getNativeScopes() {
- return Collections.<String>emptyList();
- }
-
- /** {@inheritDoc} */
public List<String> getAvailableScopes() {
return context.getAvailableScopes();
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java b/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
index c5254a9..08e4a59 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
@@ -71,15 +71,6 @@
Map<String, Object> getContext(String scope);
/**
- * Returns the native scopes, i.e. scopes that are native to the
- * implementation of the request itself (request, session and application
- * for example).
- *
- * @return The native scopes.
- */
- List<String> getNativeScopes();
-
- /**
* Returns all available scopes, that are the ones returned by
* {@link #getNativeScopes()} plus derivative scopes (e.g. flash scope).
*
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
deleted file mode 100644
index 0cfdc29..0000000
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * $Id$
- *
- * 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.tiles.request.scope;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tiles.request.Request;
-import org.apache.tiles.request.RequestWrapper;
-
-/**
- * Resolves scopes and contexts by using reflection.
- * To expose a scope, add a <code>get<name_of_the_scope>Scope</code> without parameters
- * that returns a <code>Map<String, Object></code>.
- *
- * @version $Rev$ $Date$
- */
-public final class ReflectionContextResolver{
-
- /**
- * Maps a request class to all available scopes.
- */
- private Map<Class<? extends Request>, Set<String>> class2scopes =
- new HashMap<Class<? extends Request>, Set<String>>();
-
- public Map<String, Object> getContext(Request request, String scope) {
- String methodName = "get" + Character.toUpperCase(scope.charAt(0))
- + scope.substring(1) + "Scope";
- Method method;
- try {
- method = request.getClass().getMethod(methodName);
- } catch (NoSuchMethodException e) {
- if (request instanceof RequestWrapper) {
- RequestWrapper wrapper = (RequestWrapper) request;
- return getContext(wrapper.getWrappedRequest(), scope);
- }
- throw new IllegalArgumentException("No accessor method for '" + scope
- + "' scope.", e);
- }
- try {
- return (Map<String, Object>) method.invoke(request);
- } catch (IllegalAccessException e) {
- // Should not ever happen, since method is public.
- throw new IllegalArgumentException("No accessible method for '" + scope
- + "' scope.", e);
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException(
- "Exception during execution of accessor method for '"
- + scope + "' scope.", e);
- }
- }
-
- public String[] getAvailableScopes(Request r) {
- Request request = r;
- Set<String> scopes = new LinkedHashSet<String>();
- boolean finished = false;
- do {
- scopes.addAll(getSpecificScopeSet(request));
- if (request instanceof RequestWrapper) {
- request = ((RequestWrapper) request).getWrappedRequest();
- } else {
- finished = true;
- }
- } while(!finished);
- String[] retValue = new String[scopes.size()];
- return scopes.toArray(retValue);
- }
-
- /**
- * Returns the scopes for a single class. To be used in an iteration to get the scopes
- * of all the hierarchy of the request.
- *
- * @param request The request to analyze.
- * @return The scope set.
- */
- private Set<String> getSpecificScopeSet(Request request) {
- Set<String> scopes = class2scopes.get(request.getClass());
- if (scopes == null) {
- scopes = new LinkedHashSet<String>();
- for (String scopeName : request.getNativeScopes()) {
- scopes.add(scopeName);
- }
- class2scopes.put(request.getClass(), scopes);
- }
- return scopes;
- }
-}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/package-info.java b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/package-info.java
deleted file mode 100644
index 06bc270..0000000
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * $Id$
- *
- * 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.
- */
-/**
- * Classes to manipulate scopes containing attributes.
- */
-package org.apache.tiles.request.scope;
diff --git a/tiles-request-api/src/test/java/org/apache/tiles/request/DefaultRequestWrapperTest.java b/tiles-request-api/src/test/java/org/apache/tiles/request/DefaultRequestWrapperTest.java
index 58b7439..c768d4c 100644
--- a/tiles-request-api/src/test/java/org/apache/tiles/request/DefaultRequestWrapperTest.java
+++ b/tiles-request-api/src/test/java/org/apache/tiles/request/DefaultRequestWrapperTest.java
@@ -151,19 +151,6 @@
}
/**
- * Test method for {@link org.apache.tiles.request.DefaultRequestWrapper#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- Request wrappedRequest = createMockRequest();
-
- replay(wrappedRequest);
- RequestWrapper request = createRequestWrapper(wrappedRequest);
- assertTrue(0 == request.getNativeScopes().size());
- verify(wrappedRequest);
- }
-
- /**
* Test method for {@link org.apache.tiles.request.DefaultRequestWrapper#getAvailableScopes()}.
*/
@SuppressWarnings("unchecked")
diff --git a/tiles-request-freemarker/src/main/java/org/apache/tiles/request/freemarker/FreemarkerRequest.java b/tiles-request-freemarker/src/main/java/org/apache/tiles/request/freemarker/FreemarkerRequest.java
index 3f1d800..0303a56 100644
--- a/tiles-request-freemarker/src/main/java/org/apache/tiles/request/freemarker/FreemarkerRequest.java
+++ b/tiles-request-freemarker/src/main/java/org/apache/tiles/request/freemarker/FreemarkerRequest.java
@@ -121,7 +121,7 @@
}
@Override
- public List<String> getNativeScopes() {
+ public List<String> getAvailableScopes() {
return SCOPES;
}
diff --git a/tiles-request-freemarker/src/test/java/org/apache/tiles/request/freemarker/FreemarkerRequestTest.java b/tiles-request-freemarker/src/test/java/org/apache/tiles/request/freemarker/FreemarkerRequestTest.java
index 972456c..1d6497e 100644
--- a/tiles-request-freemarker/src/test/java/org/apache/tiles/request/freemarker/FreemarkerRequestTest.java
+++ b/tiles-request-freemarker/src/test/java/org/apache/tiles/request/freemarker/FreemarkerRequestTest.java
@@ -157,18 +157,6 @@
}
/**
- * Tests {@link FreemarkerRequest#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
- replay(enclosedRequest);
- context = new FreemarkerRequest(enclosedRequest, env);
- assertArrayEquals(new String[] {"page"}, context.getNativeScopes().toArray());
- verify(enclosedRequest);
- }
-
- /**
* Tests {@link FreemarkerRequest#getRequestLocale()}.
*/
@Test
diff --git a/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java b/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
index f3bb0ae..ab00ef3 100644
--- a/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
+++ b/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
@@ -112,7 +112,7 @@
}
@Override
- public List<String> getNativeScopes() {
+ public List<String> getAvailableScopes() {
return SCOPES;
}
diff --git a/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java b/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
index ea7e907..14c9a47 100644
--- a/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
+++ b/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
@@ -72,17 +72,6 @@
}
/**
- * Test method for {@link org.apache.tiles.request.jsp.JspRequest#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- replay(context, enclosedRequest);
- assertArrayEquals(new String[] { "page", "request", "session",
- "application" }, request.getNativeScopes().toArray());
- verify(context, enclosedRequest);
- }
-
- /**
* Test method for {@link org.apache.tiles.request.jsp.JspRequest#getWriter()}.
*/
@Test
diff --git a/tiles-request-portlet/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java b/tiles-request-portlet/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
index df92bce..fa13cc3 100644
--- a/tiles-request-portlet/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
+++ b/tiles-request-portlet/src/main/java/org/apache/tiles/request/portlet/PortletRequest.java
@@ -229,7 +229,7 @@
}
@Override
- public List<String> getNativeScopes() {
+ public List<String> getAvailableScopes() {
return SCOPES;
}
diff --git a/tiles-request-portlet/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java b/tiles-request-portlet/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java
index d0c953a..f9d2581 100644
--- a/tiles-request-portlet/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java
+++ b/tiles-request-portlet/src/test/java/org/apache/tiles/request/portlet/PortletRequestTest.java
@@ -310,15 +310,6 @@
}
/**
- * Test method for {@link org.apache.tiles.request.portlet.PortletRequest#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- assertArrayEquals(new String[] { "request", "portletSession",
- "session", "application" }, req.getNativeScopes().toArray());
- }
-
- /**
* Test method for {@link org.apache.tiles.request.portlet.PortletRequest#getOutputStream()}.
* @throws IOException If something goes wrong.
*/
diff --git a/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/ServletRequest.java b/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/ServletRequest.java
index ec64bfc..d03809a 100644
--- a/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/ServletRequest.java
+++ b/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/ServletRequest.java
@@ -216,7 +216,7 @@
}
@Override
- public List<String> getNativeScopes() {
+ public List<String> getAvailableScopes() {
return SCOPES;
}
diff --git a/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/ServletRequestTest.java b/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/ServletRequestTest.java
index 809de57..14b05cf 100644
--- a/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/ServletRequestTest.java
+++ b/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/ServletRequestTest.java
@@ -274,14 +274,6 @@
}
/**
- * Test method for {@link org.apache.tiles.request.servlet.ServletRequest#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- assertArrayEquals(new String[] {"request", "session", "application"}, req.getNativeScopes().toArray());
- }
-
- /**
* Test method for {@link org.apache.tiles.request.servlet.ServletRequest#getOutputStream()}.
* @throws IOException If something goes wrong.
*/
diff --git a/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/VelocityRequest.java b/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/VelocityRequest.java
index 05dd5a6..09a43e3 100644
--- a/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/VelocityRequest.java
+++ b/tiles-request-velocity/src/main/java/org/apache/tiles/request/velocity/VelocityRequest.java
@@ -103,7 +103,7 @@
}
@Override
- public List<String> getNativeScopes() {
+ public List<String> getAvailableScopes() {
return SCOPES;
}
diff --git a/tiles-request-velocity/src/test/java/org/apache/tiles/request/velocity/VelocityRequestTest.java b/tiles-request-velocity/src/test/java/org/apache/tiles/request/velocity/VelocityRequestTest.java
index 70d8fb8..3c63029 100644
--- a/tiles-request-velocity/src/test/java/org/apache/tiles/request/velocity/VelocityRequestTest.java
+++ b/tiles-request-velocity/src/test/java/org/apache/tiles/request/velocity/VelocityRequestTest.java
@@ -91,18 +91,6 @@
}
/**
- * Tests {@link FreemarkerRequest#getNativeScopes()}.
- */
- @Test
- public void testGetNativeScopes() {
- DispatchRequest enclosedRequest = createMock(DispatchRequest.class);
- replay(enclosedRequest);
- context = new VelocityRequest(enclosedRequest, velocityContext, writer);
- assertArrayEquals(new String[] {"page"}, context.getNativeScopes().toArray());
- verify(enclosedRequest);
- }
-
- /**
* Tests {@link VelocityRequest#doInclude(String)}.
*
* @throws IOException If something goes wrong.