You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Srinath Perera <he...@opensource.lk> on 2004/07/06 14:43:57 UTC

GBeans? What I learn[Add to WIKI]

Hi all;

As I promised here is what I leran about Gbeans ..
I do not know much yet I able to get a simple one runing ..

pls let me know are there any way to do them better ..
if they look good I will add them to wiki.

Thanks
Srinath

***GBeans***

Notes
======
* Gbeans are way of providing managements services to Geronimo
* It is implemented on top of the JMX right now but supposes to be
independent of JMX. User should be able to use them without knowledge of
the JMX. And it can be make independent of GBeans .
* The GBean can be converted into the MBean using the GBeanMBean and use
the JMX to give the services

Creating a GBean like follows
=============================
a) write new GBean
b) start/stop .. the GBean


Let us Write a GBean
=====================
1)They should implements the GBeanLifecycle interface
(**search for all the implementetors of the GBeanLifecycle is a good way
to **find example** of the GBeans)
2) they can have attributes with getters and setters
	a) there are attributes that are final and I think they are standard ..
(What is the list of them) e.g. name, Kernel (they can use to get hold of
the system info, have a look at the sample GBeans.)
	b) there are ordinary attributes .. have getters and setters
3) GBeans can have methods ..
3) each GBean should have GBEAN_INFO attribute (see exapmles)

static {
		GBeanInfoFactory infoFactory = new GBeanInfoFactory("AxisGbean",
AxisGbean.class);
		//attributes
		infoFactory.addAttribute("Name", String.class, true);
		infoFactory.addAttribute("kernel", Kernel.class, false);
		//operations
		infoFactory.addOperation("echo", new Class[]{String.class});

		infoFactory.setConstructor(new String[] {"kernel","Name"});
		GBEAN_INFO = infoFactory.getBeanInfo();
}

4) following two are call back methods
	public void doStart() throws WaitingException, Exception {
       System.out.println("Axis GBean has started");
	}
    public void doStop() throws WaitingException, Exception {
		System.out.println("Axis GBean has stoped");
    }

Run A GBean
===========
Having created a GBean like this to start/stop/set values/invoke operaions
 and GBean service use code like follows

name = new ObjectName("test:name=AxisGBean");
kernel = new Kernel("test.kernel", "test");
kernel.boot();
ClassLoader cl = getClass().getClassLoader();
ClassLoader myCl = new URLClassLoader(new URL[0], cl);
GBeanMBean gbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
gbean.setAttribute("Name", "Test");

kernel.loadGBean(name, gbean);
Kernel.startGBean(name);
System.out.println(kernel.getMBeanServer().getAttribute(name, "state"));
System.out.println(kernel.getMBeanServer().invoke(name, "echo", new
Object[]{"Hello"}, new String[]{String.class.getName()}));

kernel.stopGBean(name);
kernel.unloadGBean(name)




Re: GBeans? What I learn[Add to WIKI]

Posted by Eric Le Goff <er...@gicm.fr>.
Srinath Perera wrote:

>how about put them in http://wiki.apache.org/geronimo/GBeans and leave a
>link from the FAQ.
>at the end the info in the GBean might grow too long and fill the FAQ :)
>
>Srinath
>
>  
>
+1

Eric

Re: GBeans? What I learn[Add to WIKI]

Posted by Davanum Srinivas <da...@gmail.com>.
+1

On Tue, 6 Jul 2004 19:17:58 -0700, Srinath Perera
<he...@cse.mrt.ac.lk> wrote:
> how about put them in http://wiki.apache.org/geronimo/GBeans and leave a
> link from the FAQ.
> at the end the info in the GBean might grow too long and fill the FAQ :)
> 
> Srinath
> 
> ----- Original Message -----
> From: "Eric Le Goff" <lg...@numericable.fr>
> To: <de...@geronimo.apache.org>
> Sent: Tuesday, July 06, 2004 2:20 PM
> Subject: Re: GBeans? What I learn[Add to WIKI]
> 
> > Davanum Srinivas wrote:
> > > please add it to the wiki :)
> >
> > +1
> > I suggest you complete  the page at :
> > http://wiki.apache.org/geronimo/FrequentlyAskedQuestions
> >
> > (Section 4.5)
> >
> > Eric
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: GBeans? What I learn[Add to WIKI]

Posted by Srinath Perera <he...@cse.mrt.ac.lk>.
how about put them in http://wiki.apache.org/geronimo/GBeans and leave a
link from the FAQ.
at the end the info in the GBean might grow too long and fill the FAQ :)

Srinath



----- Original Message -----
From: "Eric Le Goff" <lg...@numericable.fr>
To: <de...@geronimo.apache.org>
Sent: Tuesday, July 06, 2004 2:20 PM
Subject: Re: GBeans? What I learn[Add to WIKI]


> Davanum Srinivas wrote:
> > please add it to the wiki :)
>
> +1
> I suggest you complete  the page at :
> http://wiki.apache.org/geronimo/FrequentlyAskedQuestions
>
> (Section 4.5)
>
> Eric


Re: GBeans? What I learn[Add to WIKI]

Posted by Eric Le Goff <lg...@numericable.fr>.
Davanum Srinivas wrote:
> please add it to the wiki :)

+1
I suggest you complete  the page at :
http://wiki.apache.org/geronimo/FrequentlyAskedQuestions

(Section 4.5)

Eric

Re: GBeans? What I learn[Add to WIKI]

Posted by Davanum Srinivas <da...@gmail.com>.
please add it to the wiki :)

-- dims

On Tue, 6 Jul 2004 08:43:57 -0400 (EDT), Srinath Perera
<he...@opensource.lk> wrote:
> Hi all;
> 
> As I promised here is what I leran about Gbeans ..
> I do not know much yet I able to get a simple one runing ..
> 
> pls let me know are there any way to do them better ..
> if they look good I will add them to wiki.
> 
> Thanks
> Srinath
> 
> ***GBeans***
> 
> Notes
> ======
> * Gbeans are way of providing managements services to Geronimo
> * It is implemented on top of the JMX right now but supposes to be
> independent of JMX. User should be able to use them without knowledge of
> the JMX. And it can be make independent of GBeans .
> * The GBean can be converted into the MBean using the GBeanMBean and use
> the JMX to give the services
> 
> Creating a GBean like follows
> =============================
> a) write new GBean
> b) start/stop .. the GBean
> 
> Let us Write a GBean
> =====================
> 1)They should implements the GBeanLifecycle interface
> (**search for all the implementetors of the GBeanLifecycle is a good way
> to **find example** of the GBeans)
> 2) they can have attributes with getters and setters
>         a) there are attributes that are final and I think they are standard ..
> (What is the list of them) e.g. name, Kernel (they can use to get hold of
> the system info, have a look at the sample GBeans.)
>         b) there are ordinary attributes .. have getters and setters
> 3) GBeans can have methods ..
> 3) each GBean should have GBEAN_INFO attribute (see exapmles)
> 
> static {
>                 GBeanInfoFactory infoFactory = new GBeanInfoFactory("AxisGbean",
> AxisGbean.class);
>                 //attributes
>                 infoFactory.addAttribute("Name", String.class, true);
>                 infoFactory.addAttribute("kernel", Kernel.class, false);
>                 //operations
>                 infoFactory.addOperation("echo", new Class[]{String.class});
> 
>                 infoFactory.setConstructor(new String[] {"kernel","Name"});
>                 GBEAN_INFO = infoFactory.getBeanInfo();
> }
> 
> 4) following two are call back methods
>         public void doStart() throws WaitingException, Exception {
>        System.out.println("Axis GBean has started");
>         }
>     public void doStop() throws WaitingException, Exception {
>                 System.out.println("Axis GBean has stoped");
>     }
> 
> Run A GBean
> ===========
> Having created a GBean like this to start/stop/set values/invoke operaions
>  and GBean service use code like follows
> 
> name = new ObjectName("test:name=AxisGBean");
> kernel = new Kernel("test.kernel", "test");
> kernel.boot();
> ClassLoader cl = getClass().getClassLoader();
> ClassLoader myCl = new URLClassLoader(new URL[0], cl);
> GBeanMBean gbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
> gbean.setAttribute("Name", "Test");
> 
> kernel.loadGBean(name, gbean);
> Kernel.startGBean(name);
> System.out.println(kernel.getMBeanServer().getAttribute(name, "state"));
> System.out.println(kernel.getMBeanServer().invoke(name, "echo", new
> Object[]{"Hello"}, new String[]{String.class.getName()}));
> 
> kernel.stopGBean(name);
> kernel.unloadGBean(name)
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/