users@glassfish.java.net

Re: Bug? <max-pool-size> seems to count only idle EJB instances

From: Major Péter <majorpetya_at_sch.bme.hu>
Date: Tue, 01 Dec 2009 12:12:36 +0100

Hi,

The first one, e.g.:

@Session
class MyBean {
        private static MyBean INSTANCE = null;

@PostConstruct
public void initialization() {
        if (INSTANCE == null) {
                INSTANCE = this;
        }
}

public MyBean getInstance() {
        return INSTANCE;
}

public void myBusinessMethod() {
        //a sample business method
}
}

After that you just need to make sure, that when you're using the EJB's
method you use it through getInstance() in your servlet, JSP, whatever:

@EJB
private MyLocal myBean;

myBean.getInstance().myBusinessMethod();

This is a little messy, because your business methods are accessable
without using the singleton object, but this should solve the problem.

Peter


2009-12-01 10:29 keltezéssel, glassfish_at_javadesktop.org írta:
> Hi
>
> don't think I understand your suggestion. Do you want me to put a static member field in my EJB and let that field reference the EJB (i.e. point to self?)? Or do you want me to put a static member field in my client code and somehow control access to the EJB remote interface?
>
> I don't understand.
>
> In production I will not be able to control the clients (it's more than one application anyway, so there will always be the possibility of several independent programs accessing the resource).
>
> Thanks again,
> Jacob.