EJB #Stateless + Seam #Scope(ScopeType.CONVERSATION) = #Stateful? - seam2

Im a new SEAM developer and for sure im really enjoying the platform.
im wondering wether a stateless session bean plus conversation scope has the same semantic by stateful session bean ?
the EJB Client in this context is the seam, right ? so using conversation scope, the ejb bean used by the client ( seam component ) will be the same during the conversation, this way the state will be preserved until the conversation finish.
is it correct ?

No. Stateless session beans always live in the stateless context.

I think Stateless session bean is always in Stateless scope, no way to set to Conversation scope.

Related

Spring bean RequestScope with Webflux

Is there a pattern to use #RequestScope with Webflux? We used the approach suggested here (https://www.baeldung.com/spring-bean-scopes) but it gives below error.
No scope registered for scope name request
Request scope works on ThreadLocal which is not supported by Webflux because part of work can be delegated between threads and you cannot assume that request will be handled by one thread.
In such a case, you should take a look at Reactor Context which allows you to connect data with the request scope.

preventing passivation is stateful session bean in glassfish 4

I have a stateful session bean that inject extended entity manager. When I deploy the application for some time, an exception occur indicating that extended Entity manager is not serialized. after some search I found that passivation of the bean might be the cause of this exception.
Is there a way to stop passivation in glassfish (I found that there is an issue but can't find a way)?
Is it right for container to try to serialize entity manager when passivating the sfsb?
Could there be another reason for this exception to occur?
Note: please don't ask about the code it is just a stateful bean with extended entity manager called by an application scope cdi bean.
You must set passivationCapable to false.
passivationCapable Specifies whether this stateful session bean is passivation capable
#Stateful(passivationCapable=false)
public class HelloBean {
private NonSerializableType ref = ...
. . .
}

What is tenant scope in Hybris?

I am very new to hybris e-commerce software and trying to learn with the help of wiki documents provided with it.
I see use of 'tenant' scope quite frequently. I know about other scopes like 'singleton', 'prototype' etc. But I am not very clear with the tenant scope.
appreciate if someone have a good understanding about this scope, and explain in simple terms.
Thanks.
The core-spring.xml file of the core extension adds a special scope named tenant to the global ApplicationContext. The tenant scope makes sure that the bean is instantiated individually for each individual tenant of the hybris, whereas singleton would create only one instance for all tenants to use.
If you reference tenant-specific classes like services or DAOs inside your implementation, you have to use the tenant scope instead of the default Spring singleton scope. In case of doubt, use tenant instead of singleton.
<bean id="myExtension.myBean" class="de.hybris.platform.myExtension.myClass" scope="tenant" />
Since version 5.0 of hybris Commerce Suite, tenant scope is no longer in use.
Check this for more details...
Hybris has 2 tenants by default- master tenant and junit tenant. You can create more tenants as required.
Each tenant has its own set of data...say item types.
When a bean is defined in a tenant scope, it means that, that bean would be instantiated once for each tenant. And the same bean object would be used throughout the tenant.
hybris can be run in a Multi-Tenant mode which multiple individual sets of data are maintained on one single hybris installation.
When a bean is defined with a tenant scope, it will only be instantiated individually for each tenant; whereas singleton would create only one instance for all tenants to use.

Use Conversation Scoped Beans in REST service

I'm running a CDI based application on JBoss AS 7.1.1 which uses Conversation Scoped Beans.
I need to invoke one of these beans from a RESTeasy Service. Unfortunately when I invoke the Conversation Scoped Bean
#Inject
private ConversationBean service;
#GET
#Produces("text/html")
#Path("/book")
public void bookTicket(Long l) {
service.book(l);
. . . .
}
the following error is returned:
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
Is there any workaround for this issue ?
Thanks!
I know I've answered this question before (or maybe it was #SessionScoped, same thing really). The Conversation is tied to a Session in CDI. As there are no Sessions in JAX-RS there are no conversations. In the spec section 6.7.4 it states that the Conversation scope is only active during JSF requests.
If you would like to create your own Scope and Context that acts like the conversation one and make it available to JAX-RS requests, that's certainly doable, but you'd have to have some location to store the scope and also associate it with a request.

Where is the session located ? in client browser or at the server side ? and why it is used in hibernate?

I know that the session is used for the database in Hibernate, but what is the task of the session in database?
Does anyone know about this?
Update:
Apologies, my links are to Java APIs (must have missed the nhibernate tag). Regardless, there will be more than one type of session for .NET also.
There will typically be more than one type of session:
The HttpSession is a server-side object:
Provides a way to identify a user
across more than one page request or
visit to a Web site and to store
information about that user.
The hibernate Session is also a server-side object:
The lifecycle of a Session is bounded
by the beginning and end of a logical
transaction. (Long transactions might
span several database transactions.)
The main function of the Session is to
offer create, read and delete
operations for instances of mapped
entity classes.
The session is server side, if by server side you mean as in the web application or client/server application sense.
It is an implementation of the Unit of Work pattern, and does stuff like keeping track of which entities that have been changed, caching of entities and making sure that a specific entity is represented by only one actual instance in the scope of the session.
The NHibernate docs describe ISession like this:
A single-threaded, short-lived object
representing a conversation between
the application and the persistent
store. Wraps an ADO.NET connection.
Factory for ITransaction. Holds a
mandatory (first-level) cache of
persistent objects, used when
navigating the object graph or looking
up objects by identifier.