3 |
4 | Common load balance support base on spring.
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/compress/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides Compress supports. It provides messes of implementation of Compress interface.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.compress;
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/strategy/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Load balance strategy interface implementation.
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/failover/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Load balance fail over interface implementation.
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/handler/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * RPC TCP protocol transport encode and decode supports.
3 | *
4 | * @since 1.0
5 | */
6 | package com.baidu.jprotobuf.pbrpc.transport.handler;
7 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-ext-validator/src/main/java/com/baidu/jprotobuf/pbrpc/ext/validator/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Extension module package for Bean Validation(JSR303) supports
3 | *
4 | * @author xiemalin
5 | * @since 3.4.0
6 | */
7 | package com.baidu.jprotobuf.pbrpc.ext.validator;
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-test/src/main/java/com/baidu/jprotobuf/pbrpc/proto/echo.proto:
--------------------------------------------------------------------------------
1 | package pkg;
2 |
3 | option java_package = "com.baidu.jprotobuf.pbrpc.proto";
4 |
5 | //这里声明输出的java的类名
6 | option java_outer_classname = "EchoInfoClass";
7 |
8 | message EchoInfo {
9 | required string message = 1;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/test/java/com/baidu/jprotobuf/pbrpc/client/test/Greet.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.client.test;
5 |
6 | /**
7 | * The Interface ITestInterface.
8 | *
9 | * @author xiemalin
10 | * @since 3.5.22
11 | */
12 | public interface Greet {
13 |
14 | /**
15 | * Dummy call.
16 | *
17 | * @param name the arg
18 | * @return the string
19 | */
20 | String greet(String name);
21 | }
22 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/test/java/com/baidu/jprotobuf/pbrpc/client/test/SimpleGreet.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.client.test;
5 |
6 | /**
7 | * The Class SimpleGreet.
8 | *
9 | * @author xiemalin
10 | * @since 3.5.22
11 | */
12 | public class SimpleGreet implements Greet {
13 |
14 | /**
15 | * Dummy call.
16 | *
17 | * @param name the arg
18 | * @return the string
19 | */
20 | @Override
21 | public String greet(String name) {
22 | return "Hello " + name;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/ChannelPoolSharableFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.transport;
5 |
6 | /**
7 | * A factory for creating ChannelSharable objects.
8 | *
9 | * @author xiemalin
10 | * @since 3.5.20
11 | */
12 | public interface ChannelPoolSharableFactory {
13 |
14 | /**
15 | * Gets the or create channel pool.
16 | *
17 | * @param rpcClient the rpc client
18 | * @param host the host
19 | * @param port the port
20 | * @return the or create channel pool
21 | */
22 | RpcChannel getOrCreateChannelPool(RpcClient rpcClient, String host, int port);
23 | }
24 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-ext-validator/src/main/java/com/baidu/jprotobuf/pbrpc/ext/validator/ConstraintViolationsFormatter.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.baidu.jprotobuf.pbrpc.ext.validator;
5 |
6 | import java.util.Set;
7 |
8 | import javax.validation.ConstraintViolation;
9 |
10 | /**
11 | * A format tool to print out validate constraint violation result as a {@link String} object
12 | *
13 | * @author xiemalin
14 | * @since 3.4.0
15 | */
16 | public interface ConstraintViolationsFormatter {
17 |
18 |
19 | /**
20 | * format validate constraint violation result as a {@link String} object
21 | * @param result validate constraint violation result
22 | * @return formatter string
23 | */
24 | String format(Set> result);
25 | }
26 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/SimpleChannelPoolSharableFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.transport;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /**
10 | * A factory for creating GlobalChannelPoolSharable objects.
11 | *
12 | * @author xiemalin
13 | * @since 3.5.20
14 | */
15 | public class SimpleChannelPoolSharableFactory extends AbstractChannelPoolSharableFactory {
16 |
17 | /** The rpc channel map. */
18 | private Map rpcChannelMap = new HashMap();
19 |
20 | protected Map getRpcChannelMap() {
21 | return rpcChannelMap;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/GlobalChannelPoolSharableFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.jprotobuf.pbrpc.transport;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /**
10 | * A factory for creating GlobalChannelPoolSharable objects.
11 | *
12 | * @author xiemalin
13 | * @since 3.5.20
14 | */
15 | public class GlobalChannelPoolSharableFactory extends AbstractChannelPoolSharableFactory {
16 |
17 | /** The rpc channel map. */
18 | private static Map rpcChannelMap = new HashMap();
19 |
20 | protected Map getRpcChannelMap() {
21 | return rpcChannelMap;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/intercept/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * 拦截器模块
18 | *
19 | * @author xiemalin
20 | * @since 3.4.0
21 | */
22 | package com.baidu.jprotobuf.pbrpc.intercept;
--------------------------------------------------------------------------------
/jprotobuf-rpc-registry-redis/src/main/java/com/baidu/pbrpc/utils/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Utility for redis usage.
18 | *
19 | * @author xiemalin
20 | * @since 3.2.3
21 | */
22 | package com.baidu.pbrpc.utils;
--------------------------------------------------------------------------------
/jprotobuf-rpc-registry-bns/src/main/java/com/baidu/pbrpc/register/bns/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Regitser supports by Baidu Naming Service
18 | *
19 | * @author xiemalin
20 | * @since 3.0.2
21 | */
22 | package com.baidu.pbrpc.register.bns;
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/management/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Management module for protobuf RPC.
18 | *
19 | * @author xiemalin
20 | * @since 3.1.0
21 | */
22 | package com.baidu.jprotobuf.pbrpc.management;
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring/src/test/java/com/baidu/jprotobuf/pbrpc/spring/SimpleAopClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.spring;
17 |
18 | import org.springframework.stereotype.Service;
19 |
20 | /**
21 | *
22 | * @author xiemalin
23 | *
24 | */
25 | @Service("simpleAOP")
26 | public class SimpleAopClass {
27 |
28 | public void doHello() {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring2/src/test/java/com/baidu/jprotobuf/pbrpc/spring/SimpleAopClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.spring;
17 |
18 | import org.springframework.stereotype.Service;
19 |
20 | /**
21 | *
22 | * @author xiemalin
23 | *
24 | */
25 | @Service("simpleAOP")
26 | public class SimpleAopClass {
27 |
28 | public void doHello() {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-test/src/main/java/com/baidu/jprotobuf/pbrpc/utils/SleepUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 the original author or authors.
3 | *
4 | * Licensed under the Baidu company (the "License");
5 | * you may not use this file except in compliance with the License.
6 | *
7 | */
8 | package com.baidu.jprotobuf.pbrpc.utils;
9 |
10 | import java.util.logging.Level;
11 | import java.util.logging.Logger;
12 |
13 | /**
14 | * Utility tool for test usage.
15 | *
16 | * @author xiemalin
17 | * @since 2.19
18 | */
19 | public class SleepUtils {
20 |
21 | private static final Logger LOG = Logger.getLogger(SleepUtils.class.getName());
22 |
23 | /**
24 | * time sleep for current thread.
25 | *
26 | * @param sleepTimeInMilliseconds
27 | */
28 | public static void dummySleep(int sleepTimeInMilliseconds) {
29 | try {
30 | Thread.sleep(sleepTimeInMilliseconds);
31 | } catch (Exception e) {
32 | LOG.log(Level.SEVERE, e.getMessage(), e.getCause());
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-test/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.baidu
6 | jprotobuf-rpc-socket
7 | 4.2.2
8 |
9 | jprotobuf-rpc-core-test
10 | jar
11 | ${project.artifactId}
12 | The base test module
13 |
14 |
15 |
16 | javax.servlet
17 | servlet-api
18 | ${servlet-api.version}
19 | jar
20 | compile
21 |
22 |
23 | junit
24 | junit
25 | ${junit.version}
26 | compile
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-registry-redis/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.baidu
6 | jprotobuf-rpc-socket
7 | 4.2.2
8 |
9 | jprotobuf-rpc-registry-redis
10 | jar
11 | ${project.artifactId}
12 | The registry service implements for redis
13 |
14 |
15 |
16 | com.baidu
17 | jprotobuf-rpc-core-spring
18 | ${project.parent.version}
19 |
20 |
21 | redis.clients
22 | jedis
23 | ${jedis.version}
24 | jar
25 | compile
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/data/Readable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.data;
18 |
19 | /**
20 | * Byte array serializable interface.
21 | *
22 | * @author xiemalin
23 | * @since 1.0
24 | */
25 | public interface Readable {
26 |
27 | /**
28 | * Do deserializable action.
29 | *
30 | * @param bytes the bytes
31 | */
32 | void read(byte[] bytes);
33 | }
34 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/data/Writerable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.data;
18 |
19 |
20 | /**
21 | * A byte deserializable interface.
22 | *
23 | * @author xiemalin
24 | * @since 1.0
25 | */
26 | public interface Writerable {
27 |
28 | /**
29 | * Write.
30 | *
31 | * @return all content as byte array
32 | */
33 | byte[] write();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-test/src/main/java/com/baidu/jprotobuf/pbrpc/BaseTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc;
18 |
19 | /**
20 | * Base test class
21 | *
22 | * @author xiemalin
23 | * @since 1.0
24 | */
25 | public abstract class BaseTest {
26 | protected static final String HOST = System.getProperty("host", "127.0.0.1");
27 | protected static final int PORT = Integer.parseInt(System.getProperty("port", "1031"));
28 | }
29 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/client/ServiceUrlAccessible.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client;
17 |
18 | /**
19 | * Service URL accessible interface.
20 | *
21 | *
22 | * @author xiemalin
23 | * @since 3.2.5
24 | */
25 | public interface ServiceUrlAccessible {
26 |
27 | /**
28 | * Gets the service url.
29 | *
30 | * @return the service url
31 | */
32 | String getServiceUrl();
33 | }
34 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-ext-validator/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.baidu
6 | jprotobuf-rpc-socket
7 | 4.2.1
8 |
9 | ${project.artifactId}
10 | jprotobuf-rpc-ext-validator
11 | supportsbean validation by jsr 303
12 |
13 |
14 | UTF-8
15 | 1.7
16 |
17 |
18 |
19 |
20 | org.jboss.forge.addon
21 | bean-validation
22 | 2.16.1.Final
23 |
24 |
25 | com.baidu
26 | jprotobuf-rpc-core
27 | ${project.parent.version}
28 |
29 |
30 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/registry/NotifyListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.registry;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * NotifyListener. (API, Prototype, ThreadSafe)
22 | *
23 | * @author xiemalin
24 | * @since 2.27
25 | */
26 | public interface NotifyListener {
27 |
28 | /**
29 | * 当收到服务变更通知时触发。.
30 | *
31 | * @param urls 已注册信息列表,总不为空,
32 | */
33 | void notify(List urls);
34 |
35 | }
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/spring/PlaceholderResolved.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.spring;
17 |
18 | /**
19 | * Placehoader resolved call back .
20 | *
21 | * @author xiemalin
22 | * @since 2.17
23 | */
24 | public interface PlaceholderResolved {
25 |
26 | /**
27 | * parsed placeholder value returned.
28 | *
29 | * @param placeholder the placeholder
30 | * @return parsed string
31 | */
32 | String doResolved(String placeholder);
33 | }
34 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/ExceptionCatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.transport;
17 |
18 | /**
19 | * The Interface ExceptionCatcher.
20 | *
21 | * @author xiemalin
22 | * @since 3.5.13
23 | */
24 | public interface ExceptionCatcher {
25 |
26 | /**
27 | * On exception.
28 | *
29 | * @param e the e
30 | * @return the rpc error message
31 | */
32 | RpcErrorMessage onException(Exception e);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/failover/TimeoutIngoredSocketFailOverInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client.ha.lb.failover;
17 |
18 | /**
19 | * Dummy all failover action of timeout exception.
20 | *
21 | * @author xiemalin
22 | * @since 3.1.5
23 | * @deprecated Due to error spell pls using {@link TimeoutIgnoredSocketFailOverInterceptor} instead
24 | */
25 | @Deprecated
26 | public class TimeoutIngoredSocketFailOverInterceptor extends TimeoutIgnoredSocketFailOverInterceptor {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/test/java/com/baidu/jprotobuf/pbrpc/compress/GZipCompressTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.compress;
17 |
18 | /**
19 | * Test class for {@link GZipCompress}
20 | *
21 | * @author xiemalin
22 | * @since 2.13
23 | */
24 | public class GZipCompressTest extends BaseCompressTest {
25 |
26 | /* (non-Javadoc)
27 | * @see com.baidu.jprotobuf.pbrpc.compress.BaseCompressTest#createCompress()
28 | */
29 | @Override
30 | protected Compress createCompress() {
31 | return new GZipCompress();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/test/java/com/baidu/jprotobuf/pbrpc/compress/SnappyCompressTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.compress;
17 |
18 | /**
19 | * Test class for {@link SnappyCompress}
20 | *
21 | * @author xiemalin
22 | * @since 2.13
23 | */
24 | public class SnappyCompressTest extends BaseCompressTest {
25 |
26 | /* (non-Javadoc)
27 | * @see com.baidu.jprotobuf.pbrpc.compress.BaseCompressTest#createCompress()
28 | */
29 | @Override
30 | protected Compress createCompress() {
31 | return new SnappyCompress();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-registry-bns/src/test/java/com/baidu/pbrpc/register/bns/BnsNamingServiceXmlConfigurationTest.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/transport/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.transport;
17 |
18 | /**
19 | * The Interface ExceptionHandler.
20 | *
21 | * @author xiemalin
22 | * @since 3.5.13
23 | */
24 | public interface ExceptionHandler {
25 |
26 | /**
27 | * Handle exception. if return null ignore the exception.
28 | *
29 | * @param error the error
30 | * @return the exception
31 | */
32 | Exception handleException(RpcErrorMessage error);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/meta/RpcMetaAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.meta;
18 |
19 | /**
20 | * To get Rpc service method description.
21 | *
22 | * @author xiemalin
23 | * @since 2.1
24 | */
25 | public interface RpcMetaAware {
26 |
27 | /**
28 | * Gets the input meta proto.
29 | *
30 | * @return the input meta proto
31 | */
32 | String getInputMetaProto();
33 |
34 | /**
35 | * Gets the output meta proto.
36 | *
37 | * @return the output meta proto
38 | */
39 | String getOutputMetaProto();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-spring-starter/src/main/java/com/baidu/pbrpc/spring/conf/PbRPCConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
3 | */
4 | package com.baidu.pbrpc.spring.conf;
5 |
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | import com.baidu.jprotobuf.pbrpc.spring.annotation.CommonAnnotationBeanPostProcessor;
10 | import com.baidu.jprotobuf.pbrpc.spring.annotation.ProtobufRpcAnnotationResolver;
11 |
12 | /**
13 | * spring boot configuration class
14 | *
15 | * @author xiemalin
16 | * @since 3.5.25
17 | */
18 | @Configuration
19 | public class PbRPCConfiguration {
20 |
21 |
22 | /**
23 | * Gets the common annotation bean post processor.
24 | *
25 | * @return the common annotation bean post processor
26 | */
27 | @Bean
28 | public CommonAnnotationBeanPostProcessor getCommonAnnotationBeanPostProcessor() {
29 | CommonAnnotationBeanPostProcessor cabp = new CommonAnnotationBeanPostProcessor();
30 |
31 | ProtobufRpcAnnotationResolver resolver = new ProtobufRpcAnnotationResolver();
32 | cabp.setCallback(resolver);
33 |
34 | return cabp;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/utils/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.utils;
17 |
18 | /**
19 | * Constant class.
20 | *
21 | * @author xiemalin
22 | * @since 2.27
23 | */
24 | public class Constants {
25 |
26 | /** pbrpc scheme. */
27 | public static final String PBRPC_SCHEME = "pbrpc";
28 |
29 | /** The Constant SERVICE_KEY_PREIFX. */
30 | public static final String SERVICE_KEY_PREIFX = "baidu-rpc:";
31 |
32 |
33 | /** The Constant DYNAMIC_SERVICE_NAME. */
34 | public static final String DYNAMIC_SERVICE_NAME = "__DYANMICE_SERVICE__";
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Component
31 | @RpcExporter(port = "1032", rpcServerOptionsBeanName = "rpcServerOptions")
32 | public class AnnotationEchoServiceImpl2 extends EchoServiceImpl {
33 |
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl3.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Component
31 | @RpcExporter(port = "1033" , rpcServerOptionsBeanName = "rpcServerOptions")
32 | public class AnnotationEchoServiceImpl3 extends EchoServiceImpl {
33 |
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring2/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Component
31 | @RpcExporter(port = "1032", rpcServerOptionsBeanName = "rpcServerOptions")
32 | public class AnnotationEchoServiceImpl2 extends EchoServiceImpl {
33 |
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring2/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl3.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Component
31 | @RpcExporter(port = "1033" , rpcServerOptionsBeanName = "rpcServerOptions")
32 | public class AnnotationEchoServiceImpl3 extends EchoServiceImpl {
33 |
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/utils/ServiceSignatureUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.utils;
17 |
18 | /**
19 | * Utility class for service signature string wrap.
20 | *
21 | * @author xiemalin
22 | * @since 2.3.1
23 | */
24 | public class ServiceSignatureUtils {
25 |
26 | /**
27 | * make service signature.
28 | *
29 | * @param serviceName name of service
30 | * @param methodName name of method
31 | * @return service signature
32 | */
33 | public static String makeSignature(String serviceName, String methodName) {
34 | return serviceName + '!' + methodName;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Service;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Service("echoServiceAOP")
31 | @RpcExporter(port = "1031", rpcServerOptionsBeanName = "rpcServerOptions", invokerIntercepterBeanName = "annoServerInterceptor")
32 | public class AnnotationEchoServiceImpl extends EchoServiceImpl {
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring2/src/test/java/com/baidu/jprotobuf/pbrpc/spring/AnnotationEchoServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.spring;
18 |
19 | import org.springframework.stereotype.Service;
20 |
21 | import com.baidu.jprotobuf.pbrpc.EchoServiceImpl;
22 | import com.baidu.jprotobuf.pbrpc.spring.annotation.RpcExporter;
23 |
24 | /**
25 | * Echo service for annotation exporter
26 | *
27 | * @author xiemalin
28 | * @since 2.17
29 | */
30 | @Service("echoServiceAOP")
31 | @RpcExporter(port = "1031", rpcServerOptionsBeanName = "rpcServerOptions", invokerIntercepterBeanName = "annoServerInterceptor")
32 | public class AnnotationEchoServiceImpl extends EchoServiceImpl {
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/client/ServiceLocatorCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client;
17 |
18 | import java.net.InetSocketAddress;
19 |
20 | /**
21 | * This interface is used to call back on {@link ProtobufRpcProxy} on create connection for each serviceSignature.
22 | * serviceSignature should be unique to each service for same business.
23 | *
24 | * @author xiemalin
25 | * @since 2.19
26 | */
27 | public interface ServiceLocatorCallback {
28 |
29 | /**
30 | * Fetch address.
31 | *
32 | * @param serviceSignature the service signature
33 | * @return the inet socket address
34 | */
35 | InetSocketAddress fetchAddress(String serviceSignature);
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/strategy/NamingServiceLoadBalanceStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client.ha.lb.strategy;
17 |
18 | import com.baidu.jprotobuf.pbrpc.client.ha.NamingService;
19 |
20 | /**
21 | * {@link NamingService} support load balance strategy.
22 | *
23 | * @author xiemalin
24 | * @since 2.17
25 | */
26 | public interface NamingServiceLoadBalanceStrategy extends LoadBalanceStrategy {
27 |
28 | /**
29 | * do reinit once by the naming service.
30 | *
31 | * @param serviceSignature the service signature
32 | * @param namingService {@link NamingService}
33 | */
34 | void doReInit(String serviceSignature, NamingService namingService);
35 | }
36 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/failover/DummySocketFailOverInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client.ha.lb.failover;
17 |
18 | /**
19 | * Dummy {@link FailOverInterceptor} instance to close fail over feature.
20 | *
21 | * @author xiemalin
22 | * @since 3.1.3
23 | */
24 | public class DummySocketFailOverInterceptor extends SocketFailOverInterceptor {
25 |
26 | /*
27 | * (non-Javadoc)
28 | *
29 | * @see com.baidu.jprotobuf.pbrpc.client.ha.lb.failover.FailOverInterceptor#isDoFailover(java.lang.Throwable,
30 | * java.lang.String)
31 | */
32 | @Override
33 | public boolean isDoFailover(Throwable t, String beanKey) {
34 | return false;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring/src/test/java/com/baidu/jprotobuf/pbrpc/spring/MyInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.spring;
17 |
18 | import org.aopalliance.intercept.MethodInterceptor;
19 | import org.aopalliance.intercept.MethodInvocation;
20 |
21 | /**
22 | *
23 | * @author xiemalin
24 | *
25 | */
26 | public class MyInterceptor implements MethodInterceptor {
27 |
28 | /* (non-Javadoc)
29 | * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
30 | */
31 | @Override
32 | public Object invoke(MethodInvocation arg0) throws Throwable {
33 |
34 | System.out.println("inteceptor'" + MyInterceptor.class.getName() + "' =>" + arg0.getMethod().getName());
35 | return arg0.proceed();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring2/src/test/java/com/baidu/jprotobuf/pbrpc/spring/MyInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.spring;
17 |
18 | import org.aopalliance.intercept.MethodInterceptor;
19 | import org.aopalliance.intercept.MethodInvocation;
20 |
21 | /**
22 | *
23 | * @author xiemalin
24 | *
25 | */
26 | public class MyInterceptor implements MethodInterceptor {
27 |
28 | /* (non-Javadoc)
29 | * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
30 | */
31 | @Override
32 | public Object invoke(MethodInvocation arg0) throws Throwable {
33 |
34 | System.out.println("inteceptor'" + MyInterceptor.class.getName() + "' =>" + arg0.getMethod().getName());
35 | return arg0.proceed();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/NamingService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client.ha;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 | import java.util.Set;
21 |
22 | import com.baidu.jprotobuf.pbrpc.registry.RegisterInfo;
23 |
24 | /**
25 | * Naming service interface.
26 | *
27 | * @author xiemalin
28 | * @since 2.15
29 | */
30 | public interface NamingService {
31 |
32 | /**
33 | * get server list from naming service.
34 | *
35 | * @param serviceSignatures service signatures
36 | * @return server list mapped by service signature.
37 | * @throws Exception in case of any exception
38 | */
39 | Map> list(Set serviceSignatures) throws Exception;
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/meta/RpcServiceMetaService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.baidu.jprotobuf.pbrpc.meta;
18 |
19 | import com.baidu.jprotobuf.pbrpc.ProtobufRPC;
20 |
21 | /**
22 | * {@link RpcServiceMetaService}.
23 | *
24 | * @author xiemalin
25 | * @since 2.1
26 | */
27 | public interface RpcServiceMetaService {
28 |
29 | /**
30 | * Gets the rpc service meta info.
31 | *
32 | * @return the rpc service meta info
33 | */
34 | @ProtobufRPC(serviceName = RpcServiceMetaServiceProvider.RPC_META_SERVICENAME, onceTalkTimeout = 100000)
35 | RpcServiceMetaList getRpcServiceMetaInfo();
36 |
37 | /**
38 | * Ping.
39 | */
40 | @ProtobufRPC(serviceName = RpcServiceMetaServiceProvider.RPC_META_SERVICENAME)
41 | void ping();
42 | }
43 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core-spring-base/src/main/java/com/baidu/jprotobuf/pbrpc/client/ha/lb/strategy/NamingServiceLoadBalanceStrategyFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.client.ha.lb.strategy;
17 |
18 | import com.baidu.jprotobuf.pbrpc.client.ha.NamingService;
19 |
20 | /**
21 | * Factory pattern for {@link NamingServiceLoadBalanceStrategy}.
22 | *
23 | * @author xiemalin
24 | * @since 2.19
25 | */
26 | public interface NamingServiceLoadBalanceStrategyFactory {
27 |
28 | /**
29 | * create a new {@link NamingServiceLoadBalanceStrategy}.
30 | *
31 | * @param serviceSignature service signature
32 | * @param namingService naming service
33 | * @return {@link NamingServiceLoadBalanceStrategy}
34 | */
35 | NamingServiceLoadBalanceStrategy create(String serviceSignature, NamingService namingService);
36 | }
37 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-core/src/main/java/com/baidu/jprotobuf/pbrpc/compress/Compress.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2007 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.baidu.jprotobuf.pbrpc.compress;
17 |
18 | import java.io.IOException;
19 |
20 | /**
21 | * Compress interface.
22 | *
23 | * @author xiemalin
24 | * @since 1.4
25 | */
26 | public interface Compress {
27 |
28 | /**
29 | * Compress.
30 | *
31 | * @param array the array
32 | * @return the byte[]
33 | * @throws IOException Signals that an I/O exception has occurred.
34 | */
35 | byte[] compress(byte[] array) throws IOException;
36 |
37 |
38 | /**
39 | * Un compress.
40 | *
41 | * @param array the array
42 | * @return the byte[]
43 | * @throws IOException Signals that an I/O exception has occurred.
44 | */
45 | byte[] unCompress(byte[] array) throws IOException;
46 | }
47 |
--------------------------------------------------------------------------------
/jprotobuf-rpc-ext-validator/src/main/java/com/baidu/jprotobuf/pbrpc/ext/validator/DefaultConstraintViolationsFormatter.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.baidu.jprotobuf.pbrpc.ext.validator;
5 |
6 | import java.util.Set;
7 |
8 | import javax.validation.ConstraintViolation;
9 | import javax.validation.Path;
10 |
11 | /**
12 | * Default formatter implements for {@link ConstraintViolationsFormatter}
13 | *
14 | * @author xiemalin
15 | * @since 3.4.0
16 | */
17 | public class DefaultConstraintViolationsFormatter implements ConstraintViolationsFormatter {
18 |
19 | private static final String EMPTY_STRING = "";
20 |
21 | private String formatter = "Validate violdation: property '%s' validate failed with message '%s' current value is '%s'\n";
22 |
23 | @Override
24 | public String format(Set> result) {
25 | if (result == null || result.isEmpty()) {
26 | return EMPTY_STRING;
27 | }
28 |
29 | StringBuilder builder = new StringBuilder();
30 | for (ConstraintViolation