[英]Manipulation jar file at runtime
我正在尝试在运行时在.jar
文件中更改Java
代码。 当我在运行之前将.jar文件放入wso2ei-6.4.0\\lib
时。 这种方法工作正常,但是当我尝试更改.jar文件时,wso2仍将我的旧类保存在jar中。 这是我的代码:
package com.Sample.Sample;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class Sample extends AbstractMediator {
private static final Log log = LogFactory.getLog(Sample.class);
private String name;
public boolean mediate(MessageContext context) {
// TODO Implement your mediation logic here
printTheName(context);
return true;
}
private void printTheName(MessageContext context){
String getNameFromSQ = (String)context.getProperty("NAME");
log.debug("Name Value: " + getNameFromSQ);
String upCaseName = getNameFromSQ.toUpperCase();
context.setProperty("newName", "Logging newName new new:" + upCaseName);
}
public void setPrintTheName(String newName){
this.name=newName;
}
public String getPrintTheName(){
return name;
}
}
我的SQ:
<property name="NAME" value= "Kerem"/>
<class name="com.Sample.Sample.Sample">
<property name="printTheName" value= "Log from SQ"/>
</class>
<log>
<property name="newName" expression="get-property('newName')"/>
</log>
有什么建议吗?
将.jar放在<product home>
/ lib中时,它将在启动服务器时自动复制到<product home>
/ dropins目录中。 如果您希望新的工件受到影响,也请从<product home>
/ dropins中删除旧的对应工件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.