CVS: Tapestry/framework/src/net/sf/tapestry/engine ActionService.java,1.8,1.8.2.1 AbstractEngine.java,1.34.2.4,1.34.2.5 DirectService.java,1.7,1.7.2.1
Howard Lewis Ship <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine
In directory sc8-pr-cvs1:/tmp/cvs-serv29938/framework/src/net/sf/tapestry/engine
Modified Files:
Tag: hship-2-3
ActionService.java AbstractEngine.java DirectService.java
Log Message:
Revise statefulness checks in the action and direct services to be less intrusive.
Index: ActionService.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/ActionService.java,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -d -r1.8 -r1.8.2.1
*** ActionService.java 27 Nov 2002 17:58:51 -0000 1.8
--- ActionService.java 19 Dec 2002 12:27:00 -0000 1.8.2.1
***************
*** 31,34 ****
--- 31,50 ----
public class ActionService extends AbstractService
{
+ /**
+ * Encoded into URL if engine was stateful.
+ *
+ * @since 2.4
+ **/
+
+ private static final String STATEFUL_ON = "1";
+
+ /**
+ * Encoded into URL if engine was not stateful.
+ *
+ * @since 2.4
+ **/
+
+ private static final String STATEFUL_OFF = "0";
+
public Gesture buildGesture(IRequestCycle cycle, IComponent component, Object[] parameters)
{
***************
*** 36,49 ****
throw new IllegalArgumentException(Tapestry.getString("service-single-parameter", ACTION_SERVICE));
IPage componentPage = component.getPage();
IPage responsePage = cycle.getPage();
- int length = (componentPage == responsePage) ? 3 : 4;
! String[] serviceContext = new String[length];
int i = 0;
serviceContext[i++] = responsePage.getName();
! serviceContext[i++] = (String)parameters[0];
// Because of Block/InsertBlock, the component may not be on
--- 52,68 ----
throw new IllegalArgumentException(Tapestry.getString("service-single-parameter", ACTION_SERVICE));
+ String stateful = cycle.getEngine().isStateful() ? STATEFUL_ON : STATEFUL_OFF;
IPage componentPage = component.getPage();
IPage responsePage = cycle.getPage();
! boolean complex = (componentPage != responsePage);
!
! String[] serviceContext = new String[complex ? 5 : 4];
int i = 0;
+ serviceContext[i++] = stateful;
serviceContext[i++] = responsePage.getName();
! serviceContext[i++] = (String) parameters[0];
// Because of Block/InsertBlock, the component may not be on
***************
*** 51,55 ****
// allowances for this.
! if (componentPage != responsePage)
serviceContext[i++] = componentPage.getName();
--- 70,74 ----
// allowances for this.
! if (complex)
serviceContext[i++] = componentPage.getName();
***************
*** 71,86 ****
count = serviceContext.length;
! if (count != 3 && count != 4)
! throw new ApplicationRuntimeException(
! Tapestry.getString("AbstractEngine.action-context-parameters"));
int i = 0;
String pageName = serviceContext[i++];
String targetActionId = serviceContext[i++];
! if (count == 3)
! componentPageName = pageName;
! else
componentPageName = serviceContext[i++];
String targetIdPath = serviceContext[i++];
--- 90,107 ----
count = serviceContext.length;
! if (count != 4 && count != 5)
! throw new ApplicationRuntimeException(Tapestry.getString("ActionService.context-parameters"));
!
! boolean complex = count == 5;
int i = 0;
+ String stateful = serviceContext[i++];
String pageName = serviceContext[i++];
String targetActionId = serviceContext[i++];
! if (complex)
componentPageName = serviceContext[i++];
+ else
+ componentPageName = pageName;
String targetIdPath = serviceContext[i++];
***************
*** 98,107 ****
{
throw new RequestCycleException(
! Tapestry.getString("AbstractEngine.action-component-wrong-type", component.getExtendedId()),
component,
ex);
}
! if (action.getRequiresSession())
{
HttpSession session = cycle.getRequestContext().getSession();
--- 119,131 ----
{
throw new RequestCycleException(
! Tapestry.getString("ActionService.component-wrong-type", component.getExtendedId()),
component,
ex);
}
! // Only perform the stateful check if the application was stateful
! // when the URL was rendered.
!
! if (stateful.equals(STATEFUL_ON) && action.getRequiresSession())
{
HttpSession session = cycle.getRequestContext().getSession();
Index: AbstractEngine.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/AbstractEngine.java,v
retrieving revision 1.34.2.4
retrieving revision 1.34.2.5
diff -C2 -d -r1.34.2.4 -r1.34.2.5
*** AbstractEngine.java 16 Dec 2002 12:56:34 -0000 1.34.2.4
--- AbstractEngine.java 19 Dec 2002 12:27:00 -0000 1.34.2.5
***************
*** 1397,1402 ****
* Invoked to lazily create a new visit object when it is first
* referenced (by {@link #getVisit(IRequestCycle)}). This implementation works
! * by looking up the name of the class
! * in the application specification.
*
* <p>Subclasses may want to overide this method if some other means
--- 1397,1402 ----
* Invoked to lazily create a new visit object when it is first
* referenced (by {@link #getVisit(IRequestCycle)}). This implementation works
! * by looking up the name of the class to instantiate
! * in the {@link #getPropertySource() configuration}.
*
* <p>Subclasses may want to overide this method if some other means
***************
*** 1410,1414 ****
Object result = null;
! visitClassName = _specification.getProperty(VISIT_CLASS_PROPERTY_NAME);
if (visitClassName == null)
throw new ApplicationRuntimeException(
--- 1410,1414 ----
Object result = null;
! visitClassName = _propertySource.getPropertyValue(VISIT_CLASS_PROPERTY_NAME);
if (visitClassName == null)
throw new ApplicationRuntimeException(
Index: DirectService.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/DirectService.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** DirectService.java 27 Nov 2002 17:58:51 -0000 1.7
--- DirectService.java 19 Dec 2002 12:27:00 -0000 1.7.2.1
***************
*** 31,38 ****
public class DirectService extends AbstractService
{
public Gesture buildGesture(IRequestCycle cycle, IComponent component, Object[] parameters)
{
- String[] context;
// New since 1.0.1, we use the component to determine
--- 31,52 ----
public class DirectService extends AbstractService
{
+ /**
+ * Encoded into URL if engine was stateful.
+ *
+ * @since 2.4
+ **/
+
+ private static final String STATEFUL_ON = "1";
+
+ /**
+ * Encoded into URL if engine was not stateful.
+ *
+ * @since 2.4
+ **/
+
+ private static final String STATEFUL_OFF = "0";
public Gesture buildGesture(IRequestCycle cycle, IComponent component, Object[] parameters)
{
// New since 1.0.1, we use the component to determine
***************
*** 48,64 ****
IPage componentPage = component.getPage();
! if (renderPage == componentPage)
! {
! context = new String[2];
! context[0] = componentPage.getName();
! context[1] = component.getIdPath();
! }
! else
! {
! context = new String[3];
! context[0] = renderPage.getName();
! context[1] = componentPage.getName();
! context[2] = component.getIdPath();
! }
return assembleGesture(cycle, DIRECT_SERVICE, context, parameters, true);
--- 62,80 ----
IPage componentPage = component.getPage();
! boolean complex = renderPage != componentPage;
!
! String[] context = complex ? new String[4] : new String[3];
!
! int i = 0;
!
! String stateful = cycle.getEngine().isStateful() ? STATEFUL_ON : STATEFUL_OFF;
!
! context[i++] = stateful;
!
! if (complex)
! context[i++] = renderPage.getName();
!
! context[i++] = componentPage.getName();
! context[i++] = component.getIdPath();
return assembleGesture(cycle, DIRECT_SERVICE, context, parameters, true);
***************
*** 78,92 ****
count = serviceContext.length;
! if (count != 2 && count != 3)
! throw new ApplicationRuntimeException(
! Tapestry.getString("AbstractEngine.direct-context-parameters"));
int i = 0;
String pageName = serviceContext[i++];
! if (count == 2)
! componentPageName = pageName;
! else
componentPageName = serviceContext[i++];
String componentPath = serviceContext[i++];
--- 94,110 ----
count = serviceContext.length;
! if (count != 3 && count != 4)
! throw new ApplicationRuntimeException(Tapestry.getString("DirectService.context-parameters"));
!
! boolean complex = count == 4;
int i = 0;
+ String stateful = serviceContext[i++];
String pageName = serviceContext[i++];
! if (complex)
componentPageName = serviceContext[i++];
+ else
+ componentPageName = pageName;
String componentPath = serviceContext[i++];
***************
*** 104,111 ****
cycle.setPage(page);
! if (count == 2)
! componentPage = page;
! else
componentPage = cycle.getPage(componentPageName);
IComponent component = componentPage.getNestedComponent(componentPath);
--- 122,129 ----
cycle.setPage(page);
! if (complex)
componentPage = cycle.getPage(componentPageName);
+ else
+ componentPage = page;
IComponent component = componentPage.getNestedComponent(componentPath);
***************
*** 118,127 ****
{
throw new RequestCycleException(
! Tapestry.getString("AbstractEngine.direct-component-wrong-type", component.getExtendedId()),
component,
ex);
}
! if (direct.isStateful())
{
HttpSession session = cycle.getRequestContext().getSession();
--- 136,148 ----
{
throw new RequestCycleException(
! Tapestry.getString("DirectService.component-wrong-type", component.getExtendedId()),
component,
ex);
}
! // Check for a StateSession only the session was stateful when
! // the Gesture was created.
!
! if (stateful.equals(STATEFUL_ON) && direct.isStateful())
{
HttpSession session = cycle.getRequestContext().getSession();
***************
*** 129,136 ****
if (session == null || session.isNew())
throw new StaleSessionException(
! Tapestry.getString("DirectService.stale-session-exception", direct.getExtendedId()),
! direct.getPage());
}
-
Object[] parameters = getParameters(cycle);
--- 150,156 ----
if (session == null || session.isNew())
throw new StaleSessionException(
! Tapestry.getString("DirectService.stale-session-exception", direct.getExtendedId()),
! direct.getPage());
}
Object[] parameters = getParameters(cycle);
-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now! Before the Holidays pass you by.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/