[
http://jira.jboss.com/jira/browse/JBSEAM-2219?page=all ]
Wolfgang Schwendt updated JBSEAM-2219:
--------------------------------------
Description:
The EJB programming model requires that a Session Bean never passes a
"this"-pointer to other client objects. Instead,
javax.ejb.SessionContext provides a method getBusinessObject(). If a SessionBean wants
to pass a reference pointing to itself to other clients, it first has to retrieve its own
EJB object reference by calling SessionContext.getBusinessObject() which it then can pass
to other beans. This reference returned by
javax.ejb.SessionContext.getBusinessObject() is the equivalent to Java's this pointer.
With respect to Seam's interceptor framework, such a feature is missing as far normal
JavaBean components are concerned. It leads to subtle programming errors:
Consider the implementation of org.jboss.seam.framework.Query. getDataModel():
/**
* Wrap the result set in a JSF {@link DataModel}
*
* Delegates to {@link DataModels#getDataModel(Query)}
*
*/
@Transactional
public DataModel getDataModel()
{
if (dataModel==null)
{
dataModel = DataModels.instance().getDataModel(this);
}
return dataModel;
}
This method method passes a "this"-reference to the
org.jboss.seam.faces.dataModels Seam-component.
But this can lead to a behavior not expected by the programmer. If the
(Entity)Query-component gets instantiated as a conversation-scoped component, Seam wraps
the ManagedEntityIdentityInterceptor around this component.
After each method invocation, that is intercepted by the
ManagedEntityIdentityInterceptor, the ManagedEntityIdentityInterceptor saves wrappers for
all contained Entity references in the conversation context and sets the corresponding
reference fields in the Seam component to null.
Now, consider again above implementation of Query.getDataModel(). Because a
"this" pointer is passed to the dataModels-component, any callback conducted by
the datamodel-component won't be routed through the ManagedEntityIdentity
interceptor.
This leads to a bug as described in JBSEAM-1814. In order to fix that bug, we would have
to change the implementation of Query. getDataModel(). Rather than passing a this
pointer to the dataModels component, the correct implementation would be as follows: ...
was:
The EJB programming model requires that a Session Bean never passes a
"this"-pointer to other client objects. Instead,
javax.ejb.SessionContext provides a method getBusinessObject(). If a SessionBean wants
to pass a reference pointing to itself to other clients, it first has to retrieve its own
EJB object reference by calling SessionContext.getBusinessObject() which it then can pass
to other beans. This reference returned by
javax.ejb.SessionContext.getBusinessObject() is the equivalent to Java's this pointer.
With respect to Seam's interceptor framework, such a feature is missing as far normal
JavaBean components are concerned. It leads to subtle programming errors:
Consider the implementation of org.jboss.seam.framework.Query. getDataModel():
/**
* Wrap the result set in a JSF {@link DataModel}
*
* Delegates to {@link DataModels#getDataModel(Query)}
*
*/
@Transactional
public DataModel getDataModel()
{
if (dataModel==null)
{
dataModel = DataModels.instance().getDataModel(this);
}
return dataModel;
}
This method method passes a "this"-reference to the
org.jboss.seam.faces.dataModels Seam-component.
But this can lead to a behavior not expected by the programmer. ...
[To be completed, more editing follows]
Introduce way to retrieve proxy object of a Seam JavaBean Component
-------------------------------------------------------------------
Key: JBSEAM-2219
URL:
http://jira.jboss.com/jira/browse/JBSEAM-2219
Project: JBoss Seam
Issue Type: Feature Request
Reporter: Wolfgang Schwendt
The EJB programming model requires that a Session Bean never passes a
"this"-pointer to other client objects. Instead,
javax.ejb.SessionContext provides a method getBusinessObject(). If a SessionBean wants
to pass a reference pointing to itself to other clients, it first has to retrieve its own
EJB object reference by calling SessionContext.getBusinessObject() which it then can pass
to other beans. This reference returned by
javax.ejb.SessionContext.getBusinessObject() is the equivalent to Java's this pointer.
With respect to Seam's interceptor framework, such a feature is missing as far normal
JavaBean components are concerned. It leads to subtle programming errors:
Consider the implementation of org.jboss.seam.framework.Query. getDataModel():
/**
* Wrap the result set in a JSF {@link DataModel}
*
* Delegates to {@link DataModels#getDataModel(Query)}
*
*/
@Transactional
public DataModel getDataModel()
{
if (dataModel==null)
{
dataModel = DataModels.instance().getDataModel(this);
}
return dataModel;
}
This method method passes a "this"-reference to the
org.jboss.seam.faces.dataModels Seam-component.
But this can lead to a behavior not expected by the programmer. If the
(Entity)Query-component gets instantiated as a conversation-scoped component, Seam wraps
the ManagedEntityIdentityInterceptor around this component.
After each method invocation, that is intercepted by the
ManagedEntityIdentityInterceptor, the ManagedEntityIdentityInterceptor saves wrappers for
all contained Entity references in the conversation context and sets the corresponding
reference fields in the Seam component to null.
Now, consider again above implementation of Query.getDataModel(). Because a
"this" pointer is passed to the dataModels-component, any callback conducted by
the datamodel-component won't be routed through the ManagedEntityIdentity
interceptor.
This leads to a bug as described in JBSEAM-1814. In order to fix that bug, we would
have to change the implementation of Query. getDataModel(). Rather than passing a this
pointer to the dataModels component, the correct implementation would be as follows: ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira