PageRenderTime 60ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/netty-protobuf-rpc/src/main/java/com/googlecode/protobuf/netty/example/Calculator.java

http://netty-protobuf-rpc.googlecode.com/
Java | 1083 lines | 937 code | 114 blank | 32 comment | 58 complexity | b4d845bcfcf6e69e69f408b6193c7aa9 MD5 | raw file
  1. /*
  2. * Copyright (c) 2009 Stephen Tu <stephen_tu@berkeley.edu>
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. // Generated by the protocol buffer compiler. DO NOT EDIT!
  23. package com.googlecode.protobuf.netty.example;
  24. public final class Calculator {
  25. private Calculator() {}
  26. public static void registerAllExtensions(
  27. com.google.protobuf.ExtensionRegistry registry) {
  28. }
  29. public static final class CalcRequest extends
  30. com.google.protobuf.GeneratedMessage {
  31. // Use CalcRequest.newBuilder() to construct.
  32. private CalcRequest() {}
  33. private static final CalcRequest defaultInstance = new CalcRequest();
  34. public static CalcRequest getDefaultInstance() {
  35. return defaultInstance;
  36. }
  37. public CalcRequest getDefaultInstanceForType() {
  38. return defaultInstance;
  39. }
  40. public static final com.google.protobuf.Descriptors.Descriptor
  41. getDescriptor() {
  42. return com.googlecode.protobuf.netty.example.Calculator.internal_static_CalcRequest_descriptor;
  43. }
  44. protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
  45. internalGetFieldAccessorTable() {
  46. return com.googlecode.protobuf.netty.example.Calculator.internal_static_CalcRequest_fieldAccessorTable;
  47. }
  48. // required int32 op1 = 1;
  49. public static final int OP1_FIELD_NUMBER = 1;
  50. private boolean hasOp1;
  51. private int op1_ = 0;
  52. public boolean hasOp1() { return hasOp1; }
  53. public int getOp1() { return op1_; }
  54. // required int32 op2 = 2;
  55. public static final int OP2_FIELD_NUMBER = 2;
  56. private boolean hasOp2;
  57. private int op2_ = 0;
  58. public boolean hasOp2() { return hasOp2; }
  59. public int getOp2() { return op2_; }
  60. public final boolean isInitialized() {
  61. if (!hasOp1) return false;
  62. if (!hasOp2) return false;
  63. return true;
  64. }
  65. public void writeTo(com.google.protobuf.CodedOutputStream output)
  66. throws java.io.IOException {
  67. if (hasOp1()) {
  68. output.writeInt32(1, getOp1());
  69. }
  70. if (hasOp2()) {
  71. output.writeInt32(2, getOp2());
  72. }
  73. getUnknownFields().writeTo(output);
  74. }
  75. private int memoizedSerializedSize = -1;
  76. public int getSerializedSize() {
  77. int size = memoizedSerializedSize;
  78. if (size != -1) return size;
  79. size = 0;
  80. if (hasOp1()) {
  81. size += com.google.protobuf.CodedOutputStream
  82. .computeInt32Size(1, getOp1());
  83. }
  84. if (hasOp2()) {
  85. size += com.google.protobuf.CodedOutputStream
  86. .computeInt32Size(2, getOp2());
  87. }
  88. size += getUnknownFields().getSerializedSize();
  89. memoizedSerializedSize = size;
  90. return size;
  91. }
  92. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  93. com.google.protobuf.ByteString data)
  94. throws com.google.protobuf.InvalidProtocolBufferException {
  95. return newBuilder().mergeFrom(data).buildParsed();
  96. }
  97. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  98. com.google.protobuf.ByteString data,
  99. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  100. throws com.google.protobuf.InvalidProtocolBufferException {
  101. return newBuilder().mergeFrom(data, extensionRegistry)
  102. .buildParsed();
  103. }
  104. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(byte[] data)
  105. throws com.google.protobuf.InvalidProtocolBufferException {
  106. return newBuilder().mergeFrom(data).buildParsed();
  107. }
  108. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  109. byte[] data,
  110. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  111. throws com.google.protobuf.InvalidProtocolBufferException {
  112. return newBuilder().mergeFrom(data, extensionRegistry)
  113. .buildParsed();
  114. }
  115. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(java.io.InputStream input)
  116. throws java.io.IOException {
  117. return newBuilder().mergeFrom(input).buildParsed();
  118. }
  119. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  120. java.io.InputStream input,
  121. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  122. throws java.io.IOException {
  123. return newBuilder().mergeFrom(input, extensionRegistry)
  124. .buildParsed();
  125. }
  126. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseDelimitedFrom(java.io.InputStream input)
  127. throws java.io.IOException {
  128. return newBuilder().mergeDelimitedFrom(input).buildParsed();
  129. }
  130. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseDelimitedFrom(
  131. java.io.InputStream input,
  132. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  133. throws java.io.IOException {
  134. return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
  135. .buildParsed();
  136. }
  137. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  138. com.google.protobuf.CodedInputStream input)
  139. throws java.io.IOException {
  140. return newBuilder().mergeFrom(input).buildParsed();
  141. }
  142. public static com.googlecode.protobuf.netty.example.Calculator.CalcRequest parseFrom(
  143. com.google.protobuf.CodedInputStream input,
  144. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  145. throws java.io.IOException {
  146. return newBuilder().mergeFrom(input, extensionRegistry)
  147. .buildParsed();
  148. }
  149. public static Builder newBuilder() { return Builder.create(); }
  150. public Builder newBuilderForType() { return newBuilder(); }
  151. public static Builder newBuilder(com.googlecode.protobuf.netty.example.Calculator.CalcRequest prototype) {
  152. return newBuilder().mergeFrom(prototype);
  153. }
  154. public Builder toBuilder() { return newBuilder(this); }
  155. public static final class Builder extends
  156. com.google.protobuf.GeneratedMessage.Builder<Builder> {
  157. private com.googlecode.protobuf.netty.example.Calculator.CalcRequest result;
  158. // Construct using com.googlecode.protobuf.netty.example.Calculator.CalcRequest.newBuilder()
  159. private Builder() {}
  160. private static Builder create() {
  161. Builder builder = new Builder();
  162. builder.result = new com.googlecode.protobuf.netty.example.Calculator.CalcRequest();
  163. return builder;
  164. }
  165. protected com.googlecode.protobuf.netty.example.Calculator.CalcRequest internalGetResult() {
  166. return result;
  167. }
  168. public Builder clear() {
  169. if (result == null) {
  170. throw new IllegalStateException(
  171. "Cannot call clear() after build().");
  172. }
  173. result = new com.googlecode.protobuf.netty.example.Calculator.CalcRequest();
  174. return this;
  175. }
  176. public Builder clone() {
  177. return create().mergeFrom(result);
  178. }
  179. public com.google.protobuf.Descriptors.Descriptor
  180. getDescriptorForType() {
  181. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDescriptor();
  182. }
  183. public com.googlecode.protobuf.netty.example.Calculator.CalcRequest getDefaultInstanceForType() {
  184. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  185. }
  186. public boolean isInitialized() {
  187. return result.isInitialized();
  188. }
  189. public com.googlecode.protobuf.netty.example.Calculator.CalcRequest build() {
  190. if (result != null && !isInitialized()) {
  191. throw newUninitializedMessageException(result);
  192. }
  193. return buildPartial();
  194. }
  195. private com.googlecode.protobuf.netty.example.Calculator.CalcRequest buildParsed()
  196. throws com.google.protobuf.InvalidProtocolBufferException {
  197. if (!isInitialized()) {
  198. throw newUninitializedMessageException(
  199. result).asInvalidProtocolBufferException();
  200. }
  201. return buildPartial();
  202. }
  203. public com.googlecode.protobuf.netty.example.Calculator.CalcRequest buildPartial() {
  204. if (result == null) {
  205. throw new IllegalStateException(
  206. "build() has already been called on this Builder.");
  207. }
  208. com.googlecode.protobuf.netty.example.Calculator.CalcRequest returnMe = result;
  209. result = null;
  210. return returnMe;
  211. }
  212. public Builder mergeFrom(com.google.protobuf.Message other) {
  213. if (other instanceof com.googlecode.protobuf.netty.example.Calculator.CalcRequest) {
  214. return mergeFrom((com.googlecode.protobuf.netty.example.Calculator.CalcRequest)other);
  215. } else {
  216. super.mergeFrom(other);
  217. return this;
  218. }
  219. }
  220. public Builder mergeFrom(com.googlecode.protobuf.netty.example.Calculator.CalcRequest other) {
  221. if (other == com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance()) return this;
  222. if (other.hasOp1()) {
  223. setOp1(other.getOp1());
  224. }
  225. if (other.hasOp2()) {
  226. setOp2(other.getOp2());
  227. }
  228. this.mergeUnknownFields(other.getUnknownFields());
  229. return this;
  230. }
  231. public Builder mergeFrom(
  232. com.google.protobuf.CodedInputStream input,
  233. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  234. throws java.io.IOException {
  235. com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  236. com.google.protobuf.UnknownFieldSet.newBuilder(
  237. this.getUnknownFields());
  238. while (true) {
  239. int tag = input.readTag();
  240. switch (tag) {
  241. case 0:
  242. this.setUnknownFields(unknownFields.build());
  243. return this;
  244. default: {
  245. if (!parseUnknownField(input, unknownFields,
  246. extensionRegistry, tag)) {
  247. this.setUnknownFields(unknownFields.build());
  248. return this;
  249. }
  250. break;
  251. }
  252. case 8: {
  253. setOp1(input.readInt32());
  254. break;
  255. }
  256. case 16: {
  257. setOp2(input.readInt32());
  258. break;
  259. }
  260. }
  261. }
  262. }
  263. // required int32 op1 = 1;
  264. public boolean hasOp1() {
  265. return result.hasOp1();
  266. }
  267. public int getOp1() {
  268. return result.getOp1();
  269. }
  270. public Builder setOp1(int value) {
  271. result.hasOp1 = true;
  272. result.op1_ = value;
  273. return this;
  274. }
  275. public Builder clearOp1() {
  276. result.hasOp1 = false;
  277. result.op1_ = 0;
  278. return this;
  279. }
  280. // required int32 op2 = 2;
  281. public boolean hasOp2() {
  282. return result.hasOp2();
  283. }
  284. public int getOp2() {
  285. return result.getOp2();
  286. }
  287. public Builder setOp2(int value) {
  288. result.hasOp2 = true;
  289. result.op2_ = value;
  290. return this;
  291. }
  292. public Builder clearOp2() {
  293. result.hasOp2 = false;
  294. result.op2_ = 0;
  295. return this;
  296. }
  297. }
  298. static {
  299. com.googlecode.protobuf.netty.example.Calculator.getDescriptor();
  300. }
  301. static {
  302. com.googlecode.protobuf.netty.example.Calculator.internalForceInit();
  303. }
  304. }
  305. public static final class CalcResponse extends
  306. com.google.protobuf.GeneratedMessage {
  307. // Use CalcResponse.newBuilder() to construct.
  308. private CalcResponse() {}
  309. private static final CalcResponse defaultInstance = new CalcResponse();
  310. public static CalcResponse getDefaultInstance() {
  311. return defaultInstance;
  312. }
  313. public CalcResponse getDefaultInstanceForType() {
  314. return defaultInstance;
  315. }
  316. public static final com.google.protobuf.Descriptors.Descriptor
  317. getDescriptor() {
  318. return com.googlecode.protobuf.netty.example.Calculator.internal_static_CalcResponse_descriptor;
  319. }
  320. protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
  321. internalGetFieldAccessorTable() {
  322. return com.googlecode.protobuf.netty.example.Calculator.internal_static_CalcResponse_fieldAccessorTable;
  323. }
  324. // required int32 result = 1;
  325. public static final int RESULT_FIELD_NUMBER = 1;
  326. private boolean hasResult;
  327. private int result_ = 0;
  328. public boolean hasResult() { return hasResult; }
  329. public int getResult() { return result_; }
  330. public final boolean isInitialized() {
  331. if (!hasResult) return false;
  332. return true;
  333. }
  334. public void writeTo(com.google.protobuf.CodedOutputStream output)
  335. throws java.io.IOException {
  336. if (hasResult()) {
  337. output.writeInt32(1, getResult());
  338. }
  339. getUnknownFields().writeTo(output);
  340. }
  341. private int memoizedSerializedSize = -1;
  342. public int getSerializedSize() {
  343. int size = memoizedSerializedSize;
  344. if (size != -1) return size;
  345. size = 0;
  346. if (hasResult()) {
  347. size += com.google.protobuf.CodedOutputStream
  348. .computeInt32Size(1, getResult());
  349. }
  350. size += getUnknownFields().getSerializedSize();
  351. memoizedSerializedSize = size;
  352. return size;
  353. }
  354. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  355. com.google.protobuf.ByteString data)
  356. throws com.google.protobuf.InvalidProtocolBufferException {
  357. return newBuilder().mergeFrom(data).buildParsed();
  358. }
  359. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  360. com.google.protobuf.ByteString data,
  361. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  362. throws com.google.protobuf.InvalidProtocolBufferException {
  363. return newBuilder().mergeFrom(data, extensionRegistry)
  364. .buildParsed();
  365. }
  366. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(byte[] data)
  367. throws com.google.protobuf.InvalidProtocolBufferException {
  368. return newBuilder().mergeFrom(data).buildParsed();
  369. }
  370. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  371. byte[] data,
  372. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  373. throws com.google.protobuf.InvalidProtocolBufferException {
  374. return newBuilder().mergeFrom(data, extensionRegistry)
  375. .buildParsed();
  376. }
  377. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(java.io.InputStream input)
  378. throws java.io.IOException {
  379. return newBuilder().mergeFrom(input).buildParsed();
  380. }
  381. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  382. java.io.InputStream input,
  383. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  384. throws java.io.IOException {
  385. return newBuilder().mergeFrom(input, extensionRegistry)
  386. .buildParsed();
  387. }
  388. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseDelimitedFrom(java.io.InputStream input)
  389. throws java.io.IOException {
  390. return newBuilder().mergeDelimitedFrom(input).buildParsed();
  391. }
  392. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseDelimitedFrom(
  393. java.io.InputStream input,
  394. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  395. throws java.io.IOException {
  396. return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
  397. .buildParsed();
  398. }
  399. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  400. com.google.protobuf.CodedInputStream input)
  401. throws java.io.IOException {
  402. return newBuilder().mergeFrom(input).buildParsed();
  403. }
  404. public static com.googlecode.protobuf.netty.example.Calculator.CalcResponse parseFrom(
  405. com.google.protobuf.CodedInputStream input,
  406. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  407. throws java.io.IOException {
  408. return newBuilder().mergeFrom(input, extensionRegistry)
  409. .buildParsed();
  410. }
  411. public static Builder newBuilder() { return Builder.create(); }
  412. public Builder newBuilderForType() { return newBuilder(); }
  413. public static Builder newBuilder(com.googlecode.protobuf.netty.example.Calculator.CalcResponse prototype) {
  414. return newBuilder().mergeFrom(prototype);
  415. }
  416. public Builder toBuilder() { return newBuilder(this); }
  417. public static final class Builder extends
  418. com.google.protobuf.GeneratedMessage.Builder<Builder> {
  419. private com.googlecode.protobuf.netty.example.Calculator.CalcResponse result;
  420. // Construct using com.googlecode.protobuf.netty.example.Calculator.CalcResponse.newBuilder()
  421. private Builder() {}
  422. private static Builder create() {
  423. Builder builder = new Builder();
  424. builder.result = new com.googlecode.protobuf.netty.example.Calculator.CalcResponse();
  425. return builder;
  426. }
  427. protected com.googlecode.protobuf.netty.example.Calculator.CalcResponse internalGetResult() {
  428. return result;
  429. }
  430. public Builder clear() {
  431. if (result == null) {
  432. throw new IllegalStateException(
  433. "Cannot call clear() after build().");
  434. }
  435. result = new com.googlecode.protobuf.netty.example.Calculator.CalcResponse();
  436. return this;
  437. }
  438. public Builder clone() {
  439. return create().mergeFrom(result);
  440. }
  441. public com.google.protobuf.Descriptors.Descriptor
  442. getDescriptorForType() {
  443. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDescriptor();
  444. }
  445. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse getDefaultInstanceForType() {
  446. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  447. }
  448. public boolean isInitialized() {
  449. return result.isInitialized();
  450. }
  451. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse build() {
  452. if (result != null && !isInitialized()) {
  453. throw newUninitializedMessageException(result);
  454. }
  455. return buildPartial();
  456. }
  457. private com.googlecode.protobuf.netty.example.Calculator.CalcResponse buildParsed()
  458. throws com.google.protobuf.InvalidProtocolBufferException {
  459. if (!isInitialized()) {
  460. throw newUninitializedMessageException(
  461. result).asInvalidProtocolBufferException();
  462. }
  463. return buildPartial();
  464. }
  465. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse buildPartial() {
  466. if (result == null) {
  467. throw new IllegalStateException(
  468. "build() has already been called on this Builder.");
  469. }
  470. com.googlecode.protobuf.netty.example.Calculator.CalcResponse returnMe = result;
  471. result = null;
  472. return returnMe;
  473. }
  474. public Builder mergeFrom(com.google.protobuf.Message other) {
  475. if (other instanceof com.googlecode.protobuf.netty.example.Calculator.CalcResponse) {
  476. return mergeFrom((com.googlecode.protobuf.netty.example.Calculator.CalcResponse)other);
  477. } else {
  478. super.mergeFrom(other);
  479. return this;
  480. }
  481. }
  482. public Builder mergeFrom(com.googlecode.protobuf.netty.example.Calculator.CalcResponse other) {
  483. if (other == com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance()) return this;
  484. if (other.hasResult()) {
  485. setResult(other.getResult());
  486. }
  487. this.mergeUnknownFields(other.getUnknownFields());
  488. return this;
  489. }
  490. public Builder mergeFrom(
  491. com.google.protobuf.CodedInputStream input,
  492. com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  493. throws java.io.IOException {
  494. com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  495. com.google.protobuf.UnknownFieldSet.newBuilder(
  496. this.getUnknownFields());
  497. while (true) {
  498. int tag = input.readTag();
  499. switch (tag) {
  500. case 0:
  501. this.setUnknownFields(unknownFields.build());
  502. return this;
  503. default: {
  504. if (!parseUnknownField(input, unknownFields,
  505. extensionRegistry, tag)) {
  506. this.setUnknownFields(unknownFields.build());
  507. return this;
  508. }
  509. break;
  510. }
  511. case 8: {
  512. setResult(input.readInt32());
  513. break;
  514. }
  515. }
  516. }
  517. }
  518. // required int32 result = 1;
  519. public boolean hasResult() {
  520. return result.hasResult();
  521. }
  522. public int getResult() {
  523. return result.getResult();
  524. }
  525. public Builder setResult(int value) {
  526. result.hasResult = true;
  527. result.result_ = value;
  528. return this;
  529. }
  530. public Builder clearResult() {
  531. result.hasResult = false;
  532. result.result_ = 0;
  533. return this;
  534. }
  535. }
  536. static {
  537. com.googlecode.protobuf.netty.example.Calculator.getDescriptor();
  538. }
  539. static {
  540. com.googlecode.protobuf.netty.example.Calculator.internalForceInit();
  541. }
  542. }
  543. public static abstract class CalcService
  544. implements com.google.protobuf.Service {
  545. protected CalcService() {}
  546. public interface Interface {
  547. public abstract void add(
  548. com.google.protobuf.RpcController controller,
  549. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  550. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  551. public abstract void subtract(
  552. com.google.protobuf.RpcController controller,
  553. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  554. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  555. public abstract void multiply(
  556. com.google.protobuf.RpcController controller,
  557. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  558. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  559. public abstract void divide(
  560. com.google.protobuf.RpcController controller,
  561. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  562. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  563. }
  564. public static com.google.protobuf.Service newReflectiveService(
  565. final Interface impl) {
  566. return new CalcService() {
  567. @Override
  568. public void add(
  569. com.google.protobuf.RpcController controller,
  570. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  571. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  572. impl.add(controller, request, done);
  573. }
  574. @Override
  575. public void subtract(
  576. com.google.protobuf.RpcController controller,
  577. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  578. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  579. impl.subtract(controller, request, done);
  580. }
  581. @Override
  582. public void multiply(
  583. com.google.protobuf.RpcController controller,
  584. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  585. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  586. impl.multiply(controller, request, done);
  587. }
  588. @Override
  589. public void divide(
  590. com.google.protobuf.RpcController controller,
  591. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  592. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  593. impl.divide(controller, request, done);
  594. }
  595. };
  596. }
  597. public static com.google.protobuf.BlockingService
  598. newReflectiveBlockingService(final BlockingInterface impl) {
  599. return new com.google.protobuf.BlockingService() {
  600. public final com.google.protobuf.Descriptors.ServiceDescriptor
  601. getDescriptorForType() {
  602. return getDescriptor();
  603. }
  604. public final com.google.protobuf.Message callBlockingMethod(
  605. com.google.protobuf.Descriptors.MethodDescriptor method,
  606. com.google.protobuf.RpcController controller,
  607. com.google.protobuf.Message request)
  608. throws com.google.protobuf.ServiceException {
  609. if (method.getService() != getDescriptor()) {
  610. throw new java.lang.IllegalArgumentException(
  611. "Service.callBlockingMethod() given method descriptor for " +
  612. "wrong service type.");
  613. }
  614. switch(method.getIndex()) {
  615. case 0:
  616. return impl.add(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request);
  617. case 1:
  618. return impl.subtract(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request);
  619. case 2:
  620. return impl.multiply(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request);
  621. case 3:
  622. return impl.divide(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request);
  623. default:
  624. throw new java.lang.AssertionError("Can't get here.");
  625. }
  626. }
  627. public final com.google.protobuf.Message
  628. getRequestPrototype(
  629. com.google.protobuf.Descriptors.MethodDescriptor method) {
  630. if (method.getService() != getDescriptor()) {
  631. throw new java.lang.IllegalArgumentException(
  632. "Service.getRequestPrototype() given method " +
  633. "descriptor for wrong service type.");
  634. }
  635. switch(method.getIndex()) {
  636. case 0:
  637. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  638. case 1:
  639. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  640. case 2:
  641. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  642. case 3:
  643. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  644. default:
  645. throw new java.lang.AssertionError("Can't get here.");
  646. }
  647. }
  648. public final com.google.protobuf.Message
  649. getResponsePrototype(
  650. com.google.protobuf.Descriptors.MethodDescriptor method) {
  651. if (method.getService() != getDescriptor()) {
  652. throw new java.lang.IllegalArgumentException(
  653. "Service.getResponsePrototype() given method " +
  654. "descriptor for wrong service type.");
  655. }
  656. switch(method.getIndex()) {
  657. case 0:
  658. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  659. case 1:
  660. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  661. case 2:
  662. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  663. case 3:
  664. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  665. default:
  666. throw new java.lang.AssertionError("Can't get here.");
  667. }
  668. }
  669. };
  670. }
  671. public abstract void add(
  672. com.google.protobuf.RpcController controller,
  673. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  674. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  675. public abstract void subtract(
  676. com.google.protobuf.RpcController controller,
  677. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  678. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  679. public abstract void multiply(
  680. com.google.protobuf.RpcController controller,
  681. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  682. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  683. public abstract void divide(
  684. com.google.protobuf.RpcController controller,
  685. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  686. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done);
  687. public static final
  688. com.google.protobuf.Descriptors.ServiceDescriptor
  689. getDescriptor() {
  690. return com.googlecode.protobuf.netty.example.Calculator.getDescriptor().getServices().get(0);
  691. }
  692. public final com.google.protobuf.Descriptors.ServiceDescriptor
  693. getDescriptorForType() {
  694. return getDescriptor();
  695. }
  696. public final void callMethod(
  697. com.google.protobuf.Descriptors.MethodDescriptor method,
  698. com.google.protobuf.RpcController controller,
  699. com.google.protobuf.Message request,
  700. com.google.protobuf.RpcCallback<
  701. com.google.protobuf.Message> done) {
  702. if (method.getService() != getDescriptor()) {
  703. throw new java.lang.IllegalArgumentException(
  704. "Service.callMethod() given method descriptor for wrong " +
  705. "service type.");
  706. }
  707. switch(method.getIndex()) {
  708. case 0:
  709. this.add(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request,
  710. com.google.protobuf.RpcUtil.<com.googlecode.protobuf.netty.example.Calculator.CalcResponse>specializeCallback(
  711. done));
  712. return;
  713. case 1:
  714. this.subtract(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request,
  715. com.google.protobuf.RpcUtil.<com.googlecode.protobuf.netty.example.Calculator.CalcResponse>specializeCallback(
  716. done));
  717. return;
  718. case 2:
  719. this.multiply(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request,
  720. com.google.protobuf.RpcUtil.<com.googlecode.protobuf.netty.example.Calculator.CalcResponse>specializeCallback(
  721. done));
  722. return;
  723. case 3:
  724. this.divide(controller, (com.googlecode.protobuf.netty.example.Calculator.CalcRequest)request,
  725. com.google.protobuf.RpcUtil.<com.googlecode.protobuf.netty.example.Calculator.CalcResponse>specializeCallback(
  726. done));
  727. return;
  728. default:
  729. throw new java.lang.AssertionError("Can't get here.");
  730. }
  731. }
  732. public final com.google.protobuf.Message
  733. getRequestPrototype(
  734. com.google.protobuf.Descriptors.MethodDescriptor method) {
  735. if (method.getService() != getDescriptor()) {
  736. throw new java.lang.IllegalArgumentException(
  737. "Service.getRequestPrototype() given method " +
  738. "descriptor for wrong service type.");
  739. }
  740. switch(method.getIndex()) {
  741. case 0:
  742. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  743. case 1:
  744. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  745. case 2:
  746. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  747. case 3:
  748. return com.googlecode.protobuf.netty.example.Calculator.CalcRequest.getDefaultInstance();
  749. default:
  750. throw new java.lang.AssertionError("Can't get here.");
  751. }
  752. }
  753. public final com.google.protobuf.Message
  754. getResponsePrototype(
  755. com.google.protobuf.Descriptors.MethodDescriptor method) {
  756. if (method.getService() != getDescriptor()) {
  757. throw new java.lang.IllegalArgumentException(
  758. "Service.getResponsePrototype() given method " +
  759. "descriptor for wrong service type.");
  760. }
  761. switch(method.getIndex()) {
  762. case 0:
  763. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  764. case 1:
  765. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  766. case 2:
  767. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  768. case 3:
  769. return com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance();
  770. default:
  771. throw new java.lang.AssertionError("Can't get here.");
  772. }
  773. }
  774. public static Stub newStub(
  775. com.google.protobuf.RpcChannel channel) {
  776. return new Stub(channel);
  777. }
  778. public static final class Stub extends com.googlecode.protobuf.netty.example.Calculator.CalcService implements Interface {
  779. private Stub(com.google.protobuf.RpcChannel channel) {
  780. this.channel = channel;
  781. }
  782. private final com.google.protobuf.RpcChannel channel;
  783. public com.google.protobuf.RpcChannel getChannel() {
  784. return channel;
  785. }
  786. public void add(
  787. com.google.protobuf.RpcController controller,
  788. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  789. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  790. channel.callMethod(
  791. getDescriptor().getMethods().get(0),
  792. controller,
  793. request,
  794. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance(),
  795. com.google.protobuf.RpcUtil.generalizeCallback(
  796. done,
  797. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.class,
  798. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance()));
  799. }
  800. public void subtract(
  801. com.google.protobuf.RpcController controller,
  802. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  803. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  804. channel.callMethod(
  805. getDescriptor().getMethods().get(1),
  806. controller,
  807. request,
  808. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance(),
  809. com.google.protobuf.RpcUtil.generalizeCallback(
  810. done,
  811. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.class,
  812. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance()));
  813. }
  814. public void multiply(
  815. com.google.protobuf.RpcController controller,
  816. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  817. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  818. channel.callMethod(
  819. getDescriptor().getMethods().get(2),
  820. controller,
  821. request,
  822. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance(),
  823. com.google.protobuf.RpcUtil.generalizeCallback(
  824. done,
  825. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.class,
  826. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance()));
  827. }
  828. public void divide(
  829. com.google.protobuf.RpcController controller,
  830. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request,
  831. com.google.protobuf.RpcCallback<com.googlecode.protobuf.netty.example.Calculator.CalcResponse> done) {
  832. channel.callMethod(
  833. getDescriptor().getMethods().get(3),
  834. controller,
  835. request,
  836. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance(),
  837. com.google.protobuf.RpcUtil.generalizeCallback(
  838. done,
  839. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.class,
  840. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance()));
  841. }
  842. }
  843. public static BlockingInterface newBlockingStub(
  844. com.google.protobuf.BlockingRpcChannel channel) {
  845. return new BlockingStub(channel);
  846. }
  847. public interface BlockingInterface {
  848. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse add(
  849. com.google.protobuf.RpcController controller,
  850. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  851. throws com.google.protobuf.ServiceException;
  852. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse subtract(
  853. com.google.protobuf.RpcController controller,
  854. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  855. throws com.google.protobuf.ServiceException;
  856. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse multiply(
  857. com.google.protobuf.RpcController controller,
  858. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  859. throws com.google.protobuf.ServiceException;
  860. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse divide(
  861. com.google.protobuf.RpcController controller,
  862. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  863. throws com.google.protobuf.ServiceException;
  864. }
  865. private static final class BlockingStub implements BlockingInterface {
  866. private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {
  867. this.channel = channel;
  868. }
  869. private final com.google.protobuf.BlockingRpcChannel channel;
  870. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse add(
  871. com.google.protobuf.RpcController controller,
  872. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  873. throws com.google.protobuf.ServiceException {
  874. return (com.googlecode.protobuf.netty.example.Calculator.CalcResponse) channel.callBlockingMethod(
  875. getDescriptor().getMethods().get(0),
  876. controller,
  877. request,
  878. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance());
  879. }
  880. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse subtract(
  881. com.google.protobuf.RpcController controller,
  882. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  883. throws com.google.protobuf.ServiceException {
  884. return (com.googlecode.protobuf.netty.example.Calculator.CalcResponse) channel.callBlockingMethod(
  885. getDescriptor().getMethods().get(1),
  886. controller,
  887. request,
  888. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance());
  889. }
  890. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse multiply(
  891. com.google.protobuf.RpcController controller,
  892. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  893. throws com.google.protobuf.ServiceException {
  894. return (com.googlecode.protobuf.netty.example.Calculator.CalcResponse) channel.callBlockingMethod(
  895. getDescriptor().getMethods().get(2),
  896. controller,
  897. request,
  898. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance());
  899. }
  900. public com.googlecode.protobuf.netty.example.Calculator.CalcResponse divide(
  901. com.google.protobuf.RpcController controller,
  902. com.googlecode.protobuf.netty.example.Calculator.CalcRequest request)
  903. throws com.google.protobuf.ServiceException {
  904. return (com.googlecode.protobuf.netty.example.Calculator.CalcResponse) channel.callBlockingMethod(
  905. getDescriptor().getMethods().get(3),
  906. controller,
  907. request,
  908. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.getDefaultInstance());
  909. }
  910. }
  911. }
  912. private static com.google.protobuf.Descriptors.Descriptor
  913. internal_static_CalcRequest_descriptor;
  914. private static
  915. com.google.protobuf.GeneratedMessage.FieldAccessorTable
  916. internal_static_CalcRequest_fieldAccessorTable;
  917. private static com.google.protobuf.Descriptors.Descriptor
  918. internal_static_CalcResponse_descriptor;
  919. private static
  920. com.google.protobuf.GeneratedMessage.FieldAccessorTable
  921. internal_static_CalcResponse_fieldAccessorTable;
  922. public static com.google.protobuf.Descriptors.FileDescriptor
  923. getDescriptor() {
  924. return descriptor;
  925. }
  926. private static com.google.protobuf.Descriptors.FileDescriptor
  927. descriptor;
  928. static {
  929. java.lang.String[] descriptorData = {
  930. "\n\rexample.proto\"\'\n\013CalcRequest\022\013\n\003op1\030\001 " +
  931. "\002(\005\022\013\n\003op2\030\002 \002(\005\"\036\n\014CalcResponse\022\016\n\006resu" +
  932. "lt\030\001 \002(\0052\252\001\n\013CalcService\022\"\n\003Add\022\014.CalcRe" +
  933. "quest\032\r.CalcResponse\022\'\n\010Subtract\022\014.CalcR" +
  934. "equest\032\r.CalcResponse\022\'\n\010Multiply\022\014.Calc" +
  935. "Request\032\r.CalcResponse\022%\n\006Divide\022\014.CalcR" +
  936. "equest\032\r.CalcResponseB3\n%com.googlecode." +
  937. "protobuf.netty.exampleB\nCalculator"
  938. };
  939. com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
  940. new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
  941. public com.google.protobuf.ExtensionRegistry assignDescriptors(
  942. com.google.protobuf.Descriptors.FileDescriptor root) {
  943. descriptor = root;
  944. internal_static_CalcRequest_descriptor =
  945. getDescriptor().getMessageTypes().get(0);
  946. internal_static_CalcRequest_fieldAccessorTable = new
  947. com.google.protobuf.GeneratedMessage.FieldAccessorTable(
  948. internal_static_CalcRequest_descriptor,
  949. new java.lang.String[] { "Op1", "Op2", },
  950. com.googlecode.protobuf.netty.example.Calculator.CalcRequest.class,
  951. com.googlecode.protobuf.netty.example.Calculator.CalcRequest.Builder.class);
  952. internal_static_CalcResponse_descriptor =
  953. getDescriptor().getMessageTypes().get(1);
  954. internal_static_CalcResponse_fieldAccessorTable = new
  955. com.google.protobuf.GeneratedMessage.FieldAccessorTable(
  956. internal_static_CalcResponse_descriptor,
  957. new java.lang.String[] { "Result", },
  958. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.class,
  959. com.googlecode.protobuf.netty.example.Calculator.CalcResponse.Builder.class);
  960. return null;
  961. }
  962. };
  963. com.google.protobuf.Descriptors.FileDescriptor
  964. .internalBuildGeneratedFileFrom(descriptorData,
  965. new com.google.protobuf.Descriptors.FileDescriptor[] {
  966. }, assigner);
  967. }
  968. public static void internalForceInit() {}
  969. }