package com.example.demo.vo;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* @ Author :yanbin
* @ Date :Created in 8:51 2018/8/29
* @ Description:this is a class and created by yanbin
* @ Modified By:yanbin
* @Version: 1.0
*/
public class Manager {
//普通窗口
private List<NormalWindow> normals=new ArrayList<NormalWindow>();
//VIP窗口
private List<NormalWindow> vips=new ArrayList<NormalWindow>();
//普通客户队列
private BlockingQueue<Customer> normalsCus=new ArrayBlockingQueue<Customer>(20,true);
//VIP客户队列
private BlockingQueue<Customer> VipsCus=new ArrayBlockingQueue<Customer>(20,true);
public List<NormalWindow> getNormals() {
return normals;
}
public List<NormalWindow> getVips() {
return vips;
}
public BlockingQueue<Customer> getNormalsCus() {
return normalsCus;
}
public BlockingQueue<Customer> getVipsCus() {
return VipsCus;
}
/**
* 服务端要发布,需要有人订阅 这里是订阅方法
*/
public void addWindow(NormalWindow normalWindow){
System.out.println((normalWindow.getWinType()==1?"VIP":"普通")+"窗口启动了");
if(normalWindow.getWinType()==1){//VIP窗口
vips.add(normalWindow);
}else{
normals.add(normalWindow);
}
}
/**
* 有订阅 就要有退订
*/
public void deleteWindow(NormalWindow normalWindow){
if(normalWindow.getWinType()==1){
Integer index= vips.indexOf(normalWindow);
if(index>=0){
vips.remove(normalWindow);
}
}else{
Integer index= normals.indexOf(normalWindow);
if(index>=0){
normals.remove(normalWindow);
}
}
}
/**
* 客户挂号 服务端进行分发,分发给谁呢?
*/
public void publish(Customer customer){
System.out.println("客户取号了,号码为:"+customer.getNumber()+",客户类型为:"+(customer.getType()==1?"VIP":"普通")+"客户");
if(customer.getType()==1){//VIP 客户
try {
VipsCus.put(customer);
} catch (InterruptedException e) {
System.out.println("队列中已满,请稍等");
}
notifyWindow(vips,1);
}else{//普通客户
try {
normalsCus.put(customer);
} catch (InterruptedException e) {
System.out.println("队列中已满,请稍等");
}
notifyWindow(normals,0);
}
}
/**
* 消息发布
*/
public void notifyWindow(List<NormalWindow> windows,Integer type){
BlockingQueue<Customer> tempQueue=null;
tempQueue=type==1?VipsCus:normalsCus;
if(windows!=null&&windows.size()>0){
for (int i = 0; i <windows.size() ; i++) {
windows.get(i).updateQueue(tempQueue,type);
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
demo.rar (95个子文件)
demo
pom.xml 2KB
target
test-classes
com
example
demo
DemoApplicationTests.class 622B
generated-test-sources
test-annotations
classes
application.properties 0B
templates
index.ftl 1KB
com
example
demo
controller
QueueController.class 984B
DemoApplication.class 703B
vo
QueueTest$2.class 2KB
QueueTest.class 1KB
QueueTest$1.class 1KB
Manager.class 4KB
ParentWindow.class 301B
Customer.class 798B
NormalWindow.class 2KB
static
jquery-3.3.1.min.js 85KB
generated-sources
annotations
mvnw 6KB
src
test
java
com
example
demo
DemoApplicationTests.java 340B
main
resources
application.properties 0B
templates
index.ftl 1KB
static
jquery-3.3.1.min.js 85KB
java
com
example
demo
controller
QueueController.java 931B
DemoApplication.java 316B
vo
QueueTest.java 3KB
ParentWindow.java 259B
NormalWindow.java 2KB
Customer.java 573B
Manager.java 3KB
.idea
uiDesigner.xml 9KB
misc.xml 451B
modules.xml 255B
encodings.xml 177B
compiler.xml 635B
workspace.xml 37KB
libraries
Maven__org_springframework_boot_spring_boot_starter_logging_2_0_4_RELEASE.xml 748B
Maven__net_bytebuddy_byte_buddy_agent_1_7_11.xml 578B
Maven__ch_qos_logback_logback_classic_1_2_3.xml 568B
Maven__org_springframework_boot_spring_boot_starter_2_0_4_RELEASE.xml 692B
Maven__org_ow2_asm_asm_5_0_4.xml 472B
Maven__com_fasterxml_jackson_core_jackson_databind_2_9_6.xml 623B
Maven__org_objenesis_objenesis_2_6.xml 508B
Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml 608B
Maven__javax_annotation_javax_annotation_api_1_3_2.xml 611B
Maven__org_springframework_boot_spring_boot_test_2_0_4_RELEASE.xml 671B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_4_RELEASE.xml 741B
Maven__junit_junit_4_12.xml 455B
Maven__org_hamcrest_hamcrest_library_1_3.xml 553B
Maven__org_springframework_boot_spring_boot_starter_json_2_0_4_RELEASE.xml 727B
Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml 573B
Maven__org_springframework_spring_context_support_5_0_8_RELEASE.xml 693B
Maven__org_springframework_spring_core_5_0_8_RELEASE.xml 616B
Maven__org_xmlunit_xmlunit_core_2_5_1.xml 535B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_6.xml 729B
Maven__ch_qos_logback_logback_core_1_2_3.xml 547B
Maven__org_springframework_boot_spring_boot_starter_web_2_0_4_RELEASE.xml 720B
Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_32.xml 625B
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_32.xml 660B
Maven__org_springframework_boot_spring_boot_starter_test_2_0_4_RELEASE.xml 727B
Maven__org_springframework_spring_webmvc_5_0_8_RELEASE.xml 630B
Maven__org_springframework_spring_aop_5_0_8_RELEASE.xml 609B
Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml 644B
Maven__com_fasterxml_jackson_core_jackson_core_2_9_6.xml 595B
Maven__org_mockito_mockito_core_2_15_0.xml 542B
Maven__org_slf4j_slf4j_api_1_7_25.xml 513B
Maven__org_hamcrest_hamcrest_core_1_3.xml 532B
Maven__org_slf4j_jul_to_slf4j_1_7_25.xml 534B
Maven__com_jayway_jsonpath_json_path_2_4_0.xml 546B
Maven__org_springframework_spring_test_5_0_8_RELEASE.xml 616B
Maven__org_hibernate_validator_hibernate_validator_6_0_11_Final.xml 681B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_6.xml 674B
Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_32.xml 611B
Maven__org_springframework_spring_beans_5_0_8_RELEASE.xml 623B
Maven__com_fasterxml_classmate_1_3_4.xml 522B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_6.xml 688B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_4_RELEASE.xml 734B
Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml 608B
Maven__org_skyscreamer_jsonassert_1_5_0.xml 537B
Maven__net_bytebuddy_byte_buddy_1_7_11.xml 536B
Maven__javax_validation_validation_api_2_0_1_Final.xml 611B
Maven__net_minidev_json_smart_2_3.xml 507B
Maven__org_freemarker_freemarker_2_3_28.xml 540B
Maven__org_springframework_spring_web_5_0_8_RELEASE.xml 609B
Maven__org_springframework_spring_expression_5_0_8_RELEASE.xml 658B
Maven__org_springframework_boot_spring_boot_2_0_4_RELEASE.xml 636B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_4_RELEASE.xml 769B
Maven__org_springframework_spring_jcl_5_0_8_RELEASE.xml 609B
Maven__net_minidev_accessors_smart_1_2.xml 542B
Maven__org_assertj_assertj_core_3_9_1.xml 535B
Maven__org_springframework_boot_spring_boot_starter_freemarker_1_4_1_RELEASE.xml 769B
Maven__org_yaml_snakeyaml_1_19.xml 495B
Maven__org_springframework_spring_context_5_0_8_RELEASE.xml 637B
demo.iml 8KB
.gitignore 268B
.mvn
wrapper
maven-wrapper.jar 46KB
maven-wrapper.properties 110B
mvnw.cmd 5KB
共 95 条
- 1
资源评论
- sdtzwss2019-07-25想看看这个,最近有需要励志重写JDK2019-07-29这个不要积分的,下载就是
励志重写JDK
- 粉丝: 2646
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功