Author: apetrelli
Date: Thu Feb 3 12:06:20 2011
New Revision: 1066790
URL: http://svn.apache.org/viewvc?rev=1066790&view=rev
Log:
TILESSB-38
Fixed tiles-request-jsp code style.
Added:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/package-info.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package-info.java
Removed:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package.html
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspUtil.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/ScopeExtractor.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractor.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspUtilTest.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/ScopeExtractorTest.java
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractorTest.java
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspRequest.java
Thu Feb 3 12:06:20 2011
@@ -47,6 +47,9 @@ import org.apache.tiles.request.servlet.
*/
public class JspRequest extends AbstractViewRequest {
+ /**
+ * The native available scopes.
+ */
private static final String[] SCOPES = {"page", "request", "session",
"application"};
/**
@@ -83,6 +86,13 @@ public class JspRequest extends Abstract
*/
private Map<String, Object> applicationScope = null;
+ /**
+ * Creates a JSP request.
+ *
+ * @param applicationContext The application context.
+ * @param pageContext The page context.
+ * @return A new JSP request.
+ */
public static JspRequest createServletJspRequest(ApplicationContext
applicationContext, PageContext pageContext) {
return new JspRequest(new ServletRequest(
applicationContext, (HttpServletRequest) pageContext
@@ -130,6 +140,11 @@ public class JspRequest extends Abstract
return pageContext.getOut();
}
+ /**
+ * Returns the page scope.
+ *
+ * @return The page scope.
+ */
public Map<String, Object> getPageScope() {
if ((pageScope == null) && (pageContext != null)) {
pageScope = new ScopeMap(new ScopeExtractor(pageContext,
@@ -138,6 +153,11 @@ public class JspRequest extends Abstract
return (pageScope);
}
+ /**
+ * Returns the request scope.
+ *
+ * @return The request scope.
+ */
public Map<String, Object> getRequestScope() {
if ((requestScope == null) && (pageContext != null)) {
requestScope = new ScopeMap(new ScopeExtractor(pageContext,
@@ -146,6 +166,11 @@ public class JspRequest extends Abstract
return (requestScope);
}
+ /**
+ * Returns the session scope.
+ *
+ * @return The session scope.
+ */
public Map<String, Object> getSessionScope() {
if ((sessionScope == null) && (pageContext != null)) {
sessionScope = new ScopeMap(new
SessionScopeExtractor(pageContext));
@@ -153,6 +178,11 @@ public class JspRequest extends Abstract
return (sessionScope);
}
+ /**
+ * Returns the application scope.
+ *
+ * @return The application scope.
+ */
public Map<String, Object> getApplicationScope() {
if ((applicationScope == null) && (pageContext != null)) {
applicationScope = new ScopeMap(new ScopeExtractor(pageContext,
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspUtil.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspUtil.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspUtil.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/JspUtil.java
Thu Feb 3 12:06:20 2011
@@ -1,3 +1,23 @@
+/*
+ * $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.jsp;
import javax.servlet.jsp.JspContext;
@@ -6,11 +26,27 @@ import javax.servlet.jsp.PageContext;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.util.ApplicationAccess;
+/**
+ * JSP utilities for JSP requests and related.
+ *
+ * @version $Rev$ $Date$
+ */
public final class JspUtil {
+ /**
+ * Constructor.
+ */
private JspUtil() {
}
+ /**
+ * Returns the application context. It must be
+ * first saved creating an {@link ApplicationContext} and using
+ * {@link
org.apache.tiles.request.util.ApplicationAccess#register(ApplicationContext)}.
+ *
+ * @param jspContext The JSP context.
+ * @return The application context.
+ */
public static ApplicationContext getApplicationContext(JspContext
jspContext) {
return (ApplicationContext) jspContext.getAttribute(
ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE,
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/ScopeExtractor.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/ScopeExtractor.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/ScopeExtractor.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/ScopeExtractor.java
Thu Feb 3 12:06:20 2011
@@ -1,3 +1,23 @@
+/*
+ * $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.jsp.extractor;
import java.util.Enumeration;
@@ -6,12 +26,29 @@ import javax.servlet.jsp.JspContext;
import org.apache.tiles.request.attribute.AttributeExtractor;
+/**
+ * Extracts attributes from a numbered scope from {@link JspContext}.
+ *
+ * @version $Rev$ $Date$
+ */
public class ScopeExtractor implements AttributeExtractor {
+ /**
+ * The JSP context.
+ */
private JspContext context;
+ /**
+ * The scope number to use.
+ */
private int scope;
+ /**
+ * Constructor.
+ *
+ * @param context The JSP context.
+ * @param scope The scope number.
+ */
public ScopeExtractor(JspContext context, int scope) {
this.context = context;
this.scope = scope;
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractor.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractor.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractor.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractor.java
Thu Feb 3 12:06:20 2011
@@ -1,3 +1,23 @@
+/*
+ * $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.jsp.extractor;
import java.util.Enumeration;
@@ -6,10 +26,23 @@ import javax.servlet.jsp.PageContext;
import org.apache.tiles.request.attribute.AttributeExtractor;
+/**
+ * Extracts attributes from session scope from {@link PageContext}.
+ *
+ * @version $Rev$ $Date$
+ */
public class SessionScopeExtractor implements AttributeExtractor {
+ /**
+ * The page context.
+ */
private PageContext context;
+ /**
+ * Constructor.
+ *
+ * @param context The page context.
+ */
public SessionScopeExtractor(PageContext context) {
this.context = context;
}
Added:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/package-info.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/package-info.java?rev=1066790&view=auto
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/package-info.java
(added)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/extractor/package-info.java
Thu Feb 3 12:06:20 2011
@@ -0,0 +1,24 @@
+/*
+ * $Id: package-info.java 1049711 2010-12-15 21:12:00Z apetrelli $
+ *
+ * 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.
+ */
+/**
+ * Extractors to get scopes from {@link javax.servlet.jsp.PageContext}.
+ */
+package org.apache.tiles.request.jsp.extractor;
Added:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package-info.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package-info.java?rev=1066790&view=auto
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package-info.java
(added)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/main/java/org/apache/tiles/request/jsp/package-info.java
Thu Feb 3 12:06:20 2011
@@ -0,0 +1,24 @@
+/*
+ * $Id: package-info.java 1049711 2010-12-15 21:12:00Z apetrelli $
+ *
+ * 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.
+ */
+/**
+ * Support of Tiles request in a JSP environment.
+ */
+package org.apache.tiles.request.jsp;
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspRequestTest.java
Thu Feb 3 12:06:20 2011
@@ -29,10 +29,19 @@ import org.junit.Test;
*/
public class JspRequestTest {
+ /**
+ * The enclosed request.
+ */
private Request enclosedRequest;
+ /**
+ * The page context.
+ */
private PageContext context;
+ /**
+ * The request to test.
+ */
private JspRequest request;
/**
@@ -114,7 +123,7 @@ public class JspRequestTest {
* @throws IOException If something goes wrong.
* @throws ServletException If something goes wrong.
*/
- @Test(expected=IOException.class)
+ @Test(expected = IOException.class)
public void testDoIncludeException() throws ServletException, IOException {
context.include("/my/path", false);
expectLastCall().andThrow(new ServletException());
@@ -125,7 +134,7 @@ public class JspRequestTest {
}
/**
- * Test method for {@link
org.apache.tiles.request.jsp.JspRequest#createServletJspRequest(org.apache.tiles.request.ApplicationContext,
javax.servlet.jsp.PageContext)}.
+ * Test method for {@link
JspRequest#createServletJspRequest(ApplicationContext, PageContext)}.
*/
@Test
public void testCreateServletJspRequest() {
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspUtilTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspUtilTest.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspUtilTest.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/JspUtilTest.java
Thu Feb 3 12:06:20 2011
@@ -1,5 +1,22 @@
-/**
+/*
+ * $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.jsp;
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/ScopeExtractorTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/ScopeExtractorTest.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/ScopeExtractorTest.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/ScopeExtractorTest.java
Thu Feb 3 12:06:20 2011
@@ -1,5 +1,22 @@
-/**
+/*
+ * $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.jsp.extractor;
@@ -21,8 +38,14 @@ import org.junit.Test;
*/
public class ScopeExtractorTest {
+ /**
+ * The JSP context.
+ */
private JspContext context;
+ /**
+ * The extractor to test.
+ */
private ScopeExtractor extractor;
/**
@@ -73,7 +96,7 @@ public class ScopeExtractorTest {
}
/**
- * Test method for {@link
org.apache.tiles.request.jsp.extractor.ScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+ * Test method for {@link ScopeExtractor#setValue(String, Object)}.
*/
@Test
public void testSetValue() {
Modified:
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractorTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractorTest.java?rev=1066790&r1=1066789&r2=1066790&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractorTest.java
(original)
+++
tiles/sandbox/trunk/tiles-request/tiles-request-jsp/src/test/java/org/apache/tiles/request/jsp/extractor/SessionScopeExtractorTest.java
Thu Feb 3 12:06:20 2011
@@ -1,5 +1,22 @@
-/**
+/*
+ * $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.jsp.extractor;
@@ -22,10 +39,19 @@ import org.junit.Test;
*/
public class SessionScopeExtractorTest {
+ /**
+ * The page context.
+ */
private PageContext context;
+ /**
+ * The session.
+ */
private HttpSession session;
+ /**
+ * The extracto to test.
+ */
private SessionScopeExtractor extractor;
/**
@@ -80,7 +106,7 @@ public class SessionScopeExtractorTest {
}
/**
- * Test method for {@link
org.apache.tiles.request.jsp.extractor.ScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+ * Test method for {@link ScopeExtractor#setValue(String, Object)}.
*/
@Test
public void testSetValue() {
@@ -130,7 +156,7 @@ public class SessionScopeExtractorTest {
}
/**
- * Test method for {@link
org.apache.tiles.request.jsp.extractor.ScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+ * Test method for {@link ScopeExtractor#setValue(String, Object)}.
*/
@Test
public void testSetValueNoSession() {