You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Jens Mertz <je...@stud.fh-kl.de> on 2010/04/15 08:27:08 UTC

Question about developing Gbeans

Hi,

I'm developing a Service Module in Geronimo 2.2,which got a couple of GBeans.
This Gbeans have a couple of public Methods, but they shouldn't
all published, only some of them.

Now there's my problem. When i develop my Service module all my
public Methods were published, although i only add some of them to the
GbeanInfo. Has i misunterstood the gbeans? Is there some way to solve this
problem?

At the end of this mail is a GBean-Source with Comments which should show
you what i need.

I hope you can help me

Best Regards
Jens





public class TestGBean implements GBeanLifecycle {



	public static final GBeanInfo GBEAN_INFO;

	private String name;

	static {
		GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(
				TestGBean.class.getName(), TestGBean.class);

		infoBuilder.addAttribute("name", "java.lang.String", true,false);
                infoBuilder.addOperation("publishMe",null,null);

		GBEAN_INFO = infoBuilder.getBeanInfo();
	}

	public static GBeanInfo getGBeanInfo() {
		return GBEAN_INFO;
	}

	public TestGBean() {

	}

	public void doFail() {

	}

        public void doStart() throws Exception{

	}
	public void doStop() throws Exception

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

        //this method should be published
        public void publishMe(){
        }

        //this method should not be published
	public void test(){

	}

}


Re: Question about developing Gbeans

Posted by Ivan <xh...@gmail.com>.
For those methods with primitive or non-return values,  they should work
well. IIRC, GEP use JMX to interact with those GBeans running in the Kernel.

Hi, David :
    I just checked a little about the current GBeanInfoBuilder codes, it
seems that it add all the methods in the extends tree. Its behavior is
conflict with my initial undertanding for it. Seems that it would add all
the availale methods to the GBeanInfo in the addInterface method, so is it
by design ? If does, addOperation method is only for dynamic gbean use.
Thanks !

2010/4/16 Jenson283 <je...@stud.fh-kl.de>

>
> thats pity. But thank you for the help.
> --
> View this message in context:
> http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723352.html
> Sent from the Users mailing list archive at Nabble.com.
>



-- 
Ivan

Re: Question about developing Gbeans

Posted by Jenson283 <je...@stud.fh-kl.de>.
thats pity. But thank you for the help.
-- 
View this message in context: http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723352.html
Sent from the Users mailing list archive at Nabble.com.

Re: Question about developing Gbeans

Posted by David Jencks <da...@yahoo.com>.
On Apr 15, 2010, at 11:53 PM, Jenson283 wrote:

> 
> the gbean were exposed as an mbean, the problem is that all my public methods
> were exposed in the method, although i got only a part of them added to my
> gbeaninfo. 
> 
> Yes my goal is it to prevent people from calling certain methods through

Well, you can't do that directly with gbeans.  I'm sure there are lots of other solutions, but the one I can think of right now would be to have a non-serializable object with the hidden method you can retrieve from the gbean.  Then something in-vm will be able to call it but it won't be remotable so jmx won't be able to return the object to a remote client.

david jencks

> jmx.
> 
> thanks 
> Jenson
> -- 
> View this message in context: http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723287.html
> Sent from the Users mailing list archive at Nabble.com.


Re: Question about developing Gbeans

Posted by Jenson283 <je...@stud.fh-kl.de>.
the gbean were exposed as an mbean, the problem is that all my public methods
were exposed in the method, although i got only a part of them added to my
gbeaninfo. 

Yes my goal is it to prevent people from calling certain methods through
jmx.

thanks 
Jenson
-- 
View this message in context: http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723287.html
Sent from the Users mailing list archive at Nabble.com.

Re: Question about developing Gbeans

Posted by David Jencks <da...@yahoo.com>.
All the operations on the object are exposed through the gbean info.  I thought all the attributes were too, whether or not they are declared, but I am less sure of that.

What exactly is the problem you are having?  Do you want to prevent people from calling certain methods through jmx, or does exposing the gbean as an mbean fail completely?

thanks
david jencks

On Apr 15, 2010, at 11:38 PM, Jenson283 wrote:

> 
> Hi, thanks for the quick answer,
> 
> after you're answer i tried to invoke the method test from the kernel to
> test your're answer.
> Unfortunately the kernel was able to invoke this function.
> 
> Here i've got more information what i try, if there any problems to
> understand my issue.
> 
> I have a GBean, which i want to manage like in JMX. Therefore i want to use
> the JMX Viewer from
> the Geronimo Webconsole. If there is a problem ,i also have the opportunity
> to use the JConsole.
> 
> There are a couple of public-methods, which used by externals helper
> classes. Because there are in different packages (and could not be in the
> same package as the bean), i need a mechanism that only 
> publish the public-methods i declare like in JMX.
> 
> Hope you can help me
> 
> Jenson
> -- 
> View this message in context: http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723259.html
> Sent from the Users mailing list archive at Nabble.com.


Re: Question about developing Gbeans

Posted by Jenson283 <je...@stud.fh-kl.de>.
Hi, thanks for the quick answer,

after you're answer i tried to invoke the method test from the kernel to
test your're answer.
Unfortunately the kernel was able to invoke this function.

Here i've got more information what i try, if there any problems to
understand my issue.

I have a GBean, which i want to manage like in JMX. Therefore i want to use
the JMX Viewer from
the Geronimo Webconsole. If there is a problem ,i also have the opportunity
to use the JConsole.

There are a couple of public-methods, which used by externals helper
classes. Because there are in different packages (and could not be in the
same package as the bean), i need a mechanism that only 
publish the public-methods i declare like in JMX.

Hope you can help me

Jenson
-- 
View this message in context: http://n3.nabble.com/Question-about-developing-Gbeans-tp720975p723259.html
Sent from the Users mailing list archive at Nabble.com.

Re: Question about developing Gbeans

Posted by Ivan <xh...@gmail.com>.
Not sure where do you see the method unwanted is published. From my
understanding, if the method is not published, you could not invoke the
corresponding method via Kernel.invoke, however, if you get the real gbean
instance ( I mean the instance of TestGBean ) from kernel, you could do
everything you want.

2010/4/15 Jens Mertz <je...@stud.fh-kl.de>

> Hi,
>
> I'm developing a Service Module in Geronimo 2.2,which got a couple of
> GBeans.
> This Gbeans have a couple of public Methods, but they shouldn't
> all published, only some of them.
>
> Now there's my problem. When i develop my Service module all my
> public Methods were published, although i only add some of them to the
> GbeanInfo. Has i misunterstood the gbeans? Is there some way to solve this
> problem?
>
> At the end of this mail is a GBean-Source with Comments which should show
> you what i need.
>
> I hope you can help me
>
> Best Regards
> Jens
>
>
>
>
>
> public class TestGBean implements GBeanLifecycle {
>
>
>
>        public static final GBeanInfo GBEAN_INFO;
>
>        private String name;
>
>        static {
>                GBeanInfoBuilder infoBuilder =
> GBeanInfoBuilder.createStatic(
>                                TestGBean.class.getName(), TestGBean.class);
>
>                infoBuilder.addAttribute("name", "java.lang.String",
> true,false);
>                infoBuilder.addOperation("publishMe",null,null);
>
>                GBEAN_INFO = infoBuilder.getBeanInfo();
>        }
>
>        public static GBeanInfo getGBeanInfo() {
>                return GBEAN_INFO;
>        }
>
>        public TestGBean() {
>
>        }
>
>        public void doFail() {
>
>        }
>
>        public void doStart() throws Exception{
>
>        }
>        public void doStop() throws Exception
>
>        }
>
>        public String getName() {
>                return name;
>        }
>
>        public void setName(String name) {
>                this.name = name;
>        }
>
>        //this method should be published
>        public void publishMe(){
>        }
>
>        //this method should not be published
>        public void test(){
>
>        }
>
> }
>
>


-- 
Ivan