You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by al...@apache.org on 2021/07/16 03:12:55 UTC
[dubbo-samples] branch master updated: add mybatis/hibernate sample
(#343)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 7d763bd add mybatis/hibernate sample (#343)
7d763bd is described below
commit 7d763bd11e8efb44b94ad2c7ae24bf2d2e2c6ee5
Author: Huang YunKun <ht...@gmail.com>
AuthorDate: Fri Jul 16 11:12:46 2021 +0800
add mybatis/hibernate sample (#343)
* add mybatis sample
* try fix
* move config
* switch to spring-boot
* polish
* add hibernate samples
* remove spring-boot
* fix version config for testing
* fix dependency issue
---
.../dubbo-samples-hibernate/README.md | 10 +
.../dubbo-samples-hibernate/case-configuration.yml | 24 ++
.../dubbo-samples-hibernate/case-versions.conf | 24 ++
.../dubbo-samples-hibernate/pom.xml | 169 ++++++++++++++
.../boundary/hibernate/EmbeddedZooKeeper.java | 255 +++++++++++++++++++++
.../boundary/hibernate/HibernateConsumer.java | 42 ++++
.../boundary/hibernate/HibernateProvider.java | 37 +++
.../boundary/hibernate/api/HibernateService.java | 26 +++
.../dubbo/samples/boundary/hibernate/api/User.java | 28 +++
.../hibernate/impl/HibernateServiceImpl.java | 44 ++++
.../boundary/hibernate/impl/dao/UserDao.java | 28 +++
.../boundary/hibernate/impl/dao/UserDaoImpl.java | 47 ++++
.../boundary/hibernate/impl/dao/UserModel.java | 40 ++++
.../resources/liquibase/liquibase-changelog.xml | 37 +++
.../src/main/resources/log4j.properties | 26 +++
.../main/resources/spring/hibernate-consumer.xml | 32 +++
.../main/resources/spring/hibernate-provider.xml | 67 ++++++
.../boundary/hibernate/HibernateServiceIT.java | 47 ++++
.../dubbo-samples-mybatis/README.md | 6 +
.../dubbo-samples-mybatis/case-configuration.yml | 24 ++
.../dubbo-samples-mybatis/case-versions.conf | 24 ++
.../dubbo-samples-mybatis/pom.xml | 178 ++++++++++++++
.../boundary/mybatis/EmbeddedZooKeeper.java | 255 +++++++++++++++++++++
.../samples/boundary/mybatis/MybatisConsumer.java | 39 ++++
.../samples/boundary/mybatis/MybatisProvider.java | 45 ++++
.../boundary/mybatis/api/MybatisService.java | 25 ++
.../dubbo/samples/boundary/mybatis/api/User.java | 28 +++
.../boundary/mybatis/impl/MybatisServiceImpl.java | 47 ++++
.../samples/boundary/mybatis/impl/dao/UserDao.java | 31 +++
.../boundary/mybatis/impl/dao/UserModel.java | 28 +++
.../resources/liquibase/liquibase-changelog.xml | 37 +++
.../src/main/resources/log4j.properties | 26 +++
.../src/main/resources/mapper/UserMapper.xml | 31 +++
.../spring/application-provider.properties | 12 +
.../src/main/resources/spring/mybatis-consumer.xml | 33 +++
.../samples/boundary/mybatis/MybatisServiceIT.java | 44 ++++
dubbo-samples-boundary-test/pom.xml | 13 +-
37 files changed, 1902 insertions(+), 7 deletions(-)
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/README.md b/dubbo-samples-boundary-test/dubbo-samples-hibernate/README.md
new file mode 100644
index 0000000..bf71808
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/README.md
@@ -0,0 +1,10 @@
+# Dubbo + Hibernate
+
+This is a dubbo + hibernate sample.
+
+In this sample, both provider and consumer are using xml as configuration.
+
+Please aware that dubbo doesn't require
+special hibernate version, but spring and hibernate does have some version requirement. So please make sure you are
+using right version in your own project.
+
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-configuration.yml b/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-configuration.yml
new file mode 100644
index 0000000..821c36f
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-configuration.yml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+from: app-builtin-zookeeper.yml
+
+props:
+ project_name: dubbo-samples-hibernate
+ main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
+ zookeeper_port: 2181
+ dubbo_port: 20880
+
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-versions.conf b/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-versions.conf
new file mode 100644
index 0000000..1ec5692
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/case-versions.conf
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version=2.7.*, 3.*
+spring.version=4.*
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/pom.xml b/dubbo-samples-boundary-test/dubbo-samples-hibernate/pom.xml
new file mode 100644
index 0000000..defdaab
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/pom.xml
@@ -0,0 +1,169 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-boundary-test</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.dubbo.samples.boundary.hibernate</groupId>
+ <artifactId>dubbo-samples-hibernate</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>dubbo-samples-hibernate</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>3.0.1</dubbo.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <junit.version>4.12</junit.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <hibernate.version>4.3.6.Final</hibernate.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>${spring.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.200</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.2.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>4.4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${hibernate.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.20</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <!-- For jdk 11 above JavaEE annotation -->
+ <profile>
+ <id>javax.annotation</id>
+ <activation>
+ <jdk>[1.11,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok-maven-plugin</artifactId>
+ <version>1.18.20.0</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>delombok</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..be37d35
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * 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.
+ */
+package org.apache.dubbo.samples.boundary.hibernate;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ *
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ *
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ }
+
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ }
+ catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ }
+ else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java
new file mode 100644
index 0000000..8c2918b
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate;
+
+import com.google.common.collect.Lists;
+import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
+import org.apache.dubbo.samples.boundary.hibernate.api.User;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.List;
+
+public class HibernateConsumer {
+
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-consumer.xml");
+ context.start();
+
+ HibernateService hibernateService = context.getBean(HibernateService.class);
+
+ for (int i = 0; i < 5; i++) {
+ List<User> users = hibernateService.findAll();
+ System.out.println("find users: " + users);
+ }
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java
new file mode 100644
index 0000000..9ae1839
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.concurrent.CountDownLatch;
+
+public class HibernateProvider {
+
+ public static void main(String[] args) throws Exception {
+ new EmbeddedZooKeeper(2181, false).start();
+
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-provider.xml");
+ context.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java
new file mode 100644
index 0000000..2e3e5eb
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate.api;
+
+import java.util.List;
+
+public interface HibernateService {
+ List<User> findAll();
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java
new file mode 100644
index 0000000..244d68c
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate.api;
+
+import lombok.Data;
+
+@Data
+public class User implements java.io.Serializable {
+ private long id;
+ private String name;
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java
new file mode 100644
index 0000000..b4e942e
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * 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.
+ */
+package org.apache.dubbo.samples.boundary.hibernate.impl;
+
+import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
+import org.apache.dubbo.samples.boundary.hibernate.api.User;
+import org.apache.dubbo.samples.boundary.hibernate.impl.dao.UserDao;
+import org.apache.dubbo.samples.boundary.hibernate.impl.dao.UserModel;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class HibernateServiceImpl implements HibernateService {
+ @Autowired
+ private UserDao userDao;
+
+ @Override
+ public List<User> findAll() {
+ List<UserModel> userModels = userDao.findAll();
+
+ return userModels.stream().map(u -> {
+ User user = new User();
+
+ user.setId(u.getId());
+ user.setName(u.getName());
+
+ return user;
+ }).collect(Collectors.toList());
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java
new file mode 100644
index 0000000..9932aa2
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate.impl.dao;
+
+import java.util.List;
+
+public interface UserDao {
+ List<UserModel> findAll();
+
+ void saveUserModel(UserModel userModel);
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java
new file mode 100644
index 0000000..8e82c67
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate.impl.dao;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository(value = "userDao")
+public class UserDaoImpl implements UserDao {
+ @Autowired
+ private SessionFactory sessionFactory;
+
+ @Override
+ public List<UserModel> findAll() {
+ return sessionFactory.openSession().createCriteria(UserModel.class).list();
+ }
+
+ @Override
+ public void saveUserModel(UserModel userModel) {
+ Session session = sessionFactory.openSession();
+
+ session.save(userModel);
+
+ session.close();
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java
new file mode 100644
index 0000000..a1b6153
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.hibernate.impl.dao;
+
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "user")
+public class UserModel {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private long id;
+ @Column(name = "name", nullable = false)
+ private String name;
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/liquibase/liquibase-changelog.xml b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/liquibase/liquibase-changelog.xml
new file mode 100644
index 0000000..b468536
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/liquibase/liquibase-changelog.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
+
+ <changeSet id="init table" author="htynkn">
+ <createTable tableName="user">
+ <column name="id" type="long" autoIncrement="true">
+ <constraints primaryKey="true" nullable="false"/>
+ </column>
+ <column name="name" type="varchar(50)"/>
+ </createTable>
+ </changeSet>
+
+ <changeSet author="add-test-data" id="htynkn">
+ <insert tableName="user">
+ <column name="name" value="apache dubbo"/>
+ </insert>
+ </changeSet>
+</databaseChangeLog>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/log4j.properties b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml
new file mode 100644
index 0000000..7fb555e
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="hibernate-consumer"/>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
+
+ <dubbo:reference id="hibernateService" interface="org.apache.dubbo.samples.boundary.hibernate.api.HibernateService"/>
+
+</beans>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml
new file mode 100644
index 0000000..bc186d0
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="hibernate-provider"/>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
+
+ <dubbo:protocol name="dubbo" port="20880"/>
+
+ <bean id="hibernateService" class="org.apache.dubbo.samples.boundary.hibernate.impl.HibernateServiceImpl"/>
+
+ <dubbo:service interface="org.apache.dubbo.samples.boundary.hibernate.api.HibernateService" ref="hibernateService"/>
+
+
+ <context:component-scan base-package="org.apache.dubbo.samples.boundary.hibernate.impl.dao"/>
+
+ <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
+ <property name="driverClassName" value="org.h2.Driver"/>
+ <property name="url" value="jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2"/>
+ </bean>
+
+ <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
+ <property name="dataSource" ref="dataSource"/>
+ <property name="changeLog" value="classpath:liquibase/liquibase-changelog.xml"/>
+ </bean>
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
+ <property name="dataSource" ref="dataSource"/>
+ <property name="packagesToScan" value="org.apache.dubbo.samples.boundary.hibernate.impl.dao"/>
+ <property name="hibernateProperties">
+ <props>
+ <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
+ <prop key="hibernate.show_sql">true</prop>
+ <prop key="hibernate.format_sql">true</prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory"/>
+ </bean>
+
+ <tx:annotation-driven transaction-manager="transactionManager"/>
+</beans>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java
new file mode 100644
index 0000000..e9b9c81
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * 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.
+ */
+package org.apache.dubbo.samples.boundary.hibernate;
+
+import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
+import org.apache.dubbo.samples.boundary.hibernate.api.User;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = "classpath*:spring/hibernate-consumer.xml")
+public class HibernateServiceIT {
+ @Autowired
+ private HibernateService service;
+
+ @Test
+ public void shouldGetDataFromHibernate() throws Exception {
+ List<User> users = service.findAll();
+
+ assertThat(users, not(nullValue()));
+ assertThat(users.size(), is(1));
+ assertThat(users.get(0).getName(), is("apache dubbo"));
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/README.md b/dubbo-samples-boundary-test/dubbo-samples-mybatis/README.md
new file mode 100644
index 0000000..5750aa1
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/README.md
@@ -0,0 +1,6 @@
+# Dubbo + Mybatis
+
+This is a dubbo + mybatis sample.
+
+In this sample, provider is using @ComponentScan and consumer is using xml configuration.
+
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-configuration.yml b/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-configuration.yml
new file mode 100644
index 0000000..09f661f
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-configuration.yml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+from: app-builtin-zookeeper.yml
+
+props:
+ project_name: dubbo-samples-mybatis
+ main_class: org.apache.dubbo.samples.boundary.mybatis.MybatisProvider
+ zookeeper_port: 2181
+ dubbo_port: 20880
+
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-versions.conf b/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-versions.conf
new file mode 100644
index 0000000..af1862c
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/case-versions.conf
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version=2.7.*, 3.*
+spring-boot.version=2.*
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/pom.xml b/dubbo-samples-boundary-test/dubbo-samples-mybatis/pom.xml
new file mode 100644
index 0000000..dd02412
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/pom.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-boundary-test</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.dubbo.samples.boundary</groupId>
+ <artifactId>dubbo-samples-mybatis</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>dubbo-samples-mybatis</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>3.0.1</dubbo.version>
+ <junit.version>4.12</junit.version>
+ <spring-boot.version>2.4.1</spring-boot.version>
+ <mybatis-plus-starter.version>3.4.2</mybatis-plus-starter.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ <version>${mybatis-plus-starter.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.200</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.2.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>4.4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.20</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <!-- For jdk 11 above JavaEE annotation -->
+ <profile>
+ <id>javax.annotation</id>
+ <activation>
+ <jdk>[1.11,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok-maven-plugin</artifactId>
+ <version>1.18.20.0</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>delombok</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..ae4c712
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * 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.
+ */
+package org.apache.dubbo.samples.boundary.mybatis;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ *
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ *
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ }
+
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ }
+ catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ }
+ else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java
new file mode 100644
index 0000000..f7cfd4e
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis;
+
+import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
+import org.apache.dubbo.samples.boundary.mybatis.api.User;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class MybatisConsumer {
+
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-consumer.xml");
+ context.start();
+
+ MybatisService mybatisService = (MybatisService) context.getBean(MybatisService.class);
+
+ for (int i = 0; i < 5; i++) {
+ User user = mybatisService.findByUserId(1L);
+ System.out.println("find user: " + user);
+ }
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
new file mode 100644
index 0000000..47a171d
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis;
+
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.PropertySource;
+
+@SpringBootApplication
+@EnableDubbo
+@MapperScan("org.apache.dubbo.samples.boundary.mybatis")
+@PropertySource("classpath:spring/application-provider.properties")
+public class MybatisProvider implements CommandLineRunner {
+
+ public static void main(String[] args) throws Exception {
+ new EmbeddedZooKeeper(2181, false).start();
+
+ SpringApplication.run(MybatisProvider.class, args);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+ System.out.println("dubbo service started");
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java
new file mode 100644
index 0000000..02c43e9
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java
@@ -0,0 +1,25 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis.api;
+
+public interface MybatisService {
+
+ User findByUserId(long id);
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java
new file mode 100644
index 0000000..75df5d9
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis.api;
+
+import lombok.Data;
+
+@Data
+public class User implements java.io.Serializable {
+ private long id;
+ private String name;
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java
new file mode 100644
index 0000000..e2337a0
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+package org.apache.dubbo.samples.boundary.mybatis.impl;
+
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
+import org.apache.dubbo.samples.boundary.mybatis.api.User;
+import org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserDao;
+import org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+@DubboService(version = "1.0.0")
+public class MybatisServiceImpl implements MybatisService {
+
+ @Autowired
+ private UserDao userDao;
+
+ @Override
+ public User findByUserId(long id) {
+ UserModel userModel = userDao.findByUserId(id);
+
+ User u = new User();
+
+ u.setId(userModel.getId());
+ u.setName(userModel.getName());
+
+ return u;
+ }
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java
new file mode 100644
index 0000000..2afe665
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis.impl.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface UserDao extends BaseMapper<UserModel> {
+ public UserModel findByUserId(@Param("userId") long userId);
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java
new file mode 100644
index 0000000..f191d7d
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.dubbo.samples.boundary.mybatis.impl.dao;
+
+import lombok.Data;
+
+@Data
+public class UserModel {
+ private long id;
+ private String name;
+}
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml
new file mode 100644
index 0000000..b468536
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
+
+ <changeSet id="init table" author="htynkn">
+ <createTable tableName="user">
+ <column name="id" type="long" autoIncrement="true">
+ <constraints primaryKey="true" nullable="false"/>
+ </column>
+ <column name="name" type="varchar(50)"/>
+ </createTable>
+ </changeSet>
+
+ <changeSet author="add-test-data" id="htynkn">
+ <insert tableName="user">
+ <column name="name" value="apache dubbo"/>
+ </insert>
+ </changeSet>
+</databaseChangeLog>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/log4j.properties b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 0000000..ba193d0
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserDao">
+
+ <resultMap id="BASE_RESULT" type="org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel">
+ <id column="id" property="id"/>
+ <result column="name" property="name"/>
+ </resultMap>
+ <select id="findByUserId" resultMap="BASE_RESULT">
+ SELECT id, name
+ FROM user
+ where id = #{userId}
+ </select>
+
+</mapper>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties
new file mode 100644
index 0000000..acc2a74
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties
@@ -0,0 +1,12 @@
+spring.liquibase.change-log=classpath:liquibase/liquibase-changelog.xml
+spring.application.name=mybatis-provider
+dubbo.scan.base-packages=org.apache.dubbo.samples.boundary.mybatis
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20880
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+
+dubbo.application.name=${spring.application.name}
+
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver=org.h2.Driver
+spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml
new file mode 100644
index 0000000..3501b63
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="mybatis-consumer"/>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
+
+ <dubbo:reference id="cacheService" interface="org.apache.dubbo.samples.boundary.mybatis.api.MybatisService"
+ version="1.0.0"/>
+
+</beans>
diff --git a/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java
new file mode 100644
index 0000000..4f49bd6
--- /dev/null
+++ b/dubbo-samples-boundary-test/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * 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.
+ */
+package org.apache.dubbo.samples.boundary.mybatis;
+
+import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
+import org.apache.dubbo.samples.boundary.mybatis.api.User;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.nullValue;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = "classpath*:spring/mybatis-consumer.xml")
+public class MybatisServiceIT {
+ @Autowired
+ private MybatisService service;
+
+ @Test
+ public void shouldGetDataFromMybatis() throws Exception {
+ User user = service.findByUserId(1);
+
+ assertThat(user, not(nullValue()));
+ assertThat(user.getName(), is("apache dubbo"));
+ }
+}
diff --git a/dubbo-samples-boundary-test/pom.xml b/dubbo-samples-boundary-test/pom.xml
index f5b3750..2db4e53 100644
--- a/dubbo-samples-boundary-test/pom.xml
+++ b/dubbo-samples-boundary-test/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -14,10 +14,7 @@
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.
- -->
-<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">
+ --><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">
<groupId>org.apache.dubbo</groupId>
<version>1.0-SNAPSHOT</version>
@@ -26,7 +23,9 @@
<artifactId>dubbo-samples-boundary-test</artifactId>
<modules>
- </modules>
+ <module>dubbo-samples-mybatis</module>
+ <module>dubbo-samples-hibernate</module>
+ </modules>
<repositories>
<repository>
@@ -43,4 +42,4 @@
</snapshots>
</repository>
</repositories>
-</project>
\ No newline at end of file
+</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org