[jboss-svn-commits] JBoss Portal SVN: r5386 - trunk/core/src/main/org/jboss/portal/core/controller
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Oct 9 20:30:29 EDT 2006
Author: julien at jboss.com
Date: 2006-10-09 20:30:26 -0400 (Mon, 09 Oct 2006)
New Revision: 5386
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
Log:
minor lifecycle improvement in ControllerCommand creation from within context
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java 2006-10-10 00:23:20 UTC (rev 5385)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java 2006-10-10 00:30:26 UTC (rev 5386)
@@ -78,7 +78,7 @@
*/
public abstract CommandInfo getInfo();
- public InvocationContext getContext()
+ public final InvocationContext getContext()
{
if (context == null)
{
@@ -87,13 +87,8 @@
return context;
}
- public void setContext(ControllerContext context)
+ public final ControllerContext getControllerContext()
{
- this.context = context;
- }
-
- public ControllerContext getControllerContext()
- {
return context;
}
@@ -108,19 +103,39 @@
}
/**
- * Setup state before invocation.
+ * Contextualize the command.
*/
- public void create() throws ControllerException
+ public final void createContext(ControllerContext context) throws ControllerException
{
+ this.context = context;
+
+ //
+ create();
}
/**
* Destroy state after invocation.
*/
- public void destroy()
+ public final void destroyContext()
{
+ try
+ {
+ destroy();
+ }
+ finally
+ {
+ this.context = null;
+ }
}
+ protected void create() throws ControllerException
+ {
+ }
+
+ protected void destroy()
+ {
+ }
+
/**
* Execute the command.
*/
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2006-10-10 00:23:20 UTC (rev 5385)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2006-10-10 00:30:26 UTC (rev 5386)
@@ -71,13 +71,10 @@
throw new IllegalArgumentException();
}
- //
- command.setContext(this);
+ // Contextualize
+ command.createContext(this);
//
- command.create();
-
- //
try
{
// Execute
@@ -93,10 +90,7 @@
finally
{
// Call destroy
- command.destroy();
-
- //
- command.setContext(null);
+ command.destroyContext();
}
}
More information about the jboss-svn-commits
mailing list