Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Create own bean
Create own bean [message #1857357] Wed, 01 February 2023 15:38 Go to next message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 44
Registered: June 2018
Member
Hello.

It is possible create my own bean?
I created interface and class in client part:
@Bean
interface MyInterface {
...
}

class MyClass implements MyInterface {
...
}


And I wanted to use it:
MyInterface cl = BEANS.get(MyInterface.class);
...


But this not works. The app didn't launch but froze on launch. When I removed @Bean, it started.

Am I doing something wrong or does it not work?

Thank you for response.
Re: Create own bean [message #1857360 is a reply to message #1857357] Wed, 01 February 2023 16:49 Go to previous messageGo to next message
Stephan Merkli is currently offline Stephan MerkliFriend
Messages: 40
Registered: April 2012
Member
Hi Miloslav

Yes, you can create own beans that way, your code seems to be okay.

A deadlock could occur when you reference another bean in our MyClass that reference MyClass again. Example:
@Bean
public class A {

  private static final B VALUE = BEANS.get(B.class);
}

@Bean
public class B {

  private static final A VALUE = BEANS.get(A.class);
}


Avoid such code or use LazyValue instead. You might take a thread dump and see what is the blocking operation if there is a different reason for your freeze.

Regards
Stephan
Re: Create own bean [message #1857382 is a reply to message #1857360] Thu, 02 February 2023 20:32 Go to previous message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 44
Registered: June 2018
Member
Thank you for reponse. It works. The deadlock was caused by this:
class MyClass implements MyInterface {
	private static final String LOGINTYPES = CONFIG.getPropertyValue(LoginTypes.class);
	private static final String ICON_WIDTH = CONFIG.getPropertyValue(LoginIconWidth.class);

...
}
Previous Topic:ServerAccessControlService is called twice in production code
Next Topic:TablePage pagination
Goto Forum:
  


Current Time: Thu Feb 29 00:15:55 GMT 2024

Powered by FUDForum. Page generated in 0.02374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top