java - how to listen the special class initialization? -
here want listen special classes initialization; when classess initialization actions.
present want use interface or annotation, how implement this?
we have solved problem,we use javassist;the code likes:
configuration conf = (configuration) entry.getvalue(); string clazz = conf.getclazz(); try { ctclass ctclass = classpool.getdefault().get(clazz); string appendcode = "{com.broada.bsp.gene.config.management.configurationmanager.manager.inject(this);\n}"; ctconstructor constructor[] = ctclass.getdeclaredconstructors(); (ctconstructor ctconstructor : constructor) { ctconstructor.insertafter(appendcode); } ctclass.toclass();
thank answers, himanshu bhardwaj !
here can not use solutions,because can not change users new java object actions, use javassist, append come code after constructors, users java new objects,needn't change behaves.
Comments
Post a Comment