-
Oct 27th, 2005, 10:46 AM
#1
How to setup static class in spring?
I wrote a static util class for presentation tier.
But this util class need invoke a method of one class in business tier which is not static.
How can I set it in spring?
Thanks
-
Oct 27th, 2005, 02:27 PM
#2
The problem with static classes is that they are not creating by the Spring container. If you want your static class to reference a spring configured bean, you need to explicitly get the bean by invoking getBean on a BeanFactory.
Instead, I would suggest replacing your static utility class with a non-static utility class. Then your utility can be created by the spring container and you can leverage dependency injection to reference the business tier.
-
Oct 28th, 2005, 12:54 AM
#3
If you still need the static class, you can lookup the context by using WebApplicationContextUtils. You'd need the servlet context though, but since the it's a presentation tier utility, I suspect you have that available somewhere...
regards,
Alef
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules