/** * 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