You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Jean Safar <js...@quartetfs.com> on 2005/11/03 23:42:02 UTC

Infinite Recusion Issue When Creating a Service

Hi, 

 

Sorry in advance if this is a repeat but I could not see that in the mail
archive. 

 

I am experiencing a problem by which HiveMind (version 1.1 and 1.1-beta-3)
will enter into a infinite recursion when creating a service. This
eventually exhausts all the available memory and makes the program unusable.


 

I have a Service Class MyService implementing the interface IMyService. 

 

This class has a constructor public MyService (IMyService) {...} as well as
other constructors. 

 

The service point of my service has no parameters or explicit injection via
<set-service.

 

When creating the service, it will eventually arrive at a the following test
within the method instantiateCoreServiceInstance in BuildFactoryLogic.

 

        if (_parameter.getAutowireServices() && parameters.isEmpty())

        {

            return instantiateConstructorAutowiredInstance(serviceClass);

        }

 

This test will be satisfied and the instantiateConstructorAutowiredInstance
will then be called. 

 

In it will try and get all the constructors for the given class removing
those not taking interfaces as parameters. 

 

List serviceConstructorCandidates =
getOrderedServiceConstructors(serviceClass);

 

One of this constructor will be the one with IMyService in it. If with bad
luck it comes first in the iteration that follows, the code will try and
call the constructor with parameters which are services attached to the
interfaces of the parameters. 

 

Since the interface is the very interface of the service I am trying to
build, it will enter the loop and never come back. 

 

An easy and effective fix might be to disregard constructors with the
interface of the service it is currently trying to build thus avoiding the
loop. I have tried that and it works fine. 

 

Best Regards, 

 

 


jean safar
European Technology Director 







 

Work: +33172745536
Mobile: +33611507664
Fax: +33172745537

 

Email: jsa@quartetfs.com
IM: safarje (Skype <skype:safarje?call> /Yahoo)
Professional <https://www.linkedin.com/e/fps/697532/>  Profile

 

 <http://www.quartetfs.com> Quartet Financial Systems
52 Bd Sebastopol
<http://maps.google.com/maps?q=52+Bd+Sebastopol%2CParis%2CFrance&hl=en> 
Paris France

 


 <skype:safarje?call> 

Want a <https://www.linkedin.com/e/sig/697532/>  signature like this?

 


Re: Infinite Recusion Issue When Creating a Service

Posted by Knut Wannheden <kn...@gmail.com>.
Hi Jean,

On 11/4/05, Jean Safar <js...@quartetfs.com> wrote:
>
> Indeed the constructor calls a method on IMyService which creates the loop.
>

OK, then I understand. We'll take a look at solving this. Would you
mind entering a bug report into our JIRA issue tracker?

Regards,

--knut

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: Infinite Recusion Issue When Creating a Service

Posted by Jean Safar <js...@quartetfs.com>.
Hi Kurt, 

Indeed the constructor calls a method on IMyService which creates the loop. 

Best Regards, 

jean safar
European Technology Director 	 	 	
	Work: +33172745536
Mobile: +33611507664
Fax: +33172745537
		Email: jsa@quartetfs.com
IM: safarje (Skype/Yahoo)
 Professional Profile
		Quartet Financial Systems
52 Bd Sebastopol
Paris France
		
	Want a signature like this?	

-----Original Message-----
From: Knut Wannheden [mailto:knut.wannheden@gmail.com] 
Sent: Friday, November 04, 2005 10:10 AM
To: hivemind-user@jakarta.apache.org
Subject: Re: Infinite Recusion Issue When Creating a Service

Jean,

On 11/3/05, Jean Safar <js...@quartetfs.com> wrote:
>
> I am experiencing a problem by which HiveMind (version 1.1 and 1.1-beta-3)
will enter into a infinite recursion when creating a service. This
eventually exhausts all the available memory and makes the program unusable.
>
>
> I have a Service Class MyService implementing the interface IMyService.
>
> This class has a constructor public MyService (IMyService) {...} as well
as other constructors.
>

If the constructor implementation doesn't call any methods on the
IMyService parameter and the service's model isn't primitive (which it
isn't in your case), then I reckon this kind of "self injection"
should be fine. If however the constructor implementation calls a
method on the IMyService parameter, then I can see how a loop like
this could be entered.

Can you confirm that your constructor implementation calls a method on
the IMyService parameter?

Thus a better solution than forbidding this style of "self injection"
would be to make the BuilderFactory detect such loops. This should
then also cover cases with more services involved.

--knut

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Infinite Recusion Issue When Creating a Service

Posted by Knut Wannheden <kn...@gmail.com>.
Jean,

On 11/3/05, Jean Safar <js...@quartetfs.com> wrote:
>
> I am experiencing a problem by which HiveMind (version 1.1 and 1.1-beta-3) will enter into a infinite recursion when creating a service. This eventually exhausts all the available memory and makes the program unusable.
>
>
> I have a Service Class MyService implementing the interface IMyService.
>
> This class has a constructor public MyService (IMyService) {...} as well as other constructors.
>

If the constructor implementation doesn't call any methods on the
IMyService parameter and the service's model isn't primitive (which it
isn't in your case), then I reckon this kind of "self injection"
should be fine. If however the constructor implementation calls a
method on the IMyService parameter, then I can see how a loop like
this could be entered.

Can you confirm that your constructor implementation calls a method on
the IMyService parameter?

Thus a better solution than forbidding this style of "self injection"
would be to make the BuilderFactory detect such loops. This should
then also cover cases with more services involved.

--knut

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Assigning Object from Configuration

Posted by Johan Lindquist <jo...@kawoo.co.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes, simply prefix the service id with service: (having made sure that
the attribute schema defines the translator as "object").

Johan

Derek Brown wrote:
> Hello,
> 
> How can I assign an object, which maybe a service, instance or class
> using a ConfigurationPoint? If i use a translator for this how can I
> specify more than one translator? Is there a translator that can parse:
> service: instance: etc already?
> 
> Thanks
> 
> ------------------------------------------------------------------------
> Yahoo! FareChase - Search multiple travel sites in one click.
> <http://us.lrd.yahoo.com/_ylc=X3oDMTFqODRtdXQ4BF9TAzMyOTc1MDIEX3MDOTY2ODgxNjkEcG9zAzEEc2VjA21haWwtZm9vdGVyBHNsawNmYw--/SIG=110oav78o/**http%3a//farechase.yahoo.com/>
> 

- --
you too?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDeyed1Tv8wj7aQ34RAr++AJ40u79gbPiBe6XqGr72KkPRtOR6ygCfS5CA
FvWXPGbzOZGCC9RApazJ0MU=
=T7FI
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: Assigning Object from Configuration

Posted by James Carman <ja...@carmanconsulting.com>.
Derek,

 

Have you tried using the ObjectTranslator?  It allows you to use another
translator so that the value can come from anywhere.  Take a look at how
hivemind-lib defines the MethodInterceptorFactory service.  It uses the
ObjectTranslator so that you can supply a MethodInterceptor from anywhere
(service, instance, etc.).  Hope that helps!

 

James

 

 

  _____  

From: Derek Brown [mailto:zegloman@yahoo.com] 
Sent: Wednesday, November 16, 2005 7:06 AM
To: hivemind-user@jakarta.apache.org
Subject: Assigning Object from Configuration

 

Hello,

How can I assign an object, which maybe a service, instance or class using a
ConfigurationPoint? If i use a translator for this how can I specify more
than one translator? Is there a translator that can parse: service:
instance: etc already?

Thanks

  _____  

Yahoo!
<http://us.lrd.yahoo.com/_ylc=X3oDMTFqODRtdXQ4BF9TAzMyOTc1MDIEX3MDOTY2ODgxNj
kEcG9zAzEEc2VjA21haWwtZm9vdGVyBHNsawNmYw--/SIG=110oav78o/**http%3a/farechase
.yahoo.com/>  FareChase - Search multiple travel sites in one click. 


Assigning Object from Configuration

Posted by Derek Brown <ze...@yahoo.com>.
Hello,
  
  How can I assign an object, which maybe a service, instance or class  using a ConfigurationPoint? If i use a translator for this how can I  specify more than one translator? Is there a translator that can parse:  service: instance: etc already?
  
  Thanks
  
		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  

RE: Infinite Recusion Issue When Creating a Service

Posted by Jean Safar <js...@quartetfs.com>.
Hi James, 

 

I am declaring the service point as follows: 

 

  <service-point id="MyService" interface="com.quartetfs.biz.types.I
MyService ">

    Date Implementation

    <invoke-factory>

      <construct class="com.quartetfs.MyService " />

    </invoke-factory>

  </service-point>

 

regards,

 


jean safar
European Technology Director 







 

Work: +33172745536
Mobile: +33611507664
Fax: +33172745537

 

Email: jsa@quartetfs.com
IM: safarje (Skype <skype:safarje?call> /Yahoo)
Professional Profile <https://www.linkedin.com/e/fps/697532/> 

 

 <http://www.quartetfs.com> Quartet Financial Systems
52 Bd Sebastopol
<http://maps.google.com/maps?q=52+Bd+Sebastopol%2CParis%2CFrance&hl=en> 
Paris France

 


 <skype:safarje?call> 

Want a signature like this? <https://www.linkedin.com/e/sig/697532/> 

 

  _____  

From: James Carman [mailto:james@carmanconsulting.com] 
Sent: Friday, November 04, 2005 2:33 AM
To: hivemind-user@jakarta.apache.org
Subject: RE: Infinite Recusion Issue When Creating a Service

 

Jean,

 

Are you using the primitive service lifecycle model?  

 

James

 

  _____  

From: Jean Safar [mailto:jsa@quartetfs.com] 
Sent: Thursday, November 03, 2005 5:42 PM
To: hivemind-user@jakarta.apache.org
Subject: Infinite Recusion Issue When Creating a Service

 

--> 

Hi, 

 

Sorry in advance if this is a repeat but I could not see that in the mail
archive. 

 

I am experiencing a problem by which HiveMind (version 1.1 and 1.1-beta-3)
will enter into a infinite recursion when creating a service. This
eventually exhausts all the available memory and makes the program unusable.


 

I have a Service Class MyService implementing the interface IMyService. 

 

This class has a constructor public MyService (IMyService) {...} as well as
other constructors. 

 

The service point of my service has no parameters or explicit injection via
<set-service.

 

When creating the service, it will eventually arrive at a the following test
within the method instantiateCoreServiceInstance in BuildFactoryLogic.

 

        if (_parameter.getAutowireServices() && parameters.isEmpty())

        {

            return instantiateConstructorAutowiredInstance(serviceClass);

        }

 

This test will be satisfied and the instantiateConstructorAutowiredInstance
will then be called. 

 

In it will try and get all the constructors for the given class removing
those not taking interfaces as parameters. 

 

List serviceConstructorCandidates =
getOrderedServiceConstructors(serviceClass);

 

One of this constructor will be the one with IMyService in it. If with bad
luck it comes first in the iteration that follows, the code will try and
call the constructor with parameters which are services attached to the
interfaces of the parameters. 

 

Since the interface is the very interface of the service I am trying to
build, it will enter the loop and never come back. 

 

An easy and effective fix might be to disregard constructors with the
interface of the service it is currently trying to build thus avoiding the
loop. I have tried that and it works fine. 

 

Best Regards, 

 

 


jean safar
European Technology Director 







 

Work: +33172745536
Mobile: +33611507664
Fax: +33172745537

 

Email: jsa@quartetfs.com
IM: safarje (Skype <skype:safarje?call> /Yahoo)
Professional <https://www.linkedin.com/e/fps/697532/>  Profile

 

 <http://www.quartetfs.com> Quartet Financial Systems
52 Bd Sebastopol
<http://maps.google.com/maps?q=52+Bd+Sebastopol%2CParis%2CFrance&hl=en> 
Paris France

 


 <skype:safarje?call> 

Want a signature <https://www.linkedin.com/e/sig/697532/>  like this?

 


RE: Infinite Recusion Issue When Creating a Service

Posted by James Carman <ja...@carmanconsulting.com>.
Jean,

 

Are you using the primitive service lifecycle model?  

 

James

 

  _____  

From: Jean Safar [mailto:jsa@quartetfs.com] 
Sent: Thursday, November 03, 2005 5:42 PM
To: hivemind-user@jakarta.apache.org
Subject: Infinite Recusion Issue When Creating a Service

 

--> 

Hi, 

 

Sorry in advance if this is a repeat but I could not see that in the mail
archive. 

 

I am experiencing a problem by which HiveMind (version 1.1 and 1.1-beta-3)
will enter into a infinite recursion when creating a service. This
eventually exhausts all the available memory and makes the program unusable.


 

I have a Service Class MyService implementing the interface IMyService. 

 

This class has a constructor public MyService (IMyService) {...} as well as
other constructors. 

 

The service point of my service has no parameters or explicit injection via
<set-service.

 

When creating the service, it will eventually arrive at a the following test
within the method instantiateCoreServiceInstance in BuildFactoryLogic.

 

        if (_parameter.getAutowireServices() && parameters.isEmpty())

        {

            return instantiateConstructorAutowiredInstance(serviceClass);

        }

 

This test will be satisfied and the instantiateConstructorAutowiredInstance
will then be called. 

 

In it will try and get all the constructors for the given class removing
those not taking interfaces as parameters. 

 

List serviceConstructorCandidates =
getOrderedServiceConstructors(serviceClass);

 

One of this constructor will be the one with IMyService in it. If with bad
luck it comes first in the iteration that follows, the code will try and
call the constructor with parameters which are services attached to the
interfaces of the parameters. 

 

Since the interface is the very interface of the service I am trying to
build, it will enter the loop and never come back. 

 

An easy and effective fix might be to disregard constructors with the
interface of the service it is currently trying to build thus avoiding the
loop. I have tried that and it works fine. 

 

Best Regards, 

 

 


jean safar
European Technology Director 







 

Work: +33172745536
Mobile: +33611507664
Fax: +33172745537

 

Email: jsa@quartetfs.com
IM: safarje (Skype <skype:safarje?call> /Yahoo)
Professional Profile <https://www.linkedin.com/e/fps/697532/> 

 

 <http://www.quartetfs.com> Quartet Financial Systems
52 Bd Sebastopol
<http://maps.google.com/maps?q=52+Bd+Sebastopol%2CParis%2CFrance&hl=en> 
Paris France

 


 <skype:safarje?call> 

Want a <https://www.linkedin.com/e/sig/697532/>  signature like this?