-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.glassfish.javaeetutorial</groupId> | ||
<artifactId>osgi</artifactId> | ||
<version>7.0.6-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>catalog-rest-endpoint</artifactId> | ||
<name>Simple REST endpoint</name> | ||
<packaging>bundle</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.glassfish.javaeetutorial</groupId> | ||
<artifactId>catalog-service</artifactId> | ||
<version>7.0.6-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>jsr311-api</artifactId> | ||
<version>1.1.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>2.5.3</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>bundle</goal> | ||
</goals> | ||
<configuration> | ||
<instructions> | ||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> | ||
<Bundle-Version>${project.version}</Bundle-Version> | ||
<Export-Package>com.forest.osgi.rest*</Export-Package> | ||
<Import-Package>*</Import-Package> | ||
<_dsannotations>*</_dsannotations> | ||
</instructions> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
44 changes: 44 additions & 0 deletions
44
osgi/catalog-rest-endpoint/src/main/java/com/forest/osgi/rest/ProductResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.forest.osgi.rest; | ||
|
||
import java.util.List; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
import com.forest.model.Product; | ||
import com.forest.usecase.catalog.ProductManager; | ||
|
||
@Path("product") | ||
@Component(immediate = true, service = Object.class) | ||
public class ProductResource { | ||
|
||
private ProductManager productManager; | ||
|
||
@Reference | ||
protected void bindProductManager(ProductManager productManager) { | ||
this.productManager = productManager; | ||
} | ||
|
||
protected void unbindProductManager(ProductManager productManager) { | ||
this.productManager = null; | ||
} | ||
|
||
@GET | ||
@Produces("application/json") | ||
public List<Product> getAll () { | ||
return productManager.getAll(); | ||
} | ||
|
||
@GET | ||
@Produces("application/json") | ||
@Path("{id}") | ||
public Product get (@PathParam ("id") int id) { | ||
return productManager.getProduct(id); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters