[Red5devs] [red5 commit] r3106 - in java: example/trunk/SOSample/www/WEB-INF server/trunk/src/org/red5/io/amf3 server/trun...
codesite-noreply at google.com
codesite-noreply at google.com
Thu Sep 25 14:15:35 PDT 2008
Author: mondain
Date: Thu Sep 25 14:15:08 2008
New Revision: 3106
Modified:
java/example/trunk/SOSample/www/WEB-INF/red5-web.xml
java/server/trunk/src/org/red5/io/amf3/Input.java
java/server/trunk/src/org/red5/io/object/Deserializer.java
java/server/trunk/src/org/red5/logging/ContextLoggingListener.java
java/server/trunk/src/org/red5/logging/LoggerContextFilter.java
java/server/trunk/src/org/red5/logging/LoggingContextSelector.java
java/server/trunk/src/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
Log:
Removed singleton attr from sosample config. Added debug logging and
refactored a bit to support APPSERVER-283. Fixed logger issue when multiple
webapps exist with separate loggers.
Modified: java/example/trunk/SOSample/www/WEB-INF/red5-web.xml
==============================================================================
--- java/example/trunk/SOSample/www/WEB-INF/red5-web.xml (original)
+++ java/example/trunk/SOSample/www/WEB-INF/red5-web.xml Thu Sep 25
14:15:08 2008
@@ -19,8 +19,6 @@
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>
- <bean id="web.handler"
- class="org.red5.server.adapter.ApplicationAdapter"
- singleton="true" />
+ <bean id="web.handler" class="org.red5.server.adapter.ApplicationAdapter"
/>
</beans>
Modified: java/server/trunk/src/org/red5/io/amf3/Input.java
==============================================================================
--- java/server/trunk/src/org/red5/io/amf3/Input.java (original)
+++ java/server/trunk/src/org/red5/io/amf3/Input.java Thu Sep 25 14:15:08
2008
@@ -208,6 +208,8 @@
return readDataType(currentDataType);
}
+ log.debug("Current data type (after amf checks): {}", currentDataType);
+
switch (currentDataType) {
case AMF3.TYPE_UNDEFINED:
case AMF3.TYPE_NULL:
@@ -333,6 +335,7 @@
final java.nio.ByteBuffer strBuf = buf.buf();
strBuf.limit(strBuf.position() + len);
final String string = AMF3.CHARSET.decode(strBuf).toString();
+ log.debug("String: {}", string);
buf.limit(limit); // Reset the limit
stringReferences.add(string);
return string;
@@ -524,16 +527,17 @@
break;
case AMF3.TYPE_OBJECT_EXTERNALIZABLE:
// Use custom class to deserialize the object
- if ("".equals(className))
- throw new RuntimeException("need a classname to load an externalizable
object");
-
+ if ("".equals(className)) {
+ throw new RuntimeException("Classname is required to load an
Externalizable object");
+ }
+ log.debug("Externalizable class: {}", className);
result = newInstance(className);
- if (result == null)
- throw new RuntimeException("could not instantiate class");
-
- if (!(result instanceof IExternalizable))
- throw new RuntimeException("the class must implement the
IExternalizable interface");
-
+ if (result == null) {
+ throw new RuntimeException(String.format("Could not instantiate
class: %s", className));
+ }
+ if (!(result instanceof IExternalizable)) {
+ throw new RuntimeException(String.format("Class must implement the
IExternalizable interface: %s", className));
+ }
classReferences.add(new ClassReference(className,
AMF3.TYPE_OBJECT_EXTERNALIZABLE, null));
storeReference(tempRefId, result);
((IExternalizable) result).readExternal(new DataInput(this,
deserializer));
@@ -566,16 +570,17 @@
break;
default:
case AMF3.TYPE_OBJECT_PROXY:
- if ("".equals(className))
- throw new RuntimeException("need a classname to load an externalizable
object");
-
+ if ("".equals(className)) {
+ throw new RuntimeException("Classname is required to load an
Externalizable object");
+ }
+ log.debug("Externalizable class: {}", className);
result = newInstance(className);
- if (result == null)
- throw new RuntimeException("could not instantiate class");
-
- if (!(result instanceof IExternalizable))
- throw new RuntimeException("the class must implement the
IExternalizable interface");
-
+ if (result == null) {
+ throw new RuntimeException(String.format("Could not instantiate
class: %s", className));
+ }
+ if (!(result instanceof IExternalizable)) {
+ throw new RuntimeException(String.format("Class must implement the
IExternalizable interface: %s", className));
+ }
classReferences.add(new ClassReference(className,
AMF3.TYPE_OBJECT_PROXY, null));
storeReference(tempRefId, result);
((IExternalizable) result).readExternal(new DataInput(this,
deserializer));
@@ -617,7 +622,7 @@
}
if (value instanceof PendingObject) {
- // Deferr setting of value until real object is created
+ // Defer setting of value until real object is created
((PendingObject) value).addPendingProperty(result, resultClass,
key);
continue;
}
Modified: java/server/trunk/src/org/red5/io/object/Deserializer.java
==============================================================================
--- java/server/trunk/src/org/red5/io/object/Deserializer.java (original)
+++ java/server/trunk/src/org/red5/io/object/Deserializer.java Thu Sep 25
14:15:08 2008
@@ -43,6 +43,7 @@
* @param target
* @return Object
*/
+ @SuppressWarnings("unchecked")
public <T> T deserialize(Input in, Type target) {
byte type = in.readDataType();
@@ -53,7 +54,7 @@
log.debug("Type (skip): {}", type);
}
- log.debug("Datatype: " + DataTypes.toStringValue(type));
+ log.debug("Datatype: {}", DataTypes.toStringValue(type));
Object result;
Modified: java/server/trunk/src/org/red5/logging/ContextLoggingListener.java
==============================================================================
--- java/server/trunk/src/org/red5/logging/ContextLoggingListener.java
(original)
+++ java/server/trunk/src/org/red5/logging/ContextLoggingListener.java Thu
Sep 25 14:15:08 2008
@@ -50,9 +50,11 @@
String contextName = pathToName(event);
System.out.printf("Logger name for context: %s\n", contextName);
- try {
- LoggingContextSelector selector = (LoggingContextSelector)
StaticLoggerBinder.SINGLETON.getContextSelector();
+ LoggingContextSelector selector = null;
+ try {
+ selector = (LoggingContextSelector)
StaticLoggerBinder.SINGLETON.getContextSelector();
+ //set this contexts name
selector.setContextName(contextName);
LoggerContext context = selector.getLoggerContext();
@@ -71,6 +73,9 @@
} catch (Exception e) {
System.err.println("LoggingContextSelector is not the correct type");
e.printStackTrace();
+ } finally {
+ //reset the name
+ selector.setContextName(null);
}
}
@@ -78,7 +83,7 @@
private String pathToName(ServletContextEvent event) {
String contextName = event.getServletContext().getContextPath()
.replaceAll("/", "");
- if (contextName.equals("")) {
+ if ("".equals(contextName)) {
contextName = "root";
}
return contextName;
Modified: java/server/trunk/src/org/red5/logging/LoggerContextFilter.java
==============================================================================
--- java/server/trunk/src/org/red5/logging/LoggerContextFilter.java
(original)
+++ java/server/trunk/src/org/red5/logging/LoggerContextFilter.java Thu Sep
25 14:15:08 2008
@@ -46,7 +46,7 @@
System.out.printf("Context name: %s\n", contextName);
LoggingContextSelector selector = (LoggingContextSelector)
StaticLoggerBinder.SINGLETON.getContextSelector();
- System.out.println("Context select type: " +
selector.getClass().getName());
+ System.out.printf("Context select type: %s\n",
selector.getClass().getName());
LoggerContext ctx = selector.getLoggerContext(contextName);
Modified: java/server/trunk/src/org/red5/logging/LoggingContextSelector.java
==============================================================================
--- java/server/trunk/src/org/red5/logging/LoggingContextSelector.java
(original)
+++ java/server/trunk/src/org/red5/logging/LoggingContextSelector.java Thu
Sep 25 14:15:08 2008
@@ -61,10 +61,10 @@
loggerContext = new LoggerContext();
loggerContext.setName(contextName);
- if (contextConfigFile == null) {
+ //if (contextConfigFile == null) {
contextConfigFile = String.format("logback-%s.xml", contextName);
System.out.printf("Context logger config file: %s\n",
contextConfigFile);
- }
+ //}
ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
System.out.printf("Thread context cl: %s\n", classloader);
Modified:
java/server/trunk/src/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
==============================================================================
---
java/server/trunk/src/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
(original)
+++
java/server/trunk/src/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java
Thu Sep 25 14:15:08 2008
@@ -144,12 +144,13 @@
log.error("Handshake validation failed but no current connection!?");
}
return null;
- // Exception handling is patched by Victor - we catch any exception in
the decoding
- // Then clear the buffer to eliminate memory leaks when we can't parse
protocol
- // Also close Connection because we can't parse data from it
} catch (Exception ex) {
+ // Exception handling is patched by Victor - we catch any exception in
the decoding
+ // Then clear the buffer to eliminate memory leaks when we can't parse
protocol
+ // Also close Connection because we can't parse data from it
log.error("Error decoding buffer", ex);
buffer.clear();
+
IConnection conn = Red5.getConnectionLocal();
if (conn != null) {
log.warn("Closing connection because decoding failed: {}", conn);
@@ -202,12 +203,11 @@
switch (rtmp.getState()) {
case RTMP.STATE_CONNECTED:
return decodePacket(rtmp, in);
- case RTMP.STATE_ERROR:
- // attempt to correct error
- return null;
case RTMP.STATE_CONNECT:
case RTMP.STATE_HANDSHAKE:
return decodeHandshake(rtmp, in);
+ case RTMP.STATE_ERROR:
+ // attempt to correct error?
default:
return null;
}
More information about the Red5devs
mailing list