View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.websocket.jsr356.annotations;
20  
21  import java.lang.reflect.Method;
22  import java.nio.ByteBuffer;
23  
24  import org.eclipse.jetty.websocket.jsr356.JsrPongMessage;
25  import org.eclipse.jetty.websocket.jsr356.JsrSession;
26  import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
27  
28  /**
29   * Callable for {@link OnMessage} annotated methods with a {@link PongMessage} message object.
30   */
31  public class OnMessagePongCallable extends OnMessageCallable
32  {
33      public OnMessagePongCallable(Class<?> pojo, Method method)
34      {
35          super(pojo,method);
36      }
37  
38      /**
39       * Copy Constructor
40       */
41      public OnMessagePongCallable(OnMessageCallable copy)
42      {
43          super(copy);
44      }
45  
46      public Object call(Object endpoint, ByteBuffer buf)
47      {
48          super.args[idxMessageObject] = new JsrPongMessage(buf);
49          return super.call(endpoint,super.args);
50      }
51  
52      @Override
53      public void init(JsrSession session)
54      {
55          idxMessageObject = findIndexForRole(Role.MESSAGE_PONG);
56          assertRoleRequired(idxMessageObject,"Pong Message Object");
57          super.init(session);
58      }
59  }