jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r902780 - in /jackrabbit/sandbox/jcrlog: ./ src/main/java/org/apache/jackrabbit/jcrlog/ src/main/java/org/apache/jackrabbit/jcrlog/player/ src/test/java/org/apache/jackrabbit/jcrlog/samples/ src/test/java/org/apache/jackrabbit/jcrlog/test/u...
Date Mon, 25 Jan 2010 11:10:19 GMT
Author: thomasm
Date: Mon Jan 25 11:10:19 2010
New Revision: 902780

URL: http://svn.apache.org/viewvc?rev=902780&view=rev
Log:
JCR-2477 Log / trace wrapper: upgrade to JCR API 2.0

Removed:
    jackrabbit/sandbox/jcrlog/repository.xml
Modified:
    jackrabbit/sandbox/jcrlog/pom.xml
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java
    jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java
    jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java
    jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java

Modified: jackrabbit/sandbox/jcrlog/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/pom.xml?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/pom.xml (original)
+++ jackrabbit/sandbox/jcrlog/pom.xml Mon Jan 25 11:10:19 2010
@@ -20,18 +20,15 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                              http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <prerequisites>
-        <maven>2.0.4</maven>
-    </prerequisites>
     <groupId>org.apache.jackrabbit</groupId>
     <parent>
-        <groupId>org.apache.jackrabbit</groupId>
-        <artifactId>jackrabbit</artifactId>
-        <version>1.4</version>
-        <relativePath>../..</relativePath>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-parent</artifactId>
+      <version>2.1-SNAPSHOT</version>
+      <relativePath>../jackrabbit-parent/pom.xml</relativePath>
     </parent>
     <artifactId>jackrabbit-jcrlog</artifactId>
-    <version>1.4-SNAPSHOT</version>
+    <version>2.1-SNAPSHOT</version>
     <packaging>jar</packaging>
     <name>JCR log</name>
     <description>JCR log/trace wrapper</description>
@@ -39,13 +36,19 @@
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-core</artifactId>
-            <version>1.4.6</version>
-            <scope>provided</scope>
+            <version>2.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.4</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-api</artifactId>
-            <version>1.4</version>
+            <version>2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java (original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java Mon
Jan 25 11:10:19 2010
@@ -26,23 +26,15 @@
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Properties;
 import java.util.StringTokenizer;
-
 import javax.jcr.Credentials;
 import javax.jcr.ItemVisitor;
-import javax.jcr.RepositoryException;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
 import javax.jcr.Workspace;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.observation.EventListener;
-
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
-import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 
 /**
  * A collection of utility methods for the JCR API.
@@ -56,43 +48,7 @@
     static final String CLASSNAME = JcrUtils.class.getName();
 
     /**
-     * Register a node type.
-     * This is a utility method used while playing back a log file.
-     */
-    public static void registerNodeTypes(NodeTypeManager manager,
-            Collection coll) throws InvalidNodeTypeDefException,
-            RepositoryException {
-        if (manager instanceof NodeTypeManagerImpl) {
-            NodeTypeManagerImpl mgr = (NodeTypeManagerImpl) manager;
-            mgr.getNodeTypeRegistry().registerNodeTypes(coll);
-        } else if (manager instanceof LogObject) {
-            LogObject proxy = (LogObject) manager;
-            NodeTypeManagerImpl mgr = (NodeTypeManagerImpl)proxy.getObject();
-            mgr.getNodeTypeRegistry().registerNodeTypes(coll);
-            try {
-                String s = StringUtils.serializeToString(coll);
-                proxy.log(
-                        "registerNodeTypes(StringUtils.deserializeFromString(\""
-                                + s + "\"))", null);
-            } catch (Throwable t) {
-                proxy.log("Can't serialize collection: " + coll, t);
-            }
-        }
-    }
-
-    /**
-     * Cast a NodeTypeManager to a JackrabbitNodeTypeManager.
-     * This is a utility method used while playing back a log file.
-     *
-     * @param ntMgr
-     * @return the casted object
-     */
-    public static JackrabbitNodeTypeManager cast(NodeTypeManager ntMgr) {
-        return (JackrabbitNodeTypeManager)ntMgr;
-    }
-
-    /**
-     * Cast a NodeTypeManager to a JackrabbitNodeTypeManager.
+     * Cast a Workspace to a JackrabbitWorkspace.
      * This is a utility method used while playing back a log file.
      */
     public static JackrabbitWorkspace cast(Workspace ws) {

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java (original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java Mon Jan
25 11:10:19 2010
@@ -51,6 +51,7 @@
     private boolean castToRealApi = false;
     private boolean logStream = false;
     private boolean logException = false;
+    private boolean logThread = false;
 
     private static void createDirs(String fileName) throws IOException {
         File f = new File(fileName);
@@ -201,4 +202,12 @@
     void setLogException(boolean logException) {
         this.logException = logException;
     }
+
+    boolean getLogThread() {
+        return logThread;
+    }
+
+    void setLogThread(boolean logThread) {
+        this.logThread = logThread;
+    }
 }

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java (original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java Mon
Jan 25 11:10:19 2010
@@ -59,7 +59,6 @@
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
 
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 
 /**
@@ -90,11 +89,11 @@
 
     private static int nextArrayId;
 
-    private static final ArrayList INTERFACES = new ArrayList();
+    private static final ArrayList<InterfaceDef> INTERFACES = new ArrayList<InterfaceDef>();
 
-    private static final HashSet PREFIXES = new HashSet();
+    private static final HashSet<String> PREFIXES = new HashSet<String>();
 
-    private static final HashMap INTERFACE_MAP = new HashMap();
+    private static final HashMap<Class<?>, InterfaceDef> INTERFACE_MAP = new
HashMap<Class<?>, InterfaceDef>();
 
     static final InterfaceDef INTERFACE_DEF_REPOSITORY, INTERFACE_DEF_SESSION;
 
@@ -112,7 +111,7 @@
         addInterface("ni", NodeIterator.class);
         addInterface("nt", NodeType.class);
         addInterface("nti", NodeTypeIterator.class);
-        addInterface("jntm", JackrabbitNodeTypeManager.class);
+        // addInterface("jntm", JackrabbitNodeTypeManager.class);
         addInterface("ntm", NodeTypeManager.class);
         addInterface("om", ObservationManager.class);
         addInterface("p", Property.class);
@@ -135,7 +134,7 @@
         addInterface("ws", Workspace.class);
     }
 
-    static InterfaceDef addInterface(String prefix, Class clazz) {
+    static InterfaceDef addInterface(String prefix, Class<?> clazz) {
         if (PREFIXES.contains(prefix)) {
             throw new Error("Internal error: duplicate interface prefix "
                     + prefix);
@@ -254,7 +253,13 @@
     }
 
     private void logJava(String s) {
-        log.write("/**/" + s, null);
+        String message;
+        if (log.getLogThread()) {
+            message = "/*" + Thread.currentThread() + "*/" + s;
+        } else {
+            message = "/**/" + s;
+        }
+        log.write(message, null);
     }
 
     protected String getAssign(int type, int id, String call) {
@@ -263,7 +268,7 @@
     }
 
     private static InterfaceDef getInterfaceDef(int type) {
-        return (InterfaceDef) INTERFACES.get(type);
+        return INTERFACES.get(type);
     }
 
     protected void setLog(Log log, int type, int id) {
@@ -289,7 +294,7 @@
         log.write("//" + title + ": " + e.toString(), trace ? e : null);
     }
 
-    protected void logReturn(Class clazz, Object result) {
+    protected void logReturn(Class<?> clazz, Object result) {
         logReturn();
         if (log.getLogReturn()) {
             if (clazz == String.class
@@ -307,7 +312,7 @@
         return name;
     }
 
-    protected Object wrap(Object obj, boolean array, Class clazz,
+    protected Object wrap(Object obj, boolean array, Class<?> clazz,
             int assignType, int id) {
         if (array) {
             Object[] list = (Object[]) obj;
@@ -328,16 +333,16 @@
         }
     }
 
-    private Object wrapObject(Object obj, Class clazz, int id) {
+    private Object wrapObject(Object obj, Class<?> clazz, int id) {
         LogObject handler = new LogObject();
         handler.setLog(log, assignType, id);
         handler.obj = obj;
         InterfaceDef idef = getInterfaceDef(assignType);
 
-        Class proxyClass = idef.proxyClass;
+        Class<?> proxyClass = idef.proxyClass;
         if (proxyClass == null) {
             // hack for node/property
-            Class[] interfaces;
+            Class<?>[] interfaces;
             if (clazz == Item.class && obj instanceof Node) {
                 interfaces = new Class[]{clazz, Node.class};
             } else if (clazz == Item.class && obj instanceof Property) {
@@ -366,9 +371,9 @@
             if (method.getName().equals("toString")) {
                 return result = method.invoke(obj, args);
             }
-            Class returnClass = method.getReturnType();
+            Class<?> returnClass = method.getReturnType();
             int returnType = -1;
-            InterfaceDef idef = (InterfaceDef) INTERFACE_MAP.get(returnClass);
+            InterfaceDef idef = INTERFACE_MAP.get(returnClass);
             boolean array = false;
             if (idef != null) {
                 returnType = idef.type;
@@ -424,7 +429,7 @@
         }
     }
 
-    private void wrapStreams(Class[] parameterTypes, Object[] args) {
+    private void wrapStreams(Class<?>[] parameterTypes, Object[] args) {
         for (int i = 0; args != null && i < args.length; i++) {
             Object o = args[i];
             if (o == null || !(o instanceof InputStream)) {
@@ -436,15 +441,15 @@
         }
     }
 
-    static InterfaceDef getInterface(Class clazz) {
-        InterfaceDef idef = (InterfaceDef) INTERFACE_MAP.get(clazz);
+    static InterfaceDef getInterface(Class<?> clazz) {
+        InterfaceDef idef = INTERFACE_MAP.get(clazz);
         if (idef != null) {
             return idef;
         }
-        Class[] interfaces = clazz.getInterfaces();
+        Class<?>[] interfaces = clazz.getInterfaces();
         InterfaceDef best = null;
         for (int i = 0; i < interfaces.length; i++) {
-            idef = (InterfaceDef) INTERFACE_MAP.get(interfaces[i]);
+            idef = INTERFACE_MAP.get(interfaces[i]);
             if (idef != null) {
                 if (best == null || idef.className.length() > best.className.length())
{
                     best = idef;
@@ -465,10 +470,10 @@
     static class InterfaceDef {
 
         String className;
-        Class interfaceClass;
+        Class<?> interfaceClass;
         String prefix;
         int nextId;
-        Class proxyClass;
+        Class<?> proxyClass;
         int type;
     }
 

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
Mon Jan 25 11:10:19 2010
@@ -16,13 +16,9 @@
  */
 package org.apache.jackrabbit.jcrlog;
 
-import java.io.IOException;
-
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 
-import org.apache.jackrabbit.core.TransientRepository;
-
 /**
  * This is an idea how opening a repository could be made vendor-independent.
  * Only one conrecte class (this one) needs to be provided by the JCR API. The
@@ -32,6 +28,8 @@
  *
  */
 public class RepositoryFactory {
+
+    static final String JACKRABBIT_TRANSIENT_REPOS = "org.apache.jackrabbit.core.TransientRepository";
     static final String CLASSNAME = RepositoryFactory.class.getName();
 
     /**
@@ -46,14 +44,15 @@
             url = url.substring("apache/jackrabbit/".length());
             if (url.equals("transient")) {
                 try {
-                    return new TransientRepository();
-                } catch (IOException e) {
+                    Class<?> tc = Class.forName(JACKRABBIT_TRANSIENT_REPOS);
+                    return (Repository) tc.newInstance();
+                } catch (Exception e) {
                     RepositoryException re = new RepositoryException(
-                            "Error creating TransientRepository");
+                        "Error creating TransientRepository");
                     re.initCause(e);
                     throw re;
                 }
-            } else if (url.startsWith("logger/")) {
+        } else if (url.startsWith("logger/")) {
                 url = url.substring("logger/".length());
                 return RepositoryLogger.open(url);
             } else {

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java
Mon Jan 25 11:10:19 2010
@@ -22,8 +22,7 @@
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-
-import org.apache.jackrabbit.core.TransientRepository;
+import javax.jcr.Value;
 
 /**
  * The public Repository object of the wrapper. Actually does not need to be
@@ -71,7 +70,7 @@
     public static Repository wrap(Repository repository, String settings)
             throws RepositoryException {
         String url;
-        if (repository instanceof TransientRepository) {
+        if (repository.getClass().toString().equals(RepositoryFactory.JACKRABBIT_TRANSIENT_REPOS))
{
             url = "apache/jackrabbit/transient";
         } else {
             // TODO support other repositories
@@ -95,12 +94,14 @@
         String cast = prop.getProperty("cast");
         String stream = prop.getProperty("stream");
         String exception = prop.getProperty("exception");
+        String thread = prop.getProperty("thread");
         Log log = new Log(fileName, parseBoolean(sysOut));
         log.setLogCaller(parseBoolean(logCaller));
         log.setLogReturn(parseBoolean(logReturn));
         log.setCastToRealApi(parseBoolean(cast));
         log.setLogStream(parseBoolean(stream));
         log.setLogException(parseBoolean(exception));
+        log.setLogThread(parseBoolean(thread));
         String call = RepositoryFactory.CLASSNAME + ".open("
                 + StringUtils.quoteString(url) + ");";
         int nextId = getNextId(LogObject.INTERFACE_DEF_REPOSITORY.type);
@@ -169,6 +170,62 @@
     /**
      * {@inheritDoc}
      */
+    public boolean isStandardDescriptor(String key) {
+        try {
+            logStart(-1, false, "isStandardDescriptor", StringUtils.quoteString(key));
+            boolean result = repository.isStandardDescriptor(key);
+            logReturn(Boolean.class, result);
+            return result;
+        } catch (Throwable t) {
+            throw logRuntimeException(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isSingleValueDescriptor(String key) {
+        try {
+            logStart(-1, false, "isSingleValueDescriptor", StringUtils.quoteString(key));
+            boolean result = repository.isSingleValueDescriptor(key);
+            logReturn(Boolean.class, result);
+            return result;
+        } catch (Throwable t) {
+            throw logRuntimeException(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Value getDescriptorValue(String key) {
+        try {
+            logStart(-1, false, "getDescriptorValue", StringUtils.quoteString(key));
+            Value result = repository.getDescriptorValue(key);
+            logReturn(Value.class, result);
+            return result;
+        } catch (Throwable t) {
+            throw logRuntimeException(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Value[] getDescriptorValues(String key) {
+        try {
+            logStart(-1, false, "getDescriptorValues", StringUtils.quoteString(key));
+            Value[] result = repository.getDescriptorValues(key);
+            logReturn(Value[].class, result);
+            return result;
+        } catch (Throwable t) {
+            throw logRuntimeException(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public Session login() throws RepositoryException {
         try {
             int assignType = LogObject.INTERFACE_DEF_SESSION.type;

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java
Mon Jan 25 11:10:19 2010
@@ -51,7 +51,7 @@
         if (s.length() == 0) {
             return new String[0];
         }
-        ArrayList list = new ArrayList();
+        ArrayList<String> list = new ArrayList<String>();
         StringBuffer buff = new StringBuffer(s.length());
         for (int i = 0; i < s.length(); i++) {
             char c = s.charAt(i);
@@ -215,7 +215,7 @@
         return "\"" + javaEncode(result) + "\"";
     }
 
-    static String quoteArray(Class clazz, String name, Object[] array) {
+    static String quoteArray(Class<?> clazz, String name, Object[] array) {
         if (array == null) {
             return "null";
         }
@@ -281,7 +281,7 @@
         }
     }
 
-    static String quoteArgs(Class[] argClasses, Object[] args) {
+    static String quoteArgs(Class<?>[] argClasses, Object[] args) {
         if (args == null) {
             return "";
         }
@@ -333,7 +333,7 @@
      * @param o the object
      * @return the formatted string
      */
-    public static String quote(Class clazz, Object o) {
+    public static String quote(Class<?> clazz, Object o) {
         if (o == null) {
             if (clazz == void.class) {
                 return "";
@@ -353,7 +353,7 @@
             } else if (o instanceof long[]) {
                 return quoteLongArray((long[]) o);
             } else {
-                Class ct = o.getClass().getComponentType();
+                Class<?> ct = o.getClass().getComponentType();
                 LogObject.InterfaceDef idef = LogObject.getInterface(ct);
                 if (idef == null) {
                     throw new Error("unsupported class: " + o.getClass());

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java (original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java Mon
Jan 25 11:10:19 2010
@@ -26,11 +26,11 @@
  */
 class Arg {
     private Player player;
-    private Class clazz;
+    private Class<?> clazz;
     private Object obj;
     private Statement stat;
 
-    Arg(Player player, Class clazz, Object obj) {
+    Arg(Player player, Class<?> clazz, Object obj) {
         this.player = player;
         this.clazz = clazz;
         this.obj = obj;
@@ -57,7 +57,7 @@
         }
     }
 
-    Class getValueClass() {
+    Class<?> getValueClass() {
         return clazz;
     }
 

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java
Mon Jan 25 11:10:19 2010
@@ -216,7 +216,7 @@
                     read("[");
                     read("]");
                     read("{");
-                    ArrayList values = new ArrayList();
+                    ArrayList<Object> values = new ArrayList<Object>();
                     do {
                         values.add(parseValue().getValue());
                     } while (readIf(","));
@@ -227,7 +227,7 @@
                 } else if (readIf("Value")) {
                     read("[");
                     read("]");
-                    ArrayList values = new ArrayList();
+                    ArrayList<Object> values = new ArrayList<Object>();
                     read("{");
                     do {
                         values.add(parseValue());
@@ -264,7 +264,7 @@
             className = "[L" + className + ";";
             read(")");
             read("null");
-            Class c = Player.getClass(className);
+            Class<?> c = Player.getClass(className);
             return new Arg(player, c, null);
         } else {
             throw new Error("Expected value, got: " + readToken() + " in "
@@ -281,7 +281,7 @@
 
     private void parseCall(String objectName, Object o, String methodName) {
         stat.setMethodCall(objectName, o, methodName);
-        ArrayList args = new ArrayList();
+        ArrayList<Arg> args = new ArrayList<Arg>();
         read("(");
         while (true) {
             if (readIf(")")) {

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java
Mon Jan 25 11:10:19 2010
@@ -35,8 +35,8 @@
     private final static String[] IMPORTED_PACKAGES = { "", "java.lang.",
             "java.util.", "javax.jcr.", LogObject.MY_PACKAGE_DOT };
 
-    private HashMap objects = new HashMap();
-    private HashMap uuidMap = new HashMap();
+    private HashMap<String, Object> objects = new HashMap<String, Object>();
+    private HashMap<String, String> uuidMap = new HashMap<String, String>();
     private String lastUUID;
     private String lastReturn;
     private boolean checkResults;
@@ -90,7 +90,7 @@
 
     void addUUID(String oldId, String newId) {
         if (StringUtils.isUUID(oldId) && StringUtils.isUUID(newId)) {
-            String previous = (String) uuidMap.put(oldId, newId);
+            String previous = uuidMap.put(oldId, newId);
             if (previous != null && !previous.equals(newId)) {
                 log("Duplicate UUID mapping, old:" + oldId + " last:" + previous + " now:"
+ newId);
             }
@@ -99,7 +99,7 @@
 
     String getUUID(String oldId) {
         if (StringUtils.isUUID(oldId)) {
-            return (String) uuidMap.get(oldId);
+            return uuidMap.get(oldId);
         }
         return oldId;
     }
@@ -187,7 +187,7 @@
         }
     }
 
-    static Class getClass(String className) {
+    static Class<?> getClass(String className) {
         for (int i = 0; i < IMPORTED_PACKAGES.length; i++) {
             try {
                 return Class.forName(IMPORTED_PACKAGES[i] + className);

Modified: jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java
Mon Jan 25 11:10:19 2010
@@ -48,13 +48,13 @@
 
     private Arg[] args;
 
-    private Class[] parameterTypes;
+    private Class<?>[] parameterTypes;
 
     private Object[] parameters;
 
     private Method method;
 
-    private Class returnClass;
+    private Class<?> returnClass;
 
     private Object returnObject;
 
@@ -62,13 +62,13 @@
         this.player = player;
     }
 
-    private Method findMethod(Class clazz) throws Exception {
+    private Method findMethod(Class<?> clazz) throws Exception {
         if ((clazz.getModifiers() & Modifier.PUBLIC) == 0) {
             // http://forum.java.sun.com/thread.jspa?threadID=704100&messageID=4084720
             // bug 4071957
-            Class[] interfaces = clazz.getInterfaces();
+            Class<?>[] interfaces = clazz.getInterfaces();
             for (int i = 0; i < interfaces.length; i++) {
-                Class c = interfaces[i];
+                Class<?> c = interfaces[i];
                 if (c.getName().startsWith("javax.")) {
                     try {
                         return c.getMethod(methodName, parameterTypes);
@@ -86,7 +86,7 @@
             for (int i = 0; i < methods.length; i++) {
                 Method m = methods[i];
                 if (methodName.equals(m.getName())) {
-                    Class[] argClasses = m.getParameterTypes();
+                    Class<?>[] argClasses = m.getParameterTypes();
                     for (int j = 0; j < args.length; j++) {
                         if (!argClasses[j].isAssignableFrom(args[j].getValueClass())) {
                             continue methods;
@@ -109,7 +109,7 @@
             }
             return;
         }
-        Class clazz;
+        Class<?> clazz;
         if (staticCall) {
             if (staticCallClass == null || staticCallClass.length() == 0
                     || !staticCallClass.startsWith("org.")) {
@@ -174,7 +174,7 @@
         return buff.toString();
     }
 
-    Class getReturnClass() {
+    Class<?> getReturnClass() {
         return returnClass;
     }
 
@@ -199,7 +199,7 @@
         this.methodName = methodName;
     }
 
-    public void setArgs(ArrayList list) {
+    public void setArgs(ArrayList<Arg> list) {
         args = new Arg[list.size()];
         list.toArray(args);
     }

Modified: jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java
Mon Jan 25 11:10:19 2010
@@ -16,8 +16,7 @@
  */
 package org.apache.jackrabbit.jcrlog.samples;
 
-import java.io.FileInputStream;
-
+import java.io.InputStream;
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -28,7 +27,6 @@
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
-
 import org.apache.jackrabbit.jcrlog.RepositoryFactory;
 
 /**
@@ -58,7 +56,7 @@
                 // Create an unstructured node under which to import the XML
                 root.addNode("importxml", "nt:unstructured");
                 // Import the file "test.xml" under the created node
-                FileInputStream xml = new FileInputStream("test.xml");
+                InputStream xml = Class.class.getClassLoader().getResourceAsStream("test.xml");
                 session.importXML(
                     "/importxml", xml, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
                 xml.close();

Modified: jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java?rev=902780&r1=902779&r2=902780&view=diff
==============================================================================
--- jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java
(original)
+++ jackrabbit/sandbox/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java
Mon Jan 25 11:10:19 2010
@@ -16,9 +16,11 @@
  */
 package org.apache.jackrabbit.jcrlog.test.unit;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.jcrlog.RepositoryFactory;
 import org.apache.jackrabbit.jcrlog.player.Player;
 
+import java.io.File;
 import java.io.IOException;
 
 import javax.jcr.Node;
@@ -46,12 +48,21 @@
     }
 
     public void test() throws Exception {
+        stepDeleteFiles();
         stepCleanRepository();
         stepRunApp();
         stepCheckResults();
         stepCleanRepository();
         stepReplayLog();
         stepCheckResults();
+        stepDeleteFiles();
+    }
+
+    private void stepDeleteFiles() throws IOException {
+        new File("repository.xml").delete();
+        new File("test.txt").delete();
+        new File("derby.log").delete();
+        FileUtils.deleteDirectory(new File("repository"));
     }
 
     private Session login(Repository repository) throws RepositoryException {



Mime
View raw message