Cloud World

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 21 February 2013

Java 7 and Cloud Endpoints Preview

Posted on 10:16 by Unknown


Today we are announcing two new preview features: Google App Engine Java 7 runtime support and Google Cloud Endpoints. Preview features are ‘experimental’ features on a path towards general availability.




Java 7 Runtime Support for App Engine




The App Engine Java 7 runtime allows App Engine developers to keep pace with innovations in the Java language and runtime. It is important that you begin testing your applications with the new Java 7 runtime before the complete rollout in a few months.



Some of the language features you now have access to include:



invokedynamic support, which allows developers, tools providers, and language implementations to take advantage of a new bytecode, invokedynamic, to handle method invocations efficiently even when there is no static type information. For example:





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);
}




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 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!
     
//
  }
}




Flexible Type Creation when using generics, enabling you to create parameterized types more succinctly. For example, you can write:





Map> myMap = new HashMap<>();



instead of:



Map> myMap = new HashMap>();



In addition to the language features listed above, the App Engine Java 7 runtime also includes:


  • Use of String class in Switch statements.


  • Expression of binary literals using simple prefixes 0b or 0B.


  • Single catch blocks that can handle multiple exceptions.


  • Simplified varargs method invocation.



Want to get started now? Download the latest App Engine Java SDK and then check out the docs here.





Cloud Endpoints Preview




Have you ever wanted a simple way to get a cloud backend for that Android or iPhone app you are working on? Wish it was easier to expose RESTful APIs from your web application? Google Cloud Endpoints simplifies building highly scalable and flexible backends for your web and mobile applications. Use Cloud Endpoints to store application data in the cloud that spans both devices and users. You can now easily expose your own authenticated, reliable, REST-based APIs hosted from an App Engine application and consume them in your Android, iOS, or web clients. Deeply integrated authentication support allows your users to have a transparent yet secure experience accessing your services. You have access to strongly typed client libraries for your custom service optimized for Android and iOS.






To use Cloud Endpoints, you simply write a Java or Python class with methods you want to expose to web or mobile clients. You then annotate the methods with attributes that control exactly how they are represented in REST interfaces on the wire. Finally, use Cloud Endpoints to generate your strongly-typed client libraries for Android, iOS and a lightweight JavaScript library.

For example, you can create a simple class to list some important data:



public class SuperHeroes {
  
public List listSuperHeroes() {
     List list =
new ArrayList();
     list.
add(new SuperHero ("Champion of the Obvious", "Brad Abrams"));
     list.
add(new SuperHero ("Mr. Justice", "Chris Ramsdale"));

     
return list;
  }
}




Then, expose it over a standard REST interface with a simple attribute and a versioning pattern.





@Api(name = "superheroes", version = "v1")public class SuperHeroesV1 {   ...
}



Now you have a simple REST interface.





$ curl http://localhost:8888/_ah/api/superheroes/v1/superheroes
{
"items": [
 {
  
"knownAs" : "Champion of the Obvious",
  
"realName" : "Brad Abrams"
 },
 {
  
"knownAs" : "Mr. Justice",
  
"realName" : "Chris Ramsdale"
 }


And you can make strongly typed calls from your Android clients:





Real result = superheroes.list().execute();



Or Objective-C iOS client:



GTLQuerySuperHeroesV1 *query = [GTLQuerySuperHeroesV1 queryForSuperHeroesList];
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket,

GTLSuperHeroes *object, NSError *error) {

 NSArray *items = [object items];
}];




Or the web client in JavaScript:





// ...
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);
});



Read the documentation for Java or Python to discover how you can build a simple tic-tac-toe game using Cloud Endpoints.



To get started with Cloud Endpoints, download the App Engine 1.7.5 SDK and the latest Google Plugin for Eclipse. Be sure to look at the docs and follow along in the discussion forums on Stack Overflow.



For more on using Cloud Endpoints with Python, check out +Danny Hermes and +Dan Holevoet on Google Developers Live.



-Posted by Brad Abrams, Product Manager, and Chris Ramsdale, Product Manager
Email ThisBlogThis!Share to XShare to Facebook
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Tutorial: Adding a cloud backend to your application with Android Studio
    Android Studio lets you easily add a cloud backend to your application, right from your IDE. A backend allows you to implement functionality...
  • A Day in the Cloud, new articles on scaling, and fresh open source projects for App Engine
    The latest release of Python SDK 1.2.3, which introduced the Task Queue API and integrated support for Django 1.0, may have received a lot ...
  • New Admin Console Release
    Posted by Marzia Niccolai, App Engine Team Today we've released some new features in our Admin Console to make it easier for you to mana...
  • JPA/JDO Java Persistence Tips - The Year In Review
    If you’re developing a Java application on App Engine you probably already know that you can use JPA and JDO, both standard Java persistence...
  • The new Cloud Console: designed for developers
    In June, we unveiled the new Google Cloud Console , bringing together all of Google’s APIs, Services, and Infrastructure in a single interfa...
  • Best practices for App Engine: memcache and eventual vs. strong consistency
    We have published two new articles about best practices for App Engine. Are you aware of the best ways to keep Memcache and Datastore in syn...
  • Pushing Updates with the Channel API
    If you've been watching Best Buy closely, you already know that Best Buy is constantly trying to come up with new and creative ways to...
  • Outfit 7’s Talking Friends built on Google App Engine, recently hit one billion downloads
    Today’s guest blogger is Igor Lautar, senior director of technology at Outfit7 (Ekipa2 subsidiary), one of the fastest-growing media enterta...
  • Bridging Mobile Backend as a Service to Enterprise Systems with Google App Engine and Kinvey
    The following post was contributed by Ivan Stoyanov , VP of Engineering for Kinvey, a mobile Backend as a Service provider and Google Cloud ...
  • Easy Performance Profiling with Appstats
    Since App Engine debuted 2 years ago, we’ve written extensively about best practices for writing scalable apps on App Engine. We make writ...

Categories

  • 1.1.2
  • agile
  • android
  • Announcements
  • api
  • app engine
  • appengine
  • batch
  • bicycle
  • bigquery
  • canoe
  • casestudy
  • cloud
  • Cloud Datastore
  • cloud endpoints
  • cloud sql
  • cloud storage
  • cloud-storage
  • community
  • Compute Engine
  • conferences
  • customer
  • datastore
  • delete
  • developer days
  • developer-insights
  • devfests
  • django
  • email
  • entity group
  • events
  • getting started
  • google
  • googlenew
  • gps
  • green
  • Guest Blog
  • hadoop
  • html5
  • index
  • io2010
  • IO2013
  • java
  • kaazing
  • location
  • mapreduce
  • norex
  • open source
  • partner
  • payment
  • paypal
  • pipeline
  • put
  • python
  • rental
  • research project
  • solutions
  • support
  • sustainability
  • taskqueue
  • technical
  • toolkit
  • twilio
  • video
  • websockets
  • workflows

Blog Archive

  • ▼  2013 (143)
    • ►  December (33)
    • ►  November (15)
    • ►  October (17)
    • ►  September (13)
    • ►  August (4)
    • ►  July (15)
    • ►  June (12)
    • ►  May (15)
    • ►  April (4)
    • ►  March (4)
    • ▼  February (9)
      • Improve your App Engine skills with Google Develop...
      • Deploying App Engine apps with DevTable
      • New Google Cloud Platform case studies - including...
      • Google Cloud Platform introduces new support packages
      • Java 7 and Cloud Endpoints Preview
      • New Google App Engine training videos now available
      • App Engine 1.7.5 Released
      • Research Projects on Google App Engine
      • Scaling SongPop to 60 million users with App Engin...
    • ►  January (2)
  • ►  2012 (43)
    • ►  December (2)
    • ►  November (2)
    • ►  October (8)
    • ►  September (2)
    • ►  August (3)
    • ►  July (4)
    • ►  June (2)
    • ►  May (3)
    • ►  April (4)
    • ►  March (5)
    • ►  February (3)
    • ►  January (5)
  • ►  2011 (46)
    • ►  December (3)
    • ►  November (4)
    • ►  October (4)
    • ►  September (5)
    • ►  August (3)
    • ►  July (4)
    • ►  June (3)
    • ►  May (8)
    • ►  April (2)
    • ►  March (5)
    • ►  February (3)
    • ►  January (2)
  • ►  2010 (38)
    • ►  December (2)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (6)
    • ►  May (3)
    • ►  April (5)
    • ►  March (5)
    • ►  February (2)
    • ►  January (2)
  • ►  2009 (47)
    • ►  December (4)
    • ►  November (3)
    • ►  October (6)
    • ►  September (5)
    • ►  August (3)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ►  April (5)
    • ►  March (3)
    • ►  February (7)
    • ►  January (1)
  • ►  2008 (46)
    • ►  December (4)
    • ►  November (3)
    • ►  October (10)
    • ►  September (5)
    • ►  August (6)
    • ►  July (4)
    • ►  June (2)
    • ►  May (5)
    • ►  April (7)
Powered by Blogger.

About Me

Unknown
View my complete profile