Browse files

hessian checkin

git-svn-id: svn://svn.caucho.com/resin/trunk@6509 9c94448d-38f1-0310-a231-d98308ff1ebf
  • Loading branch information...
1 parent 3bc48d8 commit f79a0cb9eef954827eeb449db816391332fd4f3a ferg committed Dec 24, 2009
View
199 conf/resin.xml
@@ -0,0 +1,199 @@
+<!--
+ - Resin 4.0 configuration file.
+ -
+ - See conf/full.xml for more sample configuration, including load
+ - balancing and database configuration.
+ -->
+<resin xmlns="http://caucho.com/ns/resin"
+ xmlns:resin="urn:java:com.caucho.resin">
+
+ <!--
+ - driver .jar files can be placed in ${resin.root}/ext-lib
+ -->
+ <class-loader>
+ <tree-loader path="${resin.root}/ext-lib"/>
+ </class-loader>
+
+ <!--
+ - project jars with maven dependencies can be placed
+ - in project-jars to be used by web-apps. A WEB-INF/pom.xml will
+ - select the project's artifacts.
+ -->
+ <resin:ProjectJarRepository path="${resin.root}/project-jars"/>
+
+ <!--
+ - Remote management requires at least one enabled admin user.
+ -->
+ <resin:AdminAuthenticator>
+ <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
+ </resin:AdminAuthenticator>
+
+ <!--
+ - Logging configuration for the JDK logging API.
+ -->
+ <log-handler name="" level="all" path="stdout:"
+ timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "/>
+
+ <!--
+ - level='info' for production
+ - 'fine' or 'finer' for development and troubleshooting
+ -->
+ <logger name="com.caucho" level="info"/>
+
+ <logger name="com.caucho.java" level="config"/>
+ <logger name="com.caucho.loader" level="config"/>
+
+ <!--
+ - For production sites, change dependency-check-interval to something
+ - like 600s, so it only checks for updates every 10 minutes.
+ -->
+ <dependency-check-interval>2s</dependency-check-interval>
+
+ <!--
+ - SMTP server for sending mail notifications
+ -->
+ <system-property mail.smtp.host="127.0.0.1"/>
+ <system-property mail.smtp.port="25"/>
+
+ <!--
+ - default configuration applied to all clusters
+ -->
+ <cluster-default>
+ <!-- standard servlet behavior, including .jsp, .php, and WEB-INF -->
+ <resin:import path="${__DIR__}/app-default.xml"/>
+
+ <!-- enables development error pages -->
+ <development-mode-error-page/>
+
+ <!--
+ - Enables the proxy cache (available in Resin Professional)
+ -->
+ <resin:if test="${resin.professional}">
+ <cache memory-size="64M">
+ <!-- Vary header rewriting for IE -->
+ <rewrite-vary-as-private/>
+ </cache>
+ </resin:if>
+
+ <!--
+ - Admin services
+ -->
+ <resin:DeployService/>
+
+ <resin:if test="${resin.professional}">
+ <resin:JmxService/>
+ <resin:LogService/>
+ <resin:StatService/>
+ <resin:XaLogService/>
+ </resin:if>
+
+ <!--
+ - Default host configuration applied to all virtual hosts.
+ -->
+ <host-default>
+ <access-log path="log/access.log"
+ format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
+ rollover-period="1W"/>
+
+ <!-- creates the webapps directory for .war expansion -->
+ <web-app-deploy path="webapps"/>
+ </host-default>
+
+ <!--
+ - Defaults applied to each web-app.
+ -->
+ <web-app-default>
+ <prologue>
+ <!--
+ - Enable EL expressions in Servlet and Filter init-param
+ -->
+ <allow-servlet-el/>
+ </prologue>
+
+ <!-- enable persistent sessions -->
+ <session-config>
+ <use-persistent-store/>
+ </session-config>
+
+ <!--
+ - Sets max-age for cacheable pages, e.g. static pages.
+ -->
+ <cache-mapping url-pattern="/" max-age="5s"/>
+ <cache-mapping url-pattern="*.gif" max-age="60s"/>
+ <cache-mapping url-pattern="*.jpg" max-age="60s"/>
+ <cache-mapping url-pattern="*.png" max-age="60s"/>
+ <cache-mapping url-pattern="*.css" max-age="60s"/>
+ <cache-mapping url-pattern="*.js" max-age="60s"/>
+ </web-app-default>
+ </cluster-default>
+
+ <!--
+ - Configures the main appliction cluster. Load-balancing configurations
+ - will also have a load-balance-tier cluster.
+ -->
+ <cluster id="app-tier">
+ <!-- sets the content root for the cluster, relative to resin.root -->
+ <root-directory>.</root-directory>
+
+ <!-- defaults for each server, i.e. JVM -->
+ <server-default>
+ <!-- The http port -->
+ <http address="*" port="8080"/>
+
+ <!-- SSL port configuration: -->
+ <http address="*" port="8443">
+ <jsse-ssl self-signed-certificate-name="resin@localhost"/>
+ </http>
+
+ <jvm-arg>-Xmx512m</jvm-arg>
+ <!--
+ - <jvm-arg>-agentlib:resin</jvm-arg>
+ -->
+
+ <!--
+ - If starting Resin as root on Unix, specify the user name
+ - and group name for the web server user.
+ -->
+ <resin:if test="${resin.userName == 'root'}">
+ <user-name>www-data</user-name>
+ <group-name>www-data</group-name>
+ </resin:if>
+ </server-default>
+
+ <!-- define the servers in the cluster -->
+ <server id="" address="127.0.0.1" port="6800">
+ <!-- server-specific configuration, e.g. jvm-arg goes here -->
+ </server>
+
+ <!-- the default host, matching any host name -->
+ <host id="" root-directory=".">
+ <!--
+ - configures an explicit root web-app matching the
+ - webapp's ROOT
+ -->
+ <web-app id="/" root-directory="webapps/ROOT"/>
+
+ <!--
+ - Administration application /resin-admin
+ -->
+ <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin">
+ <prologue>
+ <resin:set var="resin_admin_external" value="false"/>
+ <resin:set var="resin_admin_insecure" value="true"/>
+ </prologue>
+ </web-app>
+
+ <!--
+ - Resin documentation - remove for a live site
+ -->
+ <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
+
+ <!--
+ - <resin:LoadBalance regexp="^/load" cluster="backend-tier"/>
+ - <resin:HttpProxy regexp="^/http" address="localhost:9000"/>
+ - <resin:FastCgiProxy regexp="^/fcgi" address="localhost:9001"/>
+ -->
+ </host>
+ </cluster>
+</resin>
+
View
1 lib/.svnignore
@@ -0,0 +1 @@
+
View
3 modules/hessian/src/com/caucho/hessian/client/HessianProxy.java
@@ -95,9 +95,6 @@ protected HessianProxy(URL url,
_factory = factory;
_url = url;
_type = type;
-
- if (type == null)
- Thread.dumpStack();
}
/**
View
7 modules/hessian/src/com/caucho/hessian/io/AbstractDeserializer.java
@@ -128,6 +128,13 @@ public Object createField(String name)
return name;
}
+ public Object readObject(AbstractHessianInput in,
+ String []fieldNames)
+ throws IOException
+ {
+ return readObject(in, (Object []) fieldNames);
+ }
+
/**
* Reads an object instance from the input stream
*/
View
4 modules/hessian/src/com/caucho/hessian/io/AnnotationDeserializer.java
@@ -109,9 +109,11 @@ public Object readMap(AbstractHessianInput in)
}
public Object readObject(AbstractHessianInput in,
- String []fieldNames)
+ Object []fields)
throws IOException
{
+ String []fieldNames = (String []) fields;
+
try {
int ref = in.addRef(null);
View
4 modules/hessian/src/com/caucho/hessian/io/Deserializer.java
@@ -101,4 +101,8 @@ public Object readMap(AbstractHessianInput in)
public Object readObject(AbstractHessianInput in,
Object []fields)
throws IOException;
+
+ public Object readObject(AbstractHessianInput in,
+ String []fieldNames)
+ throws IOException;
}
View
4 modules/hessian/src/com/caucho/hessian/io/EnumDeserializer.java
@@ -104,9 +104,11 @@ public Object readMap(AbstractHessianInput in)
return obj;
}
- public Object readObject(AbstractHessianInput in, String []fieldNames)
+ @Override
+ public Object readObject(AbstractHessianInput in, Object []fields)
throws IOException
{
+ String []fieldNames = (String []) fields;
String name = null;
for (int i = 0; i < fieldNames.length; i++) {
View
59 modules/hessian/src/com/caucho/hessian/io/Hessian2Input.java
@@ -2154,12 +2154,17 @@ private void readObjectDefinition(Class<?> cl)
Deserializer reader = factory.getObjectDeserializer(type, null);
Object []fields = reader.createFields(len);
+ String []fieldNames = new String[len];
for (int i = 0; i < len; i++) {
- fields[i] = reader.createField(readString());
+ String name = readString();
+
+ fields[i] = reader.createField(name);
+ fieldNames[i] = name;
}
- ObjectDefinition def = new ObjectDefinition(type, reader, fields);
+ ObjectDefinition def
+ = new ObjectDefinition(type, reader, fields, fieldNames);
_classDefs.add(def);
}
@@ -2177,7 +2182,7 @@ private Object readObjectInstance(Class<?> cl,
if (cl != reader.getType() && cl != null) {
reader = factory.getObjectDeserializer(type, cl);
- return reader.readObject(this, fields);
+ return reader.readObject(this, def.getFieldNames());
}
else {
return reader.readObject(this, fields);
@@ -2805,15 +2810,16 @@ protected IOException expect(String expect, int ch)
try {
int offset = _offset;
- String context = new String(_buffer, 0, _length, "ISO-8859-1");
+ String context
+ = buildDebugContext(_buffer, 0, _length, offset);
Object obj = readObject();
if (obj != null) {
return error("expected " + expect
+ " at 0x" + Integer.toHexString(ch & 0xff)
+ " " + obj.getClass().getName() + " (" + obj + ")"
- + "\n offset=" + offset + "\n context[" + context + "]");
+ + "\n " + context + "");
}
else
return error("expected " + expect
@@ -2826,6 +2832,39 @@ protected IOException expect(String expect, int ch)
}
}
}
+
+ private String buildDebugContext(byte []buffer, int offset, int length,
+ int errorOffset)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("[");
+ for (int i = 0; i < errorOffset; i++) {
+ int ch = buffer[offset + i];
+ addDebugChar(sb, ch);
+ }
+ sb.append("] ");
+ addDebugChar(sb, buffer[offset + errorOffset]);
+ sb.append(" [");
+ for (int i = errorOffset + 1; i < length; i++) {
+ int ch = buffer[offset + i];
+ addDebugChar(sb, ch);
+ }
+ sb.append("]");
+
+ return sb.toString();
+ }
+
+ private void addDebugChar(StringBuilder sb, int ch)
+ {
+ if (ch >= 0x20 && ch < 0x7f) {
+ sb.append((char) ch);
+ }
+ else if (ch == '\n')
+ sb.append((char) ch);
+ else
+ sb.append(String.format("\\x%02x", ch & 0xff));
+ }
protected String codeName(int ch)
{
@@ -2894,14 +2933,17 @@ public void close()
private final String _type;
private final Deserializer _reader;
private final Object []_fields;
+ private final String []_fieldNames;
ObjectDefinition(String type,
Deserializer reader,
- Object []fields)
+ Object []fields,
+ String []fieldNames)
{
_type = type;
_reader = reader;
_fields = fields;
+ _fieldNames = fieldNames;
}
String getType()
@@ -2918,6 +2960,11 @@ Deserializer getReader()
{
return _fields;
}
+
+ String []getFieldNames()
+ {
+ return _fieldNames;
+ }
}
static {
View
7 modules/hessian/src/com/caucho/hessian/io/HessianOutput.java
@@ -285,6 +285,11 @@ public void writeHeader(String name)
public void writeFault(String code, String message, Object detail)
throws IOException
{
+ // hessian/3525
+ os.write('r');
+ os.write(1);
+ os.write(0);
+
os.write('f');
writeString("code");
writeString(code);
@@ -297,6 +302,8 @@ public void writeFault(String code, String message, Object detail)
writeObject(detail);
}
os.write('z');
+
+ os.write('z');
}
/**
View
5 modules/hessian/src/com/caucho/hessian/io/SqlDateDeserializer.java
@@ -100,9 +100,12 @@ public Object readMap(AbstractHessianInput in)
return value;
}
- public Object readObject(AbstractHessianInput in, String []fieldNames)
+ public Object readObject(AbstractHessianInput in,
+ Object []fields)
throws IOException
{
+ String []fieldNames = (String []) fields;
+
int ref = in.addRef(null);
long initValue = Long.MIN_VALUE;
View
76 modules/hessian/src/com/caucho/hessian/io/UnsafeDeserializer.java
@@ -71,6 +71,7 @@
= Logger.getLogger(JavaDeserializer.class.getName());
private static boolean _isEnabled;
+ @SuppressWarnings("restriction")
private static Unsafe _unsafe;
private Class<?> _type;
@@ -156,6 +157,24 @@ public Object readObject(AbstractHessianInput in,
}
}
+ @Override
+ public Object readObject(AbstractHessianInput in,
+ String []fieldNames)
+ throws IOException
+ {
+ try {
+ Object obj = instantiate();
+
+ return readObject(in, obj, fieldNames);
+ } catch (IOException e) {
+ throw e;
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOExceptionWrapper(_type.getName() + ":" + e.getMessage(), e);
+ }
+ }
+
/**
* Returns the readResolve method
*/
@@ -233,6 +252,36 @@ public Object readObject(AbstractHessianInput in,
}
}
+ public Object readObject(AbstractHessianInput in,
+ Object obj,
+ String []fieldNames)
+ throws IOException
+ {
+ try {
+ int ref = in.addRef(obj);
+
+ for (String fieldName : fieldNames) {
+ FieldDeserializer reader = _fieldMap.get(fieldName);
+
+ if (reader != null)
+ reader.deserialize(in, obj);
+ else
+ in.readObject();
+ }
+
+ Object resolve = resolve(in, obj);
+
+ if (obj != resolve)
+ in.setRef(ref, resolve);
+
+ return resolve;
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOExceptionWrapper(obj.getClass().getName() + ":" + e, e);
+ }
+ }
+
protected Object resolve(AbstractHessianInput in, Object obj)
throws Exception
{
@@ -250,6 +299,7 @@ protected Object resolve(AbstractHessianInput in, Object obj)
return obj;
}
+ @SuppressWarnings("restriction")
protected Object instantiate()
throws Exception
{
@@ -337,7 +387,7 @@ abstract void deserialize(AbstractHessianInput in, Object obj)
throws IOException;
}
- static class NullFieldDeserializer {
+ static class NullFieldDeserializer extends FieldDeserializer {
static NullFieldDeserializer DESER = new NullFieldDeserializer();
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
@@ -350,12 +400,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
ObjectFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -375,12 +427,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
BooleanFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -400,12 +454,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
ByteFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -425,12 +481,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
CharFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -457,12 +515,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
ShortFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -482,12 +542,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
IntFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -507,12 +569,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
LongFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -532,6 +596,7 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
FloatFieldDeserializer(Field field)
{
_field = field;
@@ -563,6 +628,7 @@ void deserialize(AbstractHessianInput in, Object obj)
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -582,12 +648,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
StringFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -607,12 +675,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
SqlDateFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -633,12 +703,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
SqlTimestampFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
@@ -659,12 +731,14 @@ void deserialize(AbstractHessianInput in, Object obj)
private final Field _field;
private final long _offset;
+ @SuppressWarnings("restriction")
SqlTimeFieldDeserializer(Field field)
{
_field = field;
_offset = _unsafe.objectFieldOffset(_field);
}
+ @SuppressWarnings("restriction")
void deserialize(AbstractHessianInput in, Object obj)
throws IOException
{
View
12 modules/hessian/src/com/caucho/hessian/server/HessianSkeleton.java
@@ -275,7 +275,7 @@ else if (method == null) {
return;
}
- Class []args = method.getParameterTypes();
+ Class<?> []args = method.getParameterTypes();
if (argLength != args.length && argLength >= 0) {
out.writeFault("NoSuchMethod",
@@ -288,18 +288,20 @@ else if (method == null) {
Object []values = new Object[args.length];
for (int i = 0; i < args.length; i++) {
+ // XXX: needs Marshal object
values[i] = in.readObject(args[i]);
}
Object result = null;
try {
result = method.invoke(service, values);
- } catch (Throwable e) {
- if (e instanceof InvocationTargetException)
- e = ((InvocationTargetException) e).getTargetException();
+ } catch (Exception e) {
+ Throwable e1 = e;
+ if (e1 instanceof InvocationTargetException)
+ e1 = ((InvocationTargetException) e).getTargetException();
- log.log(Level.FINE, this + " " + e.toString(), e);
+ log.log(Level.FINE, this + " " + e1.toString(), e1);
out.writeFault("ServiceException", e.getMessage(), e);
out.close();
View
1 modules/kernel/src/com/caucho/vfs/HttpStream.java
@@ -764,6 +764,7 @@ else if (! line.startsWith("HTTP/1.1 "))
_isKeepalive = false;
_attributes.put("status", String.valueOf(status));
+ _attributes.put("status-message", line.toString());
CharBuffer key = new CharBuffer();
while (true) {

0 comments on commit f79a0cb

Please sign in to comment.