@Override public String getContentType() { return ContentType.AMF.mimeType(); }
/** * Lookup the ContentType from a MIME type * @param mimeType MIME type * @return corresponding encoding/content type or null if no content type found */ public static ContentType forMimeType(String mimeType) { for (ContentType type : values()) { if (type.mimeType.equals(mimeType)) return type; } return null; } }
public static ContentType getContentType(String contentType, String protocol) { if (contentType == null) { if (protocol != null) { if ("org.granite.gravity".equals(protocol)) contentType = ContentType.AMF.mimeType(); else if (protocol.startsWith("org.granite.gravity.")) contentType = "application/x-" + protocol.substring("org.granite.gravity.".length()); else throw new RuntimeException("Missing Content-Type and unsupported Sec-WebSocket-Protocol: " + protocol); } else { contentType = ContentType.AMF.mimeType(); log.warn("Missing Content-Type and Sec-WebSocket-Protocol in handshake request. Using: %s", contentType); } } ContentType type = ContentType.forMimeType(contentType); if (type == null) { log.warn("No (or unsupported) content type in handshake request: %s. Using: %s", contentType, ContentType.AMF.mimeType()); type = ContentType.AMF; } return type; } }
serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));
protected Message[] deserialize(GravityInternal gravity, byte[] data, int offset, int length) throws ClassNotFoundException, IOException { ByteArrayInputStream is = new ByteArrayInputStream(data, offset, length); try { Message[] messages = null; if (ContentType.JMF_AMF.equals(contentType)) { @SuppressWarnings("all") // JDK7 warning (Resource leak: 'deserializer' is never closed)... JMFDeserializer deserializer = new JMFDeserializer(is, gravity.getGraniteConfig().getSharedContext()); messages = (Message[])deserializer.readObject(); } else { ObjectInput amf3Deserializer = gravity.getGraniteConfig().newAMF3Deserializer(is); Object[] objects = (Object[])amf3Deserializer.readObject(); messages = new Message[objects.length]; System.arraycopy(objects, 0, messages, 0, objects.length); } return messages; } finally { is.close(); } }
serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));
protected byte[] serialize(GravityInternal gravity, Message[] messages) throws IOException { ByteArrayOutputStream os = null; try { os = new ByteArrayOutputStream(200*messages.length); if (ContentType.JMF_AMF.equals(contentType)) { @SuppressWarnings("all") // JDK7 warning (Resource leak: 'serializer' is never closed)... JMFSerializer serializer = new JMFSerializer(os, gravity.getGraniteConfig().getSharedContext()); serializer.writeObject(messages); } else { ObjectOutput amf3Serializer = gravity.getGraniteConfig().newAMF3Serializer(os); amf3Serializer.writeObject(messages); amf3Serializer.flush(); } return os.toByteArray(); } finally { if (os != null) os.close(); } }
@Override public String getContentType() { return ContentType.AMF.mimeType(); }
public static ContentType forMimeType(String mimeType) { for (ContentType type : values()) { if (type.mimeType.equals(mimeType)) return type; } return null; } }
serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));
@Override public String getContentType() { return ContentType.JMF_AMF.mimeType(); }
/** * Lookup the ContentType from a MIME type * @param mimeType MIME type * @return corresponding encoding/content type or null if no content type found */ public static ContentType forMimeType(String mimeType) { for (ContentType type : values()) { if (type.mimeType.equals(mimeType)) return type; } return null; } }
GravityServletUtil.serialize(gravity, response, messagesArray, ContentType.forMimeType(request.getContentType()));
@Override public String getContentType() { return ContentType.AMF.mimeType(); }
/** * Lookup the ContentType from a MIME type * @param mimeType MIME type * @return corresponding encoding/content type or null if no content type found */ public static ContentType forMimeType(String mimeType) { for (ContentType type : values()) { if (type.mimeType.equals(mimeType)) return type; } return null; } }
serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));
@Override public String getContentType() { return ContentType.JMF_AMF.mimeType(); }
serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));
@Override public String getContentType() { return ContentType.AMF.mimeType(); }
GravityServletUtil.serialize(gravity, response, amf3Responses, ContentType.forMimeType(request.getContentType()));