RE: [JBoss-user] share stateful session beans

2003-12-05 Thread Yates, Danny
An EJB is just a Java class which obeys certain rules and runs in a
specific environment (i.e. the container). It is free to create an
instance of any other Java class it wishes (with certain exceptions,
such as Thread and ServerSocket). So you implement your own cache
class:

class MyCache {
  private static MyCache instance = new MyCache();
  private Map cache = new HashMap();

  private MyCache() {}

  public static MyCache getInstance() {return instance;}

  public synchronized void put(Object key, Object value) {
cache.put(key, value);
  }

  public synchronized Object get(Object key) {
return cache.get(key);
  }
}

This allows you to make your key and value type-specific if desired,
or you could just wrap a Map in a SynchronizedMap, or something.

Then, each bean instance retrieves a cache instance using
MyCache.getInstance(), and performs operations.

This is a classic (non-lazy) Singleton pattern. Note the addition of
synchronization to project against simultaneous access from multiple
bean instances (or, rather, multiple client threads). Whilst
synchronization is outlawed in the EJB spec, the reason is to
prevent objects from locking for extended periods of time. The kind
of synchronization here (for short-running, atomic operations) is
fine.

However, I note that you ask about clustering. If you apply this
pattern to a clustered environment, you will get multiple cache
instances per JVM.

Dan.

-- 
Danny Yates
 


-Original Message-
From: Pedro Salazar [mailto:[EMAIL PROTECTED] 
Sent: 04 December 2003 17:17
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] share stateful session beans


On Thu, 2003-12-04 at 16:29, Yates, Danny wrote:
 A Stateful Session Bean is specifically intended to have one instance
 allocated to each client.
 
 Your best option is to use a Stateless Session Bean, which provides the
 interface, and have it delegate to a POJO which maintains the state and
 is created using some variation of the Singleton pattern.
 
 -- 
 Danny Yates
  

Could you explain me better the theory of POJO inside stateless session
beans? I think I know what is intended to do, but I don't know how to
implement it.

A little example would be more than enough...

regards,
Pedro Salazar.
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Notice to recipient:
The information in this internet e-mail and any attachments is confidential
and may be privileged. It is intended solely for the addressee. If you are
not the intended addressee please notify the sender immediately by
telephone. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it,
is prohibited and may be unlawful.
When addressed to external clients any opinions or advice contained in this
internet e-mail are subject to the terms and conditions expressed in any
applicable governing terms of business or client engagement letter issued by
the pertinent Bank of America group entity.
If this email originates from the U.K. please note that Bank of America,
N.A., London Branch, Banc of America Securities Limited and Banc of America
Futures Incorporated are regulated by the Financial Services Authority.


---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] share stateful session beans

2003-12-04 Thread Pedro Salazar
Greetings,

I wonder if there is a way to share information in a stateful session
bean (which is not intended to persist for life rather just for the life
time of the application server) between several clients. When I say
several clients I mean I have a web service, a servlet, a ejb, or any
other access point, and I would like to access to the stateful bean from
there.

My problem is how to share the bean when the contexts are different and
heterogeneous - shouldn't exist a find method for a stateful session
bean?

I use at the moment a entity bean but it has some problems:
-slow (stores the information in the database)
-if database connection fails (for a db restart), my system blocks - and
it shouldn't.

thanks.

regards,
Pedro Salazar.
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


RE: [JBoss-user] share stateful session beans

2003-12-04 Thread Yates, Danny
A Stateful Session Bean is specifically intended to have one instance
allocated to each client.

Your best option is to use a Stateless Session Bean, which provides the
interface, and have it delegate to a POJO which maintains the state and
is created using some variation of the Singleton pattern.

-- 
Danny Yates
 


-Original Message-
From: Pedro Salazar [mailto:[EMAIL PROTECTED] 
Sent: 04 December 2003 16:21
To: [EMAIL PROTECTED]
Subject: [JBoss-user] share stateful session beans


Greetings,

I wonder if there is a way to share information in a stateful session
bean (which is not intended to persist for life rather just for the life
time of the application server) between several clients. When I say
several clients I mean I have a web service, a servlet, a ejb, or any
other access point, and I would like to access to the stateful bean from
there.

My problem is how to share the bean when the contexts are different and
heterogeneous - shouldn't exist a find method for a stateful session
bean?

I use at the moment a entity bean but it has some problems:
-slow (stores the information in the database)
-if database connection fails (for a db restart), my system blocks - and
it shouldn't.

thanks.

regards,
Pedro Salazar.
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Notice to recipient:
The information in this internet e-mail and any attachments is confidential
and may be privileged. It is intended solely for the addressee. If you are
not the intended addressee please notify the sender immediately by
telephone. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it,
is prohibited and may be unlawful.
When addressed to external clients any opinions or advice contained in this
internet e-mail are subject to the terms and conditions expressed in any
applicable governing terms of business or client engagement letter issued by
the pertinent Bank of America group entity.
If this email originates from the U.K. please note that Bank of America,
N.A., London Branch, Banc of America Securities Limited and Banc of America
Futures Incorporated are regulated by the Financial Services Authority.


---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


RE: [JBoss-user] share stateful session beans

2003-12-04 Thread Pedro Salazar
On Thu, 2003-12-04 at 16:29, Yates, Danny wrote:
 A Stateful Session Bean is specifically intended to have one instance
 allocated to each client.
 
 Your best option is to use a Stateless Session Bean, which provides the
 interface, and have it delegate to a POJO which maintains the state and
 is created using some variation of the Singleton pattern.
 
 -- 
 Danny Yates
  

Could you explain me better the theory of POJO inside stateless session
beans? I think I know what is intended to do, but I don't know how to
implement it.

A little example would be more than enough...

regards,
Pedro Salazar.
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


RE: [JBoss-user] share stateful session beans

2003-12-04 Thread Arvinder Singh
I *think* Danny implied:

Your-Session-Bean {

// what ever your store is
private static SomeStoreImpl store =
SomeStoreImpl.getInstance();


public void store(String key, Object value) throws RemoteException {
store.put(key, value);
}

}



-Original Message-
From: Pedro Salazar [mailto:[EMAIL PROTECTED]
Sent: 04 December 2003 17:17
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] share stateful session beans


On Thu, 2003-12-04 at 16:29, Yates, Danny wrote:
 A Stateful Session Bean is specifically intended to have one instance
 allocated to each client.
 
 Your best option is to use a Stateless Session Bean, which provides the
 interface, and have it delegate to a POJO which maintains the state and
 is created using some variation of the Singleton pattern.
 
 -- 
 Danny Yates
  

Could you explain me better the theory of POJO inside stateless session
beans? I think I know what is intended to do, but I don't know how to
implement it.

A little example would be more than enough...

regards,
Pedro Salazar.
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk



This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


RE: [JBoss-user] share stateful session beans

2003-12-04 Thread Pedro Salazar
On Thu, 2003-12-04 at 17:22, Arvinder Singh wrote:
 I *think* Danny implied:
 
 Your-Session-Bean {
 
   // what ever your store is
   private static SomeStoreImpl store =
 SomeStoreImpl.getInstance();
 
 
   public void store(String key, Object value) throws RemoteException {
   store.put(key, value);
   }
 
 }

Does it works in cluster? I don't know if stateless EJBs are
clustered... So, if I have more than one application server instance,
the values would be replicated?
-- 
-PS



---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278alloc_id=3371op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user