portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r731466 [9/12] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/ components/jetspeed-page-manager/ com...
Date Mon, 05 Jan 2009 06:04:18 GMT
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/jpa/NodeSetImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/jpa/NodeSetImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/jpa/NodeSetImpl.java
(added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/jpa/NodeSetImpl.java
Sun Jan  4 22:04:13 2009
@@ -0,0 +1,232 @@
+/*
+ * 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.jetspeed.page.document.jpa;
+
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Pattern;
+
+import org.apache.commons.collections.map.LRUMap;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.page.document.NodeSet;
+
+/**
+ * NodeSetImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class NodeSetImpl implements NodeSet
+{
+    public static final NodeSetImpl EMPTY_NODE_SET = new NodeSetImpl();
+
+    private static final Map patternCache = new LRUMap(128);
+
+    private Map nodes;
+    private Comparator comparator;
+
+    public NodeSetImpl(List nodes, Comparator comparator)
+    {
+        this.nodes = new TreeMap(comparator);
+        Iterator nodesIter = nodes.iterator();
+        while (nodesIter.hasNext())
+        {
+            Node node = (Node)nodesIter.next();
+            if (!this.nodes.containsKey(node.getName()))
+            {
+                this.nodes.put(node.getName(), node);
+            }
+        }         
+        this.comparator = comparator;
+    }
+
+    public NodeSetImpl(List nodes)
+    {
+        this(nodes, null);
+    }
+
+    public NodeSetImpl(Comparator comparator)
+    {
+        this.comparator = comparator;
+    }
+
+    public NodeSetImpl(NodeSet nodeSet)
+    {
+        this((nodeSet instanceof NodeSetImpl) ? ((NodeSetImpl)nodeSet).comparator : (Comparator)null);
+    }
+
+    public NodeSetImpl()
+    {
+    }
+
+    /**
+     * getCachedPattern
+     *
+     * @param regex pattern
+     * @return cached pattern
+     */
+    private Pattern getCachedPattern(String regex)
+    {
+        synchronized (patternCache)
+        {
+            if (patternCache.containsKey(regex))
+            {
+                return (Pattern)patternCache.get(regex);
+            }
+            else
+            {
+                Pattern pattern = Pattern.compile(regex);
+                patternCache.put(regex, pattern);
+                return pattern;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#add(org.apache.jetspeed.page.document.Node)
+     */
+    public void add(Node node)
+    {
+        if (nodes == null)
+        {
+            nodes = new TreeMap(comparator);
+        }
+        if (!nodes.containsKey(node.getName()))
+        {
+            nodes.put(node.getName(), node);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#get(java.lang.String)
+     */
+    public Node get(String name)
+    {
+        if (nodes != null)
+        {
+            return (Node)nodes.get(name);
+        }
+        return null;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#iterator()
+     */
+    public Iterator iterator()
+    {
+        if (nodes == null)
+        {
+            nodes = new TreeMap(comparator);
+        }
+        return nodes.values().iterator();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#subset(java.lang.String)
+     */
+    public NodeSet subset(String type)
+    {
+        NodeSetImpl subset = new NodeSetImpl(comparator);
+        Iterator nodeItr = iterator();
+        while (nodeItr.hasNext())
+        {
+            Node node = (Node) nodeItr.next();
+            if (node.getType().equals(type))
+            {
+                subset.add(node);
+            }
+        }
+        return subset;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#inclusiveSubset(java.lang.String)
+     */
+    public NodeSet inclusiveSubset(String regex)
+    {
+        Pattern pattern = getCachedPattern(regex);
+        NodeSetImpl subset = new NodeSetImpl(comparator);
+        Iterator nodeItr = iterator();
+        while (nodeItr.hasNext())
+        {
+            Node node = (Node) nodeItr.next();
+            if (pattern.matcher(node.getName()).matches())
+            {
+                subset.add(node);
+            }
+        }
+        return subset;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#exclusiveSubset(java.lang.String)
+     */
+    public NodeSet exclusiveSubset(String regex)
+    {
+        Pattern pattern = getCachedPattern(regex);
+        NodeSetImpl subset = new NodeSetImpl(comparator);
+        Iterator nodeItr = iterator();
+        while (nodeItr.hasNext())
+        {
+            Node node = (Node) nodeItr.next();
+            if (!pattern.matcher(node.getName()).matches())
+            {
+                subset.add(node);
+            }
+        }
+        return subset;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#size()
+     */
+    public int size()
+    {
+        if (nodes != null)
+        {
+            return nodes.size();
+        }
+        return 0;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#contains(org.apache.jetspeed.page.document.Node)
+     */
+    public boolean contains(Node node)
+    {
+        if (nodes != null)
+        {
+            return nodes.containsValue(node);
+        }
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.NodeSet#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        if (nodes != null)
+        {
+            return nodes.isEmpty();
+        }
+        return true;
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/psml/AbstractNode.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/psml/AbstractNode.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/psml/AbstractNode.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/psml/AbstractNode.java
Sun Jan  4 22:04:13 2009
@@ -21,11 +21,12 @@
 import java.util.Locale;
 
 import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.om.common.SecurityConstraints;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
+import org.apache.jetspeed.om.page.PageLocalizedFieldImpl;
 import org.apache.jetspeed.om.page.PageMetadataImpl;
 import org.apache.jetspeed.om.page.PageSecurity;
 import org.apache.jetspeed.om.page.psml.AbstractBaseElement;
-import org.apache.jetspeed.om.page.psml.SecurityConstraintsImpl;
+import org.apache.jetspeed.om.page.psml.SecurityConstraintsContextImpl;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
 import org.apache.jetspeed.page.document.Node;
 
@@ -111,7 +112,7 @@
     {
         if (metadata == null)
         {
-            metadata = new PageMetadataImpl();
+            metadata = new PageMetadataImpl(PageLocalizedFieldImpl.class);
         }
         return metadata;
     }
@@ -400,10 +401,10 @@
             // check node constraints if available; otherwise,
             // recursively check parent constraints until
             // default constraints for node are checked
-            SecurityConstraints constraints = getSecurityConstraints();
-            if ((constraints != null) && !constraints.isEmpty())
+            SecurityConstraintsContext constraintsContext = getSecurityConstraintsContext();
+            if ((constraintsContext != null) && !constraintsContext.isEmpty())
             {
-                ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals,
rolePrincipals, groupPrincipals, getEffectivePageSecurity());
+                ((SecurityConstraintsContextImpl)constraintsContext).checkConstraints(actions,
userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
             }
             else if (parent != null)
             {
@@ -416,10 +417,10 @@
             // to be skipped due to explicity granted access
             if (!checkParentsOnly)
             {
-                SecurityConstraints constraints = getSecurityConstraints();
-                if ((constraints != null) && !constraints.isEmpty())
+                SecurityConstraintsContext constraintsContext = getSecurityConstraintsContext();
+                if ((constraintsContext != null) && !constraintsContext.isEmpty())
                 {
-                    ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals,
rolePrincipals, groupPrincipals, getEffectivePageSecurity());
+                    ((SecurityConstraintsContextImpl)constraintsContext).checkConstraints(actions,
userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
                 }
             }
 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
Sun Jan  4 22:04:13 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed.page.impl;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -28,7 +29,7 @@
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
 import org.apache.jetspeed.om.common.SecurityConstraint;
-import org.apache.jetspeed.om.common.SecurityConstraints;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.folder.InvalidFolderException;
@@ -66,7 +67,7 @@
 import org.apache.jetspeed.om.page.impl.PageSecurityImpl;
 import org.apache.jetspeed.om.page.impl.PageSecuritySecurityConstraintImpl;
 import org.apache.jetspeed.om.page.impl.SecurityConstraintsDefImpl;
-import org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl;
+import org.apache.jetspeed.om.page.impl.SecurityConstraintsContextImpl;
 import org.apache.jetspeed.om.preference.FragmentPreference;
 import org.apache.jetspeed.page.DelegatingPageManager;
 import org.apache.jetspeed.page.FolderNotRemovedException;
@@ -120,7 +121,7 @@
         modelClasses.put("PageMenuIncludeDefinitionImpl", PageMenuIncludeDefinitionImpl.class);
         modelClasses.put("PageMenuOptionsDefinitionImpl", PageMenuOptionsDefinitionImpl.class);
         modelClasses.put("PageMenuSeparatorDefinitionImpl", PageMenuSeparatorDefinitionImpl.class);
-        modelClasses.put("SecurityConstraintsImpl", SecurityConstraintsImpl.class);
+        modelClasses.put("SecurityConstraintsContextImpl", SecurityConstraintsContextImpl.class);
         modelClasses.put("FolderSecurityConstraintImpl", FolderSecurityConstraintImpl.class);
         modelClasses.put("PageSecurityConstraintImpl", PageSecurityConstraintImpl.class);
         modelClasses.put("FragmentSecurityConstraintImpl", FragmentSecurityConstraintImpl.class);
@@ -187,6 +188,30 @@
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#registerContext(java.lang.Object)
+     */
+    public void registerContext(Object context)
+    {
+        delegator.registerContext(context);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#getContext()
+     */
+    public Object getContext()
+    {
+        return delegator.getContext();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#unregisterContext(java.lang.Object)
+     */
+    public void unregisterContext(Object context)
+    {
+        delegator.unregisterContext(context);
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.page.PageManager#newPage(java.lang.String)
      */
     public Page newPage(String path)
@@ -315,11 +340,11 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.page.PageManager#newSecurityConstraints()
+     * @see org.apache.jetspeed.page.PageManager#newSecurityConstraintsContext()
      */
-    public SecurityConstraints newSecurityConstraints()
+    public SecurityConstraintsContext newSecurityConstraintsContext()
     {
-        return delegator.newSecurityConstraints();
+        return delegator.newSecurityConstraintsContext();
     }
 
     /* (non-Javadoc)
@@ -402,7 +427,7 @@
         // propagate to delegator
         delegator.reset();
 
-        // clear cache to force subsequent refreshs from persistent store
+        // clear cache to force subsequent refreshes from persistent store
         DatabasePageManagerCache.cacheClear();
     }
 
@@ -667,17 +692,23 @@
             Collection folders = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 
             // cache folders in folder
-            folderImpl.accessFolders().clear();
-            if (folders != null)
+            synchronized (folderImpl.accessCacheLock())
             {
-                folderImpl.accessFolders().addAll(folders);
+                folderImpl.accessFolders().clear();
+                if (folders != null)
+                {
+                    folderImpl.accessFolders().addAll(folders);
+                }
+                folderImpl.resetFolders(true);
             }
-            folderImpl.resetFolders(true);
         }
         catch (Exception e)
         {
             // reset cache in folder
-            folderImpl.resetFolders(false);
+            synchronized (folderImpl.accessCacheLock())
+            {
+                folderImpl.resetFolders(false);
+            }
             throw new DocumentException("Unable to access folders for folder " + folder.getPath()
+ ".");
         }
 
@@ -724,17 +755,23 @@
             Collection pages = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 
             // cache pages in folder
-            folderImpl.accessPages().clear();
-            if (pages != null)
+            synchronized (folderImpl.accessCacheLock())
             {
-                folderImpl.accessPages().addAll(pages);
+                folderImpl.accessPages().clear();
+                if (pages != null)
+                {
+                    folderImpl.accessPages().addAll(pages);
+                }
+                folderImpl.resetPages(true);
             }
-            folderImpl.resetPages(true);
         }
         catch (Exception e)
         {
             // reset cache in folder
-            folderImpl.resetPages(false);
+            synchronized (folderImpl.accessCacheLock())
+            {
+                folderImpl.resetPages(false);
+            }
             throw new NodeException("Unable to access pages for folder " + folder.getPath()
+ ".");
         }
 
@@ -781,17 +818,23 @@
             Collection links = getPersistenceBrokerTemplate().getCollectionByQuery(query);
 
             // cache links in folder
-            folderImpl.accessLinks().clear();
-            if (links != null)
+            synchronized (folderImpl.accessCacheLock())
             {
-                folderImpl.accessLinks().addAll(links);
+                folderImpl.accessLinks().clear();
+                if (links != null)
+                {
+                    folderImpl.accessLinks().addAll(links);
+                }
+                folderImpl.resetLinks(true);
             }
-            folderImpl.resetLinks(true);
         }
         catch (Exception e)
         {
             // reset cache in folder
-            folderImpl.resetLinks(false);
+            synchronized (folderImpl.accessCacheLock())
+            {
+                folderImpl.resetLinks(false);
+            }
             throw new NodeException("Unable to access links for folder " + folder.getPath()
+ ".");
         }
 
@@ -874,7 +917,7 @@
         try
         {
             // query for all nodes
-            List all = DatabasePageManagerUtils.createList();
+            List all = new ArrayList();
             Criteria filter = new Criteria();
             filter.addEqualTo("parent", Integer.valueOf(folderImpl.getId()));
             QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter);
@@ -903,14 +946,20 @@
             }
 
             // cache links in folder
-            folderImpl.accessAll().clear();
-            folderImpl.accessAll().addAll(all);
-            folderImpl.resetAll(true);
+            synchronized (folderImpl.accessCacheLock())
+            {
+                folderImpl.accessAll().clear();
+                folderImpl.accessAll().addAll(all);
+                folderImpl.resetAll(true);
+            }
         }
         catch (Exception e)
         {
             // reset cache in folder
-            folderImpl.resetAll(false);
+            synchronized (folderImpl.accessCacheLock())
+            {
+                folderImpl.resetAll(false);
+            }
             throw new DocumentException("Unable to access all nodes for folder " + folder.getPath()
+ ".");
         }
 
@@ -1855,17 +1904,13 @@
     /* (non-Javadoc)
      * @see org.apache.jetspeed.page.PageManager#addPages(org.apache.jetspeed.om.page.Page[])
      */
-    public int addPages(Page[] pages)
-    throws NodeException
+    public int addPages(Page[] pages) throws NodeException
     {   
         if (pages.length > 0 && pages[0].getPath().equals("/tx__test1.psml"))
         {
             // for tx testing
-            System.out.println("Adding first page");
             this.updatePage(pages[0]);
-            System.out.println("Adding second page");
             this.updatePage(pages[1]);
-            System.out.println("About to throw ex");
             throw new NodeException("Its gonna blow captain!");
         }
         for (int ix = 0; ix < pages.length; ix++)

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
(original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
Sun Jan  4 22:04:13 2009
@@ -189,19 +189,18 @@
                     final String path = cacheObject.getPath();
                     if ((oid != null) || (path != null))
                     {
+                        NodeImpl node = null;
                         synchronized (DatabasePageManagerCache.class)
                         {
                             if (oid != null)
                             {
                                 // get object cached by oid
-                                final NodeImpl node = (NodeImpl)cacheLookup(oid);
+                                node = (NodeImpl)cacheLookup(oid);
                                 // reset internal FolderImpl caches
                                 if (node instanceof FolderImpl)
                                 {
                                     ((FolderImpl)node).resetAll(false);
                                 }
-                                // notify page manager of update
-                                pageManager.notifyUpdatedNode(node);
                                 // remove from cache
                                 oidCache.removeQuiet(oid);
                             }
@@ -211,6 +210,10 @@
                                 final int pathLastSeparatorIndex = path.lastIndexOf(Folder.PATH_SEPARATOR);
                                 final String parentPath = ((pathLastSeparatorIndex > 0)
? path.substring(0, pathLastSeparatorIndex) : Folder.PATH_SEPARATOR);
                                 final NodeImpl parentNode = cacheLookup(parentPath);
+                                if (node == null)
+                                {
+                                    node = parentNode;
+                                }
                                 // reset internal FolderImpl caches in case element removed
                                 if (parentNode instanceof FolderImpl)
                                 {
@@ -219,7 +222,9 @@
                                 // ensure removed from cache
                                 pathCache.removeQuiet(path);
                             }
-                        }                        
+                        }
+                        // notify page manager of update
+                        pageManager.notifyUpdatedNode(node);                        
                     }
                 }
             }
@@ -503,6 +508,16 @@
     {
         return pathCache.isDistributed();
     }
+    
+    /**
+     * Returns page manager proxy configured with this node.
+     * 
+     * @return configured page manager
+     */
+    public static PageManager getPageManager()
+    {
+        return pageManager;
+    }
 
     // OJB Constructor
     

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManager.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManager.java
(added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManager.java
Sun Jan  4 22:04:13 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.jetspeed.page.jpa;
+
+import org.apache.jetspeed.page.PageManager;
+
+/**
+ * DatabasePageManager
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public interface DatabasePageManager extends PageManager
+{
+    /**
+     * Inject proxied page manager interface used to
+     * inject into Folder instances to provide
+     * transaction/interception.
+     *
+     * @param proxy proxied page manager interface.
+     */
+    public void setDatabasePageManagerProxy(DatabasePageManager proxy);
+    
+    /**
+     * Return global cached constraints version used to validate cached
+     * constraints in base elements managed by this page manager.
+     * 
+     * @return global cached constraints version
+     */
+    public long getCachedConstraintsVersion();
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
(added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/DatabasePageManagerContext.java
Sun Jan  4 22:04:13 2009
@@ -0,0 +1,83 @@
+/*
+ * 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.jetspeed.page.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+/**
+ * DatabasePageManagerContext
+ * 
+ * Stateful object uses to hold JPA extended entity manager.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class DatabasePageManagerContext
+{
+    private EntityManager extendedEntityManager;
+    private DatabasePageManager databasePageManager;
+
+    /**
+     * Set extended conversational entity manager instance for context.
+     * 
+     * @param entityManager injected entity manager.
+     */
+    @PersistenceContext (type=PersistenceContextType.EXTENDED, unitName="jetspeed-page-manager")
+    public void setExtendedEntityManager(EntityManager entityManager)
+    {
+        extendedEntityManager = entityManager;
+    }
+    
+    /**
+     * Get extended conversational entity manager instance for context.
+     * 
+     * @return entity manager.
+     */
+    public EntityManager getExtendedEntityManager()
+    {
+        return extendedEntityManager;
+    }
+    
+    /**
+     * Set database page manager associated with context.
+     * 
+     * @param databasePageManager
+     */
+    public void setDatabasePageManager(DatabasePageManager databasePageManager)
+    {
+        this.databasePageManager = databasePageManager;
+    }
+    
+    /**
+     * Initialize context by registering with page manager on creating thread.
+     */
+    public void initialize()
+    {
+        databasePageManager.registerContext(this);        
+    }
+
+    /**
+     * Terminate context by unregistering with page manager on creating thread.
+     */
+    public void terminate()
+    {
+        databasePageManager.unregisterContext(this);
+        extendedEntityManager.close();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message