Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a bean with a dot(.) in its ID

In a flow definition, I am trying to access a bean that has a dot in its ID

(example: <evaluate expression="bus.MyServiceFacade.someAction()" />

However, it does not work. SWF tries to find a bean "bus" instead.

Initially, I got over it by using a helper bean to load the required bean, but the solution is inelegant and uncomfortable. The use of alias'es is also out of the question since the beans are part of a large system and I cannot tamper with them.

In a nutshell, none of the solution allowed me to refernce the bean directly by using its original name. Is that even possible in the current SWF release?

like image 984
Arnelism Avatar asked Sep 15 '08 13:09

Arnelism


People also ask

Can we define bean without id?

You are not required to supply a name or id for a bean. If no name or id is supplied explicitly, the container generates a unique name for that bean. However, if you want to refer to that bean by name, through the use of the ref element or Service Locator style lookup, you must provide a name.

What is id in bean?

Every bean has one or more ids (also called identifiers, or names; these terms refer to the same thing). These ids must be unique within the container the bean is hosted in. A bean will almost always have only one id, but if a bean has more than one id, the extra ones can essentially be considered aliases.

What is the id of the created bean?

When Spring creates a Bean Definition from a @Service or @Component annotation, it will by default create an id for the bean by lowercasing the first letter of the Class Name. If you want to override that the behavior, you can provide an alternative id in the annotation, eg. @Service("profileService").

Is bean id mandatory in Spring?

Sr.No. This attribute is mandatory and specifies the bean class to be used to create the bean. This attribute specifies the bean identifier uniquely. In XMLbased configuration metadata, you use the id and/or name attributes to specify the bean identifier(s).


1 Answers

I was able to do this by using both the bean accessor (@) symbol and single-quotes around the name of the bean.

Using your example: #{@'bus.MyServiceFacade'.someAction()}

like image 160
Ryan Ransford Avatar answered Oct 26 '22 23:10

Ryan Ransford