在运行时操作jar文件

问题描述 投票:0回答:1

我想在我的Java文件中运行时更改我的.jar代码。当我在运行之前将我的.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>

有什么建议吗?

java jar wso2 wso2carbon
1个回答
0
投票

当您将.jar放入<product home> / lib时,它将在您启动服务器时自动复制到<product home> / dropins目录。如果您想要新的工件受到影响,请从<product home> / dropins中删除旧的相应工件。

© www.soinside.com 2019 - 2024. All rights reserved.