Using the spring framework in Eclipse RCP

Source: Internet
Author: User

Long thought about how to use spring in an RCP program. Let the spring container manage the beans in our RCP program. See the benefits of using spring in a Web project (the most direct thing is to see less code). When do you think my good days will come.

Having this vision, I began to think about how to do it. Everyone knows that if you use the beanfactory in the Eclipse RCP program that uses spring directly, no matter how you use it, you will say that you cannot find the configuration file. The reason for this is that every plug-in in Eclipse uses their own classloader (class load)

Description: The detailed loading process for classes in eclipse can be contributing to eclipse Chinese version of P44.

So it's a problem to find the bean's configuration file correctly. Another problem is how to manage beanfactory is also a problem. Now that you have raised these two issues, then one of the face AH. The solution to the first problem. It can be obtained by a class in a plug-in.

I tried it. You can switch class load with the following code. The most troubling question is how to manage spring's beanfactory. If you add the creation of Beanfactory to the inheritance class of each plugin class. It's a disgusting thing to think about. Just keep stalling for this thing. I'm going to die of boredom.

When I was dying, I saw a project called Eclipsespring (http://sourceforge.net/projects/eclipse-spring/). A look super cool. He directly did what I wanted to do.

Let's take a look at the example in his release package. This example is very simple. It just provides a view. A greeting is displayed in the view.

Oh, is not very interface too simple. We will not talk about this. Let's talk about how he did it in this example.

Take a look at his plugin.xml file first.

Look at the extension point of that org.eclipse.ui.view. Isn't it a little strange? His class is net.sourceforge.eclipsespring.springextensionfactory:example/usernameview this way. A word does not look like a class. Instead, a class is a surrogate for a point parameter.

But it can be concluded that he is the view shown above.

Look at the extension on the top.

<extension
point="net.sourceforge.eclipsespring.beanFactoryContributors">
<beanFactoryContributor
class="net.sourceforge.eclipsespring.example.spring.BeanFactoryContributor"
id="example"/>
</extension>

What's this extension point for? Well, that's a problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.