jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r784691 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ persistence/bundle/util/ value/ xml/
Date Mon, 15 Jun 2009 08:44:37 GMT
Author: thomasm
Date: Mon Jun 15 08:44:36 2009
New Revision: 784691

URL: http://svn.apache.org/viewvc?rev=784691&view=rev
Log:
JCR-2149 Data Store: remove kill switch "InternalValue.USE_DATA_STORE"

Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBValue.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=784691&r1=784690&r2=784691&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Mon Jun 15 08:44:36 2009
@@ -296,9 +296,6 @@
             ntReg = createNodeTypeRegistry(nsReg, new BasedFileSystem(repStore, "/nodetypes"));
 
             dataStore = repConfig.getDataStore();
-            if (dataStore != null) {
-                assert InternalValue.USE_DATA_STORE;
-            }
 
             // init workspace configs
             Iterator iter = repConfig.getWorkspaceConfigs().iterator();
@@ -315,7 +312,7 @@
                 clusterNode = createClusterNode();
                 nsReg.setEventChannel(clusterNode);
                 ntReg.setEventChannel(clusterNode);
-                
+
                 createWorkspaceEventChannel = clusterNode;
                 clusterNode.setListener(this);
             }
@@ -789,7 +786,7 @@
     /**
      * Creates a workspace with the given name and given workspace configuration
      * template.
-     * 
+     *
      * The difference between this method and {@link #createWorkspace(String, InputSource)}
      * is that the later notifies the other cluster node that workspace has been created
      * whereas this method only creates the workspace.
@@ -816,7 +813,7 @@
             wspInfos.put(workspaceName, info);
         }
     }
-    
+
     /**
      * Creates a workspace with the given name and given workspace configuration
      * template.
@@ -836,7 +833,7 @@
             createWorkspaceInternal(workspaceName, configTemplate);
         }
         else {
-        
+
             ClonedInputSource template = new ClonedInputSource(configTemplate);
             createWorkspaceInternal(workspaceName, template.cloneInputSource());
             createWorkspaceEventChannel.workspaceCreated(workspaceName, template);
@@ -1156,7 +1153,7 @@
                 log.error("failed to persist repository properties", e);
             }
         }
-        
+
         if (dataStore != null) {
             try {
                 // close the datastore
@@ -1187,7 +1184,7 @@
                 repLock.release();
             } catch (RepositoryException e) {
                 log.error("failed to release the repository lock", e);
-            }            
+            }
         }
 
         log.info("Repository has been shutdown");
@@ -1432,7 +1429,7 @@
      * {@inheritDoc}
      */
     public String[] getDescriptorKeys() {
-        String[] keys = (String[]) repProps.keySet().toArray(new String[repProps.keySet().size()]);
+        String[] keys = repProps.keySet().toArray(new String[repProps.keySet().size()]);
         Arrays.sort(keys);
         return keys;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=784691&r1=784690&r2=784691&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
Mon Jun 15 08:44:36 2009
@@ -609,7 +609,7 @@
                 case PropertyType.BINARY:
                     try {
                         long size = val.getLength();
-                        if (InternalValue.USE_DATA_STORE && dataStore != null) {
+                        if (dataStore != null) {
                             int maxMemorySize = dataStore.getMinRecordLength() - 1;
                             if (size < maxMemorySize) {
                                 writeSmallBinary(out, val, state, i);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=784691&r1=784690&r2=784691&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
Mon Jun 15 08:44:36 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.value;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.data.DataIdentifier;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.data.DataStoreException;
@@ -41,7 +40,6 @@
 import javax.jcr.Binary;
 
 import java.io.ByteArrayInputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.SequenceInputStream;
@@ -81,12 +79,6 @@
     private static final InternalValue BOOLEAN_FALSE = new InternalValue(false);
 
     /**
-     * If set to 'true', the data store is used when configured in repository.xml
-     */
-    public static final boolean USE_DATA_STORE =
-        Boolean.valueOf(System.getProperty("org.jackrabbit.useDataStore", "true")).booleanValue();
-
-    /**
      * Temporary binary values smaller or equal this size are kept in memory
      */
     private static final int MIN_BLOB_FILE_SIZE = 1024;
@@ -119,35 +111,24 @@
         switch (value.getType()) {
             case PropertyType.BINARY:
                 InternalValue result;
-                if (USE_DATA_STORE) {
-                    BLOBFileValue blob = null;
-                    if (value instanceof BinaryValueImpl) {
-                        BinaryValueImpl bin = (BinaryValueImpl) value;
-                        DataIdentifier identifier = bin.getDataIdentifier();
-                        if (identifier != null) {
-                            // access the record to ensure it is not garbage collected
-                            if (store.getRecordIfStored(identifier) != null) {
-                                // it exists - so we don't need to stream it again
-                                // but we need to create a new object because the original
-                                // one might be in a different data store (repository)
-                                blob = BLOBInDataStore.getInstance(store, identifier);
-                            }
+                BLOBFileValue blob = null;
+                if (value instanceof BinaryValueImpl) {
+                    BinaryValueImpl bin = (BinaryValueImpl) value;
+                    DataIdentifier identifier = bin.getDataIdentifier();
+                    if (identifier != null) {
+                        // access the record to ensure it is not garbage collected
+                        if (store.getRecordIfStored(identifier) != null) {
+                            // it exists - so we don't need to stream it again
+                            // but we need to create a new object because the original
+                            // one might be in a different data store (repository)
+                            blob = BLOBInDataStore.getInstance(store, identifier);
                         }
                     }
-                    if (blob == null) {
-                        blob = getBLOBFileValue(store, value.getBinary().getStream(), true);
-                    }
-                    result = new InternalValue(blob);
-                } else if (value instanceof BLOBFileValue) {
-                    result = new InternalValue((BLOBFileValue) value);
-                } else {
-                    InputStream stream = value.getBinary().getStream();
-                    try {
-                        result = createTemporary(stream);
-                    } finally {
-                        IOUtils.closeQuietly(stream);
-                    }
                 }
+                if (blob == null) {
+                    blob = getBLOBFileValue(store, value.getBinary().getStream(), true);
+                }
+                result = new InternalValue(blob);
                 return result;
             case PropertyType.BOOLEAN:
                 return create(value.getBoolean());
@@ -279,10 +260,7 @@
      * @return the created value
      */
     public static InternalValue create(byte[] value) {
-        if (USE_DATA_STORE) {
-            return new InternalValue(BLOBInMemory.getInstance(value));
-        }
-        return new InternalValue(new BLOBValue(value));
+        return new InternalValue(BLOBInMemory.getInstance(value));
     }
 
     /**
@@ -292,14 +270,7 @@
      * @return the internal value
      */
     public static InternalValue createTemporary(InputStream value) throws RepositoryException
{
-        if (USE_DATA_STORE) {
-            return new InternalValue(getBLOBFileValue(null, value, true));
-        }
-        try {
-            return new InternalValue(new BLOBValue(value, true));
-        } catch (IOException e) {
-            throw new RepositoryException("Error creating temporary file", e);
-        }
+        return new InternalValue(getBLOBFileValue(null, value, true));
     }
 
     /**
@@ -309,14 +280,7 @@
      * @return the internal value
      */
     static InternalValue create(InputStream value, DataStore store) throws RepositoryException
{
-        if (USE_DATA_STORE) {
-            return new InternalValue(getBLOBFileValue(store, value, false));
-        }
-        try {
-            return new InternalValue(new BLOBValue(value, false));
-        } catch (IOException e) {
-            throw new RepositoryException("Error creating file", e);
-        }
+        return new InternalValue(getBLOBFileValue(store, value, false));
     }
 
     /**
@@ -325,14 +289,7 @@
      * @throws IOException
      */
     public static InternalValue create(InputStream value) throws RepositoryException {
-        if (USE_DATA_STORE) {
-            return new InternalValue(getBLOBFileValue(null, value, false));
-        }
-        try {
-            return new InternalValue(new BLOBValue(value, false));
-        } catch (IOException e) {
-            throw new RepositoryException("Error creating file", e);
-        }
+        return new InternalValue(getBLOBFileValue(null, value, false));
     }
 
     /**
@@ -341,20 +298,7 @@
      * @throws IOException
      */
     public static InternalValue create(FileSystemResource value) throws IOException {
-        if (USE_DATA_STORE) {
-            return new InternalValue(BLOBInResource.getInstance(value));
-        }
-        return new InternalValue(new BLOBValue(value));
-    }
-
-    /**
-     * @param value
-     * @return
-     * @throws IOException
-     */
-    public static InternalValue create(File value) throws IOException {
-        assert !USE_DATA_STORE;
-        return new InternalValue(new BLOBValue(value));
+        return new InternalValue(BLOBInResource.getInstance(value));
     }
 
     /**
@@ -365,7 +309,6 @@
      * @return the value
      */
     public static InternalValue create(DataStore store, String id) {
-        assert USE_DATA_STORE && store != null;
         return new InternalValue(getBLOBFileValue(store, id));
     }
 
@@ -445,10 +388,8 @@
             return this;
         }
         BLOBFileValue v = (BLOBFileValue) val;
-        if (USE_DATA_STORE) {
-            if (v.isImmutable()) {
-                return this;
-            }
+        if (v.isImmutable()) {
+            return this;
         }
         // return a copy since the wrapped BLOBFileValue instance is mutable
         InputStream stream = v.getStream();
@@ -635,7 +576,6 @@
      * @throws RepositoryException
      */
     public void store(DataStore dataStore) throws RepositoryException {
-        assert USE_DATA_STORE;
         assert dataStore != null;
         assert type == PropertyType.BINARY;
         BLOBFileValue v = (BLOBFileValue) val;
@@ -697,7 +637,8 @@
         } else {
             try {
                 // convert via string
-                return new BLOBValue(getString().getBytes(InternalValueFactory.DEFAULT_ENCODING));
+                byte[] data = getString().getBytes(InternalValueFactory.DEFAULT_ENCODING);
+                return BLOBInMemory.getInstance(data);
             } catch (UnsupportedEncodingException e) {
                 throw new RepositoryException(InternalValueFactory.DEFAULT_ENCODING + " is
not supported encoding on this platform", e);
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java?rev=784691&r1=784690&r2=784691&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
Mon Jun 15 08:44:36 2009
@@ -58,7 +58,7 @@
     InternalValueFactory(DataStore store) {
         this.store = store;
     }
-    
+
     public static QValueFactory getInstance() {
         return INSTANCE;
     }
@@ -154,11 +154,7 @@
     }
 
     public QValue create(File value) throws RepositoryException, IOException {
-        if (InternalValue.USE_DATA_STORE) {
-            InputStream in = new FileInputStream(value);
-            return InternalValue.createTemporary(in);
-        } else {
-            return InternalValue.create(value);
-        }
+        InputStream in = new FileInputStream(value);
+        return InternalValue.createTemporary(in);
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java?rev=784691&r1=784690&r2=784691&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
Mon Jun 15 08:44:36 2009
@@ -63,12 +63,12 @@
      * The maximum size for buffering data in memory.
      */
     private static final int MAX_BUFFER_SIZE = 0x10000;
-    
+
     /**
      * The in-memory buffer.
      */
     private StringWriter buffer;
-    
+
     /**
      * The number of characters written so far.
      * If the in-memory buffer is used, this is position within buffer (size of actual data
in buffer)
@@ -80,7 +80,7 @@
      * MAX_BUFFER_SIZE.
      */
     private File tmpFile;
-    
+
     /**
      * Writer used to write to tmpFile.
      */
@@ -88,7 +88,7 @@
 
     private final NamePathResolver nsContext;
     private final ValueFactory valueFactory;
-    
+
     /**
      * Whether the value is base64 encoded.
      */
@@ -116,7 +116,7 @@
     public long length() throws IOException {
         return length;
     }
-    
+
     private String retrieveString() throws IOException {
         String value = retrieve();
         if (base64) {
@@ -158,7 +158,7 @@
             throw new IOException("this instance has already been disposed");
         }
     }
-    
+
     private Reader openReader() throws IOException {
         return new InputStreamReader(
                 new BufferedInputStream(new FileInputStream(tmpFile)), "UTF-8");
@@ -290,21 +290,8 @@
                 } else {
                     // >= 65kb: deserialize BINARY type
                     // using Reader and temporary file
-                    if (InternalValue.USE_DATA_STORE) {
-                        Base64ReaderInputStream in = new Base64ReaderInputStream(reader());
-                        return InternalValue.createTemporary(in);
-                    }
-                    TransientFileFactory fileFactory = TransientFileFactory.getInstance();
-                    File tmpFile = fileFactory.createTransientFile("bin", null, null);
-                    FileOutputStream out = new FileOutputStream(tmpFile);
-                    Reader reader = reader();
-                    try {
-                        Base64.decode(reader, out);
-                    } finally {
-                        reader.close();
-                        out.close();
-                    }
-                    return InternalValue.create(tmpFile);
+                    Base64ReaderInputStream in = new Base64ReaderInputStream(reader());
+                    return InternalValue.createTemporary(in);
                 }
             } else {
                 // convert serialized value to InternalValue using
@@ -383,7 +370,7 @@
 
     /**
      * Whether this value is base64 encoded
-     * 
+     *
      * @param base64 the flag
      */
     public void setBase64(boolean base64) {



Mime
View raw message