Hi Gary,
you are right, but isn't this the duty of the IoC (like JSF). The "don't
call us, we call you" thing.
I don't like the idea to check all the time if my object references are
properly injected.
Maybe it could be handled by an aspect that checks if all properties are
correctly injected.
But this sounds not very smart to me. I'm just thinking about the
performance impact of putting my controller objects into the application
scope,
by a clear separation of data and service objects. For instance it will
minimize the reach size of the session objects, because the object tree
behind these managed-beans would not be so huge.
Ingo
Gary VanMatre schrieb:
>From: Ingo Düppe <[EMAIL PROTECTED]>
>
> Hi,
>
> I have a conceptional question. Within my application I define a
> managed-bean "registrationController" that gets a reference to a spring
> bean "registrationService" by the jsf property injection. The spring
> bean is stateless and is not serializable, so I need to define the
field
> reference in "registrationController" as transient. This prevents me
for
> getting NotSerializableException.
>
> But what happens if the session is reloaded, will jsf reinject the
> properties?
> Is there any recommended way how to deal with this.
>
> The obvious way to make the service bean serializable doesn't seem to
> work, because a whole data access layer is bound to the service bean.
>
> Or do I need to clearly separate. All managed-beans that have a
> reference to the service layer need to be scoped as application (or
> maybe as request) and only the value objects or entities are allowed to
> be stored in the session scope.
>
Instead of only using jsf property injections, you could obtain your
service object in the getter.
This might cover the case where the session fails-over.
public ServiceBean getService() {
if (service == null) {
FacesContext context = getFacesContext();
service = (ServiceBean)
context.getApplication().getVariableResolver().
resolveVariable(context, "registrationService");
}
return service;
}
> Regards,
> Ingo
>
Gary
>Here is an example of my configuration:
> <managed-bean>
> <managed-bean-name>registrationController</managed-bean-name>
>
><managed-bean-class>org.openuss.security.registration.RegistrationController</ma
>naged-bean-class>
> <managed-bean-scope>session</managed-bean-scope>
> <managed-property>
> <property-name>service</property-name>
> <value>#{registrationService}</value>
> </managed-property>
> </managed-bean>
>
>