[jboss-cvs] jboss-seam/src/main/org/jboss/seam/framework ...
Gavin King
gavin.king at jboss.com
Sat Jan 27 13:10:55 EST 2007
User: gavin
Date: 07/01/27 13:10:55
Modified: src/main/org/jboss/seam/framework Controller.java
EntityController.java EntityHome.java
HibernateEntityController.java
HibernateEntityHome.java Home.java Query.java
Added: src/main/org/jboss/seam/framework
MutableController.java
Log:
make Home and Query objects extend Controller
Revision Changes Path
1.3 +19 -2 jboss-seam/src/main/org/jboss/seam/framework/Controller.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Controller.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Controller.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Controller.java 27 Jan 2007 02:27:46 -0000 1.2
+++ Controller.java 27 Jan 2007 18:10:55 -0000 1.3
@@ -5,6 +5,8 @@
import javax.faces.context.FacesContext;
import org.hibernate.validator.ClassValidator;
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.contexts.Context;
import org.jboss.seam.contexts.Contexts;
@@ -21,7 +23,7 @@
import org.jboss.seam.log.Log;
/**
- * Superclass for controller objects. Provides various
+ * Base class for controller objects. Provides various
* helper methods that help slightly reduce the code
* required to create a Seam component that acts as
* a controller.
@@ -29,7 +31,7 @@
* @author Gavin King
*
*/
-public class Controller
+public abstract class Controller
{
@Logger Log log;
@@ -229,4 +231,19 @@
getEvents().raiseTransactionSuccessEvent(type, parameters);
}
+ protected Object getComponentInstance(String name)
+ {
+ return Component.getInstance(name);
+ }
+
+ protected Object getComponentInstance(Class clazz)
+ {
+ return Component.getInstance(clazz);
+ }
+
+ protected void invalidateSession()
+ {
+ Seam.invalidateSession();
+ }
+
}
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/framework/EntityController.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EntityController.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/EntityController.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- EntityController.java 27 Jan 2007 01:55:25 -0000 1.1
+++ EntityController.java 27 Jan 2007 18:10:55 -0000 1.2
@@ -7,7 +7,7 @@
import org.jboss.seam.Component;
/**
- * Superclass for controller objects that perform
+ * Base class for controller objects that perform
* persistence operations using JPA. Adds
* convenience methods for access to the JPA
* EntityManager.
1.14 +1 -1 jboss-seam/src/main/org/jboss/seam/framework/EntityHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EntityHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/EntityHome.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- EntityHome.java 27 Jan 2007 01:55:25 -0000 1.13
+++ EntityHome.java 27 Jan 2007 18:10:55 -0000 1.14
@@ -6,7 +6,7 @@
import org.jboss.seam.persistence.PersistenceProvider;
/**
- * A Home object for JPA.
+ * Base class for Home objects of JPA entities.
*
* @author Gavin King
*
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityController.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HibernateEntityController.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityController.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HibernateEntityController.java 27 Jan 2007 01:55:25 -0000 1.1
+++ HibernateEntityController.java 27 Jan 2007 18:10:55 -0000 1.2
@@ -12,7 +12,7 @@
import org.jboss.seam.Component;
/**
- * Superclass for controller objects that perform
+ * Base class for controller objects that perform
* persistence operations using Hibernate. Adds
* convenience methods for access to the Hibernate
* Session object.
1.11 +1 -1 jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HibernateEntityHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityHome.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- HibernateEntityHome.java 27 Jan 2007 01:55:25 -0000 1.10
+++ HibernateEntityHome.java 27 Jan 2007 18:10:55 -0000 1.11
@@ -6,7 +6,7 @@
import org.jboss.seam.annotations.Transactional;
/**
- * A Home object for Hibernate.
+ * Base class for Home objects for Hibernate entities.
*
* @author Gavin King
*
1.13 +6 -12 jboss-seam/src/main/org/jboss/seam/framework/Home.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Home.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Home.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- Home.java 27 Jan 2007 01:55:25 -0000 1.12
+++ Home.java 27 Jan 2007 18:10:55 -0000 1.13
@@ -2,21 +2,17 @@
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
-import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Transactional;
-import org.jboss.seam.core.AbstractMutable;
-import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.core.Expressions.ValueBinding;
/**
- * Superclass for components which provide persistence
+ * Base class for components which provide persistence
* operations to a managed entity instance. This class
* may be reused by either configuration or extension,
* and may be bound directly to a view, or accessed by
@@ -26,9 +22,10 @@
*
*/
@Scope(ScopeType.CONVERSATION)
-public class Home<E> extends AbstractMutable implements Serializable
+public abstract class Home<E> extends MutableController
{
private static final long serialVersionUID = -5462396456614090423L;
+
private Object id;
protected E instance;
private Class<E> entityClass;
@@ -38,22 +35,19 @@
private String createdMessage = "Successfully created";
private String updatedMessage = "Successfully updated";
- @In(create=true)
- private FacesMessages facesMessages;
-
protected void updatedMessage()
{
- facesMessages.addFromResourceBundle( SEVERITY_INFO, getUpdatedMessageKey(), getUpdatedMessage() );
+ getFacesMessages().addFromResourceBundle( SEVERITY_INFO, getUpdatedMessageKey(), getUpdatedMessage() );
}
protected void deletedMessage()
{
- facesMessages.addFromResourceBundle( SEVERITY_INFO, getDeletedMessageKey(), getDeletedMessage() );
+ getFacesMessages().addFromResourceBundle( SEVERITY_INFO, getDeletedMessageKey(), getDeletedMessage() );
}
protected void createdMessage()
{
- facesMessages.addFromResourceBundle( SEVERITY_INFO, getCreatedMessageKey(), getCreatedMessage() );
+ getFacesMessages().addFromResourceBundle( SEVERITY_INFO, getCreatedMessageKey(), getCreatedMessage() );
}
@Create
1.18 +3 -2 jboss-seam/src/main/org/jboss/seam/framework/Query.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Query.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Query.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- Query.java 27 Jan 2007 01:55:25 -0000 1.17
+++ Query.java 27 Jan 2007 18:10:55 -0000 1.18
@@ -1,5 +1,6 @@
package org.jboss.seam.framework;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -15,7 +16,7 @@
import org.jboss.seam.jsf.ListDataModel;
/**
- * Superclass for components which manage a query
+ * Base class for components which manage a query
* result set. This class may be reused by either
* configuration or extension, and may be bound
* directly to a view, or accessed by some
@@ -24,7 +25,7 @@
* @author Gavin King
*
*/
-public abstract class Query
+public abstract class Query extends Controller implements Serializable //TODO: extend MutableController!
{
private static final Pattern FROM_PATTERN = Pattern.compile("(^|\\s)(from)\\s", Pattern.CASE_INSENSITIVE);
private static final Pattern ORDER_PATTERN = Pattern.compile("\\s(order)(\\s)+by\\s", Pattern.CASE_INSENSITIVE);
1.1 date: 2007/01/27 18:10:55; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/framework/MutableController.java
Index: MutableController.java
===================================================================
package org.jboss.seam.framework;
import java.io.Serializable;
import org.jboss.seam.core.Mutable;
/**
* Base class for controllers which implement the
* Mutable interface.
*
* @author Gavin King
*
*/
public abstract class MutableController
extends Controller
implements Serializable, Mutable
{
//copy/paste from AbstractMutable
private transient boolean dirty;
public boolean clearDirty()
{
boolean result = dirty;
dirty = false;
return result;
}
/**
* Set the dirty flag if the value has changed.
* Call whenever a subclass attribute is updated.
*
* @param oldValue the old value of an attribute
* @param newValue the new value of an attribute
* @return true if the newValue is not equal to the oldValue
*/
protected <T> boolean setDirty(T oldValue, T newValue)
{
boolean attributeDirty = oldValue!=newValue && (
oldValue==null ||
!oldValue.equals(newValue)
);
dirty = dirty || attributeDirty;
return attributeDirty;
}
/**
* Set the dirty flag.
*/
protected void setDirty()
{
dirty = true;
}
}
More information about the jboss-cvs-commits
mailing list