Skip to content

Commit

Permalink
Disabled jee validators in eclipse. Refactored SO's to work in flex w…
Browse files Browse the repository at this point in the history
…ith AMF3 encoding (see ByteArray).

git-svn-id: http://red5.googlecode.com/svn/java/server/trunk@4257 1b6495e4-3631-0410-8e05-8f51eee8b9cc
  • Loading branch information
mondain committed Jul 27, 2011
1 parent 03b3318 commit 3ae4b33
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 176 deletions.
13 changes: 8 additions & 5 deletions .settings/org.eclipse.wst.validation.prefs
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,9 @@
#Tue Apr 15 14:43:33 PDT 2008 #Wed Jul 27 09:56:05 PDT 2011
DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator; DELEGATES_PREFERENCE=delegateValidatorList
USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.html.internal.validation.HTMLValidator\:org.eclipse.php.core.phpsource;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator; USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;
USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.html.internal.validation.HTMLValidator\:org.eclipse.php.core.phpsource;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;
USER_PREFERENCE=overrideGlobalPreferencesfalse USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationtrueversion1.2.202.v201103212041
eclipse.preferences.version=1 eclipse.preferences.version=1
override=true
suspend=true
vf.version=3
5 changes: 0 additions & 5 deletions src/org/red5/io/amf3/AMF3.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */


import java.nio.charset.Charset;


/** /**
* AMF3 data type definitions. * AMF3 data type definitions.
Expand All @@ -35,10 +34,6 @@
* @author Paul Gregoire (mondain@gmail.com) * @author Paul Gregoire (mondain@gmail.com)
*/ */
public class AMF3 { public class AMF3 {
/**
* UTF-8 is used
*/
public static final Charset CHARSET = Charset.forName("UTF-8");


/** /**
* Minimum possible value for integer number encoding. * Minimum possible value for integer number encoding.
Expand Down
3 changes: 2 additions & 1 deletion src/org/red5/io/amf3/DataInput.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.charset.Charset; import java.nio.charset.Charset;


import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.red5.io.amf.AMF;
import org.red5.io.object.Deserializer; import org.red5.io.object.Deserializer;


/** /**
Expand Down Expand Up @@ -154,7 +155,7 @@ public String readUTFBytes(int length) {
int limit = buffer.limit(); int limit = buffer.limit();
final ByteBuffer strBuf = buffer.buf(); final ByteBuffer strBuf = buffer.buf();
strBuf.limit(strBuf.position() + length); strBuf.limit(strBuf.position() + length);
final String string = AMF3.CHARSET.decode(strBuf).toString(); final String string = AMF.CHARSET.decode(strBuf).toString();
buffer.limit(limit); // Reset the limit buffer.limit(limit); // Reset the limit
return string; return string;
} }
Expand Down
5 changes: 3 additions & 2 deletions src/org/red5/io/amf3/DataOutput.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.nio.charset.Charset; import java.nio.charset.Charset;


import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.red5.io.amf.AMF;
import org.red5.io.object.Serializer; import org.red5.io.object.Serializer;


/** /**
Expand Down Expand Up @@ -134,7 +135,7 @@ public void writeUnsignedInt(long value) {
public void writeUTF(String value) { public void writeUTF(String value) {
// fix from issue #97 // fix from issue #97
try { try {
byte[] strBuf = value.getBytes(AMF3.CHARSET.name()); byte[] strBuf = value.getBytes(AMF.CHARSET.name());
buffer.putShort((short) strBuf.length); buffer.putShort((short) strBuf.length);
buffer.put(strBuf); buffer.put(strBuf);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Expand All @@ -144,7 +145,7 @@ public void writeUTF(String value) {


/** {@inheritDoc} */ /** {@inheritDoc} */
public void writeUTFBytes(String value) { public void writeUTFBytes(String value) {
final java.nio.ByteBuffer strBuf = AMF3.CHARSET.encode(value); final java.nio.ByteBuffer strBuf = AMF.CHARSET.encode(value);
buffer.put(strBuf); buffer.put(strBuf);
} }


Expand Down
6 changes: 3 additions & 3 deletions src/org/red5/io/amf3/Input.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public String readString(Type target) {
log.debug("readString - limit: {}", limit); log.debug("readString - limit: {}", limit);
final ByteBuffer strBuf = buf.buf(); final ByteBuffer strBuf = buf.buf();
strBuf.limit(strBuf.position() + len); strBuf.limit(strBuf.position() + len);
final String string = AMF3.CHARSET.decode(strBuf).toString(); final String string = AMF.CHARSET.decode(strBuf).toString();
log.debug("String: {}", string); log.debug("String: {}", string);
buf.limit(limit); // reset the limit buf.limit(limit); // reset the limit
refStorage.stringReferences.add(string); refStorage.stringReferences.add(string);
Expand All @@ -393,7 +393,7 @@ public String readString(int length) {
int limit = buf.limit(); int limit = buf.limit();
final ByteBuffer strBuf = buf.buf(); final ByteBuffer strBuf = buf.buf();
strBuf.limit(strBuf.position() + length); strBuf.limit(strBuf.position() + length);
final String string = AMF3.CHARSET.decode(strBuf).toString(); final String string = AMF.CHARSET.decode(strBuf).toString();
log.debug("String: {}", string); log.debug("String: {}", string);
buf.limit(limit); buf.limit(limit);
//check for null termination //check for null termination
Expand Down Expand Up @@ -959,7 +959,7 @@ public Document readXML(Type target) {
int limit = buf.limit(); int limit = buf.limit();
final ByteBuffer strBuf = buf.buf(); final ByteBuffer strBuf = buf.buf();
strBuf.limit(strBuf.position() + len); strBuf.limit(strBuf.position() + len);
final String xmlString = AMF3.CHARSET.decode(strBuf).toString(); final String xmlString = AMF.CHARSET.decode(strBuf).toString();
buf.limit(limit); // Reset the limit buf.limit(limit); // Reset the limit
Document doc = null; Document doc = null;
try { try {
Expand Down
8 changes: 1 addition & 7 deletions src/org/red5/io/amf3/Output.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected static byte[] encodeString(String string) {
Element element = getStringCache().get(string); Element element = getStringCache().get(string);
byte[] encoded = (element == null ? null : (byte[]) element.getObjectValue()); byte[] encoded = (element == null ? null : (byte[]) element.getObjectValue());
if (encoded == null) { if (encoded == null) {
ByteBuffer buf = AMF3.CHARSET.encode(string); ByteBuffer buf = AMF.CHARSET.encode(string);
encoded = new byte[buf.limit()]; encoded = new byte[buf.limit()];
buf.get(encoded); buf.get(encoded);
getStringCache().put(new Element(string, encoded)); getStringCache().put(new Element(string, encoded));
Expand Down Expand Up @@ -374,26 +374,22 @@ public void writeMap(Collection<?> array, Serializer serializer) {
@Override @Override
protected void writeArbitraryObject(Object object, Serializer serializer) { protected void writeArbitraryObject(Object object, Serializer serializer) {
Class<?> objectClass = object.getClass(); Class<?> objectClass = object.getClass();

// If we need to serialize class information... // If we need to serialize class information...
if (!objectClass.isAnnotationPresent(Anonymous.class)) { if (!objectClass.isAnnotationPresent(Anonymous.class)) {
putString(serializer.getClassName(objectClass)); putString(serializer.getClassName(objectClass));
} else { } else {
putString(""); putString("");
} }

// Store key/value pairs // Store key/value pairs
amf3_mode += 1; amf3_mode += 1;
// Iterate thru fields of an object to build "name-value" map from it // Iterate thru fields of an object to build "name-value" map from it
for (Field field : objectClass.getFields()) { for (Field field : objectClass.getFields()) {
String fieldName = field.getName(); String fieldName = field.getName();

log.debug("Field: {} class: {}", field, objectClass); log.debug("Field: {} class: {}", field, objectClass);
// Check if the Field corresponding to the getter/setter pair is transient // Check if the Field corresponding to the getter/setter pair is transient
if (!serializeField(serializer, objectClass, fieldName, field, null)) { if (!serializeField(serializer, objectClass, fieldName, field, null)) {
continue; continue;
} }

Object value; Object value;
try { try {
// Get field value // Get field value
Expand All @@ -402,7 +398,6 @@ protected void writeArbitraryObject(Object object, Serializer serializer) {
// Swallow on private and protected properties access exception // Swallow on private and protected properties access exception
continue; continue;
} }

// Write out prop name // Write out prop name
putString(fieldName); putString(fieldName);
// Write out // Write out
Expand Down Expand Up @@ -548,7 +543,6 @@ public void writeByteArray(ByteArray array) {
putInteger(getReferenceId(array) << 1); putInteger(getReferenceId(array) << 1);
return; return;
} }

storeReference(array); storeReference(array);
IoBuffer data = array.getData(); IoBuffer data = array.getData();
putInteger(data.limit() << 1 | 1); putInteger(data.limit() << 1 | 1);
Expand Down
2 changes: 1 addition & 1 deletion src/org/red5/server/api/Red5.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* *
* @author The Red5 Project (red5@osflash.org) * @author The Red5 Project (red5@osflash.org)
* @author Luke Hubbard (luke@codegent.com) * @author Luke Hubbard (luke@codegent.com)
* @author Paul Gregoire (mondain@gmail.com) * @author Paul Gregoire (mondain@gmail.com)
*/ */
public final class Red5 { public final class Red5 {


Expand Down
119 changes: 61 additions & 58 deletions src/org/red5/server/net/remoting/message/RemotingPacket.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,86 +31,89 @@
* Packet of remote calls. Used by RemoteProtocolDecoder. * Packet of remote calls. Used by RemoteProtocolDecoder.
*/ */
public class RemotingPacket { public class RemotingPacket {
/** /**
* HTTP request object * HTTP request object
*/ */
protected HttpServletRequest request; protected HttpServletRequest request;
/**
* Byte buffer data /**
*/ * Byte buffer data
*/
protected ByteBuffer data; protected ByteBuffer data;

/** /**
* Headers sent with request. * Headers sent with request.
*/ */
protected Map<String, Object> headers; protected Map<String, Object> headers;
/**
* List of calls /**
*/ * List of calls
*/
protected List<RemotingCall> calls; protected List<RemotingCall> calls;
/**
* Scope path /**
*/ * Scope path
*/
protected String scopePath; protected String scopePath;


/** /**
* Create remoting packet from list of pending calls * Create remoting packet from list of pending calls
* @param headers headers * @param headers headers
* @param calls List of call objects * @param calls List of call objects
*/ */
public RemotingPacket(Map<String, Object> headers, List<RemotingCall> calls) { public RemotingPacket(Map<String, Object> headers, List<RemotingCall> calls) {
this.headers = headers; this.headers = headers;
this.calls = calls; this.calls = calls;
} }


/**
* Get the headers sent with the request.
*
* @return headers
*/
public Map<String, Object> getHeaders() {
return headers;
}

/** /**
* Getter for calls. * Get the headers sent with the request.
* *
* @return List of remote calls * @return headers
*/ */
public List<RemotingCall> getCalls() { public Map<String, Object> getHeaders() {
return headers;
}

/**
* Getter for calls.
*
* @return List of remote calls
*/
public List<RemotingCall> getCalls() {
return calls; return calls;
} }


/** /**
* Setter for scope path. * Setter for scope path.
* *
* @param path Value to set for property 'scopePath'. * @param path Value to set for property 'scopePath'.
*/ */
public void setScopePath(String path) { public void setScopePath(String path) {
scopePath = path; scopePath = path;
} }


/** /**
* Getter for property scope path. * Getter for property scope path.
* *
* @return Scope path to set * @return Scope path to set
*/ */
public String getScopePath() { public String getScopePath() {
return scopePath; return scopePath;
} }


/** /**
* Return the encoding of the included calls. * Return the encoding of the included calls.
* *
* @return encoding * @return encoding
*/ */
public Encoding getEncoding() { public Encoding getEncoding() {
List<RemotingCall> calls = getCalls(); List<RemotingCall> calls = getCalls();
if (calls == null || calls.isEmpty()) { if (calls == null || calls.isEmpty()) {
return Encoding.AMF0; return Encoding.AMF0;
} }

RemotingCall call = calls.get(0);
RemotingCall call = calls.get(0); return call.isAMF3 ? Encoding.AMF3 : Encoding.AMF0;
return call.isAMF3 ? Encoding.AMF3 : Encoding.AMF0; }
}

} }
2 changes: 1 addition & 1 deletion src/org/red5/server/net/rtmp/RTMPConnection.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void setup(String host, String path, String sessionId, Map<String, Object
this.path = path; this.path = path;
this.sessionId = sessionId; this.sessionId = sessionId;
this.params = params; this.params = params;
if (params.get("objectEncoding") == Integer.valueOf(3)) { if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
log.info("Setting object encoding to AMF3"); log.info("Setting object encoding to AMF3");
encoding = Encoding.AMF3; encoding = Encoding.AMF3;
} }
Expand Down
34 changes: 18 additions & 16 deletions src/org/red5/server/net/rtmp/RTMPHandler.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -341,21 +341,23 @@ protected void onInvoke(RTMPConnection conn, Channel channel, Header source, Not
disconnectOnReturn = true; disconnectOnReturn = true;
} }
// Evaluate request for AMF3 encoding // Evaluate request for AMF3 encoding
if (Integer.valueOf(3).equals(params.get("objectEncoding")) && call instanceof IPendingServiceCall) { if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
Object pcResult = ((IPendingServiceCall) call).getResult(); if (call instanceof IPendingServiceCall) {
Map<String, Object> result; Object pcResult = ((IPendingServiceCall) call).getResult();
if (pcResult instanceof Map) { Map<String, Object> result;
result = (Map<String, Object>) pcResult; if (pcResult instanceof Map) {
result.put("objectEncoding", 3); result = (Map<String, Object>) pcResult;
} else if (pcResult instanceof StatusObject) { result.put("objectEncoding", 3);
result = new HashMap<String, Object>(); } else if (pcResult instanceof StatusObject) {
StatusObject status = (StatusObject) pcResult; result = new HashMap<String, Object>();
result.put("code", status.getCode()); StatusObject status = (StatusObject) pcResult;
result.put("description", status.getDescription()); result.put("code", status.getCode());
result.put("application", status.getApplication()); result.put("description", status.getDescription());
result.put("level", status.getLevel()); result.put("application", status.getApplication());
result.put("objectEncoding", 3); result.put("level", status.getLevel());
((IPendingServiceCall) call).setResult(result); result.put("objectEncoding", 3);
((IPendingServiceCall) call).setResult(result);
}
} }
rtmp.setEncoding(Encoding.AMF3); rtmp.setEncoding(Encoding.AMF3);
} }
Expand Down Expand Up @@ -493,7 +495,7 @@ protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping
* @param persistent * @param persistent
*/ */
private void sendSOCreationFailed(RTMPConnection conn, String name, boolean persistent) { private void sendSOCreationFailed(RTMPConnection conn, String name, boolean persistent) {
log.warn("sendSOCreationFailed - name: {} persistent: {} conn: {}", new Object[]{name, persistent, conn}); log.warn("sendSOCreationFailed - name: {} persistent: {} conn: {}", new Object[] { name, persistent, conn });
SharedObjectMessage msg = new SharedObjectMessage(name, 0, persistent); SharedObjectMessage msg = new SharedObjectMessage(name, 0, persistent);
msg.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_CREATION_FAILED)); msg.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_CREATION_FAILED));
conn.getChannel(3).write(msg); conn.getChannel(3).write(msg);
Expand Down
Loading

0 comments on commit 3ae4b33

Please sign in to comment.