avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject svn commit: rev 36736 - in avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore: . xml
Date Mon, 23 Aug 2004 01:54:21 GMT
Author: hammant
Date: Sun Aug 22 18:54:20 2004
New Revision: 36736

Added:
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentObjectRepository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentStreamRepository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfig.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfigBean.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/CDIXMLFilePersistentObjectRepository.java
Modified:
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentObjectRepository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentStreamRepository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Object_Repository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Stream_Repository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/AbstractXMLFilePersistentObjectRepository.java
   avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/XMLFilePersistentObjectRepository.java
Log:
more of non-avalon capability for store

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentObjectRepository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentObjectRepository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentObjectRepository.java
Sun Aug 22 18:54:20 2004
@@ -111,4 +111,9 @@
             throw new RuntimeException( "Exception caught while storing an object: " + e
);
         }
     }
+
+    protected String getExtensionDecorator()
+    {
+        return ".FileObjectStore";
+    }
 }

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentStreamRepository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentStreamRepository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFilePersistentStreamRepository.java
Sun Aug 22 18:54:20 2004
@@ -132,4 +132,9 @@
 
         super.remove( key );
     }
+
+    protected String getExtensionDecorator()
+    {
+        return ".FileStreamStore";
+    }
 }

Added: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentObjectRepository.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentObjectRepository.java
Sun Aug 22 18:54:20 2004
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.cornerstone.blocks.masterstore;
+
+import org.apache.avalon.cornerstone.services.store.ObjectRepository;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * This is a simple implementation of persistent object store using
+ * object serialization on the file system.
+ *
+ * @author <a href="mailto:paul_hammant@yahoo.com">Paul Hammant</a>
+ */
+public class CDIFilePersistentObjectRepository
+    extends AbstractFilePersistentObjectRepository
+    implements ObjectRepository
+{
+
+    public CDIFilePersistentObjectRepository(FileRepositoryMonitor monitor, ObjectRespositoryConfig
config) throws IOException {
+        m_baseDirectory = config.getBaseDirectory();
+        this.monitor = monitor;
+
+        setDestination( config.getURL() );
+
+        monitor.initialized(CDIFilePersistentObjectRepository.class);
+        m_name = RepositoryManager.getName();
+        m_extension = "." + m_name + getExtensionDecorator();
+        m_filter = new ExtensionFileFilter( m_extension );
+        final File directory = new File( m_path );
+        directory.mkdirs();
+        monitor.pathOpened(CDIFilePersistentObjectRepository.class, m_path);
+    }
+
+    protected void initializeChild(AbstractFileRepository child) throws Exception {
+    }
+
+}

Added: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentStreamRepository.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/CDIFilePersistentStreamRepository.java
Sun Aug 22 18:54:20 2004
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.cornerstone.blocks.masterstore;
+
+import org.apache.avalon.cornerstone.services.store.StreamRepository;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Implementation of a StreamRepository to a File.
+ * TODO: -retieve(String key) should return a FilterInputStream to allow
+ * mark and reset methods. (working not like BufferedInputStream!!!)
+ *
+ * @author  Federico Barbieri <fede@apache.org>
+ */
+public class CDIFilePersistentStreamRepository
+    extends AbstractFilePersistentStreamRepository
+    implements StreamRepository
+{
+
+    public CDIFilePersistentStreamRepository(FileRepositoryMonitor monitor, ObjectRespositoryConfig
config) throws IOException {
+        m_baseDirectory = config.getBaseDirectory();
+        this.monitor = monitor;
+
+        setDestination( config.getURL() );
+
+        monitor.initialized(CDIFilePersistentStreamRepository.class);
+
+        m_name = RepositoryManager.getName();
+        m_extension = "." + m_name + getExtensionDecorator();
+        m_filter = new ExtensionFileFilter( m_extension );
+
+        final File directory = new File( m_path );
+        directory.mkdirs();
+        monitor.pathOpened(CDIFilePersistentStreamRepository.class, m_path);
+
+    }
+
+    protected void initializeChild(AbstractFileRepository child) throws Exception {
+    }
+
+}
+
+

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Object_Repository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Object_Repository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Object_Repository.java
Sun Aug 22 18:54:20 2004
@@ -43,10 +43,7 @@
     extends AbstractFilePersistentObjectRepository
     implements ObjectRepository, Contextualizable, Initializable, Configurable, LogEnabled
 {
-    protected String getExtensionDecorator()
-    {
-        return ".FileObjectStore";
-    }
+
 
     public void enableLogging(Logger logger) {
         AvalonFileRepositoryMonitor avMonitor = new AvalonFileRepositoryMonitor();

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Stream_Repository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Stream_Repository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/File_Persistent_Stream_Repository.java
Sun Aug 22 18:54:20 2004
@@ -43,11 +43,6 @@
     implements StreamRepository, Contextualizable, Initializable, Configurable, LogEnabled
 {
 
-    protected String getExtensionDecorator()
-    {
-        return ".FileStreamStore";
-    }
-
     public void enableLogging(Logger logger) {
         AvalonFileRepositoryMonitor avMonitor = new AvalonFileRepositoryMonitor();
         avMonitor.enableLogging(logger);

Added: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfig.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfig.java
Sun Aug 22 18:54:20 2004
@@ -0,0 +1,12 @@
+package org.apache.avalon.cornerstone.blocks.masterstore;
+
+import java.io.File;
+
+/**
+ * @author Paul Hammant
+ * @version $Revision: 1.8 $
+ */
+public interface ObjectRespositoryConfig {
+    String getURL();
+    File getBaseDirectory();
+}

Added: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfigBean.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/ObjectRespositoryConfigBean.java
Sun Aug 22 18:54:20 2004
@@ -0,0 +1,30 @@
+package org.apache.avalon.cornerstone.blocks.masterstore;
+
+import java.io.File;
+
+/**
+ * @author Paul Hammant
+ * @version $Revision: 1.8 $
+ */
+public class ObjectRespositoryConfigBean implements ObjectRespositoryConfig {
+
+    private String url;
+    private File baseDirectory;
+
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getURL() {
+        return url;
+    }
+
+    public void setBaseDirectory(File baseDirectory) {
+        this.baseDirectory = baseDirectory;
+    }
+
+    public File getBaseDirectory() {
+        return baseDirectory;
+    }
+}

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/AbstractXMLFilePersistentObjectRepository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/AbstractXMLFilePersistentObjectRepository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/AbstractXMLFilePersistentObjectRepository.java
Sun Aug 22 18:54:20 2004
@@ -101,4 +101,9 @@
             throw new RuntimeException( "Exception caught while storing an object: " + e
);
         }
     }
+
+    protected String getExtensionDecorator()
+    {
+        return ".FileObjectStore";
+    }
 }

Added: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/CDIXMLFilePersistentObjectRepository.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/CDIXMLFilePersistentObjectRepository.java
Sun Aug 22 18:54:20 2004
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.cornerstone.blocks.masterstore.xml;
+
+import org.apache.avalon.cornerstone.blocks.masterstore.AbstractFileRepository;
+import org.apache.avalon.cornerstone.blocks.masterstore.ExtensionFileFilter;
+import org.apache.avalon.cornerstone.blocks.masterstore.FileRepositoryMonitor;
+import org.apache.avalon.cornerstone.blocks.masterstore.RepositoryManager;
+import org.apache.avalon.cornerstone.blocks.masterstore.ObjectRespositoryConfig;
+import org.apache.avalon.cornerstone.services.store.ObjectRepository;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * This is a simple implementation of persistent object store using
+ * XML serialization from JDK 1.4 to a file system.
+ *
+ * This implementation of ObjectRepository comes with the following warning:
+ * "XMLEncoder provides suitable persistence delegates
+ * for all public subclasses of java.awt.Component in J2SE and the types of
+ * all of their properties, recursively. All other classes will be handled
+ * with the default persistence delegate which assumes the class follows
+ * the beans conventions" (snipped from the BugParade)
+ *
+ * Basically, don't use this block for anything other than Swing component
+ * serialization.  Sun will have to do a lot of work writing a
+ * "PersistenceDelegate" to handle other JDK types let alone custom classes.
+ *
+ * @author <a href="mailto:paul_hammant@yahoo.com">Paul Hammant</a>
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
+ */
+public class CDIXMLFilePersistentObjectRepository
+    extends AbstractXMLFilePersistentObjectRepository
+    implements ObjectRepository
+{
+
+    public CDIXMLFilePersistentObjectRepository(FileRepositoryMonitor monitor, ObjectRespositoryConfig
config) throws IOException {
+        m_baseDirectory = config.getBaseDirectory();
+        this.monitor = monitor;
+
+        setDestination( config.getURL() );
+
+        monitor.initialized(CDIXMLFilePersistentObjectRepository.class);
+
+        m_name = RepositoryManager.getName();
+        m_extension = "." + m_name + getExtensionDecorator();
+        m_filter = new ExtensionFileFilter( m_extension );
+
+        final File directory = new File( m_path );
+        directory.mkdirs();
+
+        monitor.pathOpened(CDIXMLFilePersistentObjectRepository.class, m_path);
+
+    }
+
+    protected void initializeChild(AbstractFileRepository child) throws Exception {
+    }
+
+}

Modified: avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/XMLFilePersistentObjectRepository.java
==============================================================================
--- avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/XMLFilePersistentObjectRepository.java
(original)
+++ avalon/trunk/planet/cornerstone/store/impl/src/main/org/apache/avalon/cornerstone/blocks/masterstore/xml/XMLFilePersistentObjectRepository.java
Sun Aug 22 18:54:20 2004
@@ -58,10 +58,6 @@
     extends AbstractXMLFilePersistentObjectRepository
     implements ObjectRepository, Contextualizable, Initializable, Configurable, LogEnabled
 {
-    protected String getExtensionDecorator()
-    {
-        return ".FileObjectStore";
-    }
 
     public void enableLogging(Logger logger) {
         AvalonFileRepositoryMonitor avMonitor = new AvalonFileRepositoryMonitor();

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message