zheng-demo增加服务提供者
This commit is contained in:
parent
c6bc69fa0f
commit
18a11eb91e
|
@ -19,6 +19,8 @@
|
|||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>zheng-demo-rpc-api</module>
|
||||
<module>zheng-demo-rpc-service</module>
|
||||
<module>zheng-demo-web</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.zheng</groupId>
|
||||
<artifactId>zheng-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zheng-demo-rpc-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>zheng-demo-rpc-api</name>
|
||||
<url>http://www.zhangshuzheng.cn</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zheng</groupId>
|
||||
<artifactId>zheng-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>zheng-upms-rpc-api</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.zheng.demo.rpc.api;
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* Created by shuzheng on 2017/4/1.
|
||||
*/
|
||||
public interface DemoService {
|
||||
|
||||
String sayHello(String name);
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.zheng.demo.rpc.api;
|
||||
|
||||
/**
|
||||
* 降级实现DemoService接口
|
||||
* Created by shuzheng on 2017/4/1.
|
||||
*/
|
||||
public class DemoServiceMock implements DemoService {
|
||||
|
||||
@Override
|
||||
public String sayHello(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zheng</groupId>
|
||||
<artifactId>zheng-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>zheng-demo-rpc-service</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>zheng-demo-rpc-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*.properties</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac</artifactId>
|
||||
<version>1.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.sh</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.bat</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,25 @@
|
|||
<assembly>
|
||||
<id>assembly</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>true</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>src/main/assembly/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<fileMode>0755</fileMode>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>src/main/assembly/conf</directory>
|
||||
<outputDirectory>conf</outputDirectory>
|
||||
<fileMode>0644</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
</assembly>
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
BIN_DIR=`pwd`
|
||||
cd ..
|
||||
DEPLOY_DIR=`pwd`
|
||||
CONF_DIR=$DEPLOY_DIR/conf
|
||||
|
||||
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
LOGS_FILE=`sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
|
||||
if [ -z "$SERVER_NAME" ]; then
|
||||
SERVER_NAME=`hostname`
|
||||
fi
|
||||
|
||||
PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
|
||||
if [ -z "$PIDS" ]; then
|
||||
echo "ERROR: The $SERVER_NAME does not started!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOGS_DIR=""
|
||||
if [ -n "$LOGS_FILE" ]; then
|
||||
LOGS_DIR=`dirname $LOGS_FILE`
|
||||
else
|
||||
LOGS_DIR=$DEPLOY_DIR/logs
|
||||
fi
|
||||
if [ ! -d $LOGS_DIR ]; then
|
||||
mkdir $LOGS_DIR
|
||||
fi
|
||||
DUMP_DIR=$LOGS_DIR/dump
|
||||
if [ ! -d $DUMP_DIR ]; then
|
||||
mkdir $DUMP_DIR
|
||||
fi
|
||||
DUMP_DATE=`date +%Y%m%d%H%M%S`
|
||||
DATE_DIR=$DUMP_DIR/$DUMP_DATE
|
||||
if [ ! -d $DATE_DIR ]; then
|
||||
mkdir $DATE_DIR
|
||||
fi
|
||||
|
||||
echo -e "Dumping the $SERVER_NAME ...\c"
|
||||
for PID in $PIDS ; do
|
||||
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
|
||||
echo -e ".\c"
|
||||
if [ -r /usr/sbin/lsof ]; then
|
||||
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
|
||||
echo -e ".\c"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -r /bin/netstat ]; then
|
||||
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/iostat ]; then
|
||||
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/mpstat ]; then
|
||||
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/vmstat ]; then
|
||||
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/free ]; then
|
||||
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/sar ]; then
|
||||
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
if [ -r /usr/bin/uptime ]; then
|
||||
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
|
||||
echo -e ".\c"
|
||||
fi
|
||||
|
||||
echo "OK!"
|
||||
echo "DUMP: $DATE_DIR"
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
./stop.sh
|
||||
./start.sh
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
if [ "$1" = "start" ]; then
|
||||
./start.sh
|
||||
else
|
||||
if [ "$1" = "stop" ]; then
|
||||
./stop.sh
|
||||
else
|
||||
if [ "$1" = "debug" ]; then
|
||||
./start.sh debug
|
||||
else
|
||||
if [ "$1" = "restart" ]; then
|
||||
./restart.sh
|
||||
else
|
||||
if [ "$1" = "dump" ]; then
|
||||
./dump.sh
|
||||
else
|
||||
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,22 @@
|
|||
@echo off & setlocal enabledelayedexpansion
|
||||
|
||||
set LIB_JARS=""
|
||||
cd ..\lib
|
||||
for %%i in (*) do set LIB_JARS=!LIB_JARS!;..\lib\%%i
|
||||
cd ..\bin
|
||||
|
||||
if ""%1"" == ""debug"" goto debug
|
||||
if ""%1"" == ""jmx"" goto jmx
|
||||
|
||||
java -Xms64m -Xmx1024m -XX:MaxPermSize=64M -classpath ..\conf;%LIB_JARS% com.alibaba.dubbo.container.Main
|
||||
goto end
|
||||
|
||||
:debug
|
||||
java -Xms64m -Xmx1024m -XX:MaxPermSize=64M -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -classpath ..\conf;%LIB_JARS% com.alibaba.dubbo.container.Main
|
||||
goto end
|
||||
|
||||
:jmx
|
||||
java -Xms64m -Xmx1024m -XX:MaxPermSize=64M -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -classpath ..\conf;%LIB_JARS% com.alibaba.dubbo.container.Main
|
||||
|
||||
:end
|
||||
pause
|
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
BIN_DIR=`pwd`
|
||||
cd ..
|
||||
DEPLOY_DIR=`pwd`
|
||||
CONF_DIR=$DEPLOY_DIR/conf
|
||||
|
||||
|
||||
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
SERVER_PROTOCOL=`sed '/dubbo.protocol.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
SERVER_PORT=`sed '/dubbo.protocol.port/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
LOGS_FILE=`sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
|
||||
if [ -z "$SERVER_NAME" ]; then
|
||||
SERVER_NAME=`hostname`
|
||||
fi
|
||||
|
||||
PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
|
||||
if [ -n "$PIDS" ]; then
|
||||
echo "ERROR: The $SERVER_NAME already started!"
|
||||
echo "PID: $PIDS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$SERVER_PORT" ]; then
|
||||
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
|
||||
if [ $SERVER_PORT_COUNT -gt 0 ]; then
|
||||
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
LOGS_DIR=""
|
||||
if [ -n "$LOGS_FILE" ]; then
|
||||
LOGS_DIR=`dirname $LOGS_FILE`
|
||||
else
|
||||
LOGS_DIR=$DEPLOY_DIR/logs
|
||||
fi
|
||||
if [ ! -d $LOGS_DIR ]; then
|
||||
mkdir $LOGS_DIR
|
||||
fi
|
||||
STDOUT_FILE=$LOGS_DIR/stdout.log
|
||||
|
||||
LIB_DIR=$DEPLOY_DIR/lib
|
||||
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
|
||||
|
||||
LOCK_ZOOKEEPER_FILE="$LOGS_DIR/`echo $PWD|awk -F/ '{print $NF}'`.properties"
|
||||
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Ddubbo.registry.file=$LOCK_ZOOKEEPER_FILE"
|
||||
JAVA_DEBUG_OPTS=""
|
||||
if [ "$1" = "debug" ]; then
|
||||
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
|
||||
fi
|
||||
JAVA_JMX_OPTS=""
|
||||
if [ "$1" = "jmx" ]; then
|
||||
JAVA_JMX_OPTS=" -Djava.rmi.server.hostname=172.21.32.38 -Dcom.sun.management.jmxremote.port=1088 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
|
||||
fi
|
||||
JAVA_MEM_OPTS=""
|
||||
BITS=`java -version 2>&1 | grep -i 64-bit`
|
||||
if [ -n "$BITS" ]; then
|
||||
JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
|
||||
else
|
||||
JAVA_MEM_OPTS=" -server -Xms1g -Xmx1g -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
|
||||
fi
|
||||
|
||||
echo -e "Starting the $SERVER_NAME ...\c"
|
||||
nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main > $STDOUT_FILE 2>&1 &
|
||||
|
||||
COUNT=0
|
||||
while [ $COUNT -lt 1 ]; do
|
||||
echo -e ".\c"
|
||||
sleep 1
|
||||
if [ -n "$SERVER_PORT" ]; then
|
||||
if [ "$SERVER_PROTOCOL" == "dubbo" ]; then
|
||||
COUNT=`echo status | nc -i 1 172.21.32.38 $SERVER_PORT | grep -c OK`
|
||||
else
|
||||
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
|
||||
fi
|
||||
else
|
||||
COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
|
||||
fi
|
||||
if [ $COUNT -gt 0 ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "OK!"
|
||||
PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
|
||||
echo "PID: $PIDS"
|
||||
echo "STDOUT: $STDOUT_FILE"
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
BIN_DIR=`pwd`
|
||||
cd ..
|
||||
DEPLOY_DIR=`pwd`
|
||||
CONF_DIR=$DEPLOY_DIR/conf
|
||||
|
||||
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
|
||||
|
||||
if [ -z "$SERVER_NAME" ]; then
|
||||
SERVER_NAME=`hostname`
|
||||
fi
|
||||
|
||||
PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'`
|
||||
if [ -z "$PIDS" ]; then
|
||||
echo "ERROR: The $SERVER_NAME does not started!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" != "skip" ]; then
|
||||
$BIN_DIR/dump.sh
|
||||
fi
|
||||
|
||||
echo -e "Stopping the $SERVER_NAME ...\c"
|
||||
for PID in $PIDS ; do
|
||||
kill $PID > /dev/null 2>&1
|
||||
done
|
||||
|
||||
COUNT=0
|
||||
while [ $COUNT -lt 1 ]; do
|
||||
echo -e ".\c"
|
||||
sleep 1
|
||||
COUNT=1
|
||||
for PID in $PIDS ; do
|
||||
PID_EXIST=`ps -f -p $PID | grep java`
|
||||
if [ -n "$PID_EXIST" ]; then
|
||||
COUNT=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "OK!"
|
||||
echo "PID: $PIDS"
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# Copyright 1999-2011 Alibaba Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
dubbo.container=log4j,spring
|
||||
dubbo.application.name=zheng-demo-rpc-service
|
||||
dubbo.application.owner=
|
||||
#dubbo.registry.address=multicast://224.5.6.7:1234
|
||||
dubbo.registry.address=zookeeper://127.0.0.1:2181
|
||||
#dubbo.registry.address=redis://127.0.0.1:6379
|
||||
#dubbo.registry.address=dubbo://127.0.0.1:9090
|
||||
dubbo.monitor.protocol=registry
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=20880
|
||||
dubbo.service.loadbalance=roundrobin
|
||||
dubbo.log4j.file=logs/zheng-demo-rpc-service.log
|
||||
dubbo.log4j.level=WARN
|
|
@ -0,0 +1,16 @@
|
|||
package com.zheng.demo.rpc.service.impl;
|
||||
|
||||
import com.zheng.demo.rpc.api.DemoService;
|
||||
|
||||
/**
|
||||
* 实现DemoService接口
|
||||
* Created by shuzheng on 2017/4/1.
|
||||
*/
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
|
||||
@Override
|
||||
public String sayHello(String name) {
|
||||
return "hello " + name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
|
||||
|
||||
<bean id="demoService" class="com.zheng.demo.rpc.service.impl.DemoServiceImpl"/>
|
||||
<dubbo:service interface="com.zheng.demo.rpc.api.DemoService" ref="demoService" timeout="5000" retries="0" />
|
||||
|
||||
</beans>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.zheng;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
|
@ -21,6 +21,12 @@
|
|||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zheng</groupId>
|
||||
<artifactId>zheng-demo-rpc-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.zheng.demo.web.controller;
|
||||
|
||||
import com.zheng.common.base.BaseController;
|
||||
import com.zheng.demo.rpc.api.DemoService;
|
||||
import com.zheng.demo.web.model.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -21,6 +23,9 @@ public class IndexController extends BaseController {
|
|||
|
||||
private static Logger _log = LoggerFactory.getLogger(IndexController.class);
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
/**
|
||||
* jsp视图
|
||||
* @return
|
||||
|
@ -37,7 +42,7 @@ public class IndexController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/thymeleaf", method = RequestMethod.GET)
|
||||
public String thymeleaf(Model model) {
|
||||
model.addAttribute("host", "http://www.zhangshuzheng.cn");
|
||||
model.addAttribute("host", demoService.sayHello("http://www.zhangshuzheng.cn/"));
|
||||
List<User> users = new ArrayList<>();
|
||||
User user = new User();
|
||||
user.setId(1l);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<dubbo:application name="zheng-demo-web"/>
|
||||
|
||||
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
|
||||
|
||||
<!-- 订阅服务 -->
|
||||
<dubbo:consumer check="false"/>
|
||||
|
||||
<dubbo:reference id="upmsSystemService" interface="com.zheng.demo.rpc.api.DemoService" mock="true"/>
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue