Skip to content

Commit 3082e21

Browse files
committed
WSO2 MSF4J HelloWorld
1 parent 572b854 commit 3082e21

7 files changed

Lines changed: 219 additions & 0 deletions

File tree

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
1+
# Compiled class file
12
*.class
23

4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
310
# Mobile Tools for Java (J2ME)
411
.mtj.tmp/
512

613
# Package Files #
714
*.jar
815
*.war
916
*.ear
17+
*.zip
18+
*.tar.gz
19+
*.rar
1020

1121
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1222
hs_err_pid*
23+
24+
# Eclipse
25+
.classpath
26+
.project
27+
.settings/
28+
29+
# Intellij
30+
.idea/
31+
*.iml
32+
*.iws
33+
34+
# Maven
35+
log/
36+
target/
37+
.cache-tests
38+
.cache-main
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>msf4j-service</artifactId>
5+
<groupId>org.wso2.msf4j</groupId>
6+
<version>2.0.0</version>
7+
<relativePath>../pom.xml/pom.xml</relativePath>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
<groupId>com.javahelps</groupId>
11+
<artifactId>Hello-Service</artifactId>
12+
<name>WSO2 MSF4J Microservice</name>
13+
<version>0.1-SNAPSHOT</version>
14+
<properties>
15+
<microservice.mainClass>com.javahelps.service.Application</microservice.mainClass>
16+
</properties>
17+
</project>
18+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2016, WSO2 Inc. (http://wso2.com) All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
22+
<parent>
23+
<groupId>org.wso2.msf4j</groupId>
24+
<artifactId>msf4j-service</artifactId>
25+
<version>2.0.0</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<groupId>com.javahelps</groupId>
30+
<artifactId>Hello-Service</artifactId>
31+
<version>0.1-SNAPSHOT</version>
32+
<name>WSO2 MSF4J Microservice</name>
33+
34+
35+
<dependencies>
36+
<!-- Uncomment the following if you want to enable metrics & monitoring -->
37+
<!--
38+
<dependency>
39+
<groupId>org.wso2.msf4j</groupId>
40+
<artifactId>msf4j-analytics</artifactId>
41+
</dependency>
42+
-->
43+
</dependencies>
44+
45+
<properties>
46+
<microservice.mainClass>com.javahelps.service.Application</microservice.mainClass>
47+
</properties>
48+
49+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2016, WSO2 Inc. (http://wso2.com) All Rights Reserved.
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.javahelps.service;
18+
19+
import org.wso2.msf4j.MicroservicesRunner;
20+
21+
/**
22+
* Application entry point.
23+
*
24+
* @since 0.1-SNAPSHOT
25+
*/
26+
public class Application {
27+
public static void main(String[] args) {
28+
new MicroservicesRunner()
29+
.deploy(new HelloService())
30+
.start();
31+
}
32+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2016, WSO2 Inc. (http://wso2.com) All Rights Reserved.
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.javahelps.service;
18+
19+
import javax.ws.rs.Consumes;
20+
import javax.ws.rs.DELETE;
21+
import javax.ws.rs.GET;
22+
import javax.ws.rs.POST;
23+
import javax.ws.rs.PUT;
24+
import javax.ws.rs.Path;
25+
import javax.ws.rs.Produces;
26+
import javax.ws.rs.core.MediaType;
27+
28+
/**
29+
* This is the Microservice resource class. See <a href=
30+
* "https://github.com/wso2/msf4j#getting-started">https://github.com/wso2/msf4j#getting-started</a>
31+
* for the usage of annotations.
32+
*
33+
* @since 0.1-SNAPSHOT
34+
*/
35+
@Path("/service")
36+
public class HelloService {
37+
38+
@GET
39+
@Path("/")
40+
public String get() {
41+
// TODO: Implementation for HTTP GET request
42+
System.out.println("GET invoked");
43+
return "Hello from WSO2 MSF4J";
44+
}
45+
46+
@POST
47+
@Path("/")
48+
@Consumes(MediaType.APPLICATION_JSON)
49+
@Produces(MediaType.APPLICATION_JSON)
50+
public Student post(Student student) {
51+
52+
student.setName(student.getName().toUpperCase());
53+
return student;
54+
}
55+
56+
@PUT
57+
@Path("/")
58+
public void put() {
59+
// TODO: Implementation for HTTP PUT request
60+
System.out.println("PUT invoked");
61+
}
62+
63+
@DELETE
64+
@Path("/")
65+
public void delete() {
66+
// TODO: Implementation for HTTP DELETE request
67+
System.out.println("DELETE invoked");
68+
}
69+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.javahelps.service;
2+
3+
public class Student {
4+
5+
private String name;
6+
private int age;
7+
8+
public String getName() {
9+
return name;
10+
}
11+
12+
public void setName(String name) {
13+
this.name = name;
14+
}
15+
16+
public int getAge() {
17+
return age;
18+
}
19+
20+
public void setAge(int age) {
21+
this.age = age;
22+
}
23+
24+
}

0 commit comments

Comments
 (0)