exo-jcr SVN: r440 - in jcr/branches/1.12.0-JBC/component/core: src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-28 15:21:30 -0400 (Wed, 28 Oct 2009)
New Revision: 440
Modified:
jcr/branches/1.12.0-JBC/component/core/pom.xml
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/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-200: WorkspaceStorageConnection impl parts
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-10-28 16:24:19 UTC (rev 439)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-10-28 19:21:30 UTC (rev 440)
@@ -568,10 +568,10 @@
</property>
</systemProperties>
<includes>
- <include>**/**/TestErrorMultithreading__.java</include>
<include>**/**/JBossCacheServiceTest__.java</include>
-
- <include>**/**/TestItem.java</include>
+ <include>**/**/TestItem_.java</include>
+
+ <include>**/**/JBossCacheStorageConnectionTest.java</include>
</includes>
</configuration>
</plugin>
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-28 16:24:19 UTC (rev 439)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-28 19:21:30 UTC (rev 440)
@@ -142,8 +142,7 @@
Fqn<String> parentFqn = makeParentFqn(data.getQPath());
// add an attr to the parent node as key=PropertyName value=PropertyId
- cache.put(parentFqn, data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString(true),
- data.getIdentifier());
+ cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
}
@@ -217,12 +216,13 @@
List<PropertyData> childs = new ArrayList<PropertyData>();
// TODO keys Serializable shoudl be!!!
- for (Object key : parentNode.getKeys())
+ for (Serializable key : parentNode.getKeys())
{
if (!key.equals(ITEM_ID))
{
+ String propId = (String) parentNode.get(key);
// TODO NodeData or PropertyData? As ItemData check then and cast.
- PropertyData property = (PropertyData)cache.get(makeIdFqn((String)key), ITEM_DATA);
+ PropertyData property = (PropertyData)cache.get(makeIdFqn(propId), ITEM_DATA);
if (property == null)
{
throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-28 16:24:19 UTC (rev 439)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-28 19:21:30 UTC (rev 440)
@@ -36,20 +36,25 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import java.io.Serializable;
+import java.util.List;
+
import junit.framework.TestCase;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import java.io.Serializable;
-
/**
* Created by The eXo Platform SAS.
*
@@ -77,7 +82,7 @@
super.setUp();
// JBossCache
- String jbcConfig = "/conf/portal/exojcr-jboss-cache-conf.xml";
+ String jbcConfig = "conf/portal/exojcr-jboss-cache-conf.xml";
cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
@@ -108,23 +113,274 @@
super.tearDown();
}
+ private void treePrint(Node<Serializable, Object> node)
+ {
+ for (Node<Serializable, Object> child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
+ private Fqn<String> makeFqn(Node<Serializable, Object> root, 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(root.getFqn(), Fqn.fromElements(fqns));
+ }
+
public void testAddNode() throws Exception
{
- // add
- conn.add(new TransientNodeData(QPath.parse("[]:node:1"), "1", 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
- 0, Constants.ROOT_UUID, new AccessControlList()));
-
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
// test
- tree.getChildren();
+ treePrint(tree);
+
+ // get root node ([]:1)
+ Node<Serializable, Object> rootNode =
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertNotNull("Node expected", rootNode);
+
+ assertEquals("Childs expected", 2, rootNode.getChildren().size());
+
+ for (Node<Serializable, Object> child : rootNode.getChildren())
+ {
+ String nodeName = child.getFqn().getLastElementAsString();
+ String nodeId = (String)child.get(JBossCacheStorageConnection.ITEM_ID);
+ if (nodeName.equals(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)))
+ {
+ assertEquals("Node id wrong", node1id, nodeId);
+ }
+ else if (nodeName
+ .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1]
+ .getAsString(true)))
+ {
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
+ }
+ else
+ {
+ fail("Wrong Node name " + nodeName);
+ }
+ }
}
- public void testGetChildNodesData()
+ public void testAddProperty() throws Exception
{
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
- // prepare
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+ 1, 1, Constants.ROOT_UUID, false));
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // test
+ treePrint(tree);
+
+ Node<Serializable, Object> rootNode =
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
+
+ String pid = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
+ assertNotNull("Property ID should exists", pid);
+ assertEquals("Property ID wrong", propId1, pid);
+
+ pid = (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsString());
+ assertNotNull("Property ID should exists", pid);
+ assertEquals("Property ID wrong", propId2, pid);
+
+ // TODO check order
+ int index = 0;
+ for (Serializable key : rootNode.getKeys())
+ {
+ //System.out.println(key);
+ //index++;
+ }
+ }
+
+ public void testDeleteNode() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ // get root node ([]:1)
+ Node<Serializable, Object> rootNode =
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertEquals("Childs expected", 2, rootNode.getChildren().size());
+
+ // delete /node
+ conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // test
+ treePrint(tree);
+
+ Node<Serializable, Object> node =
+ rootNode.getChild(Fqn
+ .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
+
+ assertNull("Node should be deleted", node);
+
+ assertEquals("Childs expected", 1, rootNode.getChildren().size());
+
+ Node<Serializable, Object> child = rootNode.getChildren().iterator().next();
+ assertEquals("Node name wrong",
+ Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1].getAsString(true),
+ child.getFqn().getLastElementAsString());
+
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
+ }
+
+ public void testGetChildNodes() throws Exception
+ {
+ // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
// check
+ List<NodeData> childs =
+ conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+ assertEquals("Childs amount wrong", 2, childs.size());
+
+ for (NodeData child : childs)
+ {
+ if (child.getQPath().equals(node1path))
+ {
+ assertEquals("Node id wrong", node1id, child.getIdentifier());
+ }
+ else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
+ {
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.getIdentifier());
+ }
+ else
+ {
+ fail("Wrong Node found");
+ }
+ }
}
+ public void testGetChildProperties() throws Exception
+ {
+ // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/a)
+ String propId3 = "3";
+ InternalQName propName3 = InternalQName.parse("[]a");
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName3), propId3, 1, 1,
+ Constants.ROOT_UUID, false));
+
+ // add property (/b)
+ String propId4 = "4";
+ InternalQName propName4 = InternalQName.parse("[]b");
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName4), propId4, 1, 1,
+ Constants.ROOT_UUID, false));
+
+ // check
+ treePrint(tree);
+
+ List<PropertyData> childs =
+ conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ assertEquals("Childs amount wrong", 4, childs.size());
+
+ for (PropertyData child : childs)
+ {
+ if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
+ {
+ assertEquals("Property id wrong", propId1, child.getIdentifier());
+ }
+ else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYPES))
+ {
+ assertEquals("Property id wrong", propId2, child.getIdentifier());
+ }
+ else if (child.getQPath().getName().equals(propName3))
+ {
+ assertEquals("Property id wrong", propId3, child.getIdentifier());
+ }
+ else if (child.getQPath().getName().equals(propName4))
+ {
+ assertEquals("Property id wrong", propId4, child.getIdentifier());
+ }
+ else
+ {
+ fail("Wrong Property found");
+ }
+ }
+ }
+
}
14 years, 6 months
exo-jcr SVN: r439 - jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-28 12:24:19 -0400 (Wed, 28 Oct 2009)
New Revision: 439
Modified:
jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/UploadFileCommand.java
Log:
EXOJCR-216 Upload image bug fixed
Modified: jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/UploadFileCommand.java
===================================================================
--- jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/UploadFileCommand.java 2009-10-28 12:52:51 UTC (rev 438)
+++ jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/UploadFileCommand.java 2009-10-28 16:24:19 UTC (rev 439)
@@ -110,9 +110,10 @@
fields.put(item.getFieldName(), item);
}
FileItem uplFile = (FileItem)fields.get("NewFile");
+
// On IE, the file name is specified as an absolute path.
- String fileName = new File(uplFile.getName()).getName();
+ String fileName = org.apache.commons.io.FilenameUtils.getName(uplFile.getName());
Node file =
JCRCommandHelper
14 years, 6 months
exo-jcr SVN: r438 - in jcr/trunk/exo.jcr.component.core: src/test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-28 08:52:51 -0400 (Wed, 28 Oct 2009)
New Revision: 438
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
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-jcr-config-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-165: valid XMLs committed
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2009-10-28 08:54:26 UTC (rev 437)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2009-10-28 12:52:51 UTC (rev 438)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright (C) 2009 eXo Platform SAS.
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2009-10-28 08:54:26 UTC (rev 437)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2009-10-28 12:52:51 UTC (rev 438)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright (C) 2009 eXo Platform SAS.
@@ -18,7 +19,6 @@
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
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-10-28 08:54:26 UTC (rev 437)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2009-10-28 12:52:51 UTC (rev 438)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright (C) 2009 eXo Platform SAS.
@@ -18,7 +19,6 @@
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2009-10-28 08:54:26 UTC (rev 437)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2009-10-28 12:52:51 UTC (rev 438)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright (C) 2009 eXo Platform SAS.
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-10-28 08:54:26 UTC (rev 437)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-10-28 12:52:51 UTC (rev 438)
@@ -1,4 +1,4 @@
-
+<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright (C) 2009 eXo Platform SAS.
14 years, 6 months
exo-jcr SVN: r437 - 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: areshetnyak
Date: 2009-10-28 04:54:26 -0400 (Wed, 28 Oct 2009)
New Revision: 437
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
Log:
EXOJCR-201 : ExoJCRCacheLoader was changed.
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-10-28 06:47:29 UTC (rev 436)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-10-28 08:54:26 UTC (rev 437)
@@ -18,28 +18,29 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+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;
+
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.datamodel.QPath;
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.Modification.ModificationType;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.CacheLoader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
*
@@ -48,11 +49,19 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class ExoJCRCacheLoader implements CacheLoader
+public class ExoJCRCacheLoader
+ 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.
*
@@ -60,10 +69,11 @@
*/
public void initDataContainer(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
{
- if (this.dataContainer != null) {
+ if (this.dataContainer != null)
+ {
throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
}
-
+
this.dataContainer = dataContainer;
}
@@ -72,8 +82,11 @@
*/
public void commit(Object tx) throws Exception
{
- // TODO Auto-generated method stub
-
+ List<Modification> modifications = transactions.remove(tx);
+ if (modifications != null)
+ doModified(modifications);
+ else
+ throw new ExoJCRCacheLoaderException("Transaction " + tx + " not exist in transaction table");
}
/**
@@ -108,8 +121,7 @@
*/
public IndividualCacheLoaderConfig getConfig()
{
- // TODO Auto-generated method stub
- return null;
+ return config;
}
/**
@@ -135,33 +147,64 @@
*/
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 (Modification md : modifications)
+ try
+ {
+ for (int modificatinIndex = 0; modificatinIndex < modifications.size(); modificatinIndex++)
{
- switch (md.getType()) {
- case PUT_KEY_VALUE:
- doModified(md, jdbcConnection);
+ Modification md = modifications.get(modificatinIndex);
+ switch (md.getType())
+ {
+ case PUT_KEY_VALUE :
+ doModifiedAddOrUpdate(md, jdbcConnection);
break;
- case REMOVE_NODE:
- doRemove(md, jdbcConnection);
+ case REMOVE_NODE :
+ doRemove(md, jdbcConnection, "TODO $<Node identifier>");
break;
}
}
-
+
if (jdbcConnection != null)
jdbcConnection.commit();
- } finally {
+ }
+ finally
+ {
if (jdbcConnection != null && jdbcConnection.isOpened())
jdbcConnection.rollback();
}
}
-
- private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection) {
- //TODO
+
+ 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
@@ -169,34 +212,41 @@
* @throws IllegalStateException
* @throws RepositoryException
*/
- private void doModified(Modification modification, JDBCStorageConnection jdbcConnection) throws IllegalStateException, RepositoryException
+ private void doModifiedAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
+ throws IllegalStateException, RepositoryException
{
- if (modification.getValue() instanceof NodeData)
+ if (modification.getValue() instanceof NodeData)
{
//add or update node data
NodeData nodeData = (NodeData) modification.getValue();
-
+
ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
-
- if (itemData == null) {
+
+ if (itemData == null)
+ {
//add
jdbcConnection.add(nodeData);
- } else {
+ }
+ 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) {
+
+ if (itemData == null)
+ {
//add
jdbcConnection.add(propertyData);
- } else {
+ }
+ else
+ {
//update
jdbcConnection.update(propertyData);
}
@@ -261,8 +311,7 @@
*/
public void rollback(Object tx)
{
- // TODO Auto-generated method stub
-
+ transactions.remove(tx);
}
/**
@@ -270,7 +319,7 @@
*/
public void setCache(CacheSPI c)
{
- // TODO Auto-generated method stub
+ this.cache = c;
}
@@ -279,7 +328,7 @@
*/
public void setConfig(IndividualCacheLoaderConfig config)
{
- // TODO Auto-generated method stub
+ this.config = config;
}
@@ -288,8 +337,7 @@
*/
public void setRegionManager(RegionManager manager)
{
- // TODO Auto-generated method stub
-
+ this.regionManager = manager;
}
/**
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java 2009-10-28 08:54:26 UTC (rev 437)
@@ -0,0 +1,73 @@
+/*
+ * 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.storage.jbosscache;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 27.10.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class ExoJCRCacheLoaderException
+ extends Exception
+{
+ /**
+ * Constructs an Exception without a message.
+ */
+ public ExoJCRCacheLoaderException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an Exception with a detailed message.
+ *
+ * @param Message
+ * The message associated with the exception.
+ */
+ public ExoJCRCacheLoaderException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs an Exception with a detailed message and base exception.
+ *
+ * @param Message
+ * The message associated with the exception.
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public ExoJCRCacheLoaderException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * RepositoryConfigurationException constructor.
+ *
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public ExoJCRCacheLoaderException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
14 years, 6 months
exo-jcr SVN: r436 - in ws/branches/2.2.x: rest and 33 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2009-10-28 02:47:29 -0400 (Wed, 28 Oct 2009)
New Revision: 436
Added:
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationPublisher.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/StandaloneRestServlet.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/pom.xml
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/ExoJAXRSApplication.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/StartableApplicationPublisher.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/portal/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/portal/configuration.xml
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/DependencySupplierTest.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/StartableApplicationPublisherTest.java
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/standalone/
ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/standalone/test-configuration.xml
Removed:
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationDeployer.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RestComponentDeployer.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/BaseRestServlet.java
ws/branches/2.2.x/rest/ext/src/main/java/conf/portal/
ws/branches/2.2.x/rest/ext/src/main/java/org/exoplatform/services/rest/impl/
ws/branches/2.2.x/rest/ext/src/main/java/org/exoplatform/services/rest/servlet/
ws/branches/2.2.x/rest/ext/src/test/java/conf/standalone/
ws/branches/2.2.x/rest/ext/src/test/java/org/exoplatform/services/rest/impl/
Modified:
ws/branches/2.2.x/pom.xml
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/DependencySupplier.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/SimpleDependencySupplier.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/InjectableProvider.java
ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/RestInitializedListener.java
ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java
ws/branches/2.2.x/rest/ext/pom.xml
Log:
EXOJCR-214 : created deploy sub-project, made required changes in exo.ws.rest.core and exo.ws.res.ext
Modified: ws/branches/2.2.x/pom.xml
===================================================================
--- ws/branches/2.2.x/pom.xml 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/pom.xml 2009-10-28 06:47:29 UTC (rev 436)
@@ -58,6 +58,7 @@
<module>testframework</module>
<module>rest/core</module>
<module>rest/ext</module>
+ <module>rest/exo.ws.rest.deploy</module>
<module>packaging/module</module>
</modules>
@@ -80,6 +81,11 @@
</dependency>
<dependency>
<groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.ext</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.testframework</artifactId>
<version>${project.version}</version>
</dependency>
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/DependencySupplier.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/DependencySupplier.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/DependencySupplier.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -35,6 +35,6 @@
* @return object of required type or null if instance described by
* <code>parameter</code> may not be produced
*/
- Object getInstanceOfType(Parameter parameter);
+ Object getComponent(Parameter parameter);
}
Deleted: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationDeployer.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationDeployer.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationDeployer.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -1,50 +0,0 @@
-/*
- * 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.rest.impl;
-
-import org.exoplatform.services.rest.ResourceBinder;
-
-import javax.ws.rs.core.Application;
-
-/**
- * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
- * @version $Id: $
- */
-public class ApplicationDeployer extends RestComponentDeployer
-{
-
- public ApplicationDeployer(ResourceBinder resources, ProviderBinder providers)
- {
- super(resources, providers);
- }
-
- @SuppressWarnings("unchecked")
- public void deploy(Application application)
- {
- for (Object instance : application.getSingletons())
- {
- deploy(instance);
- }
- for (Class clazz : application.getClasses())
- {
- deploy(clazz);
- }
- }
-
-}
Copied: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationPublisher.java (from rev 435, ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationDeployer.java)
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationPublisher.java (rev 0)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationPublisher.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,58 @@
+/*
+ * 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.rest.impl;
+
+import java.util.Set;
+
+import org.exoplatform.services.rest.ResourceBinder;
+
+import javax.ws.rs.core.Application;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class ApplicationPublisher
+{
+
+ protected RestComponentResolver resolver;
+
+ public ApplicationPublisher(ResourceBinder resources, ProviderBinder providers)
+ {
+ resolver = new RestComponentResolver(resources, providers);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void publish(Application application)
+ {
+ Set<Object> singletons = application.getSingletons();
+ if (singletons != null)
+ {
+ for (Object instance : singletons)
+ resolver.addSingleton(instance);
+ }
+ Set<Class<?>> perRequests = application.getClasses();
+ if (perRequests != null)
+ {
+ for (Class clazz : perRequests)
+ resolver.addPerRequest(clazz);
+ }
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ApplicationPublisher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -254,7 +254,7 @@
.type(MediaType.TEXT_PLAIN).build());
}
- Object tmp = context.getDependencySupplier().getInstanceOfType(cp);
+ Object tmp = context.getDependencySupplier().getComponent(cp);
if (tmp == null)
{
String msg =
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -228,7 +228,7 @@
{
if (context.getDependencySupplier() != null)
{
- Object tmp = context.getDependencySupplier().getInstanceOfType(this);
+ Object tmp = context.getDependencySupplier().getComponent(this);
if (tmp != null)
{
try
Deleted: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RestComponentDeployer.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RestComponentDeployer.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/RestComponentDeployer.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -1,48 +0,0 @@
-/*
- * 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.rest.impl;
-
-import org.exoplatform.services.rest.ResourceBinder;
-
-/**
- * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
- * @version $Id: $
- */
-public abstract class RestComponentDeployer
-{
-
- protected RestComponentResolver resolver;
-
- public RestComponentDeployer(ResourceBinder resources, ProviderBinder providers)
- {
- resolver = new RestComponentResolver(resources, providers);
- }
-
- public void deploy(Object instance)
- {
- resolver.addSingleton(instance);
- }
-
- @SuppressWarnings("unchecked")
- public void deploy(Class clazz)
- {
- resolver.addPerRequest(clazz);
- }
-
-}
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/SimpleDependencySupplier.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/SimpleDependencySupplier.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/SimpleDependencySupplier.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -38,7 +38,7 @@
/**
* {@inheritDoc}
*/
- public Object getInstanceOfType(Parameter parameter)
+ public Object getComponent(Parameter parameter)
{
if (parameter instanceof FieldInjector)
{
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/InjectableProvider.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/InjectableProvider.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/impl/method/InjectableProvider.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -25,6 +25,7 @@
/**
* @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
* @version $Id$
+ * @deprecated
*/
public class InjectableProvider extends ParameterResolver<Inject>
{
@@ -40,7 +41,7 @@
public Object resolve(Parameter parameter, ApplicationContext context) throws Exception
{
if (context.getDependencySupplier() != null)
- return context.getDependencySupplier().getInstanceOfType(parameter);
+ return context.getDependencySupplier().getComponent(parameter);
return null;
}
Deleted: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/BaseRestServlet.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/BaseRestServlet.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/BaseRestServlet.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -1,89 +0,0 @@
-/*
- * 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.rest.servlet;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.RequestHandler;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.EnvironmentContext;
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
- * @version $Id$
- */
-public class BaseRestServlet extends HttpServlet
-{
-
- private static final long serialVersionUID = -8234561611241680339L;
-
- private static final Log LOG = ExoLogger.getLogger(BaseRestServlet.class.getName());
-
- private RequestHandler requestHandler;
-
- private ServletConfig servletConfig;
-
- protected RequestHandler getRequestHandler()
- {
- return requestHandler;
- }
-
- public void init(ServletConfig servletConfig)
- {
- this.servletConfig = servletConfig;
- requestHandler = (RequestHandler)servletConfig.getServletContext().getAttribute(RequestHandler.class.getName());
- }
-
- public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException,
- ServletException
- {
-
- EnvironmentContext env = new EnvironmentContext();
- env.put(HttpServletRequest.class, httpRequest);
- env.put(HttpServletResponse.class, httpResponse);
- env.put(ServletConfig.class, servletConfig);
- env.put(ServletContext.class, servletConfig.getServletContext());
-
- try
- {
- EnvironmentContext.setCurrent(env);
- ServletContainerRequest request = new ServletContainerRequest(httpRequest);
- ContainerResponse response = new ContainerResponse(new ServletContainerResponseWriter(httpResponse));
- getRequestHandler().handleRequest(request, response);
- }
- catch (Exception e)
- {
- LOG.error(e);
- throw new ServletException(e);
- }
- finally
- {
- EnvironmentContext.setCurrent(null);
- }
- }
-
-}
Modified: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/RestInitializedListener.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/RestInitializedListener.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/RestInitializedListener.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -25,7 +25,7 @@
import org.exoplatform.services.rest.Filter;
import org.exoplatform.services.rest.RequestHandler;
import org.exoplatform.services.rest.ResourceBinder;
-import org.exoplatform.services.rest.impl.ApplicationDeployer;
+import org.exoplatform.services.rest.impl.ApplicationPublisher;
import org.exoplatform.services.rest.impl.ProviderBinder;
import org.exoplatform.services.rest.impl.ResourceBinderImpl;
import org.exoplatform.services.rest.impl.RequestHandlerImpl;
@@ -35,6 +35,7 @@
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.net.URL;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -71,7 +72,7 @@
String dependencyInjectorFQN = event.getServletContext().getInitParameter(DependencySupplier.class.getName());
ResourceBinder resources = new ResourceBinderImpl();
- ApplicationDeployer deployer = new ApplicationDeployer(resources, ProviderBinder.getInstance());
+ ApplicationPublisher publisher = new ApplicationPublisher(resources, ProviderBinder.getInstance());
String applicationFQN = event.getServletContext().getInitParameter("javax.ws.rs.Application");
if (applicationFQN != null)
@@ -85,7 +86,7 @@
{
Class<?> cl = Thread.currentThread().getContextClassLoader().loadClass(applicationFQN.trim());
Application application = (Application)cl.newInstance();
- deployer.deploy(application);
+ publisher.publish(application);
}
catch (ClassNotFoundException cnfe)
{
@@ -113,6 +114,7 @@
annotationDB.scanArchives(classes);
annotationDB.scanArchives(libs);
+ final Set<Class<?>> scanned = new HashSet<Class<?>>();
Map<String, Set<String>> results = annotationDB.getAnnotationIndex();
for (String annotation : new String[]{Path.class.getName(), Provider.class.getName(),
Filter.class.getName()})
@@ -129,8 +131,7 @@
LOG.info("Skip abstract class or interface " + fqn);
continue;
}
- deployer.deploy(cl);
- LOG.info("Deployed component: " + fqn);
+ scanned.add(cl);
}
catch (ClassNotFoundException e)
{
@@ -139,6 +140,14 @@
}
}
}
+ publisher.publish(new Application()
+ {
+ @Override
+ public Set<Class<?>> getClasses()
+ {
+ return scanned;
+ }
+ });
}
catch (IOException e)
{
Copied: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/StandaloneRestServlet.java (from rev 435, ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/BaseRestServlet.java)
===================================================================
--- ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/StandaloneRestServlet.java (rev 0)
+++ ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/StandaloneRestServlet.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,89 @@
+/*
+ * 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.rest.servlet;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.RequestHandler;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class StandaloneRestServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = -8234561611241680339L;
+
+ private static final Log LOG = ExoLogger.getLogger(StandaloneRestServlet.class.getName());
+
+ private RequestHandler requestHandler;
+
+ private ServletConfig servletConfig;
+
+ protected RequestHandler getRequestHandler()
+ {
+ return requestHandler;
+ }
+
+ public void init(ServletConfig servletConfig)
+ {
+ this.servletConfig = servletConfig;
+ requestHandler = (RequestHandler)servletConfig.getServletContext().getAttribute(RequestHandler.class.getName());
+ }
+
+ public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException,
+ ServletException
+ {
+
+ EnvironmentContext env = new EnvironmentContext();
+ env.put(HttpServletRequest.class, httpRequest);
+ env.put(HttpServletResponse.class, httpResponse);
+ env.put(ServletConfig.class, servletConfig);
+ env.put(ServletContext.class, servletConfig.getServletContext());
+
+ try
+ {
+ EnvironmentContext.setCurrent(env);
+ ServletContainerRequest request = new ServletContainerRequest(httpRequest);
+ ContainerResponse response = new ContainerResponse(new ServletContainerResponseWriter(httpResponse));
+ getRequestHandler().handleRequest(request, response);
+ }
+ catch (Exception e)
+ {
+ LOG.error(e);
+ throw new ServletException(e);
+ }
+ finally
+ {
+ EnvironmentContext.setCurrent(null);
+ }
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/core/src/main/java/org/exoplatform/services/rest/servlet/StandaloneRestServlet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java
===================================================================
--- ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/core/src/test/java/org/exoplatform/services/rest/impl/resource/ApplicationTest.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -24,7 +24,7 @@
import org.exoplatform.services.rest.RequestFilter;
import org.exoplatform.services.rest.ResponseFilter;
import org.exoplatform.services.rest.impl.AbstractResourceTest;
-import org.exoplatform.services.rest.impl.ApplicationDeployer;
+import org.exoplatform.services.rest.impl.ApplicationPublisher;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.method.MethodInvokerFilter;
import org.exoplatform.services.rest.resource.GenericMethodResource;
@@ -188,8 +188,8 @@
public void testRegistry()
{
- ApplicationDeployer deployer = new ApplicationDeployer(resources, providers);
- deployer.deploy(new Application1());
+ ApplicationPublisher deployer = new ApplicationPublisher(resources, providers);
+ deployer.publish(new Application1());
assertEquals(4, resources.getSize());
assertEquals(1, providers.getRequestFilters(null).size());
assertEquals(1, providers.getResponseFilters(null).size());
@@ -204,8 +204,8 @@
public void testAsResources() throws Exception
{
- ApplicationDeployer deployer = new ApplicationDeployer(resources, providers);
- deployer.deploy(new Application1());
+ ApplicationPublisher deployer = new ApplicationPublisher(resources, providers);
+ deployer.publish(new Application1());
// per-request
ContainerResponse resp = service("GET", "/a", "", null, null);
assertEquals(200, resp.getStatus());
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/pom.xml
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/pom.xml (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/pom.xml 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,45 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>ws-parent</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.ws.rest.deploy</artifactId>
+
+ <name>eXo WS :: REST :: Deploy</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/ExoJAXRSApplication.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/ExoJAXRSApplication.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/ExoJAXRSApplication.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -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.
+ */
+package org.exoplatform.services.rest.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class ExoJAXRSApplication extends Application implements Startable
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(ExoJAXRSApplication.class);
+
+ private ExoContainer container;
+
+ private Set<Class<?>> cls = new HashSet<Class<?>>();
+
+ private Set<Object> singletons = new HashSet<Object>();
+
+ public ExoJAXRSApplication(InitParams initParams, ExoContainerContext containerContext)
+ {
+ if (initParams != null)
+ {
+ for (Object cl : initParams.getValuesParam("ws.rest.components").getValues())
+ {
+ try
+ {
+ cls.add(Class.forName((String)cl));
+ }
+ catch (ClassNotFoundException e)
+ {
+ LOG.error("Failed load class " + cl, e);
+ }
+ }
+ }
+ container = containerContext.getContainer();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<Class<?>> getClasses()
+ {
+ return cls;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Object> getSingletons()
+ {
+ return singletons;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start()
+ {
+ for (Object resource : container.getComponentInstancesOfType(ResourceContainer.class))
+ singletons.add(resource);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/ExoJAXRSApplication.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/StartableApplicationPublisher.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/StartableApplicationPublisher.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/StartableApplicationPublisher.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,90 @@
+/*
+ * 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.rest.impl;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import javax.ws.rs.core.Application;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.rest.DependencySupplier;
+import org.exoplatform.services.rest.FieldInjector;
+import org.exoplatform.services.rest.Inject;
+import org.exoplatform.services.rest.Parameter;
+import org.exoplatform.services.rest.ResourceBinder;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class StartableApplicationPublisher extends ApplicationPublisher implements DependencySupplier, Startable
+{
+
+ private ExoContainer container;
+
+ public StartableApplicationPublisher(ResourceBinder resources, ExoContainerContext containerContext)
+ {
+ super(resources, ProviderBinder.getInstance());
+ container = containerContext.getContainer();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getComponent(Parameter parameter)
+ {
+ // Container can different.
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+
+ if (parameter instanceof FieldInjector)
+ {
+ for (Annotation a : parameter.getAnnotations())
+ {
+ // Do not process fields without annotation Inject
+ if (a.annotationType() == Inject.class)
+ {
+ return container.getComponentInstanceOfType(parameter.getParameterClass());
+ }
+ }
+ }
+ return container.getComponentInstanceOfType(parameter.getParameterClass());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void start()
+ {
+ List<Application> applications = container.getComponentInstancesOfType(Application.class);
+ for (Application application : applications)
+ publish(application);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/impl/StartableApplicationPublisher.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,87 @@
+/*
+ * 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.rest.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.web.AbstractHttpServlet;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.Connector;
+import org.exoplatform.services.rest.RequestHandler;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.EnvironmentContext;
+
+/**
+ * This servlet is front-end for the REST engine.
+ *
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class RestServlet extends AbstractHttpServlet implements Connector
+{
+
+ private static final Log LOG = ExoLogger.getLogger(RestServlet.class.getName());
+
+ /**
+ * Generated by Eclipse.
+ */
+ private static final long serialVersionUID = 2152962763071591181L;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onService(ExoContainer container, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
+ throws IOException, ServletException
+ {
+
+ RequestHandler requestHandler = (RequestHandler)container.getComponentInstanceOfType(RequestHandler.class);
+
+ EnvironmentContext env = new EnvironmentContext();
+ env.put(HttpServletRequest.class, httpRequest);
+ env.put(HttpServletResponse.class, httpResponse);
+ env.put(ServletConfig.class, config);
+ env.put(ServletContext.class, getServletContext());
+
+ try
+ {
+ EnvironmentContext.setCurrent(env);
+ ServletContainerRequest request = new ServletContainerRequest(httpRequest);
+ ContainerResponse response = new ContainerResponse(new ServletContainerResponseWriter(httpResponse));
+ requestHandler.handleRequest(request, response);
+ }
+ catch (Exception e)
+ {
+ LOG.error(e);
+ throw new ServletException(e);
+ }
+ finally
+ {
+ EnvironmentContext.setCurrent(null);
+ }
+ }
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/portal/configuration.xml
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/main/resources/conf/portal/configuration.xml 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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.
+
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.slf4j.Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout" />
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
+ <property name="log4j.appender.stdout.threshold" value="DEBUG" />
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
+ <property name="log4j.appender.file.File" value="target/container.log" />
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ </properties-param>
+ </init-params>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.ExoJAXRSApplication</type>
+ <init-params>
+ <values-param>
+ <name>ws.rest.components</name>
+ <value>org.exoplatform.services.rest.ext.provider.HierarchicalPropertyEntityProvider</value>
+ <value>org.exoplatform.services.rest.ext.filter.MethodOverrideFilter</value>
+ <value>org.exoplatform.services.rest.ext.method.filter.MethodAccessFilter</value>
+ </values-param>
+ </init-params>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.StartableApplicationPublisher</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.RequestHandlerImpl</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.ResourceBinderImpl</type>
+ </component>
+
+</configuration>
\ No newline at end of file
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,45 @@
+/*
+ * 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.rest.impl;
+
+import org.exoplatform.container.StandaloneContainer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public abstract class BaseTest extends TestCase
+{
+
+ protected StandaloneContainer container;
+
+ public void setUp() throws Exception
+ {
+ StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml");
+ container = StandaloneContainer.getInstance();
+ }
+
+ protected void setContext()
+ {
+ ApplicationContextImpl.setCurrent(new ApplicationContextImpl(null, null, ProviderBinder.getInstance()));
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/BaseTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/DependencySupplierTest.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/DependencySupplierTest.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/DependencySupplierTest.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,54 @@
+/*
+ * 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.rest.impl;
+
+import java.lang.annotation.Annotation;
+
+import org.exoplatform.services.rest.DependencySupplier;
+import org.exoplatform.services.rest.Parameter;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class DependencySupplierTest extends BaseTest
+{
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ setContext();
+ }
+
+ public static class Component1
+ {
+ // For testing DependencySupplier.
+ }
+
+ public void testDependencySupplier()
+ {
+ DependencySupplier depSupplier =
+ (DependencySupplier)container.getComponentInstanceOfType(DependencySupplier.class);
+ assertNotNull(depSupplier);
+ container.registerComponentInstance(new Component1());
+ Parameter t = new ConstructorParameterImpl(null, new Annotation[0], Component1.class, null, null, false);
+ assertNotNull(depSupplier.getComponent(t));
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/DependencySupplierTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/StartableApplicationPublisherTest.java
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/StartableApplicationPublisherTest.java (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/StartableApplicationPublisherTest.java 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,179 @@
+/*
+ * 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.rest.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+
+import org.exoplatform.services.rest.Filter;
+import org.exoplatform.services.rest.GenericContainerRequest;
+import org.exoplatform.services.rest.GenericContainerResponse;
+import org.exoplatform.services.rest.RequestFilter;
+import org.exoplatform.services.rest.RequestHandler;
+import org.exoplatform.services.rest.ResponseFilter;
+import org.exoplatform.services.rest.method.MethodInvokerFilter;
+import org.exoplatform.services.rest.provider.EntityProvider;
+import org.exoplatform.services.rest.resource.GenericMethodResource;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
+/**
+ * @author <a href="mailto:andrey.parfonov@exoplatform.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class StartableApplicationPublisherTest extends BaseTest
+{
+
+ private RequestHandler handler;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ setContext();
+ handler = (RequestHandler)container.getComponentInstanceOfType(RequestHandler.class);
+ assertNotNull(handler);
+ }
+
+ // Check does we get all additional component specified in configuration.
+ public void testDeployAdditionalComponents()
+ {
+ ProviderBinder providers = ProviderBinder.getInstance();
+ // XXX Able (no NPE) to use null instead "path" because UriPattern
+ // for filters is null and path will be never checked.
+ assertEquals(1, providers.getRequestFilters(null).size());
+ assertEquals(1, providers.getMethodInvokerFilters(null).size());
+ // -----
+ assertNotNull(providers.getMessageBodyReader(FakeEntity.class, null, null, MediaType.APPLICATION_XML_TYPE));
+ assertNotNull(providers.getMessageBodyWriter(FakeEntity.class, null, null, MediaType.APPLICATION_XML_TYPE));
+ }
+
+ public void testResource() throws Exception
+ {
+ ContainerRequest request =
+ new ContainerRequest("GET", new URI("http://localhost:8080/rest/a/b"), new URI("http://localhost:8080/rest"),
+ new ByteArrayInputStream("to be or not to be".getBytes("UTF-8")), new MultivaluedMapImpl());
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse response = new ContainerResponse(writer);
+ handler.handleRequest(request, response);
+ assertEquals(200, response.getStatus());
+ assertEquals("echo: to be or not to be", new String(writer.getBody()));
+ }
+
+ @Provider
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ public static class FakeEntityProvider implements EntityProvider<FakeEntity>
+ {
+
+ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
+ {
+ return type == FakeEntity.class;
+ }
+
+ public FakeEntity readFrom(Class<FakeEntity> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException,
+ WebApplicationException
+ {
+ return new FakeEntity();
+ }
+
+ public long getSize(FakeEntity t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
+ {
+ return 0;
+ }
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
+ {
+ return type == FakeEntity.class;
+ }
+
+ public void writeTo(FakeEntity t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
+ WebApplicationException
+ {
+ entityStream.write("fake-entity".getBytes("UTF-8"));
+ }
+
+ }
+
+ public static class FakeEntity
+ {
+
+ }
+
+ // --------------
+
+ @Filter
+ public static class FakeRequestFilter implements RequestFilter
+ {
+ public void doFilter(GenericContainerRequest request)
+ {
+ }
+ }
+
+ // --------------
+
+ @Filter
+ public static class FakeResponseFilter implements ResponseFilter
+ {
+ public void doFilter(GenericContainerResponse response)
+ {
+ }
+ }
+
+ // --------------
+
+ @Filter
+ public static class FakeMethodInvokerFilter implements MethodInvokerFilter
+ {
+ public void accept(GenericMethodResource genericMethodResource)
+ {
+ }
+ }
+
+ // -------------- Component of exo-container. It will become to be singleton resource.
+
+ @Path("a")
+ public static class Resource1 implements ResourceContainer
+ {
+
+ @GET
+ @Path("b")
+ public String m0(String s)
+ {
+ return "echo: " + s;
+ }
+
+ }
+
+}
Property changes on: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/java/org/exoplatform/services/rest/impl/StartableApplicationPublisherTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/standalone/test-configuration.xml (rev 0)
+++ ws/branches/2.2.x/rest/exo.ws.rest.deploy/src/test/resources/conf/standalone/test-configuration.xml 2009-10-28 06:47:29 UTC (rev 436)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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.
+
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.slf4j.Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout" />
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
+ <property name="log4j.appender.stdout.threshold" value="DEBUG" />
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
+ <property name="log4j.appender.file.File" value="target/container.log" />
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
+ <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ </properties-param>
+ </init-params>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.ExoJAXRSApplication</type>
+ <init-params>
+ <values-param>
+ <name>ws.rest.components</name>
+ <value>org.exoplatform.services.rest.impl.StartableApplicationPublisherTest$FakeEntityProvider</value>
+ <value>org.exoplatform.services.rest.impl.StartableApplicationPublisherTest$FakeRequestFilter</value>
+ <value>org.exoplatform.services.rest.impl.StartableApplicationPublisherTest$FakeResponseFilter</value>
+ <value>org.exoplatform.services.rest.impl.StartableApplicationPublisherTest$FakeMethodInvokerFilter</value>
+ </values-param>
+ </init-params>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.StartableApplicationPublisher</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.RequestHandlerImpl</type>
+ </component>
+ <component>
+ <type>org.exoplatform.services.rest.impl.ResourceBinderImpl</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.rest.impl.StartableApplicationPublisherTest$Resource1</type>
+ </component>
+
+</configuration>
\ No newline at end of file
Modified: ws/branches/2.2.x/rest/ext/pom.xml
===================================================================
--- ws/branches/2.2.x/rest/ext/pom.xml 2009-10-27 15:02:22 UTC (rev 435)
+++ ws/branches/2.2.x/rest/ext/pom.xml 2009-10-28 06:47:29 UTC (rev 436)
@@ -34,10 +34,6 @@
<dependencies>
<dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
<groupId>org.exoplatform.ws</groupId>
<artifactId>exo.ws.commons</artifactId>
</dependency>
@@ -46,10 +42,6 @@
<artifactId>exo.ws.rest.core</artifactId>
</dependency>
<dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.xml-processing</artifactId>
</dependency>
14 years, 6 months
exo-jcr SVN: r435 - in jcr/trunk/exo.jcr.component.webdav/src: main/java/org/exoplatform/services/jcr/webdav/command and 3 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-27 11:02:22 -0400 (Tue, 27 Oct 2009)
New Revision: 435
Added:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java
jcr/trunk/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-178 TestCache added
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java 2009-10-27 14:52:30 UTC (rev 434)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java 2009-10-27 15:02:22 UTC (rev 435)
@@ -280,16 +280,6 @@
*/
public static final String NO_CACHE = "no-cache";
- /**
- * Cache-Control value for images.
- */
- public static final String IMAGE_CACHE = "max-age=3600, must-revalidate";
-
- /**
- * Cache-Control value for audio-files.
- */
- public static final String AUDIO_CACHE = "max-age=118000, must-revalidate";
-
}
/**
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-27 14:52:30 UTC (rev 434)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-27 15:02:22 UTC (rev 435)
@@ -134,7 +134,7 @@
public static final String INIT_PARAM_CACHE_CONTROL = "cache-control";
- private HashMap<String, String> cacheControlMap = new HashMap<String, String>();
+ public static HashMap<String, String> cacheControlMap = new HashMap<String, String>();
/**
* Logger.
@@ -256,12 +256,6 @@
autoVersionType = pAutoVersion.getValue();
log.info(INIT_PARAM_AUTO_VERSION + " = " + autoVersionType);
}
-
-
-// <value-param>
-// <name>cache-control</name>
-// <value>^(gif|jpg|png)$:max-age=3600;^(image/jpeg|text/html)$:max-age=1800</value>
-// </value-param>
ValueParam pCacheControl = params.getValueParam(INIT_PARAM_CACHE_CONTROL);
if (pCacheControl != null)
@@ -269,9 +263,14 @@
String cacheControlValue = pCacheControl.getValue();
for (String element : cacheControlValue.split(";"))
{
- String mask = element.split(":")[0];
+ String contentTypes = element.split(":")[0];
String value = element.split(":")[1];
- cacheControlMap.put(mask, value);
+ String[] types = contentTypes.split(",");
+ for (String type : types)
+ {
+ cacheControlMap.put(type, value);
+ }
+
}
log.info(INIT_PARAM_CACHE_CONTROL + " = " + pCacheControl);
}
@@ -540,7 +539,7 @@
String uri =
uriInfo.getBaseUriBuilder().path(getClass()).path(repoName).path(workspaceName(repoPath)).build()
.toString();
- return new GetCommand().get(session, path(repoPath), version, uri, ranges, ifModifiedSince);
+ return new GetCommand().get(session, path(repoPath), version, uri, ranges, ifModifiedSince, cacheControlMap);
}
catch (PathNotFoundException exc)
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2009-10-27 14:52:30 UTC (rev 434)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2009-10-27 15:02:22 UTC (rev 435)
@@ -21,6 +21,7 @@
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
import org.exoplatform.services.jcr.webdav.Range;
+import org.exoplatform.services.jcr.webdav.WebDavServiceImpl;
import org.exoplatform.services.jcr.webdav.WebDavConst.CacheConstants;
import org.exoplatform.services.jcr.webdav.resource.CollectionResource;
import org.exoplatform.services.jcr.webdav.resource.FileResource;
@@ -40,6 +41,7 @@
import java.io.InputStream;
import java.net.URI;
+import java.util.HashMap;
import java.util.List;
import javax.jcr.Node;
@@ -78,7 +80,7 @@
* @param ranges ranges
* @return the instance of javax.ws.rs.core.Response
*/
- public Response get(Session session, String path, String version, String baseURI, List<Range> ranges, String ifModifiedSince)
+ public Response get(Session session, String path, String version, String baseURI, List<Range> ranges, String ifModifiedSince, HashMap<String, String> cahceControls)
{
if (version == null)
@@ -140,10 +142,11 @@
if (ranges.size() == 0)
{
+
return Response.ok().header(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength)).header(
ExtHttpHeaders.ACCEPT_RANGES, "bytes").header(ExtHttpHeaders.LAST_MODIFIED,
lastModifiedProperty.getValue()).header(ExtHttpHeaders.CACHE_CONTROL,
- generateCacheControl(contentType)).entity(istream).type(contentType).build();
+ generateCacheControl(cahceControls, contentType)).entity(istream).type(contentType).build();
}
@@ -264,17 +267,18 @@
* @param contentType content type
* @return Cache-Control value
*/
- private String generateCacheControl(String contentType)
+ private String generateCacheControl(HashMap<String, String> controls, String contentType)
{
- if (contentType.contains("image"))
+
+
+ if (controls.containsKey(contentType))
{
- return CacheConstants.IMAGE_CACHE;
+ return controls.get(contentType);
}
- else if (contentType.contains("audio"))
+ else
{
- return CacheConstants.AUDIO_CACHE;
+ return CacheConstants.NO_CACHE;
}
- return CacheConstants.NO_CACHE;
}
}
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java 2009-10-27 14:52:30 UTC (rev 434)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java 2009-10-27 15:02:22 UTC (rev 435)
@@ -24,22 +24,12 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-import java.util.TimeZone;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
import org.exoplatform.services.jcr.webdav.utils.TestUtils;
-import org.exoplatform.services.rest.ExtHttpHeaders;
import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.InputHeadersMap;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
/**
* Created by The eXo Platform SAS Author : Dmytro Katayev
@@ -51,15 +41,13 @@
private String path = TestUtils.getFileName();
private String fileContent = TestUtils.getFileContent();
-
- private Node node;
@Override
public void setUp() throws Exception
{
super.setUp();
InputStream inputStream = new ByteArrayInputStream(fileContent.getBytes());
- node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
+ TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
}
public void testSimpleGet() throws Exception
@@ -76,19 +64,6 @@
assertEquals(fileContent, str);
}
- public void testIfModifiedSince() throws Exception{
- Node contentNode = node.getNode("jcr:content");
- Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
- String formatPattern = "EEE, dd MMM yyyy HH:mm:ss z";
- SimpleDateFormat dateFormat = new SimpleDateFormat(formatPattern, Locale.ENGLISH);
- dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- String lastModified = dateFormat.format(lastModifiedProperty.getDate().getTime());
- MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, lastModified);
- ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
- assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
- }
-
public void testNotFoundGet() throws Exception
{
ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + "/not-found" + path, "", null, null);
Added: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java (rev 0)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java 2009-10-27 15:02:22 UTC (rev 435)
@@ -0,0 +1,96 @@
+/*
+ * 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.webdav.ext;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.exoplatform.common.http.HTTPStatus;
+import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
+import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
+import org.exoplatform.services.jcr.webdav.utils.TestUtils;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+
+/**
+ * Created by The eXo Platform SAS Author : Dmytro Katayev
+ * work.visor.ck(a)gmail.com Aug 13, 2008
+ */
+public class TestCashing extends BaseStandaloneTest
+{
+
+ private String path = TestUtils.getFileName();
+
+ private String fileContent = TestUtils.getFileContent();
+
+ private Node node;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ InputStream inputStream = new ByteArrayInputStream(fileContent.getBytes());
+ node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType, "");
+ }
+
+
+ public void testIfModifiedSince() throws Exception{
+ Node contentNode = node.getNode("jcr:content");
+ Property lastModifiedProperty = contentNode.getProperty("jcr:lastModified");
+ String formatPattern = "EEE, dd MMM yyyy HH:mm:ss z";
+ SimpleDateFormat dateFormat = new SimpleDateFormat(formatPattern, Locale.ENGLISH);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ String lastModified = dateFormat.format(lastModifiedProperty.getDate().getTime());
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, lastModified);
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
+ assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
+ }
+
+ public void testCacheConf() throws Exception {
+ Node contentNode = node.getNode("jcr:content");
+ contentNode.setProperty("jcr:mimeType", "text/xml");
+ contentNode.getSession().save();
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", null, null);
+ String cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
+ assertEquals(cacheControlHeader, "[max-age=1800]");
+
+ contentNode.setProperty("jcr:mimeType", "image/jpeg");
+ contentNode.getSession().save();
+ response = service(WebDAVMethods.GET, getPathWS() + path, "", null, null);
+ cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
+ assertEquals(cacheControlHeader, "[max-age=3600]");
+ }
+
+ @Override
+ protected String getRepositoryName()
+ {
+ return null;
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml 2009-10-27 14:52:30 UTC (rev 434)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/resources/conf/standalone/test-configuration.xml 2009-10-27 15:02:22 UTC (rev 435)
@@ -182,9 +182,13 @@
<value-param>
<name>update-policy</name>
<value>create-version</value>
- <!--value>replace</value -->
- <!-- value>add</value -->
</value-param>
+
+ <value-param>
+ <name>cache-control</name>
+ <value>image/jpeg,image/png:max-age=3600;text/html,text/xml:max-age=1800</value>
+ </value-param>
+
</init-params>
</component>
14 years, 6 months
exo-jcr SVN: r434 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/core and 3 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-27 10:52:30 -0400 (Tue, 27 Oct 2009)
New Revision: 434
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
Log:
EXOJCR-211: remove cache from config and DM hierarchy
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -48,11 +48,8 @@
import org.exoplatform.services.jcr.impl.core.query.QueryManagerFactory;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
-import org.exoplatform.services.jcr.impl.core.query.SystemSearchManager;
-import org.exoplatform.services.jcr.impl.core.query.SystemSearchManagerHolder;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.JBossCacheWorkspaceDataManager;
import org.exoplatform.services.jcr.impl.dataflow.persistent.LocalWorkspaceDataManagerStub;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.impl.storage.value.StandaloneStoragePluginProvider;
@@ -229,24 +226,25 @@
}
// cache type
- try
- {
- String className = wsConfig.getCache().getType();
- if (className != null && className.length() > 0)
- {
- workspaceContainer.registerComponentImplementation(Class.forName(className));
- }
- else
- workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
- }
- catch (ClassNotFoundException e)
- {
- log.warn("Workspace cache class not found " + wsConfig.getCache().getType()
- + ", will use default. Error : " + e);
- workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
- }
+ // TODO remove cache
+// try
+// {
+// String className = wsConfig.getCache().getType();
+// if (className != null && className.length() > 0)
+// {
+// workspaceContainer.registerComponentImplementation(Class.forName(className));
+// }
+// else
+// workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
+// }
+// catch (ClassNotFoundException e)
+// {
+// log.warn("Workspace cache class not found " + wsConfig.getCache().getType()
+// + ", will use default. Error : " + e);
+// workspaceContainer.registerComponentImplementation(LinkedWorkspaceStorageCacheImpl.class);
+// }
- workspaceContainer.registerComponentImplementation(CacheableWorkspaceDataManager.class);
+ workspaceContainer.registerComponentImplementation(JBossCacheWorkspaceDataManager.class);
workspaceContainer.registerComponentImplementation(LocalWorkspaceDataManagerStub.class);
workspaceContainer.registerComponentImplementation(ObservationManagerRegistry.class);
@@ -270,14 +268,14 @@
// Query handler
if (wsConfig.getQueryHandler() != null)
{
- workspaceContainer.registerComponentImplementation(SearchManager.class);
- workspaceContainer.registerComponentImplementation(QueryManager.class);
- workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
- workspaceContainer.registerComponentInstance(wsConfig.getQueryHandler());
- if (isSystem)
- {
- workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
- }
+// workspaceContainer.registerComponentImplementation(SearchManager.class);
+// workspaceContainer.registerComponentImplementation(QueryManager.class);
+// workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
+// workspaceContainer.registerComponentInstance(wsConfig.getQueryHandler());
+// TODO if (isSystem)
+// {
+// workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
+// }
}
// access manager
@@ -439,8 +437,9 @@
// }
}
- SystemSearchManagerHolder searchManager =
- (SystemSearchManagerHolder)this.getComponentInstanceOfType(SystemSearchManagerHolder.class);
+// TODO SystemSearchManagerHolder searchManager =
+// (SystemSearchManagerHolder)this.getComponentInstanceOfType(SystemSearchManagerHolder.class);
+
// if (searchManager != null)
// {
// typeManager.addQueryHandler(searchManager.get().getHandler());
@@ -509,13 +508,13 @@
String systemWsname = config.getSystemWorkspaceName();
WorkspaceEntry systemWsEntry = getWorkspaceEntry(systemWsname);
- if (systemWsEntry != null && systemWsEntry.getQueryHandler() != null)
- {
- SystemSearchManager systemSearchManager =
- (SystemSearchManager)getWorkspaceContainer(systemWsname).getComponentInstanceOfType(
- SystemSearchManager.class);
- registerComponentInstance(new SystemSearchManagerHolder(systemSearchManager));
- }
+// TODO if (systemWsEntry != null && systemWsEntry.getQueryHandler() != null)
+// {
+// SystemSearchManager systemSearchManager =
+// (SystemSearchManager)getWorkspaceContainer(systemWsname).getComponentInstanceOfType(
+// SystemSearchManager.class);
+// registerComponentInstance(new SystemSearchManagerHolder(systemSearchManager));
+// }
try
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -28,6 +28,7 @@
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
import org.exoplatform.services.jcr.dataflow.DataManager;
import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.PersistentDataManager;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
@@ -39,7 +40,6 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -72,7 +72,7 @@
private final String workspaceName;
- private final DataManager dataManager;
+ private final PersistentDataManager dataManager;
private final String accessControlType;
@@ -83,7 +83,7 @@
private final InternalQName rootNodeType;
public ScratchWorkspaceInitializer(WorkspaceEntry config, RepositoryEntry repConfig,
- CacheableWorkspaceDataManager dataManager, LocationFactory locationFactory)
+ PersistentDataManager dataManager, LocationFactory locationFactory)
throws RepositoryConfigurationException, PathNotFoundException, RepositoryException
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -96,7 +96,7 @@
/**
* @param dataManager
* @param config
- * @param searchManager
+ * @param searchManager TODO
* @throws RepositoryConfigurationException
* @throws RepositoryException
*/
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -43,11 +43,9 @@
public class ACLInheritanceSupportedWorkspaceDataManager implements SharedDataManager
{
- private static Log log = ExoLogger.getLogger("jcr.ACLInheritanceSupportedWorkspaceDataManager");
+ protected final JBossCacheWorkspaceDataManager persistentManager;
- protected final CacheableWorkspaceDataManager persistentManager;
-
- public ACLInheritanceSupportedWorkspaceDataManager(CacheableWorkspaceDataManager persistentManager)
+ public ACLInheritanceSupportedWorkspaceDataManager(JBossCacheWorkspaceDataManager persistentManager)
{
this.persistentManager = persistentManager;
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
/**
* Created by The eXo Platform SAS.
@@ -31,9 +29,7 @@
public class LocalWorkspaceDataManagerStub extends VersionableWorkspaceDataManager
{
- private static Log log = ExoLogger.getLogger("jcr.LocalWorkspaceDataManagerStub");
-
- public LocalWorkspaceDataManagerStub(CacheableWorkspaceDataManager persistentManager)
+ public LocalWorkspaceDataManagerStub(JBossCacheWorkspaceDataManager persistentManager)
{
super(persistentManager);
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -54,11 +54,9 @@
public class VersionableWorkspaceDataManager extends ACLInheritanceSupportedWorkspaceDataManager
{
- private static Log log = ExoLogger.getLogger("jcr.VersionableWorkspaceDataManager");
-
private ACLInheritanceSupportedWorkspaceDataManager versionDataManager;
- public VersionableWorkspaceDataManager(CacheableWorkspaceDataManager persistentManager)
+ public VersionableWorkspaceDataManager(JBossCacheWorkspaceDataManager persistentManager)
{
super(persistentManager);
}
@@ -72,11 +70,8 @@
this.versionDataManager = (ACLInheritanceSupportedWorkspaceDataManager)systemDataManager;
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildNodes(org.exoplatform.services
- * .jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<NodeData> getChildNodesData(final NodeData nodeData) throws RepositoryException
@@ -88,11 +83,8 @@
return super.getChildNodesData(nodeData);
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.impl.core.WorkspaceDataManager#getChildProperties(org.exoplatform
- * .services.jcr.datamodel.NodeData)
+ /**
+ * {@inheritDoc}
*/
@Override
public List<PropertyData> getChildPropertiesData(final NodeData nodeData) throws RepositoryException
@@ -126,41 +118,41 @@
return super.getItemData(parentData, name);
}
- /**
- * @see org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager#getItemData(java.lang.String)
- */
- public ItemData getItemData(String identifier) throws RepositoryException
- {
- // from cache at first
- ItemData cdata = persistentManager.getCachedItemData(identifier);
- if (cdata != null)
- return super.getItemData(identifier);
+// /**
+// * {@inheritDoc}
+// */
+// public ItemData getItemData(String identifier) throws RepositoryException
+// {
+// // from cache at first
+// ItemData cdata = persistentManager.getCachedItemData(identifier);
+// if (cdata != null)
+// return super.getItemData(identifier);
+//
+// if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
+// {
+// // search in System cache for /jcr:system nodes only
+// cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
+// if (cdata != null)
+// if (isSystemDescendant(cdata.getQPath()))
+// return versionDataManager.getItemData(identifier);
+// else
+// return null;
+// }
+//
+// // then from persistence
+// ItemData data = super.getItemData(identifier);
+// if (data != null)
+// return data;
+// else if (!this.equals(versionDataManager))
+// {
+// // try from version storage if not the same
+// data = versionDataManager.getItemData(identifier);
+// if (data != null && isSystemDescendant(data.getQPath()))
+// return data;
+// }
+// return null;
+// }
- if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
- {
- // search in System cache for /jcr:system nodes only
- cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
- if (cdata != null)
- if (isSystemDescendant(cdata.getQPath()))
- return versionDataManager.getItemData(identifier);
- else
- return null;
- }
-
- // then from persistence
- ItemData data = super.getItemData(identifier);
- if (data != null)
- return data;
- else if (!this.equals(versionDataManager))
- {
- // try from version storage if not the same
- data = versionDataManager.getItemData(identifier);
- if (data != null && isSystemDescendant(data.getQPath()))
- return data;
- }
- return null;
- }
-
public void save(CompositeChangesLog changesLog) throws RepositoryException, InvalidItemStateException
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2009-10-27 14:50:02 UTC (rev 433)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2009-10-27 14:52:30 UTC (rev 434)
@@ -102,7 +102,7 @@
ws1back.setAccessManager(ws1e.getAccessManager());
ws1back.setAutoInitializedRootNt(ws1e.getAutoInitializedRootNt());
ws1back.setAutoInitPermissions(ws1e.getAutoInitPermissions());
- ws1back.setCache(ws1e.getCache());
+ // TODO ws1back.setCache(ws1e.getCache());
ws1back.setContainer(ws1e.getContainer());
ws1back.setLockManager(ws1e.getLockManager());
14 years, 6 months
exo-jcr SVN: r433 - in jcr/branches/1.12.0-JBC/component/core: src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 5 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-27 10:50:02 -0400 (Tue, 27 Oct 2009)
New Revision: 433
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCachePersistentDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/conf/
Modified:
jcr/branches/1.12.0-JBC/component/core/pom.xml
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
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exojcr-jboss-cache-conf.xml
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-200: persistence based on JBC JDBC loader (for tests)
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-10-27 14:50:02 UTC (rev 433)
@@ -569,9 +569,9 @@
</systemProperties>
<includes>
<include>**/**/TestErrorMultithreading__.java</include>
- <include>**/**/TestConcurrentItems__.java</include>
-
- <include>**/**/JBossCacheServiceTest.java</include>
+ <include>**/**/JBossCacheServiceTest__.java</include>
+
+ <include>**/**/TestItem.java</include>
</includes>
</configuration>
</plugin>
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCachePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCachePersistentDataManager.java 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCachePersistentDataManager.java 2009-10-27 14:50:02 UTC (rev 433)
@@ -1,182 +0,0 @@
-/*
- * 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.dataflow.persistent;
-
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
-import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-
-import java.util.HashSet;
-import java.util.Iterator;
-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 JBossCachePersistentDataManager extends WorkspacePersistentDataManager
-{
-
- /**
- * JBossCachePersistentDataManager constructor.
- *
- * @param dataContainer WorkspaceDataContainer
- * @param systemDataContainerHolder SystemDataContainerHolder
- */
- public JBossCachePersistentDataManager(WorkspaceDataContainer dataContainer,
- SystemDataContainerHolder<WorkspaceDataContainer> systemDataContainerHolder)
- {
- super(dataContainer, systemDataContainerHolder);
- }
-
- @Override
- public void save(ItemStateChangesLog changesLog) throws RepositoryException
- {
- // check if this workspace container is not read-only
- if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
- throw new ReadOnlyWorkspaceException("Workspace container '" + dataContainer.getName() + "' is read-only.");
-
- final Set<QPath> addedNodes = new HashSet<QPath>();
-
- WorkspaceStorageConnection thisConnection = null;
- WorkspaceStorageConnection systemConnection = null;
-
- try
- {
- for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
- {
- ItemState itemState = iter.next();
-
- if (!itemState.isPersisted())
- continue;
-
- long start = System.currentTimeMillis();
-
- TransientItemData data = (TransientItemData)itemState.getData();
-
- WorkspaceStorageConnection conn = null;
- if (isSystemDescendant(data.getQPath()))
- {
- conn = systemConnection == null
- // we need system connection but it's not exist
- ? systemConnection = (systemDataContainer != dataContainer
- // if it's different container instances
- ? systemDataContainer.equals(dataContainer) && thisConnection != null
- // but container confugrations are same and non-system connnection open
- // reuse this connection as system
- ? systemDataContainer.reuseConnection(thisConnection)
- // or open one new system
- : systemDataContainer.openConnection()
- // else if it's same container instances (system and this)
- : thisConnection == null
- // and non-system connection doens't exist - open it
- ? thisConnection = dataContainer.openConnection()
- // if already open - use it
- : thisConnection)
- // system connection opened - use it
- : systemConnection;
- }
- else
- {
- conn = thisConnection == null
- // we need this conatiner conection
- ? thisConnection = (systemDataContainer != dataContainer
- // if it's different container instances
- ? dataContainer.equals(systemDataContainer) && systemConnection != null
- // but container confugrations are same and system connnection open
- // reuse system connection as this
- ? dataContainer.reuseConnection(systemConnection)
- // or open one new
- : dataContainer.openConnection()
- // else if it's same container instances (system and this)
- : systemConnection == null
- // and system connection doens't exist - open it
- ? systemConnection = dataContainer.openConnection()
- // if already open - use it
- : systemConnection)
- // this connection opened - use it
- : thisConnection;
- }
-
- data.increasePersistedVersion();
-
- if (itemState.isAdded())
- {
- doAdd(data, conn, addedNodes);
- }
- else if (itemState.isUpdated())
- {
- doUpdate(data, conn);
- }
- else if (itemState.isDeleted())
- {
- doDelete(data, conn);
- }
- else if (itemState.isRenamed())
- {
- doRename(data, conn, addedNodes);
- }
-
- if (LOG.isDebugEnabled())
- LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " + (System.currentTimeMillis() - start)
- + "ms, " + data.getQPath().getAsString());
- }
- if (thisConnection != null)
- thisConnection.commit();
- if (systemConnection != null && !systemConnection.equals(thisConnection))
- systemConnection.commit();
- }
- finally
- {
- if (thisConnection != null && thisConnection.isOpened())
- thisConnection.rollback();
- if (systemConnection != null && !systemConnection.equals(thisConnection) && systemConnection.isOpened())
- systemConnection.rollback();
-
- // help to GC
- addedNodes.clear();
- }
- }
-
-
- /**
- * Tell if the path is jcr:system descendant.
- *
- * @param path
- * path to check
- * @return boolean result, true if yes - it's jcr:system tree path
- */
- private boolean isSystemDescendant(QPath path)
- {
- return path.isDescendantOf(Constants.JCR_SYSTEM_PATH) || path.equals(Constants.JCR_SYSTEM_PATH);
- }
-
-}
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java (from rev 431, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCachePersistentDataManager.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java 2009-10-27 14:50:02 UTC (rev 433)
@@ -0,0 +1,182 @@
+/*
+ * 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.dataflow.persistent;
+
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+
+import java.util.HashSet;
+import java.util.Iterator;
+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 JBossCacheWorkspaceDataManager extends WorkspacePersistentDataManager
+{
+
+ /**
+ * JBossCachePersistentDataManager constructor.
+ *
+ * @param dataContainer WorkspaceDataContainer
+ * @param systemDataContainerHolder SystemDataContainerHolder
+ */
+ public JBossCacheWorkspaceDataManager(WorkspaceDataContainer dataContainer,
+ SystemDataContainerHolder<WorkspaceDataContainer> systemDataContainerHolder)
+ {
+ super(dataContainer, systemDataContainerHolder);
+ }
+
+ @Override
+ public void save(ItemStateChangesLog changesLog) throws RepositoryException
+ {
+ // check if this workspace container is not read-only
+ if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
+ throw new ReadOnlyWorkspaceException("Workspace container '" + dataContainer.getName() + "' is read-only.");
+
+ final Set<QPath> addedNodes = new HashSet<QPath>();
+
+ WorkspaceStorageConnection thisConnection = null;
+ WorkspaceStorageConnection systemConnection = null;
+
+ try
+ {
+ for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
+ {
+ ItemState itemState = iter.next();
+
+ if (!itemState.isPersisted())
+ continue;
+
+ long start = System.currentTimeMillis();
+
+ TransientItemData data = (TransientItemData)itemState.getData();
+
+ WorkspaceStorageConnection conn = null;
+ if (isSystemDescendant(data.getQPath()))
+ {
+ conn = systemConnection == null
+ // we need system connection but it's not exist
+ ? systemConnection = (systemDataContainer != dataContainer
+ // if it's different container instances
+ ? systemDataContainer.equals(dataContainer) && thisConnection != null
+ // but container confugrations are same and non-system connnection open
+ // reuse this connection as system
+ ? systemDataContainer.reuseConnection(thisConnection)
+ // or open one new system
+ : systemDataContainer.openConnection()
+ // else if it's same container instances (system and this)
+ : thisConnection == null
+ // and non-system connection doens't exist - open it
+ ? thisConnection = dataContainer.openConnection()
+ // if already open - use it
+ : thisConnection)
+ // system connection opened - use it
+ : systemConnection;
+ }
+ else
+ {
+ conn = thisConnection == null
+ // we need this conatiner conection
+ ? thisConnection = (systemDataContainer != dataContainer
+ // if it's different container instances
+ ? dataContainer.equals(systemDataContainer) && systemConnection != null
+ // but container confugrations are same and system connnection open
+ // reuse system connection as this
+ ? dataContainer.reuseConnection(systemConnection)
+ // or open one new
+ : dataContainer.openConnection()
+ // else if it's same container instances (system and this)
+ : systemConnection == null
+ // and system connection doens't exist - open it
+ ? systemConnection = dataContainer.openConnection()
+ // if already open - use it
+ : systemConnection)
+ // this connection opened - use it
+ : thisConnection;
+ }
+
+ data.increasePersistedVersion();
+
+ if (itemState.isAdded())
+ {
+ doAdd(data, conn, addedNodes);
+ }
+ else if (itemState.isUpdated())
+ {
+ doUpdate(data, conn);
+ }
+ else if (itemState.isDeleted())
+ {
+ doDelete(data, conn);
+ }
+ else if (itemState.isRenamed())
+ {
+ doRename(data, conn, addedNodes);
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " + (System.currentTimeMillis() - start)
+ + "ms, " + data.getQPath().getAsString());
+ }
+ if (thisConnection != null)
+ thisConnection.commit();
+ if (systemConnection != null && !systemConnection.equals(thisConnection))
+ systemConnection.commit();
+ }
+ finally
+ {
+ if (thisConnection != null && thisConnection.isOpened())
+ thisConnection.rollback();
+ if (systemConnection != null && !systemConnection.equals(thisConnection) && systemConnection.isOpened())
+ systemConnection.rollback();
+
+ // help to GC
+ addedNodes.clear();
+ }
+ }
+
+
+ /**
+ * Tell if the path is jcr:system descendant.
+ *
+ * @param path
+ * path to check
+ * @return boolean result, true if yes - it's jcr:system tree path
+ */
+ private boolean isSystemDescendant(QPath path)
+ {
+ return path.isDescendantOf(Constants.JCR_SYSTEM_PATH) || path.equals(Constants.JCR_SYSTEM_PATH);
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.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-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-27 14:50:02 UTC (rev 433)
@@ -56,7 +56,7 @@
{
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();
@@ -192,6 +192,10 @@
// TODO NodeData or PropertyData? As ItemData check then and cast.
NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
+ if (node == null)
+ {
+ throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+ }
childs.add(node);
}
@@ -219,6 +223,10 @@
{
// TODO NodeData or PropertyData? As ItemData check then and cast.
PropertyData property = (PropertyData)cache.get(makeIdFqn((String)key), ITEM_DATA);
+ if (property == null)
+ {
+ throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+ }
childs.add(property);
}
}
@@ -259,7 +267,7 @@
else
{
// it's Node Item
- Node<Serializable, Object> node = parentNode.getChild(Fqn.fromString(itemName)); // TODO not Fqn?
+ Node<Serializable, Object> node = parentNode.getChild(itemName); // TODO String not Fqn?
if (node != null)
{
String nodeId = (String)node.get(ITEM_ID);
@@ -301,8 +309,7 @@
startBatch();
// TODO move Node to a new position at the tree,
// but prev location was in prev DELETE.
-
-
+
}
/**
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-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-10-27 14:50:02 UTC (rev 433)
@@ -18,13 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.naming.NamingException;
-
import org.exoplatform.services.jbosscache.JBossCacheService;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -38,13 +31,17 @@
import org.exoplatform.services.log.Log;
import org.exoplatform.services.naming.InitialContextInitializer;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.picocontainer.Startable;
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.jcr.RepositoryException;
+import javax.naming.NamingException;
+
/**
* Created by The eXo Platform SAS.
*
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exojcr-jboss-cache-conf.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exojcr-jboss-cache-conf.xml 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exojcr-jboss-cache-conf.xml 2009-10-27 14:50:02 UTC (rev 433)
@@ -52,15 +52,15 @@
</clustering>
<loaders passivation="false" shared="false">
- <loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
+ <!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
fetchPersistentState="true" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
</properties>
- </loader>
+ </loader -->
- <!-- loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
ignoreModifications="false" purgeOnStartup="false">
<properties>
cache.jdbc.table.name=jdbcjcr
@@ -70,14 +70,14 @@
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=VARCHAR(512)
cache.jdbc.node.column=node
- cache.jdbc.node.type=BLOB
+ cache.jdbc.node.type=VARBINARY(65535)
cache.jdbc.parent.column=parent
cache.jdbc.driver=org.hsqldb.jdbcDriver
cache.jdbc.url=jdbc:hsqldb:file:target/temp/data/exojcr
cache.jdbc.user=sa
cache.jdbc.password=
</properties>
- </loader -->
+ </loader>
</loaders>
<!-- Enable batching -->
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-27 14:50:02 UTC (rev 433)
@@ -36,15 +36,9 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.Serializable;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
import junit.framework.TestCase;
import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
@@ -54,6 +48,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import java.io.Serializable;
+
/**
* Created by The eXo Platform SAS.
*
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-configuration.xml 2009-10-27 14:50:02 UTC (rev 433)
@@ -107,7 +107,7 @@
<init-params>
<value-param>
<name>jboss-cache-configuration</name>
- <value>/conf/portal/exojcr-jboss-cache-conf.xml</value>
+ <value>conf/portal/exojcr-jboss-cache-conf.xml</value>
</value-param>
</init-params>
</component>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-10-27 14:39:23 UTC (rev 432)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-10-27 14:50:02 UTC (rev 433)
@@ -30,7 +30,7 @@
<workspaces>
<workspace name="ws">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JBossCacheWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr" />
<property name="dialect" value="hsqldb" />
@@ -59,19 +59,19 @@
<property name="root-nodetype" value="nt:unstructured" />
</properties>
</initializer>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <!-- query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir" value="target/temp/index/db1/ws" />
</properties>
- </query-handler>
- <lock-manager>
+ </query-handler -->
+ <!-- lock-manager>
<time-out>15m</time-out>
<persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
<properties>
<property name="path" value="target/temp/lock" />
</properties>
</persister>
- </lock-manager>
+ </lock-manager -->
</workspace>
<workspace name="ws1">
14 years, 6 months
exo-jcr SVN: r431 - jcr/trunk.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-27 04:29:11 -0400 (Tue, 27 Oct 2009)
New Revision: 431
Modified:
jcr/trunk/pom.xml
Log:
EXOJCR-163 pom.xml updated
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2009-10-27 08:24:19 UTC (rev 430)
+++ jcr/trunk/pom.xml 2009-10-27 08:29:11 UTC (rev 431)
@@ -61,12 +61,12 @@
<module>exo.jcr.framework.web</module>
<module>exo.jcr.framework.ftpclient</module>
- <module>applications/config</module>
- <module>applications/java/web/samples/browser</module>
- <module>applications/java/web/samples/fckeditor</module>
- <module>applications/java/web/rest</module>
- <module>applications/java/web/ear</module>
- <module>applications/java/standalone/backupconsole</module>
+ <module>applications/exo.jcr.applications.config</module>
+ <module>applications/java/exo.jcr.applications.browser</module>
+ <module>applications/java/exo.jcr.applications.fckeditor</module>
+ <module>applications/java/exo.jcr.applications.rest</module>
+ <module>applications/java/exo.jcr.ear</module>
+ <module>applications/java/exo.jcr.applications.backupconsole</module>
<module>packaging/module</module>
</modules>
14 years, 6 months