jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1171197 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: CommitMessage.java QBinaryValue.java RepositoryServiceImpl.java
Date Thu, 15 Sep 2011 17:55:22 GMT
Author: mduerig
Date: Thu Sep 15 17:55:22 2011
New Revision: 1171197

URL: http://svn.apache.org/viewvc?rev=1171197&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: use cast function instead of explicit casts wherever casting is provable correct


Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/QBinaryValue.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java?rev=1171197&r1=1171196&r2=1171197&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/CommitMessage.java
Thu Sep 15 17:55:22 2011
@@ -1,6 +1,7 @@
 package org.apache.jackrabbit.spi2microkernel;
 
 
+import org.apache.jackrabbit.spi.commons.util.Unchecked;
 import org.apache.jackrabbit.util.Text;
 
 public class CommitMessage {
@@ -58,7 +59,7 @@ public class CommitMessage {
 
     @Override
     public boolean equals(Object other) {
-        return other == this || other instanceof CommitMessage && ((CommitMessage)
other).equals(this);
+        return other == this || other instanceof CommitMessage && equals(Unchecked.<CommitMessage>cast(other));
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/QBinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/QBinaryValue.java?rev=1171197&r1=1171196&r2=1171197&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/QBinaryValue.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/QBinaryValue.java
Thu Sep 15 17:55:22 2011
@@ -37,6 +37,8 @@ import java.math.BigDecimal;
 import java.net.URI;
 import java.util.Calendar;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 public class QBinaryValue implements QValue {
     private final String blobId;
     private final MicroKernel microKernel;
@@ -214,7 +216,7 @@ public class QBinaryValue implements QVa
             return true;
         }
         if (obj instanceof QBinaryValue) {
-            QBinaryValue other = (QBinaryValue) obj;
+            QBinaryValue other = cast(obj);
             return blobId == null
                 ? other.blobId == null
                 : blobId.equals(other.blobId);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1171197&r1=1171196&r2=1171197&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Thu Sep 15 17:55:22 2011
@@ -124,6 +124,7 @@ import static org.apache.jackrabbit.spi.
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.REP_ROOT;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.ROOT;
 import static org.apache.jackrabbit.spi.commons.util.Maps.getOrElse;
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
 import static org.apache.jackrabbit.spi2microkernel.ItemInfos.buildItemInfos;
 
 public class RepositoryServiceImpl extends AbstractRepositoryService {
@@ -450,7 +451,7 @@ public class RepositoryServiceImpl exten
     @Override
     public void submit(Batch batch) throws RepositoryException {
         ChangeLog changeLog = changeLog(batch);
-        CommitBuilder commitBuilder = new CommitBuilder(changeLog.sessionInfo);
+        CommitBuilder commitBuilder = new CommitBuilder(sessionInfoImpl(changeLog.sessionInfo));
         changeLog.apply(commitBuilder);
         commitBuilder.commit();
     }
@@ -642,7 +643,7 @@ public class RepositoryServiceImpl exten
 
     private static SubscriptionImpl subscription(Subscription subscription) throws RepositoryException
{
         if (subscription instanceof SubscriptionImpl) {
-            return (SubscriptionImpl) subscription;
+            return cast(subscription);
         }
         else {
             throw new RepositoryException("Invalid subscription " + subscription);
@@ -651,13 +652,22 @@ public class RepositoryServiceImpl exten
 
     private static ChangeLog changeLog(Batch batch) throws RepositoryException {
         if (batch instanceof ChangeLog) {
-            return (ChangeLog) batch;
+            return cast(batch);
         }
         else {
             throw new RepositoryException("Invalid batch " + batch);
         }
     }
 
+    private static SessionInfoImpl sessionInfoImpl(SessionInfo sessionInfo) throws RepositoryException
{
+        if (sessionInfo instanceof SessionInfoImpl) {
+            return cast(sessionInfo);
+        }
+        else {
+            throw new RepositoryException("Invalid session " + sessionInfo);
+        }
+    }
+
     private SessionState sessionState(SessionInfo sessionInfo) throws RepositoryException
{
         SessionState state = sessions.get(sessionInfo);
 
@@ -741,11 +751,11 @@ public class RepositoryServiceImpl exten
 
     private class CommitBuilder implements Batch {
 
-        private final SessionInfo sessionInfo;
+        private final SessionInfoImpl sessionInfo;
 
         private final StringBuilder jsop = new StringBuilder();
 
-        public CommitBuilder(SessionInfo sessionInfo) {
+        public CommitBuilder(SessionInfoImpl sessionInfo) {
             this.sessionInfo = sessionInfo;
         }
 
@@ -857,7 +867,7 @@ public class RepositoryServiceImpl exten
                 public String call() {
                     String rev = microKernel.getHeadRevision();
                     String userId = sessionInfo.getUserID();
-                    String userData = ((SessionInfoImpl) sessionInfo).getUserData();
+                    String userData = sessionInfo.getUserData();
                     CommitMessage commitMessage = new CommitMessage(userId, userData == null
? "" : userData);
                     return microKernel.commit("/", jsop.toString(), rev, commitMessage.encode());
                 }



Mime
View raw message