Load spring containers using eclipse RPC

Source: Internet
Author: User

The load statement is as follows:

.....
Static beanfactory;
Public void start (bundlecontext context) throws exception {
Super. Start (context );
Initspring ();
Plugin = this;
}

Private void initspring (){
Classloader oldloader = thread. currentthread (). getcontextclassloader ();
Try {
Object o = This. getclass (). getclassloader ();
Thread. currentthread (). setcontextclassloader (classloader) O );
Beanfactory = new classpathxmlapplicationcontext (
"/Applicationcontext. xml ");
} Finally {
Thread. currentthread (). setcontextclassloader (oldloader );
}

}

Public static beanfactory getbeanfactory (){
Return beanfactory;
}

After the preceding content is added:

Put the modified statement in the start of activator. Because RCP is delayed loading, the required package is not loaded when you need to use the spring container. Therefore, you must load the preceding statements immediately before the activator plug-in is loaded. Create a class to implement istartup. Load the RCP extension point.

 

Header in the spring configuration file:

<Beans xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context"
Xsi: schemalocation = "http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-2.5.xsd>

 

The XSD file cannot be found because it cannot connect to the Internet, but the loaded spring. the jar package exists, but the system cannot be associated (the RCP project puts all the jar packages to be used in an agreed plug-in ). This is because, although all the third-party package plug-ins jar are exposed to other plug-ins. handlers cannot be found, so only spring. put the jar package in the plug-in that uses the spring configuration file.

Add the jar package to the classpath for runtime in plugin. xml.

 

To solve this 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.