├── .gitignore
├── CREDITS
├── LICENSE
├── README.md
├── hcp-cf-mongodb-tutorial
├── manifest.yml
├── pom.xml
├── readme.md
└── src
│ └── main
│ └── java
│ └── com
│ └── sap
│ └── hcp
│ └── cf
│ └── tutorials
│ └── mongodb
│ ├── HCPWebApplication.java
│ ├── RootController.java
│ └── model
│ ├── DBObject.java
│ └── Result.java
├── hcp-cf-postgres-tutorial
├── manifest.yml
├── pom.xml
├── readme.md
└── src
│ └── main
│ └── java
│ └── com
│ └── sap
│ └── hcp
│ └── cf
│ └── tutorials
│ └── postgres
│ ├── HCPWebApplication.java
│ ├── RootController.java
│ └── model
│ ├── Contact.java
│ └── Result.java
├── hcp-cf-rabbitmq-tutorial
├── manifest.yml
├── pom.xml
├── readme.md
└── src
│ └── main
│ └── java
│ └── com
│ └── sap
│ └── hcp
│ └── cf
│ └── tutorials
│ └── rabbitmq
│ ├── HCPWebApplication.java
│ ├── RootController.java
│ └── model
│ ├── RabbitMessage.java
│ └── Result.java
└── hcp-cf-redis-tutorial
├── manifest.yml
├── pom.xml
├── readme.md
└── src
└── main
└── java
└── com
└── sap
└── hcp
└── cf
└── tutorials
└── redis
├── HCPWebApplication.java
├── RootController.java
└── model
├── RedisObject.java
└── Result.java
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | target/
3 | .settings/
4 | pom.xml.tag
5 | pom.xml.releaseBackup
6 | pom.xml.versionsBackup
7 | pom.xml.next
8 | release.properties
9 | dependency-reduced-pom.xml
10 | buildNumber.properties
11 | .mvn/timing.properties
12 | bin/
13 | .classpath
14 | .project
15 |
--------------------------------------------------------------------------------
/CREDITS:
--------------------------------------------------------------------------------
1 |
2 | This program references the following third party open source or other free download components.
3 | The third party licensors of these components may provide additional license rights,
4 | terms and conditions and/or require certain notices as described below.
5 |
6 | Springframework
7 | Licensed under Apache Software License v2.0 - https://github.com/spring-projects/spring-framework
8 |
9 | Spring-boot
10 | Licensed under Apache Software License v2.0 - https://github.com/spring-projects/spring-boot
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Important Notice
4 | This public repository is read-only and no longer maintained.
5 |
6 | # hcp-cloud-foundry-tutorials
7 | This repository consists of tutorials for SAP HANA Cloud Platform which show how the available backing services of Cloud Foundry can be used. For detailed documentation, have a look [here](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/8105b26e430a4aea9dc46a7aa6f8d011.html).
8 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hcp-cf-mongodb-tutorial
4 | memory: 512M
5 | host: hcp-cf-mongodb-tutorial
6 | path: target/hcp-cf-mongodb-tutorial-1.0-SNAPSHOT.jar
7 | services:
8 | - mongo-service
9 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | hcp-cf-mongodb-tutorial
6 | hcp-cf-mongodb-tutorial
7 | 1.0-SNAPSHOT
8 |
9 | org.springframework.boot
10 | spring-boot-starter-parent
11 | 1.3.3.RELEASE
12 |
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-data-rest
18 |
19 |
20 | org.springframework.data
21 | spring-data-mongodb
22 |
23 |
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-maven-plugin
29 |
30 |
31 |
32 |
33 |
34 | spring-milestones
35 | Spring Milestones
36 | http://repo.spring.io/milestone
37 |
38 | false
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/readme.md:
--------------------------------------------------------------------------------
1 | # hcp-cf-mongodb-tutorial
2 | This project in the repository consists of a tutorial for the MongoDB service of SAP HANA Cloud Platform. For detailed documentation, have a look [here](https://uacp2.hana.ondemand.com/viewer/#/hcp_cf/65ede018945e47e79edaa7aff3dd3c4d.html).
3 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/src/main/java/com/sap/hcp/cf/tutorials/mongodb/HCPWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.mongodb;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.boot.context.web.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class HCPWebApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | new SpringApplicationBuilder(HCPWebApplication.class).run(args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/src/main/java/com/sap/hcp/cf/tutorials/mongodb/RootController.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.mongodb;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.data.mongodb.core.MongoTemplate;
10 | import org.springframework.stereotype.Controller;
11 | import org.springframework.web.bind.annotation.RequestMapping;
12 | import org.springframework.web.bind.annotation.RequestMethod;
13 | import org.springframework.web.bind.annotation.ResponseBody;
14 |
15 | import com.mongodb.BasicDBObject;
16 | import com.mongodb.DBCollection;
17 | import com.mongodb.DBCursor;
18 | import com.sap.hcp.cf.tutorials.mongodb.model.DBObject;
19 | import com.sap.hcp.cf.tutorials.mongodb.model.Result;
20 |
21 | @Controller
22 | @RequestMapping("/")
23 | public class RootController {
24 |
25 | private static final Logger log = LoggerFactory.getLogger(RootController.class);
26 |
27 | @Autowired
28 | MongoTemplate mongoTemplate;
29 |
30 | @RequestMapping(method = RequestMethod.GET)
31 | public @ResponseBody Result onRootAccess() {
32 |
33 | DBCollection collection = mongoTemplate.getCollection("test");
34 | long count = collection.getCount();
35 | log.info("Object count in 'test' collection before insert: " + count + "
Inserting one object.
");
36 |
37 | BasicDBObject dBObject = new BasicDBObject();
38 | dBObject.put("hello", "world");
39 | collection.insert(dBObject);
40 | count = collection.count();
41 | log.info("Object count in test collection after insert:" + count);
42 |
43 | Result result = new Result();
44 | List dbObjects = new ArrayList();
45 | DBCursor cursor = collection.find();
46 | while (cursor.hasNext()) {
47 | com.mongodb.DBObject obj = cursor.next();
48 | final String value = (String) obj.get("hello");
49 | DBObject object = new DBObject();
50 | object.setKey("hello");
51 | object.setValue(value);
52 | dbObjects.add(object);
53 | }
54 | result.setDbObjects(dbObjects);
55 | result.setStatus(
56 | "Successfully accessed Mongodb service. Retrieving the data object inserted in test collection.");
57 | collection.drop();
58 | return result;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/src/main/java/com/sap/hcp/cf/tutorials/mongodb/model/DBObject.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.mongodb.model;
2 |
3 | public class DBObject {
4 |
5 | private String key;
6 | private String value;
7 |
8 | public String getKey() {
9 | return key;
10 | }
11 |
12 | public void setKey(String key) {
13 | this.key = key;
14 | }
15 |
16 | public String getValue() {
17 | return value;
18 | }
19 |
20 | public void setValue(String value) {
21 | this.value = value;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/hcp-cf-mongodb-tutorial/src/main/java/com/sap/hcp/cf/tutorials/mongodb/model/Result.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.mongodb.model;
2 |
3 | import java.util.List;
4 |
5 | public class Result {
6 |
7 | private String status;
8 |
9 | private List dbObjects;
10 |
11 | public String getStatus() {
12 | return status;
13 | }
14 |
15 | public void setStatus(String status) {
16 | this.status = status;
17 | }
18 |
19 | public List getDbObjects() {
20 | return dbObjects;
21 | }
22 |
23 | public void setDbObjects(List dbObjects) {
24 | this.dbObjects = dbObjects;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hcp-cf-postgres-tutorial
4 | memory: 512M
5 | host: hcp-cf-postgres-tutorial
6 | path: target/hcp-cf-postgres-tutorial-1.0-SNAPSHOT.jar
7 | services:
8 | - postgres-service
9 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | hcp-cf-postgres-tutorial
6 | hcp-cf-postgres-tutorial
7 | 1.0-SNAPSHOT
8 |
9 | org.springframework.boot
10 | spring-boot-starter-parent
11 | 1.3.3.RELEASE
12 |
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-data-jpa
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-data-rest
22 |
23 |
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-maven-plugin
29 |
30 |
31 |
32 |
33 |
34 | spring-milestones
35 | Spring Milestones
36 | http://repo.spring.io/milestone
37 |
38 | false
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/readme.md:
--------------------------------------------------------------------------------
1 | # hcp-cf-postgres-tutorial
2 | This project in the repository consists of a tutorial for the PostgreSQL service of SAP HANA Cloud Platform. For detailed documentation, have a look [here](https://uacp2.hana.ondemand.com/viewer/#/hcp_cf/65ede018945e47e79edaa7aff3dd3c4d.html).
3 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/src/main/java/com/sap/hcp/cf/tutorials/postgres/HCPWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.postgres;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.boot.context.web.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class HCPWebApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | new SpringApplicationBuilder(HCPWebApplication.class).run(args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/src/main/java/com/sap/hcp/cf/tutorials/postgres/RootController.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.postgres;
2 |
3 | import java.util.List;
4 |
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
9 | import org.springframework.jdbc.core.JdbcTemplate;
10 | import org.springframework.stereotype.Controller;
11 | import org.springframework.web.bind.annotation.RequestMapping;
12 | import org.springframework.web.bind.annotation.RequestMethod;
13 | import org.springframework.web.bind.annotation.ResponseBody;
14 |
15 | import com.sap.hcp.cf.tutorials.postgres.model.Contact;
16 | import com.sap.hcp.cf.tutorials.postgres.model.Result;
17 |
18 | @Controller
19 | @RequestMapping("/")
20 | public class RootController {
21 | private static final Logger log = LoggerFactory.getLogger(RootController.class);
22 |
23 | @Autowired
24 | JdbcTemplate jdbcTemplate;
25 |
26 | @RequestMapping(method = RequestMethod.GET)
27 | public @ResponseBody Result onRootAccess() {
28 | log.info("Creating table");
29 |
30 | jdbcTemplate.execute("DROP TABLE IF EXISTS contacts");
31 | jdbcTemplate.execute("CREATE TABLE contacts(" + "id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");
32 |
33 | log.info("Inserting data in table");
34 | jdbcTemplate.update("INSERT INTO contacts(first_name, last_name) VALUES ('John','Wright')");
35 |
36 | log.info("Retrieving data from table");
37 | final List contacts = jdbcTemplate.query("SELECT id, first_name, last_name FROM contacts",
38 | new BeanPropertyRowMapper(Contact.class));
39 |
40 | Result result = new Result();
41 | result.setStatus("Successfully connected to PostgreSQL. Retrieved data from contacts table");
42 | result.setContacts(contacts);
43 | return result;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/src/main/java/com/sap/hcp/cf/tutorials/postgres/model/Contact.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.postgres.model;
2 |
3 | public class Contact {
4 |
5 | private int id;
6 | private String firstName;
7 | private String lastName;
8 | public int getId() {
9 | return id;
10 | }
11 | public void setId(int id) {
12 | this.id = id;
13 | }
14 | public String getFirstName() {
15 | return firstName;
16 | }
17 | public void setFirstName(String firstName) {
18 | this.firstName = firstName;
19 | }
20 | public String getLastName() {
21 | return lastName;
22 | }
23 | public void setLastName(String lastName) {
24 | this.lastName = lastName;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hcp-cf-postgres-tutorial/src/main/java/com/sap/hcp/cf/tutorials/postgres/model/Result.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.postgres.model;
2 |
3 | import java.util.List;
4 |
5 | public class Result {
6 |
7 | private List contacts;
8 |
9 | private String status;
10 |
11 | public String getStatus() {
12 | return status;
13 | }
14 |
15 | public void setStatus(String status) {
16 | this.status = status;
17 | }
18 |
19 | public List getContacts() {
20 | return contacts;
21 | }
22 |
23 | public void setContacts(List contacts) {
24 | this.contacts = contacts;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hcp-cf-rabbitmq-tutorial
4 | memory: 512M
5 | host: hcp-cf-rabbitmq-tutorial
6 | path: target/hcp-cf-rabbitmq-tutorial-1.0-SNAPSHOT.jar
7 | services:
8 | - rabbitmq-service
9 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | hcp-cf-rabbitmq-tutorial
6 | hcp-cf-rabbitmq-tutorial
7 | 1.0-SNAPSHOT
8 |
9 | org.springframework.boot
10 | spring-boot-starter-parent
11 | 1.3.3.RELEASE
12 |
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-data-rest
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-amqp
22 |
23 |
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-maven-plugin
29 |
30 |
31 |
32 |
33 |
34 | spring-milestones
35 | Spring Milestones
36 | http://repo.spring.io/milestone
37 |
38 | false
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/readme.md:
--------------------------------------------------------------------------------
1 | # hcp-cf-rabbitmq-tutorial
2 | This project in the repository consists of a tutorial for the RabbitMQ service of SAP HANA Cloud Platform. For detailed documentation, have a look [here](https://uacp2.hana.ondemand.com/viewer/#/hcp_cf/65ede018945e47e79edaa7aff3dd3c4d.html).
3 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/src/main/java/com/sap/hcp/cf/tutorials/rabbitmq/HCPWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.rabbitmq;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.boot.context.web.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class HCPWebApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | new SpringApplicationBuilder(HCPWebApplication.class).run(args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/src/main/java/com/sap/hcp/cf/tutorials/rabbitmq/RootController.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.rabbitmq;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 | import org.springframework.amqp.core.Queue;
9 | import org.springframework.amqp.rabbit.core.RabbitTemplate;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.context.annotation.Bean;
12 | import org.springframework.stereotype.Controller;
13 | import org.springframework.web.bind.annotation.RequestMapping;
14 | import org.springframework.web.bind.annotation.RequestMethod;
15 | import org.springframework.web.bind.annotation.ResponseBody;
16 |
17 | import com.sap.hcp.cf.tutorials.rabbitmq.model.RabbitMessage;
18 | import com.sap.hcp.cf.tutorials.rabbitmq.model.Result;
19 |
20 | @Controller
21 | @RequestMapping("/")
22 | public class RootController {
23 | private static final Logger log = LoggerFactory.getLogger(RootController.class);
24 |
25 | @Autowired
26 | private RabbitTemplate template;
27 |
28 | private static final String QUEUE_NAME = "amqp-test";
29 | private static final String MESSAGE = "rabbitmq-test";
30 |
31 | @Bean
32 | Queue queue() {
33 | return new Queue(QUEUE_NAME, false);
34 | }
35 |
36 | @RequestMapping(method = RequestMethod.GET)
37 | public @ResponseBody Result onRootAccess() {
38 |
39 | RabbitMessage rabbitMessage = new RabbitMessage();
40 |
41 | log.info("Sending message: " + MESSAGE);
42 | template.convertAndSend(QUEUE_NAME, MESSAGE);
43 | rabbitMessage.setProducedMessage(MESSAGE);
44 |
45 | log.info("Receiving message: ");
46 | String msg = (String) template.receiveAndConvert(QUEUE_NAME);
47 | rabbitMessage.setConsumedMessage(msg);
48 |
49 | Result result = new Result();
50 | result.setStatus("Successfully connected to rabbit and produced a message and consumed the same message");
51 | List rabbitMessages = new ArrayList();
52 | rabbitMessages.add(rabbitMessage);
53 | result.setRabbitMessages(rabbitMessages);
54 |
55 | return result;
56 | }
57 | }
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/src/main/java/com/sap/hcp/cf/tutorials/rabbitmq/model/RabbitMessage.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.rabbitmq.model;
2 |
3 | public class RabbitMessage {
4 |
5 | private String producedMessage;
6 | private String consumedMessage;
7 |
8 | public String getProducedMessage() {
9 | return producedMessage;
10 | }
11 | public void setProducedMessage(String producedMessage) {
12 | this.producedMessage = producedMessage;
13 | }
14 | public String getConsumedMessage() {
15 | return consumedMessage;
16 | }
17 | public void setConsumedMessage(String consumedMessage) {
18 | this.consumedMessage = consumedMessage;
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/hcp-cf-rabbitmq-tutorial/src/main/java/com/sap/hcp/cf/tutorials/rabbitmq/model/Result.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.rabbitmq.model;
2 |
3 | import java.util.List;
4 |
5 | public class Result {
6 |
7 | private String status;
8 |
9 | private List rabbitMessages;
10 |
11 | public String getStatus() {
12 | return status;
13 | }
14 |
15 | public void setStatus(String status) {
16 | this.status = status;
17 | }
18 |
19 | public List getRabbitMessages() {
20 | return rabbitMessages;
21 | }
22 |
23 | public void setRabbitMessages(List rabbitMessages) {
24 | this.rabbitMessages = rabbitMessages;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | applications:
3 | - name: hcp-cf-redis-tutorial
4 | memory: 512M
5 | host: hcp-cf-redis-tutorial
6 | path: target/hcp-cf-redis-tutorial-1.0-SNAPSHOT.jar
7 | services:
8 | - redis-service
9 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | hcp-cf-redis-tutorial
6 | hcp-cf-redis-tutorial
7 | 1.0-SNAPSHOT
8 |
9 | org.springframework.boot
10 | spring-boot-starter-parent
11 | 1.3.3.RELEASE
12 |
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-data-rest
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-starter-redis
22 |
23 |
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-maven-plugin
29 |
30 |
31 |
32 |
33 |
34 | spring-milestones
35 | Spring Milestones
36 | http://repo.spring.io/milestone
37 |
38 | false
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/readme.md:
--------------------------------------------------------------------------------
1 | # hcp-cf-redis-tutorial
2 | This project in the repository consists of a tutorial for the Redis service of SAP HANA Cloud Platform. For detailed documentation, have a look [here](https://uacp2.hana.ondemand.com/viewer/#/hcp_cf/65ede018945e47e79edaa7aff3dd3c4d.html).
3 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/src/main/java/com/sap/hcp/cf/tutorials/redis/HCPWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.redis;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.boot.context.web.SpringBootServletInitializer;
6 |
7 | @SpringBootApplication
8 | public class HCPWebApplication extends SpringBootServletInitializer {
9 |
10 | public static void main(String[] args) {
11 | new SpringApplicationBuilder(HCPWebApplication.class).run(args);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/src/main/java/com/sap/hcp/cf/tutorials/redis/RootController.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.redis;
2 |
3 | import java.util.ArrayList;
4 |
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.data.redis.connection.RedisConnection;
9 | import org.springframework.data.redis.connection.RedisConnectionFactory;
10 | import org.springframework.stereotype.Controller;
11 | import org.springframework.web.bind.annotation.RequestMapping;
12 | import org.springframework.web.bind.annotation.RequestMethod;
13 | import org.springframework.web.bind.annotation.ResponseBody;
14 |
15 | import com.sap.hcp.cf.tutorials.redis.model.RedisObject;
16 | import com.sap.hcp.cf.tutorials.redis.model.Result;
17 |
18 | @Controller
19 | @RequestMapping("/")
20 | public class RootController {
21 |
22 | private static final Logger log = LoggerFactory.getLogger(RootController.class);
23 |
24 | @Autowired
25 | RedisConnectionFactory redisConnectionFactory;
26 |
27 | @RequestMapping(method = RequestMethod.GET)
28 | public @ResponseBody Result onRootAccess() {
29 |
30 | RedisConnection redisConnection = redisConnectionFactory.getConnection();
31 | log.info("Setting key/value pair 'hello'/'world'");
32 | redisConnection.set("hello".getBytes(), "world".getBytes());
33 |
34 | log.info("Retrieving value for key 'hello': ");
35 | final String value = new String(redisConnection.get("hello".getBytes()));
36 | Result result = new Result();
37 | result.setStatus("Succesfully connected to Redis and retrieved the key/value pair that was inserted");
38 | RedisObject redisObject = new RedisObject();
39 | redisObject.setKey("hello");
40 | redisObject.setValue(value);
41 | final ArrayList redisObjects = new ArrayList();
42 | redisObjects.add(redisObject);
43 | result.setRedisObjects(redisObjects);
44 | return result;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/src/main/java/com/sap/hcp/cf/tutorials/redis/model/RedisObject.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.redis.model;
2 |
3 | public class RedisObject {
4 |
5 | private String key;
6 | private String value;
7 |
8 | public String getKey() {
9 | return key;
10 | }
11 |
12 | public void setKey(String key) {
13 | this.key = key;
14 | }
15 |
16 | public String getValue() {
17 | return value;
18 | }
19 |
20 | public void setValue(String value) {
21 | this.value = value;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/hcp-cf-redis-tutorial/src/main/java/com/sap/hcp/cf/tutorials/redis/model/Result.java:
--------------------------------------------------------------------------------
1 | package com.sap.hcp.cf.tutorials.redis.model;
2 |
3 | import java.util.List;
4 |
5 | public class Result {
6 |
7 | private String status;
8 |
9 | private List redisObjects;
10 |
11 | public String getStatus() {
12 | return status;
13 | }
14 |
15 | public void setStatus(String status) {
16 | this.status = status;
17 | }
18 |
19 | public List getRedisObjects() {
20 | return redisObjects;
21 | }
22 |
23 | public void setRedisObjects(List redisObjects) {
24 | this.redisObjects = redisObjects;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------