FactoryBean « Bean « Spring Q&A





1. Spring: How to programmatically define FactoryBean    stackoverflow.com

I want to programmatically setup a FactoryBean on an existing ApplicationContext. There are a lot of examples on how to define a bean programmatically (e.g.: http://www.carlobonamico.com/blog/2008/01/22/how-to-dynamicallyprogrammatically-define-spring-beans/), but they do not ...

2. How to autowire factorybean    stackoverflow.com

I have a ServiceListFactoryBean which creates a list of service implementations:

<bean id="services"
      class="org.springframework.beans...ServiceListFactoryBean"
      p:serviceType="ServiceInterface"/>
I can access the services using the applicationContext ...

3. Spring FactoryBean - iterating over an "object creation" list    stackoverflow.com

Santa's got a list. He wants to make a "present" for every child on hist list (we're assuming for the moment they're all good) and load them all in his sled. ...

4. Spring FactoryBean and scopes working together    stackoverflow.com

I'd like to use FactoryBeans and scopes together. Specifically, I'd like the object created and returned by a FactoryBean to be placed into a specified (perhaps custom) scope. The issue is ...

5. How to inject FactoryBean instead of object it produces?    stackoverflow.com

Let's say I have following Spring config (version of Spring is 3.0.3):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd">

   <bean id="theFactoryBean" class="wax.MyFactoryBean"/>

   ...

6. How to get beans created by FactoryBean spring managed?    stackoverflow.com

The FactoryBean can be used to programmatically create objects which might require complex instantiation logic. However, it seems that the beans created by the FactoryBean doesn't become spring managed. ...

7. FactoryBeans and the annotation-based configuration in Spring 3.0    stackoverflow.com

Spring provides the FactoryBean interface to allow non-trivial initialisation of beans. The framework provides many implementations of factory beans and -- when using Spring's XML config -- factory beans are easy ...

8. How to autowire factorybean instance (not the getObject() object) with annotations?    stackoverflow.com

I know it is possible to get the reference to the factorybean instance when defining the beans with XML (Spring). e.g.:

<property name="factoryBean" ref="&amp;theFactoryBean" />
But is this also posible to ...

9. Multiple calls to getObject in step scoped FactoryBean    forum.springsource.org

Multiple calls to getObject in step scoped FactoryBean I wanted to raise this in the forum, before I created a jira. I have a factorybean which I have configured with step ...





10. FactoryBean threadsafety and scopes    forum.springsource.org

The factorybean's javadoc says Code: * NOTE: FactoryBean objects participate in the containing * BeanFactory's synchronization of bean creation. There is usually no * need for internal synchronization other than for ...

11. Injecting FactoryBean properties    forum.springsource.org

Injecting FactoryBean properties Hello all, Consider this example: bean1FactoryBean is a bean which, obviously, implements FactoryBean. I have two questions. Well, an observation and ...

12. FactoryBean with Orchestra    forum.springsource.org

FactoryBean with Orchestra Hello, I guess this is not a Spring problem, but i found no other forum, so i try here. I am Using Spring 3 with Orchestra 1.4. I ...

13. Populate properties on non-FactoryBean build objects    forum.springsource.org

Populate properties on non-FactoryBean build objects I have an object that is NOT instantiated by a BeanFactory, but that I would like to use Spring's @Value and @Autowire annotations. Specifically, I ...

14. Find FactoryBeans that implement a specific interface    forum.springsource.org

Hello, I need to find FactoryBeans in my ApplicationContext that implement a certain interface. There doesn't seem to be any way of accomplishing this from the ApplicationContext interface? I can get ...

15. FactoryBean, BeanPostProcessor, and BeanFactoryPostProcessor    forum.springsource.org

FactoryBean, BeanPostProcessor, and BeanFactoryPostProcessor I wanted to write a BeanFactoryPostProcessor that looked at the other bean definitions and created a Map based on those according to some criteria. I intended to ...

16. FactoryBean.getObject being called before afterPropertiesSet    forum.springsource.org

FactoryBean.getObject being called before afterPropertiesSet I don't have a simple test case yet, but the gist is: Code: ruleset.xml: ...





17. FactoryBean how does it work ?    forum.springsource.org

I'm a bit confused with FactoryBean, especially with the singleton attribute. the question is : how can I get a different object on each call to a FactoryBean ? I'm using ...

18. FactoryBean for configuring Resources.    forum.springsource.org

Apr 17th, 2005, 10:55 PM #1 rcui View Profile View Forum Posts Private Message Junior Member Join Date Oct 2004 Location New York, NY Posts 8 FactoryBean for configuring Resources. Since ...

19. Non signaled problem with FactoryBeans    forum.springsource.org

Non signaled problem with FactoryBeans Spring 1.2. As far as I understood a FactoryBean *must* be always a singleton. This bean definition is resulting in an exception (this is correct as ...

20. destroy-method usage with FactoryBean    forum.springsource.org

Hello, I've setup a FactoryBean to build MQSeries MQQueue objects. I'd like to setup a detroy-method to the objects built by my factory. I've configured : Code: ...

21. How to get a FactoryBean reference in my context definition?    forum.springsource.org

How to get a FactoryBean reference in my context definition? Yep...it's gotta be a stupid question, but I just can't seem to find the answer. I want to populate a custom ...

22. BeanPostProcessor not invoked for FactoryBean created beans?    forum.springsource.org

I am seeing that BeanPostProcessor is invoked for FactoryBeans, but not the beans the created by the FactoryBean's. Is this is the intended behavior? Is it worth my while to file ...

23. best practice for destroy method for FactoryBeans    forum.springsource.org

What is the best practice to deal with the destroy method for a FactoryBean if the innerbean has multiple shutdown methods? If you take a look at the ScheduledThreadPoolExecutor there are ...

24. BeanFactory, FactoryBean and &    forum.springsource.org

BeanFactory, FactoryBean and & This is section 3.6.1 from the ref manual: "3.6.1. Obtaining a FactoryBean, not its product Sometimes there is a need to ask a BeanFactory for an actual ...

25. Accessing a FactoryBean    forum.springsource.org

Hi all, What is the best way to access a FactoryBean instance itself? How can i do this? The interface itself has the following documentation: >> A bean that implements this ...

26. BeanNameAutoProxyCreator and FactoryBeans    forum.springsource.org

BeanNameAutoProxyCreator and FactoryBeans I have been playing around with BeanNameAutoProxyCreator it looks like it does not work with ProxyFactoryBean or any FactoryBeans for that matter. Also if you use parent beans ...

27. FactoryBean for Values?    forum.springsource.org

Hello everyone, Is there a FactoryBean that returns simple values, so I can use it in place of a just by referencing the FactoryBean? This sounds like a very generic ...

28. FactoryBean injection    forum.springsource.org

FactoryBean injection I have a rather basic question, but after searching through boards I have not been able to find a solution. I'm looking for a way to inject a property ...

29. FactoryBean problem: getObject() invoked before properties set    forum.springsource.org

Dec 20th, 2005, 10:15 AM #1 DaVinci79 View Profile View Forum Posts Private Message Junior Member Join Date Aug 2004 Posts 12 FactoryBean problem: getObject() invoked before properties set I'm using ...

30. Scoped Beans and Prototype FactoryBeans    forum.springsource.org

Hi, I'm trying the scoped beans feature delivered with Spring 2.0 Mx. There seems to be no documentation except the sample at http://wiki.opensymphony.com/display...ts+Workarounds. Unfortunately adopting this example does not work for ...

31. getObject() on FactoryBean with singleton product    forum.springsource.org

getObject() on FactoryBean with singleton product I have implemented a FactoryBean that returns singleton instance and returns true from isSingleton(). The product of this factory is set as a property on ...

32. Initialize scoped bean using FactoryBean    forum.springsource.org

Initialize scoped bean using FactoryBean Does anyone know how to go about initializing an AOP proxied request or session scoped bean via a FactoryBean? Take the UserPreferences example from the Spring ...

33. Injecting or retrieving the FactoryBean of a bean    forum.springsource.org

Injecting or retrieving the FactoryBean of a bean Hi, I tried both to inject or to retrieve the FactoryBean of a bean according to the last paragraph in section 3.7.3. Customizing ...

34. Using a FactoryBean to return String from file    forum.springsource.org

Some of my XML configuration files are getting a bit hefty, due to some chunks of SQL being injected into Strings. I'd like to pull out the SQL to different files, ...

35. FactoryBean clarification    forum.springsource.org

In the interface, every impl has to implement isSingleton(). Since Spring 2.0 has been released, we have an option of replacing singleton = "true|false" is replaced by scope variable. Do we ...

36. aop:scoped-proxy and Map/List-FactoryBean    forum.springsource.org

aop:scoped-proxy and Map/List-FactoryBean hi all, i am currently running in a problem when using an injected map which is "aop:scoped". here is some code: Code:

37. configuring factory object created via FactoryBean    forum.springsource.org

configuring factory object created via FactoryBean I have use a JndiObjectFactoryBean to retrieve an object from a JNDI repository like this:

38. JCR SimpleCredentials - FactoryBean    forum.springsource.org

JCR SimpleCredentials - FactoryBean Costin I really like the module for JCR, I was begining to work on something like this myself but glad I came across this first. I read ...

39. FactoryBean: injecting to returned bean.    forum.springsource.org

How do you set a property on a bean returned by a FactoryBean? You can set properties on the FactoryBean itself, but I need to inject into the returned object. I'm ...

40. FactoryBean and prototype    forum.springsource.org

FactoryBean and prototype Hi, I'm trying to launch a scheduled job that exports some data into files. The file name represents the date at which the job has been launched (classical ...

41. PropertyPlaceholderConfigurer not working with FactoryBean    forum.springsource.org

PropertyPlaceholderConfigurer not working with FactoryBean I have an application context in which I define a PropertyPlaceholderConfigurer which works as expected when defining normal beans. Code: classpath:allconnection.${environment}.properties ...

42. FactoryBean vs ApplicationContextAware    forum.springsource.org

the problem is that once i make the bean applicationContextAware i get these errors. Code: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openProjectJob' defined in ServletContext resource [/WEB-INF/quartz/quartzJobSpringBeans.xml]: Invocation of init method ...

43. unwanted pre-initialization of a FactoryBean    forum.springsource.org

unwanted pre-initialization of a FactoryBean Hi all, I have a bean that needs to be a prototype, and proxied with transactions. I have created this bean definition: ...

44. Problem assigned a scoped factorybean to a string property    forum.springsource.org

Problem assigned a scoped factorybean to a string property Hi, I'm having a problem when I want to assign a scoped FactoryBean (that can return a String) to a string property. ...

45. Unable to understand concept behind FactoryBean    forum.springsource.org

Unable to understand concept behind FactoryBean Hello, I am using Spring 1.2.8. Gone through the documentation but am unable to grasp the concept behind FactoryBean. Quoted from Spring 1.2.8 documentation : ...

46. How to define bean of type LegacyBean.getInstance() without FactoryBean?    forum.springsource.org

How to define bean of type LegacyBean.getInstance() without FactoryBean? HI, I have to support a special type of legacy bean of for my legacy application. Actual fully initialized instance of that ...

47. Correct Usage of FactoryBeans in JavaConfig    forum.springsource.org

Correct Usage of FactoryBeans in JavaConfig Hi, folks! I didn't find any documentation on how to convert XML's declarations of FactoryBeans into JavaConfig. For example, consider the following XML configuration: Code: ...

48. FactoryBean threw exception on object creation    forum.springsource.org

FactoryBean threw exception on object creation I have the following case : taskMetadataService has ref to runtimeConfigService and verificationService beans; verificationService has ref to taskMetadataService bean; runtimeConfigService has ref to taskMetadataService ...

49. Annotations not processed on beans from custom FactoryBean    forum.springsource.org

Hi all, I have just started using spring and so far I like it, a lot. However, I am having my first issue. How do I get annotation processing to occur ...

50. FactoryBean and bean() PCD    forum.springsource.org

FactoryBean and bean() PCD Hi I just come across a silly behavior of bean() PCD - if bean we want to advice is created by FactoryBean both factory and its product ...

51. @Autowire and FactoryBean    forum.springsource.org

I've annotated a few setters on a custom FactoryBean with the Autowire annotation. However, after trying out the application, it doesn't seem the Autowire annotations are processed for FactoryBeans? Is that ...

52. Looking for a FactoryBean that returns a list of all beans implementing an interface    forum.springsource.org

Looking for a FactoryBean that returns a list of all beans implementing an interface Hi, Looking at the Spring API (2.5.6), I can't find this kind of factory, something that collects ...

53. Annotation configuration and FactoryBeans    forum.springsource.org

Annotation configuration and FactoryBeans I currently have a Spring Portlet application and am seeing some behavior in the portlet context that I can not explain. My issue surrounds the use of ...

54. Help with a FactoryBean    forum.springsource.org

Help with a FactoryBean Hello! I'm quite new to Spring and I can't understand one thing about FactoryBeans. Suppose I have a FactoryBean like the following: Code: public class MyFactoryBean implements ...

55. autowire bean created factorybean does not work    forum.springsource.org

autowire bean created factorybean does not work Hi, It's seem that beans created by fatorybean cannot be autowired. Here's the code : @Service class MyService { @Autowired private Cache cache; ... ...

56. Overriding a FactoryBean implementatino to specialize the getObject() method    forum.springsource.org

Overriding a FactoryBean implementatino to specialize the getObject() method Hello, I would like to override a BeanFactory, let's say the SimpleHttpServerFactoryBean. When I do this: Code: public class MySimpleHttpServerFactoryBean extends SimpleHttpServerFactoryBean ...

57. Exposing FactoryBean as ManagedResource    forum.springsource.org

Exposing FactoryBean as ManagedResource Hi, Can someone suggest the simplest way to expose a FactoryBean as a ManagedResource? I'm trying to extend the Spring TimerFactoryBean so that Timers can be 'paused' ...

58. Inject into Interceptor via FactoryBean    forum.springsource.org

I'm trying to inject an object via a FactoryBean into an Interceptor but keep getting the a "Singleton instance not initialized yet" exception: Code: Error setting property values; nested exception is ...

59. Post-processing of the FactoryBean's object failed; GenericSignatureFormatError    forum.springsource.org

Nov 20th, 2009, 08:22 PM #1 lumpynose View Profile View Forum Posts Private Message Senior Member Join Date May 2005 Location California, US Posts 735 Post-processing of the FactoryBean's object failed; ...

60. Problem with FactoryBean and generics in 3.0    forum.springsource.org

Problem with FactoryBean and generics in 3.0 An issue was filed in JIRA which seems to have been lost in the noise, converning the use of generics in the 3.0 FactoryBean ...

61. How to make factoryBeans work with javaConfig?    forum.springsource.org

How to make factoryBeans work with javaConfig? Hi, I am trying to set up spring with javaConfig. Now I am coming across a problem that seems to be known but can't ...

62. Attaching AOP advice to beans instantiated via FactoryBean    forum.springsource.org

Basically, the question boils down to - will spring proxy (if needed) a bean instantiated via factory bean. And if not - then is there a way to do that? Code: ...

63. Could not autowire field when using FactoryBean?    forum.springsource.org

Could not autowire field when using FactoryBean? Hi, Not sure what happened, but I've been migrating my codebase to annotation-based Controllers. Now when I start my application I get an error ...

64. FactoryBean in Spring 3 + Configuration    forum.springsource.org

FactoryBean in Spring 3 + Configuration Hi, i moved from Spring Java Config project towards Spring 3. in Spring Java Config, when u wanted to return an object of a factory ...

65. FactoryBean does not deliver the targetclass but itself    forum.springsource.org

FactoryBean does not deliver the targetclass but itself Hi, I've recently upgraded the spring framework from 3.0.2 to 3.05 and from Java 1.4 to Java 1.6 for a existing project. This ...

66. FactoryBean that uses computed selector of desired bean?    forum.springsource.org

FactoryBean that uses computed selector of desired bean? During startup the app computes a value and based on this value sets a bean's property. Sounds like a job for 'MethodInvokingFactoryBean'. However, ...