Wednesday Apr 17, 2013

Suggestions for Java EE and Cloud Track at JavaOne 2013: CFP ends Apr 23




JavaOne Call for Papers has been extended and now will close on April 23. There are eight tracks to submit your talks:
  • Client and Embedded Development with JavaFX
  • Core Java Platform
  • Edge Computing with Java in Embedded, Smart Card, and IoT applications
  • Emerging Languages and the Java Virtual Machine
  • Securing Java
  • Java Development Tools and Techniques
  • Java EE Web Profile and Platform Technologies
  • Java Web Services and the Cloud

A complete description of each track is provided here. Five different kind of sessions can be submitted for each track:

  • Conference Session: A 60-minute session presented by Oracle, customers, partners, developers, and/or user group members
  • Panel: A 60-minute session presented in a panel format by multiple speakers consisting of Oracle, customers, partners, developers, and/or user group members
  • Tutorials: A 2 hour speaker led session where the presenter literally show attendees a live "How to" tutorial, and attendees can ask questions to the presenter during this. It doesn't require the attendee to have any equipment whatsoever. Ideally, the attendee should be listening and taking notes.
  • Birds of a Feather (BOFs): A  60-minute session that allows a closer interaction with the speakers and attendees focusing on a particular aspect of technology.
  • Hands-on Lab (HOL): A two-hour hands-on, interactive lab session
We've seen a good response to paper submission so far and really thankful for that!

You've a few more days to submit your talks. As a track co-lead for Java EE and Cloud tracks, here are some talks that I'd like to see there:
  • Anything related to WebSocket, JSON, Concurrency, Batch, HTML5, Persistence, Dependency Injection, Transactions ?
  • Do you have a creative use of Java EE technologies in your applications ?
  • Are you an extreme believer in Java EE and use most of the components for creating world-class applications ?
  • Are you using multiple application servers in your deployment environment ?
  • Do you have any experience of migrating from earlier versions of J2EE to Java EE ? Tutorials here would be nice.
  • Do you want to show value of standards-based application development over proprietary frameworks ?
  • Are you building support for Java EE 7 in your applications already ?
  • Performance, monitoring, testing, development, deployment strategies ?
  • Any other enterprise Java technologies from the ecosystem ?
  • Real case studies on how Java EE helped you deliver on time, within budget, and stay competitive
And now some suggestions for the Cloud track:
  • How are your Java services powering web and cloud ?
  • Anything related to REST/SOAP Web services and design patterns ?
  • How is Service Oriented Architecture (SOA) helping you realize the benefits ?
  • Do you have an interesting deployment topology across your private and public cloud ?
  • Do you have a case study showing why a particular deployment scenario works ?
  • Are you exposing services at IaaS, PaaS, and SaaS layers and share guidelines on them ?
  • How are you simplifying DevOps ?
  • How are you using BigData in development and deployment ?
  • Anything related to NoSQL ? Using a mix of NoSQL and RDBMS ?
Keep the job of Content Review Committe interesting, demanding, and challenging. Submit as many sessions as you can before April 23rd 11:50pm PT.

Read the content review process and tips for submission from 2 years ago to improve your chances of getting a paper selected.

Submit now!

Thursday Apr 04, 2013

WebSocket Client and Server Endpoint: Annotated and Programmatic (TOTD #212)


JSR 356 defines Java API for WebSocket 1.0. It defines a standard-based programming model for creating WebSocket client and server endpoint. Both kind of endpoints can be created programmatically or using annotations. This Tip Of The Day (TOTD) provide short snippets of how to write a WebSocket client and server endpoint programmatically or using annotations.

The complete source code in this sample can be downloaded from here.

Lets start with annotation-based server endpoint.

@ServerEndpoint("/websocket")
public class MyEndpoint {
   
  @OnMessage
  public String echoText(String name) {
    return name;
  }
}

@ServerEndpoint marks the POJO as a WebSocket server endpoint. URI of the deployed endpoint is as value attribute of the annotation.  echoText method is invoked whenever a message with text payload is received by this endpoint. Payload of the message is mapped to the parameter name. A synchronous response is returned to the client using the return value.

Programmatic server endpoint can be defined as:

public class MyEndpoint extends Endpoint {

  @Override
  public void onOpen(final Session session, EndpointConfig ec) {
    session.addMessageHandler(new MessageHandler.Whole<String>() {

      @Override
      public void onMessage(String text) {
        try {
          session.getBasicRemote().sendText(text);
        } catch (IOException ex) {
          Logger.getLogger(MyEndpoint.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
  });
}

A programmatic server endpoint is defined by extending Endpoint abstract class. onOpen method is overridden to be notified of when a new conversation has started. Session captures the other end of the conversation. EndpointConfig identifies the configuration object used to configure this endpoint. Multiple MessageHandlers are registered to handle text, binary, and pong messages. The first parameter of onOpen captures the other end of the conversation. A synchronous response to the client is sent by calling getBasicRemote().sendText(...) method.

Programmatic server endpoint needs to be configured using ServerApplicationConfig.

public class MyApplicationConfig implements ServerApplicationConfig {

  @Override
  public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> set) {
    return new HashSet<ServerEndpointConfig>() {
      {
        add(ServerEndpointConfig.Builder
            .create(MyEndpoint.class, "/websocket")
            .build());
      }
    };
  }

  @Override
  public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> set) {
    return Collections.emptySet();
  }
}

WebSocket runtime scans the WAR file with all implementations of ServerApplicationConfig and registers the endpoint returned from getEndpointConfigs and getAnnotatedEndpointClasses. The URI of the server endpoint is published using ServerEndpointConfig.Builder.

Now lets take a look at annotated client endpoint.

@ClientEndpoint
public class MyClient {
  @OnOpen
  public void onOpen(Session session) {
    try {
      String name = "Duke";
      System.out.println("Sending message to endpoint: " + name);
      session.getBasicRemote().sendText(name);
    } catch (IOException ex) {
      Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}

@ClientEndpoint marks the POJO as a WebSocket client endpoint. onOpen method is invoked whenever a new WebSocket connection is opened and is identified by @OnOpen annotation. Session captures the other end of the conversation. A synchronous message is sent to the server using session.getBasicRemote.sendText() method.

This client can connect to the endpoint as:

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
container.connectToServer(MyClient.class, URI.create(uri));

And finally programmatic client endpoint.

public class MyClient extends Endpoint {
  @Override
  public void onOpen(final Session session, EndpointConfig ec) {
    session.addMessageHandler(new MessageHandler.Whole<String>() {

      @Override
      public void onMessage(String text) {
        System.out.println("Received response in client from endpoint: " + text);
      }
  });
  try {
    String name = "Duke";
      System.out.println("Sending message from client -> endpoint: " + name);
      session.getBasicRemote().sendText(name);
    } catch (IOException ex) {
      Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}


The first parameter of onOpen captures the other end of the conversation.  EndpointConfig identifies the configuration object used to configure this endpoint. Multiple MessageHandlers are registered to handle text, binary, and pong messages. onMessage method is called whenever a message is received from the endpoint. A synchronous request to the server is sent by calling getBasicRemote().sendText(...) method.

This client can connect to the endpoint as:

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
container.connectToServer(MyClient.class,
                null,
                URI.create(uri));

Now go download your GlassFish b82, samples source code, and run them.


About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2013 »
SunMonTueWedThuFriSat
 
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today