You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by steff aka sid <sr...@brockhaus-gruppe.de> on 2008/10/06 09:55:52 UTC

servicemix-bean singleton

Hi is it possible to have only one instance of an bean component (like a
singleton)? I've created serveral beans but all seem to have two instances.
In example I've got a init()-Method like:

       @PostConstruct
	public void init() throws IOException, MessagingException {
		if (null == this.context || null == this.channel) {
			throw new IllegalStateException("ClusteringBean not initialized!");
		}
		
		log.info("ClusteringBean initialized!");
	}

When I deploy this component I get:

INFO  - ClusteringBean                 - ClusteringBean initialized!
INFO  - ClusteringBean                 - ClusteringBean initialized!

And even each logging output I create in bean will be printed twice. But I
only need one instance. The beans are MessageExchangeListeners. Maybe there
is a better way to create such beans? I've thought about servicemix-jsr181
component but not sure for that.

Regards
/steffen

-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by steff aka sid <sr...@brockhaus-gruppe.de>.
Ah, ok thank you.

Regards
/steffen


gnodet wrote:
> 
> Instead of bean="#xxx", you could use beanClassName="className".
> This only works if the bean class does not need to be configured
> further using spring.
> In such a case, a new bean will be created for each request.
> 
> On Mon, Oct 6, 2008 at 12:23 PM, steff aka sid
> <sr...@brockhaus-gruppe.de> wrote:
>>
>> One question only for my understanding. You sayed using bean class
>> directly
>> for configuration. What does this mean. Did it mean directly calling the
>> bean (by providing a configuration with the URI and the method to use)
>> without configuring a bean endpoint (or is in this case the bean not
>> bound)?
>> Regards
>> /Steffen
>>
>>
>> gnodet wrote:
>>>
>>> Using servicemix-bean, you can either configure a bean or the bean
>>> class.
>>> If you configure the bean directly, only that instance will be used to
>>> service all requests, whereas if you use the bean class, a new bean
>>> will be created for each request.
>>>
>>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>>> <sr...@brockhaus-gruppe.de> wrote:
>>>>
>>>> Hi is it possible to have only one instance of an bean component (like
>>>> a
>>>> singleton)? I've created serveral beans but all seem to have two
>>>> instances.
>>>> In example I've got a init()-Method like:
>>>>
>>>>       @PostConstruct
>>>>        public void init() throws IOException, MessagingException {
>>>>                if (null == this.context || null == this.channel) {
>>>>                        throw new IllegalStateException("ClusteringBean
>>>> not initialized!");
>>>>                }
>>>>
>>>>                log.info("ClusteringBean initialized!");
>>>>        }
>>>>
>>>> When I deploy this component I get:
>>>>
>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>
>>>> And even each logging output I create in bean will be printed twice.
>>>> But
>>>> I
>>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>>> there
>>>> is a better way to create such beans? I've thought about
>>>> servicemix-jsr181
>>>> component but not sure for that.
>>>>
>>>> Regards
>>>> /steffen
>>>>
>>>> -----
>>>> Brockhaus GmbH
>>>> COMPETITIVE THROUGH KNOWLEDGE
>>>>
>>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>> ------------------------
>>> Open Source SOA
>>> http://open.iona.com
>>>
>>>
>>
>>
>> -----
>> Brockhaus GmbH
>> COMPETITIVE THROUGH KNOWLEDGE
>>
>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>> http://www.brockhaus-group.com www.brockhaus-group.com
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19835299.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://open.iona.com
> 
> 


-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19835458.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by Guillaume Nodet <gn...@gmail.com>.
Instead of bean="#xxx", you could use beanClassName="className".
This only works if the bean class does not need to be configured
further using spring.
In such a case, a new bean will be created for each request.

On Mon, Oct 6, 2008 at 12:23 PM, steff aka sid
<sr...@brockhaus-gruppe.de> wrote:
>
> One question only for my understanding. You sayed using bean class directly
> for configuration. What does this mean. Did it mean directly calling the
> bean (by providing a configuration with the URI and the method to use)
> without configuring a bean endpoint (or is in this case the bean not bound)?
> Regards
> /Steffen
>
>
> gnodet wrote:
>>
>> Using servicemix-bean, you can either configure a bean or the bean class.
>> If you configure the bean directly, only that instance will be used to
>> service all requests, whereas if you use the bean class, a new bean
>> will be created for each request.
>>
>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>> <sr...@brockhaus-gruppe.de> wrote:
>>>
>>> Hi is it possible to have only one instance of an bean component (like a
>>> singleton)? I've created serveral beans but all seem to have two
>>> instances.
>>> In example I've got a init()-Method like:
>>>
>>>       @PostConstruct
>>>        public void init() throws IOException, MessagingException {
>>>                if (null == this.context || null == this.channel) {
>>>                        throw new IllegalStateException("ClusteringBean
>>> not initialized!");
>>>                }
>>>
>>>                log.info("ClusteringBean initialized!");
>>>        }
>>>
>>> When I deploy this component I get:
>>>
>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>
>>> And even each logging output I create in bean will be printed twice. But
>>> I
>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>> there
>>> is a better way to create such beans? I've thought about
>>> servicemix-jsr181
>>> component but not sure for that.
>>>
>>> Regards
>>> /steffen
>>>
>>> -----
>>> Brockhaus GmbH
>>> COMPETITIVE THROUGH KNOWLEDGE
>>>
>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>> --
>>> View this message in context:
>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://open.iona.com
>>
>>
>
>
> -----
> Brockhaus GmbH
> COMPETITIVE THROUGH KNOWLEDGE
>
> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
> http://www.brockhaus-group.com www.brockhaus-group.com
> --
> View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19835299.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://open.iona.com

Re: servicemix-bean singleton

Posted by steff aka sid <sr...@brockhaus-gruppe.de>.
One question only for my understanding. You sayed using bean class directly
for configuration. What does this mean. Did it mean directly calling the
bean (by providing a configuration with the URI and the method to use)
without configuring a bean endpoint (or is in this case the bean not bound)? 
Regards
/Steffen


gnodet wrote:
> 
> Using servicemix-bean, you can either configure a bean or the bean class.
> If you configure the bean directly, only that instance will be used to
> service all requests, whereas if you use the bean class, a new bean
> will be created for each request.
> 
> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
> <sr...@brockhaus-gruppe.de> wrote:
>>
>> Hi is it possible to have only one instance of an bean component (like a
>> singleton)? I've created serveral beans but all seem to have two
>> instances.
>> In example I've got a init()-Method like:
>>
>>       @PostConstruct
>>        public void init() throws IOException, MessagingException {
>>                if (null == this.context || null == this.channel) {
>>                        throw new IllegalStateException("ClusteringBean
>> not initialized!");
>>                }
>>
>>                log.info("ClusteringBean initialized!");
>>        }
>>
>> When I deploy this component I get:
>>
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>
>> And even each logging output I create in bean will be printed twice. But
>> I
>> only need one instance. The beans are MessageExchangeListeners. Maybe
>> there
>> is a better way to create such beans? I've thought about
>> servicemix-jsr181
>> component but not sure for that.
>>
>> Regards
>> /steffen
>>
>> -----
>> Brockhaus GmbH
>> COMPETITIVE THROUGH KNOWLEDGE
>>
>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>> http://www.brockhaus-group.com www.brockhaus-group.com
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://open.iona.com
> 
> 


-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19835299.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by steff aka sid <sr...@brockhaus-gruppe.de>.
A I've got a idea. I've added some configuration for the logging System so
maybe this is the problem. So that for my custom log for my beans has two
appenders (default and one custom) and so it prints the informations
twice... Thank you very much for your help.

Regards
/steffen


gnodet wrote:
> 
> This may be a problem in the log system rather than a problem in
> servicemix-bean.
> If only one stack trace is displayed, this certainly means the method
> is only called once.
> 
> On Mon, Oct 6, 2008 at 10:29 AM, steff aka sid
> <sr...@brockhaus-gruppe.de> wrote:
>>
>> Ok, here is the output:
>> INFO  - ClusteringBean                 -
>> de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
>> INFO  - ClusteringBean                 -
>> de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>> java.lang.Throwable
>>        at
>> de.brockhaus-gruppe.beans.ClusteringBean.init(ClusteringBean.java:143)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:585)
>>        at
>> org.apache.servicemix.bean.support.ReflectionUtils$1.doWith(ReflectionUtils.java:32)
>>        at
>> org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:226)
>>        at
>> org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:203)
>>        at
>> org.apache.servicemix.bean.support.ReflectionUtils.callLifecycleMethod(ReflectionUtils.java:28)
>>        at
>> org.apache.servicemix.bean.BeanEndpoint.start(BeanEndpoint.java:111)
>>        at
>> org.apache.servicemix.common.endpoints.SimpleEndpoint.activate(SimpleEndpoint.java:55)
>>        at
>> org.apache.servicemix.common.ServiceUnit.start(ServiceUnit.java:53)
>>        at
>> org.apache.servicemix.common.BaseServiceUnitManager.start(BaseServiceUnitManager.java:151)
>>        at
>> org.apache.servicemix.jbi.framework.ServiceUnitLifeCycle.start(ServiceUnitLifeCycle.java:103)
>>        at
>> org.apache.servicemix.jbi.framework.ServiceAssemblyLifeCycle.start(ServiceAssemblyLifeCycle.java:132)
>>        at
>> org.apache.servicemix.jbi.framework.DeploymentService.start(DeploymentService.java:378)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:355)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:256)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:664)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:628)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>>
>> for me this looks a little bit strange here is what I added:
>> log.info(this);
>> log.info("ClusteringBean initialized!");
>> new Throwable().printStackTrace();
>>
>> But why do we get only one stacktrace? (BeanID looks like one object but
>> all
>> what I have is processed twice.
>>
>> Regards
>> /Steffen
>>
>>
>> gnodet wrote:
>>>
>>> Looks like a bug.  Could you try adding a
>>>    new Throwable().printStackTrace();
>>>
>>> statement just below your log.info() statement to determine when the
>>> method is called ?
>>>
>>> On Mon, Oct 6, 2008 at 10:11 AM, steff aka sid
>>> <sr...@brockhaus-gruppe.de> wrote:
>>>>
>>>> Hm ok, but do you have an example for that? I currently configure my
>>>> bean
>>>> using xbean configuration file like the following:
>>>>
>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>>       xmlns:bean="http://servicemix.apache.org/bean/1.0"
>>>>       xmlns:brockhaus="http://brockhaus-gruppe.de/services/category"
>>>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>       xsi:schemaLocation="http://servicemix.apache.org/bean/1.0
>>>> http://servicemix.apache.org/schema/servicemix-bean-3.2.2.xsd
>>>>       http://www.springframework.org/schema/beans
>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>
>>>>  <bean:endpoint service="brockhaus:categoryClusteringBean"
>>>> endpoint="endpoint" bean="#ClusteringBean"/>
>>>>
>>>>  <bean id="ClusteringBean"
>>>> class="de.brockhaus-gruppe.beans.ClusteringBean"/>
>>>>
>>>> </beans>
>>>>
>>>> Regards
>>>> /Steffen
>>>>
>>>> gnodet wrote:
>>>>>
>>>>> Using servicemix-bean, you can either configure a bean or the bean
>>>>> class.
>>>>> If you configure the bean directly, only that instance will be used to
>>>>> service all requests, whereas if you use the bean class, a new bean
>>>>> will be created for each request.
>>>>>
>>>>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>>>>> <sr...@brockhaus-gruppe.de> wrote:
>>>>>>
>>>>>> Hi is it possible to have only one instance of an bean component
>>>>>> (like
>>>>>> a
>>>>>> singleton)? I've created serveral beans but all seem to have two
>>>>>> instances.
>>>>>> In example I've got a init()-Method like:
>>>>>>
>>>>>>       @PostConstruct
>>>>>>        public void init() throws IOException, MessagingException {
>>>>>>                if (null == this.context || null == this.channel) {
>>>>>>                        throw new
>>>>>> IllegalStateException("ClusteringBean
>>>>>> not initialized!");
>>>>>>                }
>>>>>>
>>>>>>                log.info("ClusteringBean initialized!");
>>>>>>        }
>>>>>>
>>>>>> When I deploy this component I get:
>>>>>>
>>>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>>>
>>>>>> And even each logging output I create in bean will be printed twice.
>>>>>> But
>>>>>> I
>>>>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>>>>> there
>>>>>> is a better way to create such beans? I've thought about
>>>>>> servicemix-jsr181
>>>>>> component but not sure for that.
>>>>>>
>>>>>> Regards
>>>>>> /steffen
>>>>>>
>>>>>> -----
>>>>>> Brockhaus GmbH
>>>>>> COMPETITIVE THROUGH KNOWLEDGE
>>>>>>
>>>>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>>>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Cheers,
>>>>> Guillaume Nodet
>>>>> ------------------------
>>>>> Blog: http://gnodet.blogspot.com/
>>>>> ------------------------
>>>>> Open Source SOA
>>>>> http://open.iona.com
>>>>>
>>>>>
>>>>
>>>>
>>>> -----
>>>> Brockhaus GmbH
>>>> COMPETITIVE THROUGH KNOWLEDGE
>>>>
>>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833614.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>> ------------------------
>>> Open Source SOA
>>> http://open.iona.com
>>>
>>>
>>
>>
>> -----
>> Brockhaus GmbH
>> COMPETITIVE THROUGH KNOWLEDGE
>>
>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>> http://www.brockhaus-group.com www.brockhaus-group.com
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833838.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://open.iona.com
> 
> 


-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19834293.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by Guillaume Nodet <gn...@gmail.com>.
This may be a problem in the log system rather than a problem in
servicemix-bean.
If only one stack trace is displayed, this certainly means the method
is only called once.

On Mon, Oct 6, 2008 at 10:29 AM, steff aka sid
<sr...@brockhaus-gruppe.de> wrote:
>
> Ok, here is the output:
> INFO  - ClusteringBean                 -
> de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
> INFO  - ClusteringBean                 -
> de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
> INFO  - ClusteringBean                 - ClusteringBean initialized!
> INFO  - ClusteringBean                 - ClusteringBean initialized!
> java.lang.Throwable
>        at
> de.brockhaus-gruppe.beans.ClusteringBean.init(ClusteringBean.java:143)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:585)
>        at
> org.apache.servicemix.bean.support.ReflectionUtils$1.doWith(ReflectionUtils.java:32)
>        at
> org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:226)
>        at
> org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:203)
>        at
> org.apache.servicemix.bean.support.ReflectionUtils.callLifecycleMethod(ReflectionUtils.java:28)
>        at
> org.apache.servicemix.bean.BeanEndpoint.start(BeanEndpoint.java:111)
>        at
> org.apache.servicemix.common.endpoints.SimpleEndpoint.activate(SimpleEndpoint.java:55)
>        at
> org.apache.servicemix.common.ServiceUnit.start(ServiceUnit.java:53)
>        at
> org.apache.servicemix.common.BaseServiceUnitManager.start(BaseServiceUnitManager.java:151)
>        at
> org.apache.servicemix.jbi.framework.ServiceUnitLifeCycle.start(ServiceUnitLifeCycle.java:103)
>        at
> org.apache.servicemix.jbi.framework.ServiceAssemblyLifeCycle.start(ServiceAssemblyLifeCycle.java:132)
>        at
> org.apache.servicemix.jbi.framework.DeploymentService.start(DeploymentService.java:378)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:355)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:256)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:664)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:628)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
>
> for me this looks a little bit strange here is what I added:
> log.info(this);
> log.info("ClusteringBean initialized!");
> new Throwable().printStackTrace();
>
> But why do we get only one stacktrace? (BeanID looks like one object but all
> what I have is processed twice.
>
> Regards
> /Steffen
>
>
> gnodet wrote:
>>
>> Looks like a bug.  Could you try adding a
>>    new Throwable().printStackTrace();
>>
>> statement just below your log.info() statement to determine when the
>> method is called ?
>>
>> On Mon, Oct 6, 2008 at 10:11 AM, steff aka sid
>> <sr...@brockhaus-gruppe.de> wrote:
>>>
>>> Hm ok, but do you have an example for that? I currently configure my bean
>>> using xbean configuration file like the following:
>>>
>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>       xmlns:bean="http://servicemix.apache.org/bean/1.0"
>>>       xmlns:brockhaus="http://brockhaus-gruppe.de/services/category"
>>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>       xsi:schemaLocation="http://servicemix.apache.org/bean/1.0
>>> http://servicemix.apache.org/schema/servicemix-bean-3.2.2.xsd
>>>       http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>
>>>  <bean:endpoint service="brockhaus:categoryClusteringBean"
>>> endpoint="endpoint" bean="#ClusteringBean"/>
>>>
>>>  <bean id="ClusteringBean"
>>> class="de.brockhaus-gruppe.beans.ClusteringBean"/>
>>>
>>> </beans>
>>>
>>> Regards
>>> /Steffen
>>>
>>> gnodet wrote:
>>>>
>>>> Using servicemix-bean, you can either configure a bean or the bean
>>>> class.
>>>> If you configure the bean directly, only that instance will be used to
>>>> service all requests, whereas if you use the bean class, a new bean
>>>> will be created for each request.
>>>>
>>>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>>>> <sr...@brockhaus-gruppe.de> wrote:
>>>>>
>>>>> Hi is it possible to have only one instance of an bean component (like
>>>>> a
>>>>> singleton)? I've created serveral beans but all seem to have two
>>>>> instances.
>>>>> In example I've got a init()-Method like:
>>>>>
>>>>>       @PostConstruct
>>>>>        public void init() throws IOException, MessagingException {
>>>>>                if (null == this.context || null == this.channel) {
>>>>>                        throw new IllegalStateException("ClusteringBean
>>>>> not initialized!");
>>>>>                }
>>>>>
>>>>>                log.info("ClusteringBean initialized!");
>>>>>        }
>>>>>
>>>>> When I deploy this component I get:
>>>>>
>>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>>
>>>>> And even each logging output I create in bean will be printed twice.
>>>>> But
>>>>> I
>>>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>>>> there
>>>>> is a better way to create such beans? I've thought about
>>>>> servicemix-jsr181
>>>>> component but not sure for that.
>>>>>
>>>>> Regards
>>>>> /steffen
>>>>>
>>>>> -----
>>>>> Brockhaus GmbH
>>>>> COMPETITIVE THROUGH KNOWLEDGE
>>>>>
>>>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Cheers,
>>>> Guillaume Nodet
>>>> ------------------------
>>>> Blog: http://gnodet.blogspot.com/
>>>> ------------------------
>>>> Open Source SOA
>>>> http://open.iona.com
>>>>
>>>>
>>>
>>>
>>> -----
>>> Brockhaus GmbH
>>> COMPETITIVE THROUGH KNOWLEDGE
>>>
>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>> --
>>> View this message in context:
>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833614.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://open.iona.com
>>
>>
>
>
> -----
> Brockhaus GmbH
> COMPETITIVE THROUGH KNOWLEDGE
>
> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
> http://www.brockhaus-group.com www.brockhaus-group.com
> --
> View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833838.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://open.iona.com

Re: servicemix-bean singleton

Posted by steff aka sid <sr...@brockhaus-gruppe.de>.
Ok, here is the output:
INFO  - ClusteringBean                 -
de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
INFO  - ClusteringBean                 -
de.brockhaus-gruppe.beans.ClusteringBean@1e59f7c
INFO  - ClusteringBean                 - ClusteringBean initialized!
INFO  - ClusteringBean                 - ClusteringBean initialized!
java.lang.Throwable
        at
de.brockhaus-gruppe.beans.ClusteringBean.init(ClusteringBean.java:143)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.apache.servicemix.bean.support.ReflectionUtils$1.doWith(ReflectionUtils.java:32)
        at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:226)
        at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:203)
        at
org.apache.servicemix.bean.support.ReflectionUtils.callLifecycleMethod(ReflectionUtils.java:28)
        at
org.apache.servicemix.bean.BeanEndpoint.start(BeanEndpoint.java:111)
        at
org.apache.servicemix.common.endpoints.SimpleEndpoint.activate(SimpleEndpoint.java:55)
        at
org.apache.servicemix.common.ServiceUnit.start(ServiceUnit.java:53)
        at
org.apache.servicemix.common.BaseServiceUnitManager.start(BaseServiceUnitManager.java:151)
        at
org.apache.servicemix.jbi.framework.ServiceUnitLifeCycle.start(ServiceUnitLifeCycle.java:103)
        at
org.apache.servicemix.jbi.framework.ServiceAssemblyLifeCycle.start(ServiceAssemblyLifeCycle.java:132)
        at
org.apache.servicemix.jbi.framework.DeploymentService.start(DeploymentService.java:378)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:355)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:256)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:664)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:628)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)

for me this looks a little bit strange here is what I added:
log.info(this);
log.info("ClusteringBean initialized!");
new Throwable().printStackTrace();

But why do we get only one stacktrace? (BeanID looks like one object but all
what I have is processed twice.

Regards
/Steffen


gnodet wrote:
> 
> Looks like a bug.  Could you try adding a
>    new Throwable().printStackTrace();
> 
> statement just below your log.info() statement to determine when the
> method is called ?
> 
> On Mon, Oct 6, 2008 at 10:11 AM, steff aka sid
> <sr...@brockhaus-gruppe.de> wrote:
>>
>> Hm ok, but do you have an example for that? I currently configure my bean
>> using xbean configuration file like the following:
>>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>       xmlns:bean="http://servicemix.apache.org/bean/1.0"
>>       xmlns:brockhaus="http://brockhaus-gruppe.de/services/category"
>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>       xsi:schemaLocation="http://servicemix.apache.org/bean/1.0
>> http://servicemix.apache.org/schema/servicemix-bean-3.2.2.xsd
>>       http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>
>>  <bean:endpoint service="brockhaus:categoryClusteringBean"
>> endpoint="endpoint" bean="#ClusteringBean"/>
>>
>>  <bean id="ClusteringBean"
>> class="de.brockhaus-gruppe.beans.ClusteringBean"/>
>>
>> </beans>
>>
>> Regards
>> /Steffen
>>
>> gnodet wrote:
>>>
>>> Using servicemix-bean, you can either configure a bean or the bean
>>> class.
>>> If you configure the bean directly, only that instance will be used to
>>> service all requests, whereas if you use the bean class, a new bean
>>> will be created for each request.
>>>
>>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>>> <sr...@brockhaus-gruppe.de> wrote:
>>>>
>>>> Hi is it possible to have only one instance of an bean component (like
>>>> a
>>>> singleton)? I've created serveral beans but all seem to have two
>>>> instances.
>>>> In example I've got a init()-Method like:
>>>>
>>>>       @PostConstruct
>>>>        public void init() throws IOException, MessagingException {
>>>>                if (null == this.context || null == this.channel) {
>>>>                        throw new IllegalStateException("ClusteringBean
>>>> not initialized!");
>>>>                }
>>>>
>>>>                log.info("ClusteringBean initialized!");
>>>>        }
>>>>
>>>> When I deploy this component I get:
>>>>
>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>>
>>>> And even each logging output I create in bean will be printed twice.
>>>> But
>>>> I
>>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>>> there
>>>> is a better way to create such beans? I've thought about
>>>> servicemix-jsr181
>>>> component but not sure for that.
>>>>
>>>> Regards
>>>> /steffen
>>>>
>>>> -----
>>>> Brockhaus GmbH
>>>> COMPETITIVE THROUGH KNOWLEDGE
>>>>
>>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>> ------------------------
>>> Open Source SOA
>>> http://open.iona.com
>>>
>>>
>>
>>
>> -----
>> Brockhaus GmbH
>> COMPETITIVE THROUGH KNOWLEDGE
>>
>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>> http://www.brockhaus-group.com www.brockhaus-group.com
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833614.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://open.iona.com
> 
> 


-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833838.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by Guillaume Nodet <gn...@gmail.com>.
Looks like a bug.  Could you try adding a
   new Throwable().printStackTrace();

statement just below your log.info() statement to determine when the
method is called ?

On Mon, Oct 6, 2008 at 10:11 AM, steff aka sid
<sr...@brockhaus-gruppe.de> wrote:
>
> Hm ok, but do you have an example for that? I currently configure my bean
> using xbean configuration file like the following:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:bean="http://servicemix.apache.org/bean/1.0"
>       xmlns:brockhaus="http://brockhaus-gruppe.de/services/category"
>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="http://servicemix.apache.org/bean/1.0
> http://servicemix.apache.org/schema/servicemix-bean-3.2.2.xsd
>       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>  <bean:endpoint service="brockhaus:categoryClusteringBean"
> endpoint="endpoint" bean="#ClusteringBean"/>
>
>  <bean id="ClusteringBean"
> class="de.brockhaus-gruppe.beans.ClusteringBean"/>
>
> </beans>
>
> Regards
> /Steffen
>
> gnodet wrote:
>>
>> Using servicemix-bean, you can either configure a bean or the bean class.
>> If you configure the bean directly, only that instance will be used to
>> service all requests, whereas if you use the bean class, a new bean
>> will be created for each request.
>>
>> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
>> <sr...@brockhaus-gruppe.de> wrote:
>>>
>>> Hi is it possible to have only one instance of an bean component (like a
>>> singleton)? I've created serveral beans but all seem to have two
>>> instances.
>>> In example I've got a init()-Method like:
>>>
>>>       @PostConstruct
>>>        public void init() throws IOException, MessagingException {
>>>                if (null == this.context || null == this.channel) {
>>>                        throw new IllegalStateException("ClusteringBean
>>> not initialized!");
>>>                }
>>>
>>>                log.info("ClusteringBean initialized!");
>>>        }
>>>
>>> When I deploy this component I get:
>>>
>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>>
>>> And even each logging output I create in bean will be printed twice. But
>>> I
>>> only need one instance. The beans are MessageExchangeListeners. Maybe
>>> there
>>> is a better way to create such beans? I've thought about
>>> servicemix-jsr181
>>> component but not sure for that.
>>>
>>> Regards
>>> /steffen
>>>
>>> -----
>>> Brockhaus GmbH
>>> COMPETITIVE THROUGH KNOWLEDGE
>>>
>>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>>> http://www.brockhaus-group.com www.brockhaus-group.com
>>> --
>>> View this message in context:
>>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://open.iona.com
>>
>>
>
>
> -----
> Brockhaus GmbH
> COMPETITIVE THROUGH KNOWLEDGE
>
> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
> http://www.brockhaus-group.com www.brockhaus-group.com
> --
> View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833614.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://open.iona.com

Re: servicemix-bean singleton

Posted by steff aka sid <sr...@brockhaus-gruppe.de>.
Hm ok, but do you have an example for that? I currently configure my bean
using xbean configuration file like the following:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:bean="http://servicemix.apache.org/bean/1.0"
       xmlns:brockhaus="http://brockhaus-gruppe.de/services/category"
       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://servicemix.apache.org/bean/1.0
http://servicemix.apache.org/schema/servicemix-bean-3.2.2.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

  <bean:endpoint service="brockhaus:categoryClusteringBean"
endpoint="endpoint" bean="#ClusteringBean"/>

  <bean id="ClusteringBean"
class="de.brockhaus-gruppe.beans.ClusteringBean"/>

</beans>

Regards
/Steffen

gnodet wrote:
> 
> Using servicemix-bean, you can either configure a bean or the bean class.
> If you configure the bean directly, only that instance will be used to
> service all requests, whereas if you use the bean class, a new bean
> will be created for each request.
> 
> On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
> <sr...@brockhaus-gruppe.de> wrote:
>>
>> Hi is it possible to have only one instance of an bean component (like a
>> singleton)? I've created serveral beans but all seem to have two
>> instances.
>> In example I've got a init()-Method like:
>>
>>       @PostConstruct
>>        public void init() throws IOException, MessagingException {
>>                if (null == this.context || null == this.channel) {
>>                        throw new IllegalStateException("ClusteringBean
>> not initialized!");
>>                }
>>
>>                log.info("ClusteringBean initialized!");
>>        }
>>
>> When I deploy this component I get:
>>
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>> INFO  - ClusteringBean                 - ClusteringBean initialized!
>>
>> And even each logging output I create in bean will be printed twice. But
>> I
>> only need one instance. The beans are MessageExchangeListeners. Maybe
>> there
>> is a better way to create such beans? I've thought about
>> servicemix-jsr181
>> component but not sure for that.
>>
>> Regards
>> /steffen
>>
>> -----
>> Brockhaus GmbH
>> COMPETITIVE THROUGH KNOWLEDGE
>>
>> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
>> http://www.brockhaus-group.com www.brockhaus-group.com
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://open.iona.com
> 
> 


-----
Brockhaus GmbH
COMPETITIVE THROUGH KNOWLEDGE

Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  / 
http://www.brockhaus-group.com www.brockhaus-group.com 
-- 
View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833614.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: servicemix-bean singleton

Posted by Guillaume Nodet <gn...@gmail.com>.
Using servicemix-bean, you can either configure a bean or the bean class.
If you configure the bean directly, only that instance will be used to
service all requests, whereas if you use the bean class, a new bean
will be created for each request.

On Mon, Oct 6, 2008 at 9:55 AM, steff aka sid
<sr...@brockhaus-gruppe.de> wrote:
>
> Hi is it possible to have only one instance of an bean component (like a
> singleton)? I've created serveral beans but all seem to have two instances.
> In example I've got a init()-Method like:
>
>       @PostConstruct
>        public void init() throws IOException, MessagingException {
>                if (null == this.context || null == this.channel) {
>                        throw new IllegalStateException("ClusteringBean not initialized!");
>                }
>
>                log.info("ClusteringBean initialized!");
>        }
>
> When I deploy this component I get:
>
> INFO  - ClusteringBean                 - ClusteringBean initialized!
> INFO  - ClusteringBean                 - ClusteringBean initialized!
>
> And even each logging output I create in bean will be printed twice. But I
> only need one instance. The beans are MessageExchangeListeners. Maybe there
> is a better way to create such beans? I've thought about servicemix-jsr181
> component but not sure for that.
>
> Regards
> /steffen
>
> -----
> Brockhaus GmbH
> COMPETITIVE THROUGH KNOWLEDGE
>
> Web:  http://www.brockhaus-gruppe.de www.brockhaus-gruppe.de  /
> http://www.brockhaus-group.com www.brockhaus-group.com
> --
> View this message in context: http://www.nabble.com/servicemix-bean-singleton-tp19833428p19833428.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://open.iona.com