Dynamically implant Springbean into containers

Source: Internet
Author: User

/** * Project name:micro-services-config-springframework * File Name:D Ymanicinjectionprocesser.java * Package name:com. Micro.services.config.springframework * date:2015-9-16 Morning 9:54:21 * Copyright (c), Http://my.oschina.net/httpssl All rights Reserved. * */package Com.micro.services.config.springframework;import Org.springframework.beans.beansexception;import Org.springframework.beans.factory.factorybean;import Org.springframework.beans.factory.config.beanfactorypostprocessor;import Org.springframework.beans.factory.config.configurablelistablebeanfactory;import Org.springframework.beans.factory.support.beandefinitionregistry;import Org.springframework.beans.factory.xml.xmlbeandefinitionreader;import Org.springframework.core.io.defaultresourceloader;import Org.springframework.core.io.resource;import org.springframework.core.io.resourceloader;/** * Classname:dymanicinjectionprocesser <br/> * Function:todo ADD FUNCTION. <br/> * Reason:todo ADD Reason. <br/> * DatE:2015-9-16 Morning 9:54:21 <br/> * * @author: Http://my.oschina.net/httpssl * @email: [email protected] * @since: JDK 1.7 * @see */public class Dymanicinjectionprocesser implements beanfactorypostprocessor,factorybean< Dymanicinjectionprocesser>{private configurablelistablebeanfactorybeanfactory;/* * Simple description of handling: */private static Dymanicinjectionprocesser instance = new Dymanicinjectionprocesser (), @Overridepublic void Postprocessbeanfactory ( Configurablelistablebeanfactory beanfactory) throws beansexception {this.beanfactory = beanfactory;} @Overridepublic class<dymanicinjectionprocesser> Getobjecttype () {return dymanicinjectionprocesser.class;} @Overridepublic Boolean Issingleton () {return true;} @Overridepublic Dymanicinjectionprocesser GetObject () throws Exception {return this;} public boolean Injectionbeans (String url) throws exception{//httpclient download URL >/tmp/lib/sys-ext-1.jar//jar Contains sys-ext-1.xmltry {String sys_ext_1 = "Sys-ext-1.xml";D efaultresourceloader deFaultresourceloader = new Defaultresourceloader (); Resource Resource = Defaultresourceloader.getresource (resourceloader.classpath_url_prefix+sys_ext_1); Xmlbeandefinitionreader Definitionreader = new Xmlbeandefinitionreader ((beandefinitionregistry) this.beanFactory); Definitionreader.loadbeandefinitions (Resource); return true;} catch (Exception e) {throw e;}} public static void Main (string[] args) {try {System.out.println (DymanicInjectionProcesser.instance.injectionBeans (" Http://yourdomain.com/backdoor.jar "));} catch (Exception e) {System.err.println ("failed to weave"); E.printstacktrace ();}}



Dynamically implant Springbean into containers

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.