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.metadata;
20  
21  import javax.websocket.MessageHandler;
22  
23  /**
24   * An immutable metadata for a {@link MessageHandler}, representing a single interface on a message handling class.
25   * <p>
26   * A message handling class can contain more than 1 valid {@link MessageHandler} interface, this will result in multiple {@link MessageHandlerMetadata}
27   * instances, each tracking one of the {@link MessageHandler} interfaces declared.
28   */
29  public class MessageHandlerMetadata
30  {
31      /**
32       * The implemented MessageHandler class.
33       * <p>
34       * Commonly a end-user provided class, with 1 or more implemented {@link MessageHandler} interfaces
35       */
36      private final Class<? extends MessageHandler> handlerClass;
37      /**
38       * Indicator if this is a {@link MessageHandler.Partial} or {@link MessageHandler.Whole} interface.
39       * <p>
40       * True for MessageHandler.Partial, other wise its a MessageHandler.Whole
41       */
42      private final boolean isPartialSupported;
43      /**
44       * The class type that this specific interface's generic implements.
45       * <p>
46       * Or said another way, the first parameter type on this interface's onMessage() method.
47       */
48      private final Class<?> messageClass;
49  
50      public MessageHandlerMetadata(Class<? extends MessageHandler> handlerClass, Class<?> messageClass, boolean partial)
51      {
52          this.handlerClass = handlerClass;
53          this.isPartialSupported = partial;
54          this.messageClass = messageClass;
55      }
56  
57      public Class<? extends MessageHandler> getHandlerClass()
58      {
59          return handlerClass;
60      }
61  
62      public Class<?> getMessageClass()
63      {
64          return messageClass;
65      }
66  
67      public boolean isPartialSupported()
68      {
69          return isPartialSupported;
70      }
71  }