Stephen Ting schrieb:

Hi Adrian,


Happy new year 2004.


You mention about Interceptor stuff, where can I find information and
example on Interceptor stuff? I believe this stuff is Jboss specific,
right.


We discussed the Interceptor stuff in a lecture lest semester. Since there is no downloadrestriction I think I am allowed to post the url here.
http://www.st.informatik.tu-darmstadt.de/pages/lectures/sct/ss03/assignments/u4/interceptors.pdf


It helped me quite a lot in understanding the interceptor stuff

Chris

My objective to use Mbean is to act as a caching layer (where the cached
object is stored), I only require a simple caching algorithm to store
object retrieved from database in the static variable of the mbean.


Now, if I will to use the Interceptor, is there any caching tool which
works in Jboss. Sorry for all this novice questions, I am very new to
most of the Jboss services.


Regards, Stephen



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Brock
Sent: 31 December 2003 00:27
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Asking about Mbean usage



On Tue, 2003-12-30 at 06:59, Stephen Ting wrote:


Hello,

I am a JMX newbie, i have successfully write some standard mbean follows the example in the Jboss docs. I plan to do some serious component using this model, therefore i post this message to verify with you gurus and hope to get some comments and feedbacks.

My objective of using mbean is to create a caching layer at

the server

side where some data retrieve through session bean will be cached at the mbean. The client (web-client, java client) will access

the mbean

to retrieve data, only if the data is not available in the cache it will invoke the session bean(which will retrieve data from

database).

So rougly the flow would be

client -> mbean -> session bean -> database.

What i currently did were;

1. Create a mbean that's serializable and bind the mbean to a jndi server using the following code. The mbean have some static Map for caching.

private void bind(Context ctx, String name, Object val)throws NamingException{
Name n;
for (n = ctx.getNameParser("").parse(name); n.size() >
1; n = n.getSuffix(1)){
String ctxName = n.get(0);
try{
ctx = (Context) ctx.lookup(ctxName);
}catch (NameNotFoundException
namenotfoundexception){
ctx = ctx.createSubcontext(ctxName);
}
}
ctx.bind(n.get(0), val);
}


2. invoke the mbean through jboss RMIConnector, using the RMIAdapter bind at the Following jndi name "jmx/rmi/RMIAdaptor". Then I will invoke the mbean using the
RemoteMBeanServer instance.


RMIAdaptor adaptor = (RMIAdaptor)context.lookup(jndiName);
RemoteMBeanServer server = new RMIConnectorImpl(adaptor);



My questions are:


1. Is it appropriate to implement my objective using mbean

or there is

better altenatives?


You could just implement it as an interceptor on the session bean.

import org.jboss.ejb.plugins.AbstractInterceptor;
import org.jboss.invocation.Invocation;

public IdempotentInterceptor extends AbstractInterceptor
{
 public Object invoke(Invocation invocation) throws Exception
 {
    Object result = getResultFromCache(invocation);
    if (result != null)
       return result;
    else
       // Not in cache invoke the session bean
       return getNext().invokeNext(invocation);
 }
}








2. I notice in the example there is NonSerializable binding. What is the different in binding A serializable or non serializable

mbean? If

I require to access the mbean remotely which is more appropriate?


Neither.
If you use non serializable it won't be available outside the jvm. If you use serializable you will receive a clone of the mbean object on the client.
You have a number of options:
1) Make the MBean an RMI remote object (the client will receive a stub rather than the mbean).
2) Use the RMIAdapter to access the MBean.
3) Make your MBean invokable via a JBoss invoker and use a proxy factory to bind a proxy to the mbean in jndi (there is an example in chapter 2 of the admin docs).




3. If I had a serializable mbean, does that meant each time I invoke the mbean I will get a copy of the mbean or a 'proxy' of the mbean? From my testing I found that whenver I invoke the mbean through the connector, the changes is reflect at the server.


The connector is option 2 above.



4. Does the mbean only instantiated once in the server JVM, meaning all the client will access the same mbean instance? If no, can I create a singleton mbean?


MBeans are singletons.



5. what's the different between RMIAdaptor and RMIConnector?


The RMIAdaptor allows you to remotely invoke the MBeanServer. The RMIConnector adds extra behaviour like remote notifications. Both are remote proxies/stubs for the MBeanServer.

Regards,
Adrian



Thanks.

Any comments and suggestions are very much appreciated.


Regards, Stephen



-------------------------------------------------------
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=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user


--
xxxxxxxxxxxxxxxxxxxxxxxx Adrian Brock
Director of Support
Back Office
JBoss Group, LLC xxxxxxxxxxxxxxxxxxxxxxxx




-------------------------------------------------------
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=1278&alloc_id=3371>&op=click


_______________________________________________

JBoss-user mailing list
[EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jb>oss-user







-------------------------------------------------------
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=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user






-------------------------------------------------------
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=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to