Création des Logiciels de gestion d'Entreprise, Création et référencement des sites web, Réseaux et Maintenance, Conception
Création des Logiciels de gestion d'Entreprise, Création et référencement des sites web, Réseaux et Maintenance, Conception
Try-with-resources, which helps avoid memory leaks and related bugs by automatically closing resources that are used in a try-catch statement.
public static void invokeExample() {
String s;
MethodType mt;
MethodHandle mh;
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodType mt = MethodType.methodType(String.class, char.class,
char.class);
MethodHandle mh = lookup.findVirtual(String.class, "replace", mt);
s = (String) mh.invokeExact("App Engine Java 6 runtime",'6','7');
System.out.println(s);
}
Flexible Type Creation when using generics, enabling you to create parameterized types more succinctly. For example, you can write:
public static void viewTable(Connection con, String query) throws SQLException {
try (
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query)
) {
while (rs.next()) {
// process results
//
}
} catch (SQLException e) {
// con resource is auto-closed, no need to do anything here!
//
}
}
instead of:
Map<String, List<String>> myMap = new HashMap<>();
Map<String, List<String>> myMap = new HashMap<String, List<String>>();In addition to the language features listed above, the App Engine Java 7 runtime also includes:
Then, expose it over a standard REST interface with a simple attribute and a versioning pattern.
public class SuperHeroes {
public ListlistSuperHeroes() {
Listlist = new ArrayList ();
list.add(new SuperHero ("Champion of the Obvious", "Brad Abrams"));
list.add(new SuperHero ("Mr. Justice", "Chris Ramsdale"));
return list;
}
}
Now you have a simple REST interface.
@Api(name = "superheroes", version = "v1")
public class SuperHeroesV1 {
...
}
And you can make strongly typed calls from your Android clients:
$ curl http://localhost:8888/_ah/api/superheroes/v1/superheroes
{
"items": [
{
"knownAs" : "Champion of the Obvious",
"realName" : "Brad Abrams"
},
{
"knownAs" : "Mr. Justice",
"realName" : "Chris Ramsdale"
}
Or Objective-C iOS client:
Real result = superheroes.list().execute();
Or the web client in JavaScript:
GTLQuerySuperHeroesV1 *query = [GTLQuerySuperHeroesV1 queryForSuperHeroesList];
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLSuperHeroes *object, NSError *error) {
NSArray *items = [object items];
}];
// ...Read the documentation for Java or Python to discover how you can build a simple tic-tac-toe game using Cloud Endpoints.
var ROOT = 'https://' + window.location.host + '/_ah/api';
gapi.client.load('superheroes', 'v1',
loadSuperheroesCallback, ROOT);
// Get the list of superheroes
gapi.client.superheroes.superheroes.list().execute(function(resp) {
displaySuperheroesList(resp);
});