exo-jcr SVN: r465 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-04 03:36:42 -0500 (Wed, 04 Nov 2009)
New Revision: 465
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
Log:
EXOJCR-194 log message level changed to log.info (line 431)
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2009-11-02 16:32:35 UTC (rev 464)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2009-11-04 08:36:42 UTC (rev 465)
@@ -428,7 +428,7 @@
else
{
booting = true;
- log.error("Booting root container with id " + RootContainer.class.hashCode() + "");
+ log.info("Booting root container with id " + RootContainer.class.hashCode() + "");
log.info("Building root container");
long time = -System.currentTimeMillis();
result = buildRootContainer();
16 years, 8 months
exo-jcr SVN: r464 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/core and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-02 11:32:35 -0500 (Mon, 02 Nov 2009)
New Revision: 464
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-219 : The method SysViewWorkspaceinitializer.SVNodeData.addChildNode(InternalQName childName) was optimized.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-11-02 15:00:38 UTC (rev 463)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-11-02 16:32:35 UTC (rev 464)
@@ -55,6 +55,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
@@ -299,11 +300,14 @@
}
}
- protected class SVNodeData extends TransientNodeData
+ protected class SVNodeData
+ extends TransientNodeData
{
- List<InternalQName> childNodes = new LinkedList<InternalQName>();
+ int orderNumber = 0;
+ HashMap<InternalQName, Integer> childNodesMap = new HashMap<InternalQName, Integer>();
+
SVNodeData(QPath path, String identifier, String parentIdentifier, int version, int orderNum)
{
super(path, identifier, version, null, null, orderNum, parentIdentifier, null);
@@ -321,15 +325,16 @@
*/
int[] addChildNode(InternalQName childName)
{
- int orderNumber = childNodes.size();
- int index = 1;
- for (int i = 0; i < childNodes.size(); i++)
+ Integer count = childNodesMap.get(childName);
+ if (count != null)
{
- if (childName.equals(childNodes.get(i)))
- index++;
+ childNodesMap.put(childName, count + 1);
}
- childNodes.add(childName);
- return new int[]{orderNumber, index};
+ else
+ childNodesMap.put(childName, 1);
+
+ int index = childNodesMap.get(childName);
+ return new int[] {orderNumber++, index};
}
}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2009-11-02 16:32:35 UTC (rev 464)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.config.WorkspaceInitializerEntry;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 02.11.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class TestSVNodeDataOptimization
+ extends JcrImplBaseTest
+{
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+ if (ses != null)
+ {
+ try
+ {
+ ses.refresh(false);
+ Node rootNode = ses.getRootNode();
+ if (rootNode.hasNodes())
+ {
+ // clean test root
+ for (NodeIterator children = rootNode.getNodes(); children.hasNext();)
+ {
+ Node node = children.nextNode();
+ if (!node.getPath().startsWith("/jcr:system"))
+ {
+ // log.info("DELETing ------------- "+node.getPath());
+ node.remove();
+ }
+ }
+ ses.save();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("tearDown() ERROR " + getClass().getName() + "." + getName() + " " + e, e);
+ }
+ finally
+ {
+ ses.logout();
+ }
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+ if (ses != null)
+ {
+ try
+ {
+ ses.refresh(false);
+ Node rootNode = ses.getRootNode();
+ if (rootNode.hasNodes())
+ {
+ // clean test root
+ for (NodeIterator children = rootNode.getNodes(); children.hasNext();)
+ {
+ Node node = children.nextNode();
+ if (!node.getPath().startsWith("/jcr:system"))
+ {
+ // log.info("DELETing ------------- "+node.getPath());
+ node.remove();
+ }
+ }
+ ses.save();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("tearDown() ERROR " + getClass().getName() + "." + getName() + " " + e, e);
+ }
+ finally
+ {
+ ses.logout();
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testSVNodeData() throws Exception
+ {
+
+ //ADD content
+ SessionImpl ses = (SessionImpl) repository.login(credentials, "ws1");
+
+ //Add node with sub name sibling
+ Node nodeSNS = ses.getRootNode().addNode("node_with_sns");
+ for (int i = 0; i < 100; i++)
+ {
+ nodeSNS.addNode("node_sns_");
+ }
+
+ //Add node without sub name sibling
+ Node nodeWOSNS = ses.getRootNode().addNode("node_without_sns");
+ for (int i = 0; i < 100; i++)
+ {
+ nodeSNS.addNode("node_" + i);
+ }
+
+ ses.save();
+
+ // Cereate backup
+ File backup = File.createTempFile("full-backup", ".xml");
+ backup.deleteOnExit();
+
+ ses.exportWorkspaceSystemView(new FileOutputStream(backup), false, false);
+
+ // restore to ws1_restored
+ WorkspaceEntry ws1_restore =
+ makeWorkspaceEntry("ws1_restored", isMultiDB(session) ? "jdbcjcr2export3" : "jdbcjcr", backup, ses);
+ repository.configWorkspace(ws1_restore);
+ repository.createWorkspace(ws1_restore.getName());
+
+ // check
+ SessionImpl backupSession = (SessionImpl) repository.login(credentials, "ws1_restored");
+
+ assertNotNull(backupSession);
+
+ checkEquals(ses, backupSession);
+ }
+
+ private void checkEquals(SessionImpl expected, SessionImpl actual) throws Exception
+ {
+ NodeImpl srcNode = (NodeImpl) expected.getRootNode();
+ NodeImpl destNode = (NodeImpl) actual.getRootNode();
+
+ checkNodeEquals(srcNode, destNode);
+ }
+
+ private void checkNodeEquals(NodeImpl src, NodeImpl dest) throws Exception
+ {
+ assertTrue(dest.equals(src));
+ assertEquals(src.getIndex(), dest.getIndex());
+ assertEquals(((NodeData) src.getData()).getOrderNumber(), ((NodeData) dest.getData()).getOrderNumber());
+
+ NodeIterator srcIterator = src.getNodes();
+ NodeIterator destIterator = dest.getNodes();
+
+ assertEquals(srcIterator.getSize(), destIterator.getSize());
+
+ while (srcIterator.hasNext())
+ checkNodeEquals((NodeImpl) srcIterator.nextNode(), (NodeImpl) destIterator.nextNode());
+ }
+
+ private WorkspaceEntry makeWorkspaceEntry(String name, String sourceName, File sysViewFile, SessionImpl ses)
+ {
+ WorkspaceEntry ws1e = (WorkspaceEntry) ses.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+
+ WorkspaceEntry ws1back = new WorkspaceEntry();
+ ws1back.setName(name);
+ ws1back.setUniqueName(((RepositoryImpl) ses.getRepository()).getName() + "_" + ws1back.getName());
+
+ ws1back.setAccessManager(ws1e.getAccessManager());
+ ws1back.setAutoInitializedRootNt(ws1e.getAutoInitializedRootNt());
+ ws1back.setAutoInitPermissions(ws1e.getAutoInitPermissions());
+ ws1back.setCache(ws1e.getCache());
+ ws1back.setContainer(ws1e.getContainer());
+ ws1back.setLockManager(ws1e.getLockManager());
+
+ // Initializer
+ WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
+ wiEntry.setType(SysViewWorkspaceInitializer.class.getCanonicalName());
+
+ List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
+ wieParams
+ .add(new SimpleParameterEntry(SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER, sysViewFile.getPath()));
+
+ wiEntry.setParameters(wieParams);
+
+ ws1back.setInitializer(wiEntry);
+
+ // Indexer
+ ArrayList qParams = new ArrayList();
+ qParams.add(new SimpleParameterEntry("indexDir", "target" + File.separator + name));
+ QueryHandlerEntry qEntry =
+ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+
+ ws1back.setQueryHandler(qEntry);
+
+ ArrayList params = new ArrayList();
+ for (Iterator i = ws1back.getContainer().getParameters().iterator(); i.hasNext();)
+ {
+ SimpleParameterEntry p = (SimpleParameterEntry) i.next();
+ SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(), p.getValue());
+
+ if (isMultiDB(ses) && newp.getName().equals("source-name"))
+ newp.setValue(sourceName);
+ else if (newp.getName().equals("swap-directory"))
+ newp.setValue("target/temp/swap/" + name);
+ else if (isMultiDB(ses) && newp.getName().equals("dialect"))
+ newp.setValue("hsqldb");
+
+ params.add(newp);
+ }
+
+ ContainerEntry ce =
+ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer", params);
+ ws1back.setContainer(ce);
+
+ return ws1back;
+ }
+
+ private boolean isMultiDB(SessionImpl session)
+ {
+ WorkspaceEntry ws1e = (WorkspaceEntry) session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+
+ for (Iterator i = ws1e.getContainer().getParameters().iterator(); i.hasNext();)
+ {
+ SimpleParameterEntry p = (SimpleParameterEntry) i.next();
+ SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(), p.getValue());
+
+ if (newp.getName().equals("multi-db"))
+ return Boolean.valueOf(newp.getValue());
+ }
+
+ throw new RuntimeException("Can not get property 'multi-db' in configuration on workspace '" + ws1e.getName()
+ + "'");
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2009-11-02 15:00:38 UTC (rev 463)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2009-11-02 16:32:35 UTC (rev 464)
@@ -478,6 +478,33 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
<!-- Resource configuration for UserTransaction
use JOTM
-->
16 years, 8 months
exo-jcr SVN: r463 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-11-02 10:00:38 -0500 (Mon, 02 Nov 2009)
New Revision: 463
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
Log:
EXOJCR-166: Support separated ear delivery
The variable currentContainer_ has been removed from the PortalContainer since it is error prone as it duplicates the ThreaLocal in ExoContainerContext, only the type change (i.e. ExoContainer in ExoContainerContext and PortalContainer in PortalContainer). Now, everything relies on the TL of ExoContainerContext.
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2009-11-01 22:10:06 UTC (rev 462)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2009-11-02 15:00:38 UTC (rev 463)
@@ -93,8 +93,6 @@
}
}
- private static ThreadLocal<PortalContainer> currentContainer_ = new ThreadLocal<PortalContainer>();
-
private volatile boolean started_;
private PortalContainerInfo pinfo_;
@@ -323,38 +321,24 @@
if (container == null)
{
container = RootContainer.getInstance().getPortalContainer(DEFAULT_PORTAL_CONTAINER_NAME);
- currentContainer_.set(container);
+ PortalContainer.setInstance(container);
}
return container;
}
/**
- * @return the current instance of {@link PortalContainer} that has been stored into the related
- * {@link ThreadLocal}. If no value has been set, it will return <code>null</code>
+ * @return the current instance of {@link ExoContainer} that has been stored into the
+ * {@link ThreadLocal} of {@link ExoContainerContext}. If no {@link PortalContainer} has been set,
+ * it will return <code>null</code>
*/
public static PortalContainer getInstanceIfPresent()
{
- PortalContainer pc = currentContainer_.get();
- if (pc != null)
+ ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ if (container instanceof PortalContainer)
{
- ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
- if (container != pc)
- {
- // Clean the value of currentContainer_ since it should be equals to
- // ExoContainerContext.getCurrentContainerIfPresent()
- if (container instanceof PortalContainer)
- {
- // The current container is a PortalContainer, this value will replace the old one
- currentContainer_.set(pc = (PortalContainer)container);
- }
- else
- {
- // The current container is not a PortalContainer, the old value must be removed
- currentContainer_.set(pc = null);
- }
- }
+ return (PortalContainer)container;
}
- return pc;
+ return null;
}
/**
@@ -436,17 +420,12 @@
*/
public static PortalContainer getCurrentInstance(ServletContext context)
{
- final ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof PortalContainer)
+ final PortalContainer container = getInstanceIfPresent();
+ if (container == null)
{
- if (log.isDebugEnabled())
- log.debug("A portal container has been set in the ThreadLocal of ExoContainerContext");
- return (PortalContainer)container;
- }
- else
- {
return PortalContainer.getInstance(context);
}
+ return container;
}
/**
@@ -567,7 +546,6 @@
public static void setInstance(PortalContainer instance)
{
- currentContainer_.set(instance);
ExoContainerContext.setCurrentContainer(instance);
}
16 years, 8 months
exo-jcr SVN: r462 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-01 17:10:06 -0500 (Sun, 01 Nov 2009)
New Revision: 462
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
Log:
EXOJCR-201: new loader: get, getChilds impls
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-01 22:06:48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-01 22:10:06 UTC (rev 462)
@@ -3,7 +3,7 @@
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
+ * published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
@@ -16,51 +16,59 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.jboss.cache.CacheSPI;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.RegionManager;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.AbstractCacheLoader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
*
- * <br/>Date: 23.10.2009
+ * <br/>Date: 31.10.2009
*
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class ExoJCRCacheLoader implements CacheLoader
+public class ExoJCRCacheLoader extends AbstractCacheLoader
{
- //private CacheSPI cache;
- //private RegionManager regionManager;
-
- private IndividualCacheLoaderConfig config;
-
private WorkspaceDataContainer dataContainer;
- private HashMap<Object, List<Modification>> transactions = new HashMap<Object, List<Modification>>();
-
/**
* Init the loader DataContainer with given WorkspaceDataContainer instance.
*
@@ -77,25 +85,17 @@
this.dataContainer = dataContainer;
}
- /**
- * {@inheritDoc}
- */
- public void commit(Object tx) throws Exception
+ protected QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
{
- List<Modification> modifications = transactions.remove(tx);
- if (modifications != null)
- doModified(modifications);
- else
- throw new ExoJCRCacheLoaderException("Transaction " + tx + " not exist in transaction table");
- }
+ List<String> elements = nodeFqn.peekElements();
+ QPathEntry[] path = new QPathEntry[elements.size()];
- /**
- * {@inheritDoc}
- */
- public boolean exists(Fqn name) throws Exception
- {
- // TODO use get(Fqn), i.e. get Node!=null
- return false;
+ for (int i = 0; i < elements.size(); i++)
+ {
+ path[i] = QPathEntry.parse(elements.get(i));
+ }
+
+ return path;
}
/**
@@ -103,182 +103,182 @@
*/
public Map<Object, Object> get(Fqn name) throws Exception
{
- // TODO get Node
- return null;
- }
- /**
- * {@inheritDoc}
- */
- public Set<?> getChildrenNames(Fqn fqn) throws Exception
- {
- // TODO get child nodes names
- return null;
- }
+ Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
+ if (name.size() > 1)
+ {
+ if (name.get(1).equals(JBossCacheStorage.TREE))
+ {
+ // return Node
+ if (name.size() > 3)
+ {
+ QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
- /**
- * {@inheritDoc}
- */
- public IndividualCacheLoaderConfig getConfig()
- {
- return config;
- }
+ // TODO non effective, in this way 1) all subtree will be cached
+ // 2) all subtree will be read from DB (with allprops) for only Ids.
+ // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
+ String parentId = (String)cache.get(name.getParent(), JBossCacheStorage.ITEM_ID);
- /**
- * {@inheritDoc}
- */
- public void loadEntireState(ObjectOutputStream os) throws Exception
- {
- // TODO Auto-generated method stub
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(parentId);
- }
+ ItemData item = conn.getItemData(parent, nodeName);
- /**
- * {@inheritDoc}
- */
- public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
- {
- // TODO Auto-generated method stub
+ // item Id
+ attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier());
+ // if Node (Property cannot due to logic of StorageConnection) add props
+ for (PropertyData prop : conn.getChildPropertiesData(parent))
+ {
+ attrs.put(prop.getQPath().getName().getAsString(), prop.getIdentifier());
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
+ }
+ }
+ else if (name.get(1).equals(JBossCacheStorage.ITEMS))
+ {
+ // we have all data on thrid level
+ if (name.size() == 3)
+ {
+ // return Node or Property
+ String itemId = name.getLastElementAsString();
+
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(itemId));
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ }
+ }
+ return attrs;
}
/**
* {@inheritDoc}
*/
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ public boolean exists(Fqn name) throws Exception
{
- if (onePhase)
- {
- doModified(modifications);
- }
- else
- {
- transactions.put(tx, modifications);
- }
+ // TODO do it with less cost
+ return get(name) != null;
}
/**
- * Will be added data to DB.
- *
- * @param modifications
- * @throws Exception
+ * {@inheritDoc}
*/
- private void doModified(List<Modification> modifications) throws Exception
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
{
- JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
+ // return child nodes names
- try
+ Set<String> childs = new LinkedHashSet<String>();
+ if (fqn.size() > 2)
{
- for (int modificatinIndex = 0; modificatinIndex < modifications.size(); modificatinIndex++)
+ if (fqn.get(2).equals(JBossCacheStorage.TREE))
{
- Modification md = modifications.get(modificatinIndex);
- switch (md.getType())
+ // return Node
+ if (fqn.size() > 3)
{
- case PUT_KEY_VALUE :
- doAddOrUpdate(md, jdbcConnection);
- break;
- case REMOVE_NODE :
- doRemove(md, jdbcConnection, "TODO $<Node identifier>");
- break;
- }
- }
+ QPathEntry nodeName = QPathEntry.parse(fqn.getLastElementAsString());
- if (jdbcConnection != null)
- jdbcConnection.commit();
- }
- finally
- {
- if (jdbcConnection != null && jdbcConnection.isOpened())
- jdbcConnection.rollback();
- }
- }
+ // TODO non effective, in this way 1) all subtree will be cached
+ // 2) all subtree will be read from DB (with allprops) for only Ids.
+ // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
+ String parentId = (String)cache.get(fqn.getParent(), JBossCacheStorage.ITEM_ID);
- private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
- throws IllegalStateException, RepositoryException
- {
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(parentId);
- ItemData itemData = jdbcConnection.getItemData(identifier);
+ NodeData node = (NodeData)conn.getItemData(parent, nodeName);
- if (itemData instanceof NodeData)
- jdbcConnection.delete((NodeData)itemData);
- if (itemData instanceof PropertyData)
- jdbcConnection.delete((PropertyData)itemData);
- }
-
- /**
- * Performs ADD and UPDATE to NodeData and PropertyData.
- * @param modification
- * @param jdbcConnection
- * @throws IllegalStateException
- * @throws RepositoryException
- */
- private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
- throws IllegalStateException, RepositoryException
- {
- if (modification.getValue() instanceof NodeData)
- {
- //add or update node data
- NodeData nodeData = (NodeData)modification.getValue();
-
- ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
-
- if (itemData == null)
- {
- //add
- jdbcConnection.add(nodeData);
+ // get child nodes by parent Id
+ for (NodeData prop : conn.getChildNodesData(node))
+ {
+ childs
+ .add(node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getAsString(true));
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true));
+ }
}
- else
+ else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
{
- //update
- jdbcConnection.update(nodeData);
+ // we have all data on thrid level
+ if (fqn.size() == 3)
+ {
+ // return all Nodes and Properties Ids
+
+// WorkspaceStorageConnection conn = dataContainer.openConnection();
+// try
+// {
+// for (String itemId : conn.getAllItemIdentifiers())
+// {
+// childs.add(itemId);
+// }
+// }
+// finally
+// {
+// conn.close();
+// }
+ }
}
}
- else if (modification.getValue() instanceof PropertyData)
+ else if (fqn.equals(Fqn.ROOT))
{
- //add or update property data
- PropertyData propertyData = (PropertyData)modification.getValue();
-
- ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
-
- if (itemData == null)
- {
- //add
- jdbcConnection.add(propertyData);
- }
- else
- {
- //update
- jdbcConnection.update(propertyData);
- }
+ childs.add(JBossCacheStorage.TREE);
+ childs.add(JBossCacheStorage.ITEMS);
}
+ return childs;
}
/**
* {@inheritDoc}
*/
- public Object put(Fqn name, Object key, Object value) throws Exception
+ public IndividualCacheLoaderConfig getConfig()
{
- // i.e. put Property
+ // TODO Auto-generated method stub
return null;
}
/**
* {@inheritDoc}
*/
- public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+ public Object put(Fqn name, Object key, Object value) throws Exception
{
- // i.e. put set of Properties
-
// TODO Auto-generated method stub
-
+ return null;
}
/**
* {@inheritDoc}
*/
- public void put(List<Modification> modifications) throws Exception
+ public void put(Fqn name, Map<Object, Object> attributes) throws Exception
{
-
// TODO Auto-generated method stub
}
@@ -288,7 +288,6 @@
*/
public Object remove(Fqn fqn, Object key) throws Exception
{
- // i.e. remove Property
// TODO Auto-generated method stub
return null;
}
@@ -298,8 +297,6 @@
*/
public void remove(Fqn fqn) throws Exception
{
- // i.e. remove Node
-
// TODO Auto-generated method stub
}
@@ -309,8 +306,6 @@
*/
public void removeData(Fqn fqn) throws Exception
{
- // i.e. remove all Properties of Node
-
// TODO Auto-generated method stub
}
@@ -318,88 +313,10 @@
/**
* {@inheritDoc}
*/
- public void rollback(Object tx)
- {
- transactions.remove(tx);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCache(CacheSPI c)
- {
- //this.cache = c;
- }
-
- /**
- * {@inheritDoc}
- */
public void setConfig(IndividualCacheLoaderConfig config)
{
- this.config = config;
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void setRegionManager(RegionManager manager)
- {
- //this.regionManager = manager;
- }
-
- /**
- * {@inheritDoc}
- */
- public void storeEntireState(ObjectInputStream is) throws Exception
- {
// TODO Auto-generated method stub
}
- /**
- * {@inheritDoc}
- */
- public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void create() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void destroy()
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void start() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- // TODO Auto-generated method stub
-
- }
-
}
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java (from rev 460, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java 2009-11-01 22:10:06 UTC (rev 462)
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.CacheLoader;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 23.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class ExoJCRCacheLoader1 implements CacheLoader
+{
+ //private CacheSPI cache;
+
+ //private RegionManager regionManager;
+
+ private IndividualCacheLoaderConfig config;
+
+ private WorkspaceDataContainer dataContainer;
+
+ private HashMap<Object, List<Modification>> transactions = new HashMap<Object, List<Modification>>();
+
+ /**
+ * Init the loader DataContainer with given WorkspaceDataContainer instance.
+ *
+ * @param dataContainer WorkspaceDataContainer
+ */
+ @Inject
+ public void initDataContainer(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
+ {
+ if (this.dataContainer != null)
+ {
+ throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
+ }
+
+ this.dataContainer = dataContainer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit(Object tx) throws Exception
+ {
+ List<Modification> modifications = transactions.remove(tx);
+ if (modifications != null)
+ doModified(modifications);
+ else
+ throw new ExoJCRCacheLoaderException("Transaction " + tx + " not exist in transaction table");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn name) throws Exception
+ {
+ // TODO use get(Fqn), i.e. get Node!=null
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<Object, Object> get(Fqn name) throws Exception
+ {
+ // TODO get Node or Property
+ // e.g.
+ // if $TREE/[]:1 - return $ITEM_ID attribute and all JCR Node Properties IDs
+ // if $ITEM/idxxx - return $ITEM_DATA of JCR Node or Property
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
+ {
+ // TODO get child nodes names
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void loadEntireState(ObjectOutputStream os) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ {
+ if (onePhase)
+ {
+ doModified(modifications);
+ }
+ else
+ {
+ transactions.put(tx, modifications);
+ }
+ }
+
+ /**
+ * Will be added data to DB.
+ *
+ * @param modifications
+ * @throws Exception
+ */
+ private void doModified(List<Modification> modifications) throws Exception
+ {
+ JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
+
+ try
+ {
+ for (int modificatinIndex = 0; modificatinIndex < modifications.size(); modificatinIndex++)
+ {
+ Modification md = modifications.get(modificatinIndex);
+ switch (md.getType())
+ {
+ case PUT_KEY_VALUE :
+ doAddOrUpdate(md, jdbcConnection);
+ break;
+ case REMOVE_NODE :
+ doRemove(md, jdbcConnection, "TODO $<Node identifier>");
+ break;
+ }
+ }
+
+ if (jdbcConnection != null)
+ jdbcConnection.commit();
+ }
+ finally
+ {
+ if (jdbcConnection != null && jdbcConnection.isOpened())
+ jdbcConnection.rollback();
+ }
+ }
+
+ private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
+ throws IllegalStateException, RepositoryException
+ {
+
+ ItemData itemData = jdbcConnection.getItemData(identifier);
+
+ if (itemData instanceof NodeData)
+ jdbcConnection.delete((NodeData)itemData);
+ if (itemData instanceof PropertyData)
+ jdbcConnection.delete((PropertyData)itemData);
+ }
+
+ /**
+ * Performs ADD and UPDATE to NodeData and PropertyData.
+ * @param modification
+ * @param jdbcConnection
+ * @throws IllegalStateException
+ * @throws RepositoryException
+ */
+ private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
+ throws IllegalStateException, RepositoryException
+ {
+ if (modification.getValue() instanceof NodeData)
+ {
+ //add or update node data
+ NodeData nodeData = (NodeData)modification.getValue();
+
+ ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
+
+ if (itemData == null)
+ {
+ //add
+ jdbcConnection.add(nodeData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(nodeData);
+ }
+ }
+ else if (modification.getValue() instanceof PropertyData)
+ {
+ //add or update property data
+ PropertyData propertyData = (PropertyData)modification.getValue();
+
+ ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
+
+ if (itemData == null)
+ {
+ //add
+ jdbcConnection.add(propertyData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(propertyData);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ // i.e. put Property
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+ {
+ // i.e. put set of Properties
+
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(List<Modification> modifications) throws Exception
+ {
+
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ // i.e. remove Property
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn fqn) throws Exception
+ {
+ // i.e. remove Node
+
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn fqn) throws Exception
+ {
+ // i.e. remove all Properties of Node
+
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback(Object tx)
+ {
+ transactions.remove(tx);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCache(CacheSPI c)
+ {
+ //this.cache = c;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config = config;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRegionManager(RegionManager manager)
+ {
+ //this.regionManager = manager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void storeEntireState(ObjectInputStream is) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void create() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void destroy()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-01 22:06:48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-01 22:10:06 UTC (rev 462)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2009 eXo Platform SAS.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
16 years, 8 months
exo-jcr SVN: r461 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-01 17:06:48 -0500 (Sun, 01 Nov 2009)
New Revision: 461
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
Log:
EXOJCR-200: connection new hierarchy; paths fixes
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-01 22:06:48 UTC (rev 461)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.jboss.cache.Fqn;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 31.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public abstract class JBossCacheStorage
+{
+
+ public static final String TREE = "$TREE".intern();
+
+ public static final String ITEMS = "$ITEMS".intern();
+
+ public static final String ITEM_DATA = "$data".intern();
+
+ public static final String ITEM_ID = "$id".intern();
+
+ protected final Fqn<String> treeRoot;
+
+ protected final Fqn<String> itemsRoot;
+
+ protected JBossCacheStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
+ {
+ this.treeRoot = treeRoot;
+ this.itemsRoot = itemsRoot;
+ }
+
+ protected Fqn<String> makeNodeFqn(QPath nodePath)
+ {
+ QPathEntry[] path = nodePath.getEntries();
+ String[] fqns = new String[path.length];
+
+ for (int i = 0; i < path.length; i++)
+ {
+ fqns[i] = path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ protected Fqn<String> makeParentFqn(QPath propertyPath)
+ {
+ QPathEntry[] path = propertyPath.getEntries();
+ int pathLen = path.length - 1;
+ String[] fqns = new String[pathLen];
+
+ for (int i = 0; i < pathLen; i++)
+ {
+ fqns[i] = path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ protected Fqn<String> makeIdFqn(String itemId)
+ {
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-30 22:03:54 UTC (rev 460)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-01 22:06:48 UTC (rev 461)
@@ -18,12 +18,18 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -31,42 +37,29 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
*
* <br/>Date: 23.10.2009<br/>
*
* Cache contains several regions:<br/>
- * Workspace tree. /$repo_name/$ws_name/$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
- * Items map. /$repo_name/$ws_name/$ITEMS: Key=Id, Value = ItemData.<br/>
- * References map ??? /$repo_name/$ws_name/$REFS: Key=NodeId, Value = PropertyId.<br/>
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
+ * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
+ * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
*
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class JBossCacheStorageConnection extends DBConstants implements WorkspaceStorageConnection
+public class JBossCacheStorageConnection extends JBossCacheStorage implements WorkspaceStorageConnection
{
protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
- //public static final InternalQName NODE = new InternalQName(Constants.NS_DEFAULT_URI, "$node");
- public static final String ITEM_DATA = "$idata".intern();
-
- public static final String ITEM_ID = "$id".intern();
-
private final Cache<Serializable, Object> cache;
- private final Node<Serializable, Object> treeRoot;
+ //private final Node<Serializable, Object> treeRoot;
- private final Node<Serializable, Object> itemsRoot;
+ //private final Node<Serializable, Object> itemsRoot;
/**
* Start batching flag. 'true' if batching was started, 'false' if batching is not start.
@@ -81,46 +74,13 @@
public JBossCacheStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
Node<Serializable, Object> itemsRoot)
{
+ super(treeRoot.getFqn(), itemsRoot.getFqn());
+
this.cache = cache;
- this.itemsRoot = itemsRoot;
- this.treeRoot = treeRoot;
+ //this.itemsRoot = itemsRoot;
+ //this.treeRoot = treeRoot;
}
- private Fqn<String> makeNodeFqn(QPath nodePath)
- {
- QPathEntry[] path = nodePath.getEntries();
- String[] fqns = new String[path.length];
-
- for (int i = 0; i < path.length; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns));
- }
-
- private Fqn<String> makeParentFqn(QPath propertyPath)
- {
- QPathEntry[] path = propertyPath.getEntries();
- int pathLen = path.length - 1;
- String[] fqns = new String[pathLen];
-
- for (int i = 0; i < pathLen; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns));
- }
-
- private Fqn<String> makeIdFqn(String itemId)
- {
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(itemsRoot.getFqn(), Fqn.fromString(itemId));
- }
-
/**
* {@inheritDoc}
*/
@@ -192,7 +152,6 @@
NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
if (node == null)
{
- treePrint(treeRoot);
throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
}
childs.add(node);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-10-30 22:03:54 UTC (rev 460)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-01 22:06:48 UTC (rev 461)
@@ -57,10 +57,6 @@
public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
- public static final String ROOT = "$ROOT".intern();
-
- public static final String ITEMS = "$ITEMS".intern();
-
protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheWorkspaceDataContainer");
protected final String repositoryName;
@@ -117,8 +113,8 @@
//Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
// prepare cache structures
- this.tree = cacheRoot.addChild(Fqn.fromString(ROOT));
- this.items = cacheRoot.addChild(Fqn.fromString(ITEMS));
+ this.tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
+ this.items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
}
public void start()
16 years, 8 months