You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2013/03/03 02:24:09 UTC
svn commit: r1451981 - in
/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river:
api/io/Distributed.java api/io/DistributedObjectInputStream.java
api/io/SerialFactory.java api/io/SerialReflectionFactory.java
impl/net/UriString.java
Author: peter_firmstone
Date: Sun Mar 3 01:24:09 2013
New Revision: 1451981
URL: http://svn.apache.org/r1451981
Log:
Fix UriString normalisation, related to test failure of com/sun/jini/test/impl/start/CodebaseTest.td on OSX.
Refactor Distributed, renamed SerialFactory to SerialReflectionFactory to more accurately describe function.
Improved performance of SerialReflectionFactory, by serialising primitive Object parameters as primitives instead of objects.
Added:
river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialReflectionFactory.java
- copied, changed from r1451832, river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialFactory.java
Removed:
river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialFactory.java
Modified:
river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/Distributed.java
river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/DistributedObjectInputStream.java
river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java
Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/Distributed.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/Distributed.java?rev=1451981&r1=1451980&r2=1451981&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/Distributed.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/Distributed.java Sun Mar 3 01:24:09 2013
@@ -27,7 +27,7 @@ package org.apache.river.api.io;
* but must always share a common public interface or superclass for referential
* purposes.
* <p>
- * Distributed objects have no version, instead SerialFactory contains all
+ * Distributed objects have no version, instead SerialReflectionFactory contains all
* information required to distribute and recreate any Distributed Object using
* reflection.
* <p>
@@ -45,13 +45,13 @@ package org.apache.river.api.io;
public interface Distributed {
/**
- * Substitutes an Object in an ObjectOutput with a SerialFactory,
- * ObjectInput uses SerialFactory to reconstruct the Object at the
+ * Substitutes an Object in an ObjectOutput with a SerialReflectionFactory,
+ * ObjectInput uses SerialReflectionFactory to reconstruct the Object at the
* remote end using reflection to call a constructor, static method or
* object method.
*
- * @return SerialFactory for object instantiation using reflection to call
- * a constructor, static method or object method.
+ * @return SerialReflectionFactory for object remote instantiation using
+ * reflection to call a constructor, static method or object method.
*/
- SerialFactory substitute();
+ SerialReflectionFactory substitute();
}
Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/DistributedObjectInputStream.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/DistributedObjectInputStream.java?rev=1451981&r1=1451980&r2=1451981&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/DistributedObjectInputStream.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/DistributedObjectInputStream.java Sun Mar 3 01:24:09 2013
@@ -50,7 +50,7 @@ public class DistributedObjectInputStrea
}
protected final Object resolveObject(Object o) throws IOException{
- if (o instanceof SerialFactory) return ((SerialFactory)o).create();
+ if (o instanceof SerialReflectionFactory) return ((SerialReflectionFactory)o).create();
return o;
}
Copied: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialReflectionFactory.java (from r1451832, river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialFactory.java)
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialReflectionFactory.java?p2=river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialReflectionFactory.java&p1=river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialFactory.java&r1=1451832&r2=1451981&rev=1451981&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialFactory.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/io/SerialReflectionFactory.java Sun Mar 3 01:24:09 2013
@@ -27,8 +27,8 @@ import java.lang.reflect.Method;
import java.security.Guard;
/**
- * Distributed form, required for reflective calls to instantiate remotely,
- * using constructor, static method or Object method.
+ * Distributed form, required for reflective calls to instantiate objects remotely,
+ * using a constructor, static method or an Object method.
*
* This object must be Thread confined, it is not thread safe.
*
@@ -38,7 +38,7 @@ import java.security.Guard;
* @see Distributed
* @see DistributePermission
*/
-public final class SerialFactory implements Externalizable {
+public final class SerialReflectionFactory implements Externalizable {
private static final long serialVersionUID = 1L;
/* Guard private state */
private static final Guard distributable = new DistributePermission();
@@ -70,42 +70,37 @@ public final class SerialFactory impleme
private final boolean constructed; // default value is false.
/**
- * Public method provided for serialization framework.
+ * Public method provided for java serialization framework.
*/
- public SerialFactory(){
+ public SerialReflectionFactory(){
constructed = false;
}
/**
* Reflection is used at the remote end, with information provided to
- * SerialFactory, to call a constructor, static method
- * or object method after de-serialization by DistributedObjectInputStream.
+ * SerialReflectionFactory, to call a constructor, static method
+ * or an object method after de-serialization by DistributedObjectInputStream.
* <p>
- * Information given to SerialFactory is guarded by DistributePermission.
+ * Information given to SerialReflectionFactory is guarded by DistributePermission.
* <p>
- * Instantiation of Distributed object at remote ends proceeds as follows:
+ * Instantiation of a Distributed object at a remote endpoint proceeds as follows:
* <ul><li>
* If factoryClassOrObject is a Class and methodName is null, a constructor
* of that Class is called reflectively with parameterTypes and parameters.
* </li><li>
* If factoryClassOrObject is a Class and methodName is defined, a static
- * method with the defined name is called reflectively on that Class with
+ * method with that name is called reflectively on that Class with
* parameterTypes and parameters.
* </li><li>
* If factoryClassOrObject is an Object and methodName is defined, a method
- * with the defined name is called reflectively on that Object with
+ * with that name is called reflectively on that Object with
* parameterTypes and parameters.
* </li></ul>
* <p>
* Tip: Object versions of primitive values and String parameters
- * are relatively fast as are primitive array parameters.
- * Object versions of primitive parameters are externalized
- * as primitives, arrays of Object's are treated as object parameters.
- * <p>
- * If you really need ultimate serialization performance, consider using a
- * constructor that accepts a single parameter byte[] array.
- * Remember to compress your bytes, this will minimize the size of the
- * byte stream.
+ * are relatively fast as are primitive arrays.
+ * Object versions of primitive parameters are writen to DataOutput
+ * as primitives.
* <p>
*
* @param factoryClassOrObject will be used for constructor, factory static method,
@@ -115,7 +110,7 @@ public final class SerialFactory impleme
* @param parameters array of Objects to be passed to constructor, or null.
* @see DistributePermission
*/
- public SerialFactory(Object factoryClassOrObject, String methodName, Class[] parameterTypes, Object [] parameters){
+ public SerialReflectionFactory(Object factoryClassOrObject, String methodName, Class[] parameterTypes, Object [] parameters){
classOrObject = factoryClassOrObject;
method = methodName;
this.parameterTypes = parameterTypes;
@@ -260,7 +255,6 @@ public final class SerialFactory impleme
}
- @Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
if (constructed) throw new IllegalStateException("Object already constructed");
/* Don't defensively copy arrays, the object is used immediately after
Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java?rev=1451981&r1=1451980&r2=1451981&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java Sun Mar 3 01:24:09 2013
@@ -403,24 +403,24 @@ public class UriString {
escIndex = i;
continue;
}
- if (escIndex > 0 && i > escIndex && i < escIndex + 3 ){
- if (index(numeric, hos[i]) > 0) {
+ if (escIndex > -1 && i > escIndex && i < escIndex + 3 ){
+ if (index(numeric, hos[i]) > -1) {
sb.append(hos[i]);
continue;
}
- if (index(upalpha, hos[i]) > 0){
+ if (index(upalpha, hos[i]) > -1){
sb.append(hos[i]);
continue;
}
int n = index(lowalpha, hos[i]);
- if (n > 0){
+ if (n > -1){
sb.append(upalpha[n]);
continue;
}
throw new URISyntaxException(host, "host contains escaped sequence that has an illegal character at index " + i);
}
int n = index(upalpha, hos[i]);
- if (n > 0) {
+ if (n > -1) {
sb.append(lowalpha[n]);
continue;
}
@@ -474,17 +474,17 @@ public class UriString {
escIndex = i;
continue;
}
- if (escIndex > 0 && i > escIndex && i < escIndex + 3 ){
- if (index(numeric, pth[i]) > 0) {
+ if (escIndex > -1 && i > escIndex && i < escIndex + 3 ){
+ if (index(numeric, pth[i]) > -1) {
sb.append(pth[i]);
continue;
}
- if (index(upalpha, pth[i]) > 0){
+ if (index(upalpha, pth[i]) > -1){
sb.append(pth[i]);
continue;
}
int n = index(lowalpha, pth[i]);
- if (n > 0){
+ if (n > -1){
sb.append(upalpha[n]);
continue;
}