factory « Core « Spring Q&A





1. Spring as a glorified factory; is this acceptable?    stackoverflow.com

I just inherited a Java application and upon inspection of the code, I'm seeing what IMHO is a bastardization of the Spring framework. You see, the Java team seems to ...

2. Extending spring's default component factory    stackoverflow.com

This is a short one: I want to modify the way spring instantiates my beans (in this case, by creating a proxy instead of simply instantiating it). I can't use Jdk ...

3. Would you use DI or a factory?    stackoverflow.com

My application stores files, and you have the option of storing the files on your own server or using S3. I defined an interface:

interface FileStorage {

}
Then I have 2 implementations, S3FileStorage and ...

4. Is this a perfect problem for the factory pattern?    stackoverflow.com

I want to design the file storage part of my application with some flexibility, so one can store files in either S3 or on the web server's hard drive. I also want ...

5. Spring: Using "Lookup method injection" for my ThreadFactory looks not scalable    stackoverflow.com

We're building a ThreadFactory so everytime a singleton controller needs a new thread, i get a new instance everytime. Looking at Lookup method injection looks good but what if we ...

6. Create ObjectPool in Spring    stackoverflow.com

I have a class


class ObjPool {
 MyObject getObject() {...}
 void returnObject() {...}
 int getUsedCount() {...}
}
How can we use Spring framework so that it would provide only one copy of this factory ...

7. static factory method (Spring)    stackoverflow.com

What is the advantage and use to Instantiate a bean in Spring Framework using a static factory method?

8. Spring: Injecting Resource as InputStream into a factory-method    stackoverflow.com

I want to use anti-samy from OWASP. They got a Policy object, that is instantiated via a factory method.

public static Policy getInstance(InputStream inputStream);
The InputStream that needs to be passed to the factory-method ...

9. Using abstract factory with Spring framework    stackoverflow.com

I have some Abstract Factory

public interface AbstractViewersFactory {
    IAbstractShapeViewer createRectangle(BaseOperationsListener<RectangleDTO> p);
    IAbstractShapeViewer createOval(BaseOperationsListener<OvalDTO> p);
    IAbstractShapeViewer createTriangle(BaseOperationsListener<TriangleDTO> p);
}
And Its implementation Draw2DViewersFactory. Now, I ...





10. Create factory from static factory method, then call static factory method on that id    stackoverflow.com

I can create an object from a static factory object like so:

<bean id="myFactory" class="com.myco.MyFactory1" factory-method="createFactory">
  <constructor-arg value="aString" />
</bean>
Now I want to use the id 'myFactory' to call its static 'createFactory' ...

11. How to use @Autowired to dynamically inject implementation like a factory pattern    stackoverflow.com

I am fairly new to Sprint and am using Spring 3.x and roo1.1.1 for my application. I have multiple implementation of an interface which would be @Autowired into other different classes. I ...

12. What is the spring way to autowire factory created instances?    stackoverflow.com

I have a controller which is supposed to create version dependend instances (currently not implemented).

@Controller
public class ReportController {

    @Autowired
    private ReportCompFactory     ...

13. Create a spring like wiring class    stackoverflow.com

I want to create a bean that will act as a provider. I will give it the class that it should return and the list of properties that I should set before ...

14. Spring and passing parameters to factory-method in runtime    stackoverflow.com

The documentation of method context.getBean(name, user) says

Allows for specifying explicit constructor arguments / factory method arguments
but no matter what I do (tried everything), with the most logical setting ...

15. Dependency injeciton vs global factory    stackoverflow.com

Why do people default to DI vs a global factory with a hashmap that maps interfaces/abstracts to classes? It would seem this is a higher performance solution to the problem no? All ...

16. Factory with argument at runtime    forum.springsource.org

Hello! I'm a noob, I know...I'm facing an issue that maybe it doesn't have a solution for how I'm thinking of it.. Is it possible this: Code:





17. passing argument to factory-method during runtime    forum.springsource.org

18. "factory method" returning an interface?    forum.springsource.org

"factory method" returning an interface? Hi, I have a factory that creates different sub-classes depending on configuration. For example if might return either "EnglishComparator" or "ChineseComparator": interface Comparator { } class ...

19. Factory-Method.    forum.springsource.org

Hi all, I understand the scope of bean. I am not understanding the factory-method, could somebody help me out on the need of factory-method. Thanks in advance Madhu

20. Comparison result-factory vs result-transformer    forum.springsource.org

Where the provided result types are not sufficient a reference to a custom implementation of ResultFactory can be provided as an alternative to setting the result-type attribute using the result-factory attribute. ...

21. Abstract factory with a prototypes name as a String?    forum.springsource.org

Abstract factory with a prototypes name as a String? I'm new to Spring and I need to create an abstract factory always returns a new copy of a prototype bean. I ...

22. Error getting Factory Method in 3.1.0-BUILD-SNAPSHOT.    forum.springsource.org

Sep 12th, 2011, 07:02 PM #1 moriarty-s3a View Profile View Forum Posts Private Message Junior Member Join Date May 2011 Posts 3 Error getting Factory Method in 3.1.0-BUILD-SNAPSHOT. I decided to ...

23. Creating a dynamic Factory for a new class during runtime    forum.springsource.org

Dear Community, i am currently working on my diploma based on Spring. I have the following problem: I want to create a factory for a Class during runtime of the container. ...

24. factory-method annoyance    forum.springsource.org

factory-method annoyance Hi, I'm using Spring to connect to an old CORBA server, and I want to use the ORB.init method (the static factory method for obtaining the ORB) from XML. ...

25. stupid little problem with factory    forum.springsource.org

Hi, when I try this : Code: host db 1234 thin ...

26. Factory method in spring (newb question)    forum.springsource.org

Hello, Is it possible to define a kind of factory-method in Spring. I have an interface MyService and two implementation FooService and BarService. In one case i wanna link to FooService ...

27. factory- and init-method    forum.springsource.org

I'd like to specifiy a bean by using the factory-bean / factory-method syntax. The factory-bean which provides the method however requires custom initialization as expressed by the init-method before the factory-method ...

28. setting a dependency on a factory result    forum.springsource.org

setting a dependency on a factory result I have a somewhat tricky problem setting a dependency on a factory that has no default constructor but a getInstance method Code:

29. instance factory method doesn't work w/ static methds    forum.springsource.org

I am using bean instantiations through factory method. I noticed that if the methods in the factory are static I get an error: org.springframework.beans.factory.BeanDefinitionSt oreException: Cannot find matching factory method 'createInstance' ...

30. How can I explicity specify the no-arg factory-method?    forum.springsource.org

How can I explicity specify the no-arg factory-method? I am trying to follow the pattern described in the Spring Reference document: 3.2.3.3. Bean creation via instance factory method But I am ...

31. static factory-method fails to type check (bug?)    forum.springsource.org

static factory-method fails to type check (bug?) Hi - I have a POJO (created by a static factory-method, see ref "3.2.3.2. Bean creation via static factory method") Code:

32. springifying the factory pattern    forum.springsource.org

springifying the factory pattern Hi, I'm trying to get my head around how to springify following construct : Code: // contextObject contains info necessary to decide which Producer to instantiate Producer ...

33. Strategy for implementing a driver factory..    forum.springsource.org

Strategy for implementing a driver factory.. Hi there, I'm fairly new to Spring.. I have a service POJO that relies on what I call an AdapterFactory (essentially a driver factory). Code: ...

34. Factory method problem    forum.springsource.org

Jul 13th, 2005, 06:22 AM #1 virgo_ct View Profile View Forum Posts Private Message Member Join Date Nov 2004 Location Cape Town, South Africa Posts 33 Factory method problem Using Spring ...

35. A factory that takes an argument    forum.springsource.org

Our application includes a factory that returns an instance based on a parameter passed to the factory method. Something like this: Code: InterestingThing thing = ThingFactory.getThing(23); InterestingThing other = ThingFactory.getThing(99); How ...

36. Factory identified by reference    forum.springsource.org

I have bean (A) that is produced from a factory. I'd like to specify that factory (B) as another bean, and have A's definition identify the factory instance by reference. Is ...

37. Using Spring as a "plain" factory    forum.springsource.org

How can I use Spring to construct a non-spring bean object? eg: I have an User interface, and an UserImpl class. How can I use Spring to construct an User implementation ...

38. what to do if a factory-method returns null?    forum.springsource.org

what to do if a factory-method returns null? Hi gurus in my appContext.xml there's a factory method, that extracts a configuration object out of a DB. ...

39. How to dynamic create a instance like factory pattern in spring    forum.springsource.org

How to dynamic create a instance like factory pattern in spring I can user Factory pattern to instantiate a new object by given some type identify. But for spring, it seams ...

40. Bug in JpaDaoSupport.setEntityManager(FACTORY)?    forum.springsource.org

Bug in JpaDaoSupport.setEntityManager(FACTORY)? I'm testing support for Hibernate EntityManager in Spring 2.0-m3 but I get an exception saying Code: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined ...

41. Efficient way of using factory implementation.    forum.springsource.org

Efficient way of using factory implementation. Hi All, I have a problem where i have a map injected into a service class, and that map is of type Map Now what ...

42. New Scope "none" or "factory"    forum.springsource.org

New Scope "none" or "factory" I'm currently attempting to convert my JSF managed bean facilities to Spring scoped beans. One thing that I believe Spring scoped beans provides over JSF managed ...

43. Resolver vs. Factory    forum.springsource.org

Resolver vs. Factory It seems to me that there is a very fine line between what a Resolver does and a Factory. Is there an official definition of these terms (and ...

44. Making use of the factory as resource loader    forum.springsource.org

I know I can do this by wiring in a bean that is an instance of DefaultResourceLoader, but I am wondering how to get access to the application context and use ...

45. Pooling targets created by factory    forum.springsource.org

Pooling targets created by factory Is there currently a built in way in spring to pool objects that need to be created by a factory? For example Code: ...

46. Calling a static factory method from BeanDefinitionBuilder    forum.springsource.org

Hi! I'm implementing custom namespace support, and I'm extending AbstractSingleBeanDefinitionParser for parsing the element values. I want to call a static method on a class to create the bean to be ...

47. Factory managerBean    forum.springsource.org

Hi! I need some help. Someone knows how i can point the factory of manager-beans to spring. I need de spring use the spring manger beans, and for this I dont ...

48. No parent factory available    forum.springsource.org

No parent factory available Hello, Reading chapter 3 in the references, page 11, about the 'parent' context and the 'child' context. Using IoC, DI. I am running almost 2 identical web-sites ...

49. Obtaining multiple instances from a factory in a loop    forum.springsource.org

As the title suggests, I'm trying to obtain multiple instances of an object in a loop, but instead all the objects in my map are the same object. My loop: Code: ...

50. Synchronizing a factory method call    forum.springsource.org

Synchronizing a factory method call My web application uses Spring 2.0 to instantiate Axis 1.4 web service stubs using an Axis-generated factory class. Here's the bean config: Code: