forked from resteasy/resteasy-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RESTEASY-1361] Copying examples to dedicated repository
- Loading branch information
Showing
1,097 changed files
with
55,237 additions
and
7 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 |
---|---|---|
@@ -1,12 +1,40 @@ | ||
*.class | ||
# Intellij | ||
################### | ||
.idea | ||
*.iml | ||
|
||
# Eclipse | ||
################### | ||
**/.settings | ||
**/.project | ||
**/.classpath | ||
**/.checkstyle | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
# Compiled source # | ||
################### | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# Package Files # | ||
# Packages # | ||
############ | ||
# it's better to unpack these files and commit the raw source | ||
# git has its own built in compression methods | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.war | ||
*.ear | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
# Logs and databases # | ||
###################### | ||
*.log | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
# examples | ||
RESTEasy examples |
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,48 @@ | ||
|
||
Client example with Flickr and Twitter | ||
====================================== | ||
This project is a simple example showing usage of @Path, @GET, PUT, POST, and @PathParam. It uses pure streaming | ||
output as well. | ||
|
||
System Requirements: | ||
-------------------- | ||
* Maven 2.0.9 or higher | ||
|
||
Building the project: | ||
-------------------- | ||
In root directoy | ||
|
||
mvn clean compile | ||
|
||
****Flickr Client: | ||
1. apply for an API key from Flickr - http://www.flickr.com/services/api/keys/apply | ||
2. mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.flickr.FlickrClient" -Dexec.args="<apiKey>" | ||
|
||
****Twitter Client | ||
From August 31, 2010, Basic Auth has been deprecated by Twitter, and all applications must now use OAuth. | ||
So the Twitter Client now uses OAuth to do the authentication. In this example you can see how to inject | ||
OAuth Authentication Header via RESTEasy Proxy Client. | ||
|
||
Be sure to run the example *in following step!*: | ||
1. request token from twitter: | ||
mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.twitter.TwitterClient" -Dexec.args=request | ||
|
||
2. authorize token by twitter: | ||
mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.twitter.TwitterClient" -Dexec.args=authorize | ||
In this step you will be provided a link for authentication. Paste it to web browser and grant access to this example. | ||
|
||
3. request access token for our example: | ||
mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.twitter.TwitterClient" -Dexec.args=access | ||
Now we can play with twitter: | ||
|
||
4. tweet: | ||
mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.twitter.TwitterClient" -Dexec.args=update | ||
|
||
5. query the status: | ||
mvn exec:java -Dexec.mainClass="org.jboss.resteasy.examples.twitter.TwitterClient" -Dexec.args=query | ||
|
||
If you meet a '401 Authorization Problem' in the last two steps, it's most probably your token has expired. | ||
Redo the first three steps may solve the problem. Have fun! | ||
|
||
|
||
|
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,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>testable-examples-pom</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.jboss.resteasy.examples</groupId> | ||
<artifactId>examples-api-clients</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
<description/> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jboss</id> | ||
<name>jboss repo</name> | ||
<url>http://repository.jboss.org/nexus/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
<!-- filter out unwanted jars --> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-httpclient</groupId> | ||
<artifactId>commons-httpclient</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxb-provider</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-httpclient</groupId> | ||
<artifactId>commons-httpclient</artifactId> | ||
<version>3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>2.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>2.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.oauth.core</groupId> | ||
<artifactId>oauth-provider</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.oauth.core</groupId> | ||
<artifactId>oauth-httpclient4</artifactId> | ||
<version>20100601</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- | ||
this distributionManagement is only here for RESTEasy automated | ||
testing of examples build. You can remove if you are copying this | ||
pom.xml as a template | ||
--> | ||
<distributionManagement> | ||
<repository> | ||
<id>jboss-releases-repository</id> | ||
<name>JBoss Releases Repository</name> | ||
<url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
40 changes: 40 additions & 0 deletions
40
api-clients/src/main/java/org/jboss/resteasy/examples/flickr/BareBonesBrowserLaunch.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,40 @@ | ||
package org.jboss.resteasy.examples.flickr; | ||
|
||
import javax.swing.*; | ||
import java.lang.reflect.Method; | ||
|
||
public class BareBonesBrowserLaunch { | ||
|
||
private static final String errMsg = "Error attempting to launch web browser"; | ||
|
||
public static void openURL(String url) { | ||
String osName = System.getProperty("os.name"); | ||
try { | ||
if (osName.startsWith("Mac OS")) { | ||
Class fileMgr = Class.forName("com.apple.eio.FileManager"); | ||
Method openURL = fileMgr.getDeclaredMethod("openURL", | ||
new Class[] { String.class }); | ||
openURL.invoke(null, new Object[] { url }); | ||
} else if (osName.startsWith("Windows")) | ||
Runtime.getRuntime().exec( | ||
"rundll32 url.dll,FileProtocolHandler " + url); | ||
else { // assume Unix or Linux | ||
String[] browsers = { "firefox", "opera", "konqueror", | ||
"epiphany", "mozilla", "netscape" }; | ||
String browser = null; | ||
for (int count = 0; count < browsers.length && browser == null; count++) | ||
if (Runtime.getRuntime().exec( | ||
new String[] { "which", browsers[count] }) | ||
.waitFor() == 0) | ||
browser = browsers[count]; | ||
if (browser == null) | ||
throw new Exception("Could not find web browser"); | ||
else | ||
Runtime.getRuntime().exec(new String[] { browser, url }); | ||
} | ||
} catch (Exception e) { | ||
JOptionPane.showMessageDialog(null, errMsg + ":\n" | ||
+ e.getLocalizedMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.