You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by fm...@apache.org on 2008/01/24 13:39:37 UTC
svn commit: r614859 - in /jackrabbit/trunk/jackrabbit-jcr-rmi: ./
src/main/java/org/apache/jackrabbit/rmi/xml/
src/test/java/org/apache/jackrabbit/rmi/
src/test/java/org/apache/jackrabbit/rmi/xml/
Author: fmeschbe
Date: Thu Jan 24 04:39:32 2008
New Revision: 614859
URL: http://svn.apache.org/viewvc?rev=614859&view=rev
Log:
JCR-1342 Use bundle packaging with the Maven Bundle Plugin and export all packages
JCR-1343 Replace use of Xerces by JAXP to implement SAX DocumentHandler
Added:
jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/
jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/
jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
Modified:
jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/ImportContentHandler.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/SessionImportContentHandler.java
jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/WorkspaceImportContentHandler.java
Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml?rev=614859&r1=614858&r2=614859&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/pom.xml Thu Jan 24 04:39:32 2008
@@ -38,6 +38,7 @@
a corrupted MANIFEST.MF (see http://jira.codehaus.org/browse/MJAR-4)
-->
<description>JCR-RMI is a transparent Remote Method Invocation (RMI) layer for the Content Repository for Java Technology API (JCR). The layer makes it possible to remotely access JCR content repositories. JCR-RMI is developed as a part of the Apache Jackrabbit project, but the implementation is compatible with all JCR content repositories.</description>
+ <packaging>bundle</packaging>
<build>
<plugins>
@@ -61,6 +62,23 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.jackrabbit.rmi.*;version=${pom.version}
+ </Export-Package>
+
+ <!-- optional resolution XA -->
+ <Import-Package>
+ javax.transaction.xa;resolution:=optional,*
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -94,10 +112,6 @@
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/ImportContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/ImportContentHandler.java?rev=614859&r1=614858&r2=614859&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/ImportContentHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/ImportContentHandler.java Thu Jan 24 04:39:32 2008
@@ -18,8 +18,12 @@
import java.io.ByteArrayOutputStream;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
+import javax.jcr.RepositoryException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
@@ -39,14 +43,24 @@
private ByteArrayOutputStream buffer;
/** The internal XML serializer. */
- private ContentHandler handler;
+ private TransformerHandler handler;
/**
* Creates a SAX content handler for importing XML data.
+ *
+ * @throws RepositoryException if the this instance cannot be setup. This
+ * exception contains the reason why it cannot be setup as its cause.
*/
- public ImportContentHandler() {
+ public ImportContentHandler() throws RepositoryException {
this.buffer = new ByteArrayOutputStream();
- this.handler = new XMLSerializer(buffer, new OutputFormat());
+
+ try {
+ SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ this.handler = stf.newTransformerHandler();
+ this.handler.setResult(new StreamResult(buffer));
+ } catch (TransformerConfigurationException tce) {
+ throw new RepositoryException("Cannot create XML handler", tce);
+ }
}
/**
Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/SessionImportContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/SessionImportContentHandler.java?rev=614859&r1=614858&r2=614859&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/SessionImportContentHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/SessionImportContentHandler.java Thu Jan 24 04:39:32 2008
@@ -18,6 +18,7 @@
import java.io.ByteArrayInputStream;
+import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -41,15 +42,18 @@
private int mode;
/**
- * Creates a SAX content handler for importing XML data to the given
- * session and path.
- *
+ * Creates a SAX content handler for importing XML data to the given session
+ * and path.
+ *
* @param session repository session
* @param path import content path
* @param uuidBehaviour UUID behavior mode
+ * @throws RepositoryException if the this instance cannot be setup. This
+ * exception contains the reason why it cannot be setup as its
+ * cause.
*/
- public SessionImportContentHandler(
- Session session, String path, int uuidBehaviour) {
+ public SessionImportContentHandler(Session session, String path,
+ int uuidBehaviour) throws RepositoryException {
this.session = session;
this.path = path;
this.mode = uuidBehaviour;
Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/WorkspaceImportContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/WorkspaceImportContentHandler.java?rev=614859&r1=614858&r2=614859&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/WorkspaceImportContentHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/WorkspaceImportContentHandler.java Thu Jan 24 04:39:32 2008
@@ -18,6 +18,7 @@
import java.io.ByteArrayInputStream;
+import javax.jcr.RepositoryException;
import javax.jcr.Workspace;
@@ -43,12 +44,16 @@
/**
* Creates a SAX content handler for importing XML data to the given
* workspace and path using the given UUID behavior.
- *
+ *
* @param workspace repository workspace
* @param path import content path
* @param uuidBehaviour UUID behavior
+ * @throws RepositoryException if the this instance cannot be setup. This
+ * exception contains the reason why it cannot be setup as its
+ * cause.
*/
- public WorkspaceImportContentHandler(Workspace workspace, String path, int uuidBehaviour) {
+ public WorkspaceImportContentHandler(Workspace workspace, String path,
+ int uuidBehaviour) throws RepositoryException {
this.workspace = workspace;
this.path = path;
this.uuidBehaviour = uuidBehaviour;
Added: jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java?rev=614859&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/xml/ImportContentHandlerTest.java Thu Jan 24 04:39:32 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.rmi.xml;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.jcr.RepositoryException;
+
+import junit.framework.TestCase;
+
+import org.apache.jackrabbit.rmi.xml.ImportContentHandler;
+import org.xml.sax.SAXException;
+
+public class ImportContentHandlerTest extends TestCase {
+
+ public void testImportContentHandler() throws RepositoryException, SAXException {
+ // fail test if handler cannot be set up
+ DummyImportContentHandler ch = new DummyImportContentHandler();
+
+ // these may throw SAXException
+ ch.startDocument();
+ ch.startElement(null, "sample", "sample", null);
+ ch.endElement(null, "sample", "sample");
+ ch.endDocument();
+
+ byte[] xml = ch.getXML();
+ assertNotNull("Serialized XML is null", xml);
+ assertTrue("Serialized XML is empty", xml.length > 0);
+
+ // for the moment we don't actually care for the concrete contents
+ }
+
+ private static class DummyImportContentHandler extends ImportContentHandler {
+
+ private byte[] xml;
+
+ DummyImportContentHandler() throws RepositoryException {
+ super();
+ }
+
+ protected void importXML(byte[] xml) throws Exception {
+ this.xml = xml;
+ }
+
+ byte[] getXML() {
+ return xml;
+ }
+ }
+}