geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r706536 - in /geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore: XStore.java XStoreHolder.java XStoreImpl.java XStorePointer.java XStorePointerImpl.java XStoreRecord.java XStoreRecordImpl.java
Date Tue, 21 Oct 2008 06:26:31 GMT
Author: jdillon
Date: Mon Oct 20 23:26:31 2008
New Revision: 706536

URL: http://svn.apache.org/viewvc?rev=706536&view=rev
Log:
Added XStorePointer

Added:
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
  (contents, props changed)
      - copied, changed from r706527, geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStore.java
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreImpl.java
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
    geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecordImpl.java

Modified: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStore.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStore.java?rev=706536&r1=706535&r2=706536&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStore.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStore.java
Mon Oct 20 23:26:31 2008
@@ -27,4 +27,6 @@
 public interface XStore
 {
     XStoreRecord resolveRecord(String path);
+
+    XStorePointer createPointer(String path);
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java?rev=706536&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
Mon Oct 20 23:26:31 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.geronimo.gshell.xstore;
+
+/**
+ * {@link XStore} thread context holder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XStoreHolder
+{
+    private static final InheritableThreadLocal<XStore> holder = new InheritableThreadLocal<XStore>();
+
+    public static void clear() {
+        holder.remove();
+    }
+
+    public static void set(final XStore xstore) {
+        assert xstore != null;
+
+        holder.set(xstore);
+    }
+
+    public static XStore get() {
+        return holder.get();
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreHolder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreImpl.java?rev=706536&r1=706535&r2=706536&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreImpl.java
Mon Oct 20 23:26:31 2008
@@ -82,12 +82,26 @@
     public XStoreRecord resolveRecord(final String path) {
         assert path != null;
 
+        final XStore prev = XStoreHolder.get();
+        XStoreHolder.set(this);
+
         try {
             FileObject file = getFileSystem().resolveFile(path);
-            return new XStoreRecordImpl(file);
+            return new XStoreRecordImpl(this, file);
         }
         catch (FileSystemException e) {
             throw new XStoreException(e);
         }
+        finally {
+            if (prev != null) {
+                XStoreHolder.set(prev);
+            }
+        }
+    }
+
+    public XStorePointer createPointer(final String path) {
+        assert path != null;
+
+        return new XStorePointerImpl(this, path);
     }
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
(from r706527, geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java?p2=geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java&p1=geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java&r1=706527&r2=706536&rev=706536&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
Mon Oct 20 23:26:31 2008
@@ -19,30 +19,14 @@
 
 package org.apache.geronimo.gshell.xstore;
 
-import java.util.Collection;
-
 /**
- * A record in an {@link XStore}.
+ * A pointer to an {@link XStoreRecord}.
  *
  * @version $Rev$ $Date$
  */
-public interface XStoreRecord
+public interface XStorePointer
 {
     String getPath();
 
-    boolean exists();
-
-    void set(Object value);
-
-    <T> T get(Class<T> type);
-
-    void close();
-
-    boolean delete();
-
-    void refresh();
-
-    XStoreRecord getParent();
-
-    Collection<XStoreRecord> getChilden();
+    XStoreRecord getRecord();
 }
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java?rev=706536&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
Mon Oct 20 23:26:31 2008
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.geronimo.gshell.xstore;
+
+/**
+ * {@link XStorePointer} implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XStorePointerImpl
+    implements XStorePointer
+{
+    private transient XStore xstore;
+
+    private String path;
+
+    public XStorePointerImpl(final XStore xstore, final String path) {
+        assert xstore != null;
+        this.xstore = xstore;
+        assert path != null;
+        this.path = path;
+    }
+
+    public XStorePointerImpl() {}
+    
+    public String getPath() {
+        return path;
+    }
+
+    public XStoreRecord getRecord() {
+        return xstore.resolveRecord(getPath());
+    }
+
+    @SuppressWarnings({"UnusedDeclaration"})
+    private Object readResolve() {
+        xstore = XStoreHolder.get();
+        if (xstore == null) {
+            throw new IllegalStateException("Unable to attach to XStore instance");
+        }
+        return this;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStorePointerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java?rev=706536&r1=706535&r2=706536&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecord.java
Mon Oct 20 23:26:31 2008
@@ -45,4 +45,6 @@
     XStoreRecord getParent();
 
     Collection<XStoreRecord> getChilden();
+
+    XStorePointer createPointer();
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecordImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecordImpl.java?rev=706536&r1=706535&r2=706536&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecordImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-xstore/src/main/java/org/apache/geronimo/gshell/xstore/XStoreRecordImpl.java
Mon Oct 20 23:26:31 2008
@@ -43,11 +43,14 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private final XStore xstore;
+
     private final FileObject file;
 
-    public XStoreRecordImpl(final FileObject file) {
+    public XStoreRecordImpl(final XStore xstore, final FileObject file) {
+        assert xstore != null;
+        this.xstore = xstore;
         assert file != null;
-
         this.file = file;
     }
     
@@ -160,7 +163,7 @@
         }
 
         if (parentFile != null) {
-            return new XStoreRecordImpl(parentFile);
+            return new XStoreRecordImpl(xstore, parentFile);
         }
         return null;
     }
@@ -178,9 +181,13 @@
         List<XStoreRecord> children = new ArrayList<XStoreRecord>(files.length);
 
         for (FileObject file : files) {
-            children.add(new XStoreRecordImpl(file));
+            children.add(new XStoreRecordImpl(xstore, file));
         }
 
         return children;
     }
+
+    public XStorePointer createPointer() {
+        return xstore.createPointer(getPath());
+    }
 }
\ No newline at end of file



Mime
View raw message