SlideShare a Scribd company logo
/**
Distributive system Assignment
*/
package birhanu
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.WebTarget;
/**
* Jersey REST client generated for REST resource:StudFacadeREST
* [birie.stud]<br>
* USAGE:
* <pre>
* NewJerseyClient client = new NewJerseyClient();
* Object response = client.XXX(...);
* // do whatever with response
* client.close();
* </pre>
*
* @author birie
*/
public class NewJerseyClient {
private WebTarget webTarget;
private Client client;
private static final String BASE_URI =
"http://localhost:8080/Stud_Registration/webresources";
public NewJerseyClient() {
client = javax.ws.rs.client.ClientBuilder.newClient();
webTarget = client.target(BASE_URI).path("gashaw.stud");
}
public String countREST() throws ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path("count");
return
resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
}
public void edit_XML(Object requestEntity, String id) throws
ClientErrorException {
webTarget.path(java.text.MessageFormat.format("{0}", new Object[]
{id})).request(javax.ws.rs.core.MediaType.APPLICATION_XML).put(javax.ws.rs.clien
t.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_XML));
}
public void edit_JSON(Object requestEntity, String id) throws
ClientErrorException {
webTarget.path(java.text.MessageFormat.format("{0}", new Object[]
{id})).request(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(javax.ws.rs.clie
nt.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_JSON));
}
public <T> T find_XML(Class<T> responseType, String id) throws
ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path(java.text.MessageFormat.format("{0}", new
Object[]{id}));
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
}
public <T> T find_JSON(Class<T> responseType, String id) throws
ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path(java.text.MessageFormat.format("{0}", new
Object[]{id}));
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
}
public <T> T findRange_XML(Class<T> responseType, String from, String to)
throws ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new
Object[]{from, to}));
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
}
public <T> T findRange_JSON(Class<T> responseType, String from, String to)
throws ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new
Object[]{from, to}));
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
}
public void create_XML(Object requestEntity) throws ClientErrorException {
webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_XML).post(javax.ws.rs.c
lient.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_XML));
}
public void create_JSON(Object requestEntity) throws ClientErrorException {
webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).post(javax.ws.rs.
client.Entity.entity(requestEntity,
javax.ws.rs.core.MediaType.APPLICATION_JSON));
}
public <T> T findAll_XML(Class<T> responseType) throws ClientErrorException
{
WebTarget resource = webTarget;
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType);
}
public <T> T findAll_JSON(Class<T> responseType) throws ClientErrorException
{
WebTarget resource = webTarget;
return
resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType);
}
public void remove(String id) throws ClientErrorException {
webTarget.path(java.text.MessageFormat.format("{0}", new Object[]
{id})).request().delete();
}
public void close() {
client.close();
}
}

More Related Content

PDF
Core Data with multiple managed object contexts
PPTX
01 session tracking
PDF
Create a Core Data Observer in 10mins
PDF
Adventures in Multithreaded Core Data
PDF
High Performance Core Data
PDF
Nuxeo - OpenSocial
PPTX
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)
PPT
Core Data with multiple managed object contexts
01 session tracking
Create a Core Data Observer in 10mins
Adventures in Multithreaded Core Data
High Performance Core Data
Nuxeo - OpenSocial
Azure Table Storage: The Good, the Bad, the Ugly (15 min. lightning talk)

What's hot (20)

PDF
#win8acad : Building Metro Style Apps with XAML for .NET Developers
PDF
Simple Web Development in Java
PPTX
[AzureCamp 24 Juin 2014] Cache Distribué par Thomas Conté
PDF
第一次用Parse就深入淺出
PDF
Building a js widget
PDF
Enterprise Guice 20090217 Bejug
PDF
Multi-threaded CoreData Done Right
PPTX
Azure Web Camp : Cache Distribué
PDF
JAX-RS 2.1 Reloaded @ Devoxx
PPTX
Simple blog wall creation on Java
PPTX
Jasig Cas High Availability - Yale University
PPTX
13 networking, mobile services, and authentication
PPTX
#3 (Multi Threads With TCP)
PPTX
Test and profile your Windows Phone 8 App
PPTX
Whirlwind tour of activiti 7
PDF
End to end todo list app with NestJs - Angular - Redux & Redux Saga
PPTX
Creating Single Page Web App using Backbone JS
PDF
the Spring 4 update
PDF
Save your data
PDF
Spring 4 - A&BP CC
#win8acad : Building Metro Style Apps with XAML for .NET Developers
Simple Web Development in Java
[AzureCamp 24 Juin 2014] Cache Distribué par Thomas Conté
第一次用Parse就深入淺出
Building a js widget
Enterprise Guice 20090217 Bejug
Multi-threaded CoreData Done Right
Azure Web Camp : Cache Distribué
JAX-RS 2.1 Reloaded @ Devoxx
Simple blog wall creation on Java
Jasig Cas High Availability - Yale University
13 networking, mobile services, and authentication
#3 (Multi Threads With TCP)
Test and profile your Windows Phone 8 App
Whirlwind tour of activiti 7
End to end todo list app with NestJs - Angular - Redux & Redux Saga
Creating Single Page Web App using Backbone JS
the Spring 4 update
Save your data
Spring 4 - A&BP CC
Ad

Similar to Birhanu distributive assignment (20)

KEY
Multi Client Development with Spring
PPSX
Azure Mobile Services .NET Backend
KEY
CDI e as ideias pro futuro do VRaptor
KEY
Integrating Wicket with Java EE 6
PDF
Gdg dev fest hybrid apps your own mini-cordova
PPTX
Servlets
PDF
Cloudcamp scotland - Using cloud without losing control
PPTX
React native by example by Vadim Ruban
PDF
Java Configuration Deep Dive with Spring
PDF
From 0 to Spring Security 4.0
PDF
Architecting your GWT applications with GWT-Platform - Lesson 02
PDF
Speed up your Web applications with HTML5 WebSockets
PDF
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
PDF
Lecture6
PPTX
Academy PRO: ASP .NET Core
PDF
Dropwizard
PDF
Symfony2 from the Trenches
PDF
PDF
May 2010 - RestEasy
ODP
Codemotion appengine
Multi Client Development with Spring
Azure Mobile Services .NET Backend
CDI e as ideias pro futuro do VRaptor
Integrating Wicket with Java EE 6
Gdg dev fest hybrid apps your own mini-cordova
Servlets
Cloudcamp scotland - Using cloud without losing control
React native by example by Vadim Ruban
Java Configuration Deep Dive with Spring
From 0 to Spring Security 4.0
Architecting your GWT applications with GWT-Platform - Lesson 02
Speed up your Web applications with HTML5 WebSockets
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
Lecture6
Academy PRO: ASP .NET Core
Dropwizard
Symfony2 from the Trenches
May 2010 - RestEasy
Codemotion appengine
Ad

Recently uploaded (20)

PDF
BRANDBOOK-Presidential Award Scheme-Kenya-2023
PPTX
areprosthodontics and orthodonticsa text.pptx
PDF
Emailing DDDX-MBCaEiB.pdf DDD_Europe_2022_Intro_to_Context_Mapping_pdf-165590...
PDF
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
PDF
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
PDF
Quality Control Management for RMG, Level- 4, Certificate
PPTX
Special finishes, classification and types, explanation
PPTX
mahatma gandhi bus terminal in india Case Study.pptx
PDF
Africa 2025 - Prospects and Challenges first edition.pdf
PPT
UNIT I- Yarn, types, explanation, process
PDF
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
PDF
Interior Structure and Construction A1 NGYANQI
PDF
Urban Design Final Project-Context
PPT
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
PPTX
AD Bungalow Case studies Sem 2.pptxvwewev
PDF
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
DOCX
actividad 20% informatica microsoft project
PPTX
An introduction to AI in research and reference management
PPTX
Fundamental Principles of Visual Graphic Design.pptx
BRANDBOOK-Presidential Award Scheme-Kenya-2023
areprosthodontics and orthodonticsa text.pptx
Emailing DDDX-MBCaEiB.pdf DDD_Europe_2022_Intro_to_Context_Mapping_pdf-165590...
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
Quality Control Management for RMG, Level- 4, Certificate
Special finishes, classification and types, explanation
mahatma gandhi bus terminal in india Case Study.pptx
Africa 2025 - Prospects and Challenges first edition.pdf
UNIT I- Yarn, types, explanation, process
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
Interior Structure and Construction A1 NGYANQI
Urban Design Final Project-Context
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
AD Bungalow Case studies Sem 2.pptxvwewev
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
actividad 20% informatica microsoft project
An introduction to AI in research and reference management
Fundamental Principles of Visual Graphic Design.pptx

Birhanu distributive assignment

  • 1. /** Distributive system Assignment */ package birhanu import javax.ws.rs.ClientErrorException; import javax.ws.rs.client.Client; import javax.ws.rs.client.WebTarget; /** * Jersey REST client generated for REST resource:StudFacadeREST * [birie.stud]<br> * USAGE: * <pre> * NewJerseyClient client = new NewJerseyClient(); * Object response = client.XXX(...); * // do whatever with response * client.close(); * </pre> * * @author birie */ public class NewJerseyClient { private WebTarget webTarget; private Client client; private static final String BASE_URI = "http://localhost:8080/Stud_Registration/webresources"; public NewJerseyClient() { client = javax.ws.rs.client.ClientBuilder.newClient(); webTarget = client.target(BASE_URI).path("gashaw.stud"); } public String countREST() throws ClientErrorException { WebTarget resource = webTarget; resource = resource.path("count"); return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class); } public void edit_XML(Object requestEntity, String id) throws ClientErrorException { webTarget.path(java.text.MessageFormat.format("{0}", new Object[] {id})).request(javax.ws.rs.core.MediaType.APPLICATION_XML).put(javax.ws.rs.clien t.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_XML)); } public void edit_JSON(Object requestEntity, String id) throws ClientErrorException { webTarget.path(java.text.MessageFormat.format("{0}", new Object[] {id})).request(javax.ws.rs.core.MediaType.APPLICATION_JSON).put(javax.ws.rs.clie nt.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_JSON)); } public <T> T find_XML(Class<T> responseType, String id) throws ClientErrorException { WebTarget resource = webTarget; resource = resource.path(java.text.MessageFormat.format("{0}", new Object[]{id})); return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType); }
  • 2. public <T> T find_JSON(Class<T> responseType, String id) throws ClientErrorException { WebTarget resource = webTarget; resource = resource.path(java.text.MessageFormat.format("{0}", new Object[]{id})); return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType); } public <T> T findRange_XML(Class<T> responseType, String from, String to) throws ClientErrorException { WebTarget resource = webTarget; resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new Object[]{from, to})); return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType); } public <T> T findRange_JSON(Class<T> responseType, String from, String to) throws ClientErrorException { WebTarget resource = webTarget; resource = resource.path(java.text.MessageFormat.format("{0}/{1}", new Object[]{from, to})); return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType); } public void create_XML(Object requestEntity) throws ClientErrorException { webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_XML).post(javax.ws.rs.c lient.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_XML)); } public void create_JSON(Object requestEntity) throws ClientErrorException { webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).post(javax.ws.rs. client.Entity.entity(requestEntity, javax.ws.rs.core.MediaType.APPLICATION_JSON)); } public <T> T findAll_XML(Class<T> responseType) throws ClientErrorException { WebTarget resource = webTarget; return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(responseType); } public <T> T findAll_JSON(Class<T> responseType) throws ClientErrorException { WebTarget resource = webTarget; return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(responseType); } public void remove(String id) throws ClientErrorException { webTarget.path(java.text.MessageFormat.format("{0}", new Object[] {id})).request().delete(); } public void close() { client.close(); } }