在sandbox-1.2.0中使用@command注解时,在调用时报错信息如下:
`./sandbox.sh -p 11502 -d 'my-sandbox-module/addLog'
<title>Error 404 Not Found</title>
HTTP ERROR: 404
Problem accessing /sandbox/default/module/http/my-sandbox-module/addLog. Reason:
Not Found
Powered by Jetty://
`
如果将@command换成@http(其它什么都不变),则正常,代码如下;
import com.alibaba.jvm.sandbox.api.Information;
import com.alibaba.jvm.sandbox.api.Module;
import com.alibaba.jvm.sandbox.api.ModuleLifecycle;
import com.alibaba.jvm.sandbox.api.annotation.Command;
import com.alibaba.jvm.sandbox.api.http.Http;
import com.alibaba.jvm.sandbox.api.listener.ext.Advice;
import com.alibaba.jvm.sandbox.api.listener.ext.AdviceListener;
import com.alibaba.jvm.sandbox.api.listener.ext.EventWatchBuilder;
import com.alibaba.jvm.sandbox.api.resource.ModuleEventWatcher;
import org.kohsuke.MetaInfServices;
import javax.annotation.Resource;
import java.util.logging.Logger;
@MetaInfServices(Module.class)
@InFormation(id = "my-sandbox-module", version = "1.0.0", author = "xxxx")
public class TestSandBoxModule implements Module {
private Logger LOG = Logger.getLogger(TestSandBoxModule.class.getName());
@Resource
private ModuleEventWatcher moduleEventWatcher;
//@Command("/addLog")
@Http("/addLog")
public void addLog() {
new EventWatchBuilder(moduleEventWatcher)
.onClass("com.example.quickstart2.service.impl.SimpleServiceImpl")
.onBehavior("simle")
.onWatch(new AdviceListener() {
@Override
protected void before(Advice advice) throws Throwable {
System.out.println(" before...方法名: " + advice.getBehavior().getName());
}
@Override
protected void afterReturning(Advice advice) throws Throwable {
System.out.println(" after...方法名: " + advice.getBehavior().getName());
}
;
});
}
}
`
在sandbox-1.2.0中使用@command注解时,在调用时报错信息如下:
<title>Error 404 Not Found</title>`./sandbox.sh -p 11502 -d 'my-sandbox-module/addLog'
HTTP ERROR: 404
Problem accessing /sandbox/default/module/http/my-sandbox-module/addLog. Reason:
Powered by Jetty:// `
如果将@command换成@http(其它什么都不变),则正常,代码如下;
import com.alibaba.jvm.sandbox.api.Information;
import com.alibaba.jvm.sandbox.api.Module;
import com.alibaba.jvm.sandbox.api.ModuleLifecycle;
import com.alibaba.jvm.sandbox.api.annotation.Command;
import com.alibaba.jvm.sandbox.api.http.Http;
import com.alibaba.jvm.sandbox.api.listener.ext.Advice;
import com.alibaba.jvm.sandbox.api.listener.ext.AdviceListener;
import com.alibaba.jvm.sandbox.api.listener.ext.EventWatchBuilder;
import com.alibaba.jvm.sandbox.api.resource.ModuleEventWatcher;
import org.kohsuke.MetaInfServices;
import javax.annotation.Resource;
import java.util.logging.Logger;
@MetaInfServices(Module.class)
@InFormation(id = "my-sandbox-module", version = "1.0.0", author = "xxxx")
public class TestSandBoxModule implements Module {
}
`