当下卖接口管理平台 eoLinker 开源版的部署指南教程你早晚非思去

本文主要内容是教学如何当地方部署eoLinker开源版。

工程结构

图片 1

条件要求

1、PHP 5.5+ / PHP7+(推荐)

2、Mysql 5.5+ / Mariadb 5.5+

3、Nginx(推荐) / Apache

4、项目目录需要有了的朗读写权限(777),用于写入配置文件。安装好之后好设置另外安装目录权限

5、PHP需要安装并启用mbstring以及curl模块,用于字符串处理以及接口测试功能

上下文参数示例

以身作则程序展示了何等由上下文读取参数,并于上下文监听器中生成属性对象及当左右文中设置属性。

  • 确立一个简单易行的JavaBean对象作为性能:Dog.java

package com.example.entities;/** * Created by LTN on 2016/11/2. */public class Dog {    private String breed;    public Dog(String breed) {        this.breed = breed;    }    public String getBreed() {        return breed;    }}
  • 建一个servlet上下文监听器DogServletContextListener.java

package com.example.listener;import com.example.entities.Dog;import javax.servlet.ServletContext;import javax.servlet.ServletContextEvent;/** * Created by LTN on 2016/11/2. */public class DogServletContextListener implements javax.servlet.ServletContextListener {    public void contextInitialized(ServletContextEvent event) {        ServletContext sc = event.getServletContext();        String dogBreed = sc.getInitParameter("breed");        Dog d = new Dog(dogBreed);        sc.setAttribute("dog", d);    }    public void contextDestroyed(ServletContextEvent event) {        //do nothing.    }}
  • 起Servlet进行测试ContextListenerTester.java

package com.example.servlet;import com.example.entities.Dog;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.PrintWriter;/** * Created by LTN on 2016/11/2. */public class ContextListenerTester extends HttpServlet {    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {        response.setContentType("text/html");        PrintWriter out = response.getWriter();        out.println("test context attributes set by listener<br>");        out.println("<br>");        Dog dog = (Dog) getServletContext().getAttribute("dog");        out.println("Dog's breed is: " + dog.getBreed());    }}
  • 每当DD(web.xml)中安排上下文参数、监听器和servlet映射关系

<web-app>  <display-name>Archetype Created Web Application</display-name>  <context-param>    <param-name>breed</param-name>    <param-value>Great Dane</param-value>  </context-param>  <servlet>    <servlet-name>ListenerTester</servlet-name>    <servlet-class>com.example.servlet.ContextListenerTester</servlet-class>  </servlet>  <servlet-mapping>    <servlet-name>ListenerTester</servlet-name>    <url-pattern>/ListenTest.do</url-pattern>  </servlet-mapping>  <listener>    <listener-class>com.example.listener.DogServletContextListener</listener-class>  </listener></web-app>
  • 效果
    起步项目,在浏览器输入http://localhost:8080/servlet-listener/ListenTest.do
    显示:

test context attributes set by listenerDog's breed is: Great Dane

注意事项

1、3.x版本及2.x版本并无匹配,因此无法直接由2.x荣升到3.x,也束手无策通过覆盖代码的办法展开升级换代,切勿随意尝试以防数据丢失。

2、如果要进行数量的迁,可以运用eoLinker接口管理体系面临的【导出项目】功能:将品种导出为eoLinker专用格式(.export),然后在3.x本被导入。

3、为了以防数据丢失,请在推行外重大操作前妥善备份数据库。 

Session属性监听器

应用Session属性监听器对Session中属性进行监听,当Session属性发生大增、删除或变更时,会给拖欠监听器捕捉。

  • 始建一个Session属性监听类DogSessionAttributeListener.java

package com.example.listener;import javax.servlet.http.HttpSessionAttributeListener;import javax.servlet.http.HttpSessionBindingEvent;/** * Created by LTN on 2016/11/2. */public class DogSessionAttributeListener implements HttpSessionAttributeListener {    public void attributeAdded(HttpSessionBindingEvent event) {        String name = event.getName();        Object value = event.getValue();        System.out.println("Attribute added: " + name + ": " + value);    }    public void attributeRemoved(HttpSessionBindingEvent event) {        String name = event.getName();        Object value = event.getValue();        System.out.println("Attribute removed: " + name + ": " + value);    }    public void attributeReplaced(HttpSessionBindingEvent event) {        String name = event.getName();        Object value = event.getValue();        System.out.println("Attribute replaced: " + name + ": " + value);    }}
  • 树一个Servlet测试类AttributeListenerTester.java

package com.example.servlet;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.IOException;/** * Created by LTN on 2016/11/2. */public class AttributeListenerTester extends HttpServlet {    private static int labelCounter = 0;    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {        HttpSession session = request.getSession();        session.setAttribute("label", "label" + labelCounter++);    }}
  • 在DD中配置servlet和listener

<servlet>  <servlet-name>AttributeListenTester</servlet-name>  <servlet-class>com.example.servlet.AttributeListenerTester</servlet-class></servlet><servlet-mapping>  <servlet-name>AttributeListenTester</servlet-name>  <url-pattern>/AttributeListenerTest.do</url-pattern></servlet-mapping><listener>  <listener-class>com.example.listener.DogSessionAttributeListener</listener-class></listener>
  • 测试效果
    开行tomcat,在浏览器中输入URL:http://localhost:8080/servlet-listener/AttributeListenerTest.do
    第一赖回车后,后台打印

Attribute added: label: label0

然后连三不好刷新,后台依次打印:

Attribute replaced: label: label0Attribute replaced: label: label1Attribute replaced: label: label2

留神,event.getName()和event.getValue()都是得到该事件前的session属性的价值。

取得地址

Github:https://github.com/eolinker

码云:https://gitee.com/eoLinker-API-Management

Coding:https://coding.net/u/eolinker/project 

统计全局活动之对话

利用HttpSessionListener进行全局活动会话的统计,类似统计在线人数功能。

  • 建全局活动会话监听器

package com.example.listener;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;/** * Created by LTN on 2016/11/2. */public class GlobalCounterListener implements HttpSessionListener {    static private int activeSessions;    public static int getActiveSessions() {        return activeSessions;    }    public void sessionCreated(HttpSessionEvent event) {        activeSessions++;    }    public void sessionDestroyed(HttpSessionEvent event) {        activeSessions--;    }}
  • 建立servlet测试类GlobalCounterTester.java

package com.example.servlet;import com.example.listener.GlobalCounterListener;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.IOException;import java.io.PrintWriter;/** * Created by LTN on 2016/11/2. */public class GlobalCounterTester extends HttpServlet {    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {        PrintWriter out = response.getWriter();        HttpSession session = request.getSession();        session.setAttribute("name","counter");        String name=(String)session.getAttribute("name");        int activeSessions= GlobalCounterListener.getActiveSessions();        out.println("name: "+name);        out.println("activeSessions: "+activeSessions);    }}
  • 在DD中配置servlet和listener

<servlet>  <servlet-name>SessionCounterTester</servlet-name>  <servlet-class>com.example.servlet.GlobalCounterTester</servlet-class></servlet><servlet-mapping>  <servlet-name>SessionCounterTester</servlet-name>  <url-pattern>/CounterTest.do</url-pattern></servlet-mapping><listener>  <listener-class>com.example.listener.GlobalCounterListener</listener-class></listener>
  • 测试效果
    以浏览器输入URL:http://localhost:8080/servlet-listener/CounterTest.do
    页面显示:

name: counteractiveSessions: 1

改换一个浏览器,输入地点,会显示activeSessions数值递增。

顾,同一个浏览器开始新标签不可知教session个数增加;关闭时浏览器还跟着启动,也非克。

社区支持

中文官网:https://www.eolinker.com

开源支持:https://www.eolinker.com/#/os/download

Blog:http://blog.eolinker.com

视频教程:http://blog.eolinker.com/#/course/

性绑定监听器

当属性对象吃在session或由session删除使,对象自我可以知道。

  • 确立Session
    binding监听器Dog.java,该类继承了HttpSessionBindingListener,并贯彻valueBound和valueUnbound方法。

package com.example.entities;import javax.servlet.http.HttpSessionBindingEvent;import javax.servlet.http.HttpSessionBindingListener;/** * Created by LTN on 2016/11/2. */public class Dog implements HttpSessionBindingListener {    private String breed;    public Dog(String breed) {        this.breed = breed;    }    public String getBreed() {        return breed;    }    public void valueBound(HttpSessionBindingEvent event) {        System.out.println("I am a dog, i know i am in a conversation now.");    }    public void valueUnbound(HttpSessionBindingEvent event) {        System.out.println("I am a dog, i know i am leaving a conversation now.");    }}
  • 建立servlet测试类EntityBindingTester.java

package com.example.servlet;import com.example.entities.Dog;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.IOException;/** * Created by LTN on 2016/11/2. */public class EntityBindingTester extends HttpServlet {    public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException,ServletException {        Dog dog = (Dog) getServletContext().getAttribute("dog");        HttpSession session = request.getSession();        session.setAttribute("dog-binding",dog);        session.invalidate();    }}
  • 在DD中配置servlet,注意,属性Dog不用/能在DD中配置

<servlet>  <servlet-name>ObjectBindingTester</servlet-name>  <servlet-class>com.example.servlet.EntityBindingTester</servlet-class></servlet><servlet-mapping>  <servlet-name>ObjectBindingTester</servlet-name>  <url-pattern>/ObjectBindingTest.do</url-pattern></servlet-mapping>
  • 职能测试
    启动tomcat,输入URL:http://localhost:8080/servlet-listener/ObjectBindingTest.do
    后台打印:

I am a dog, i know i am in a conversation now.Attribute added: dog-binding: com.example.entities.Dog@6dbba86eI am a dog, i know i am leaving a conversation now.Attribute removed: dog-binding: com.example.entities.Dog@6dbba86e

安装

由Github等路线获取开源版代码之后,目录结构如下:

图片 2

附件列表

 

其中:

1、backend_resource:后端源码

2、frontend_resource:前端源码(未减,使用Angular进行编制)

3、release:安装包,可用来直装

 

开辟release文件夹,找到时版本的压缩包,解压到当的PHP环境下,并且经过浏览器访问项目根本目录。如果正常则会变动到如下引导页面:

 图片 3

图片 4

图片 5

图片 6

 

根据指引页面提示,输入相应信息以通过环境监测后,即可安装成功。随后页面会跨反至 用户注册页面。

开源版的采取操作及线达免费版基本同步,如发其它利用的题目要参考 线及本操作指南。

重复多还净的课程以及内容尽在eoLinker中文网址:https://www.eolinker.com

 

后记:

eoLinker是当下全世界领先、国内极老之在线API接口管理平台,提供自动生成API文档、API自动化测试、Mock测试、团队协作等效果,旨在缓解由于前后端分离造成的支出效率低下问题。目前eoLinker为Google、IBM、腾讯、中国联通、海尔、神州优车、国美等数千寒店供高速、专业、稳定的API管理服务。同时eoLinker还是Google谷歌开发者联盟的协作产品以及商家,不期举办线下交流分享活动推向国内API管理领域的开拓进取。