Browse Source

web请求实例

pull/1/head
richie 6 years ago
parent
commit
8fbf842ee3
  1. 2
      build.xml
  2. 5
      plugin.xml
  3. 12
      pom.xml
  4. 15
      src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java
  5. 14
      src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java
  6. 40
      src/main/java/com/fr/plugin/demo/web/request/handler/DemoHttpHandler.java

2
build.xml

@ -14,7 +14,7 @@
<!-- 插件版本-->
<property name="plugin-version" value="${current-version}"/>
<!-- 插件名字-->
<property name="plugin-name" value="file-submit-oss"/>
<property name="plugin-name" value="demo-web-request"/>
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
<target name="prepare">

5
plugin.xml

@ -12,7 +12,8 @@
[2018-11-05]初始化插件。<br/>
]]></change-notes>
<extra-decision>
<HttpHandlerProvider class="com.fr.plugin.demo.web.request.DemoRequestHandler"/>
<URLAliasProvider class="com.fr.plugin.demo.web.request.DemoURLAliasProvider"/>
<HttpHandlerProvider class="com.fr.plugin.demo.web.request.DemoRequestHandlerBridge"/>
<URLAliasProvider class="com.fr.plugin.demo.web.request.DemoURLAliasBridge"/>
</extra-decision>
<function-recorder class="com.fr.plugin.demo.web.request.handler.DemoHttpHandler"/>
</plugin>

12
pom.xml

@ -10,17 +10,9 @@
<version>10.0</version>
</parent>
<packaging>jar</packaging>
<artifactId>plugin-file-submit-oss</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
<artifactId>demo-web-request</artifactId>
<build>
<!---如果要更改调试插件,改这里的配置就可以了-->
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.file.submit.oss-1.0/classes</outputDirectory>
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.demo.web.request-1.0/classes</outputDirectory>
</build>
</project>

15
src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java

@ -0,0 +1,15 @@
package com.fr.plugin.demo.web.request;
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.plugin.demo.web.request.handler.DemoHttpHandler;
public class DemoRequestHandlerBridge extends AbstractHttpHandlerProvider {
@Override
public BaseHttpHandler[] registerHandlers() {
return new BaseHttpHandler[]{
new DemoHttpHandler()
};
}
}

14
src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java

@ -0,0 +1,14 @@
package com.fr.plugin.demo.web.request;
import com.fr.decision.fun.impl.AbstractURLAliasProvider;
import com.fr.decision.webservice.url.alias.URLAlias;
import com.fr.decision.webservice.url.alias.URLAliasFactory;
public class DemoURLAliasBridge extends AbstractURLAliasProvider {
@Override
public URLAlias[] registerAlias() {
return new URLAlias[] {
URLAliasFactory.createPluginAlias("/demo/text", "/demo/simple", true)
};
}
}

40
src/main/java/com/fr/plugin/demo/web/request/handler/DemoHttpHandler.java

@ -0,0 +1,40 @@
package com.fr.plugin.demo.web.request.handler;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
@EnableMetrics
public class DemoHttpHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return "/demo/text";
}
@Override
public boolean isPublic() {
return true;
}
@Override
@Focus(id = "com.fr.plugin.demo.web.request", text = "", source = Original.PLUGIN)
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
PrintWriter writer = WebUtils.createPrintWriter(res);
writer.println("Hello, I am a test.");
writer.flush();
writer.close();
}
}
Loading…
Cancel
Save