jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1576690 [10/10] - in /jackrabbit/trunk: examples/jackrabbit-firsthops/ examples/jackrabbit-firsthops/src/main/resources/ jackrabbit-aws-ext/ jackrabbit-aws-ext/src/main/java/org/apache/jackrabbit/aws/ext/ jackrabbit-aws-ext/src/main/java/o...
Date Wed, 12 Mar 2014 11:05:08 GMT
Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/Oracle10R1ConnectionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java Wed Mar 12 11:05:06 2014
@@ -1,82 +1,82 @@
-/*
- * 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.core.util.db;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The connection helper for Oracle databases of version 10.2 and later.
- */
-public class OracleConnectionHelper extends ConnectionHelper {
-
-    /**
-     * the default logger
-     */
-    private static Logger log = LoggerFactory.getLogger(OracleConnectionHelper.class);
-
-    /**
-     * @param dataSrc the {@code DataSource} on which this helper acts
-     * @param block whether to block on connection loss until the db is up again
-     */
-    public OracleConnectionHelper(DataSource dataSrc, boolean block) {
-        super(dataSrc, true, block);
-    }
-
-    /**
-     * Initializes the helper: checks for valid driver version.
-     * Subclasses that override this method should still call it!
-     * 
-     * @throws Exception on error
-     */
-    public void init() throws Exception {
-         // check driver version
-        Connection connection = dataSource.getConnection();
-        try {
-            DatabaseMetaData metaData = connection.getMetaData();
-            if (metaData.getDriverMajorVersion() < 10) {
-                // Oracle drivers prior to version 10 only support
-                // writing BLOBs up to 32k in size...
-                log.warn("Unsupported driver version detected: "
-                        + metaData.getDriverName()
-                        + " v" + metaData.getDriverVersion());
-            }
-        } catch (SQLException e) {
-            log.warn("Can not retrieve driver version", e);
-        } finally {
-            DbUtility.close(connection, null, null);
-        }
-    }
-
-    /**
-     * Since Oracle only supports table names up to 30 characters in
-     * length illegal characters are simply replaced with "_" rather than
-     * escaping them with "_x0000_".
-     *
-     * {@inheritDoc}
-     */
-    @Override
-    protected final void replaceCharacter(StringBuilder escaped, char c) {
-        escaped.append("_");
-    }
-}
+/*
+ * 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.core.util.db;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The connection helper for Oracle databases of version 10.2 and later.
+ */
+public class OracleConnectionHelper extends ConnectionHelper {
+
+    /**
+     * the default logger
+     */
+    private static Logger log = LoggerFactory.getLogger(OracleConnectionHelper.class);
+
+    /**
+     * @param dataSrc the {@code DataSource} on which this helper acts
+     * @param block whether to block on connection loss until the db is up again
+     */
+    public OracleConnectionHelper(DataSource dataSrc, boolean block) {
+        super(dataSrc, true, block);
+    }
+
+    /**
+     * Initializes the helper: checks for valid driver version.
+     * Subclasses that override this method should still call it!
+     * 
+     * @throws Exception on error
+     */
+    public void init() throws Exception {
+         // check driver version
+        Connection connection = dataSource.getConnection();
+        try {
+            DatabaseMetaData metaData = connection.getMetaData();
+            if (metaData.getDriverMajorVersion() < 10) {
+                // Oracle drivers prior to version 10 only support
+                // writing BLOBs up to 32k in size...
+                log.warn("Unsupported driver version detected: "
+                        + metaData.getDriverName()
+                        + " v" + metaData.getDriverVersion());
+            }
+        } catch (SQLException e) {
+            log.warn("Can not retrieve driver version", e);
+        } finally {
+            DbUtility.close(connection, null, null);
+        }
+    }
+
+    /**
+     * Since Oracle only supports table names up to 30 characters in
+     * length illegal characters are simply replaced with "_" rather than
+     * escaping them with "_x0000_".
+     *
+     * {@inheritDoc}
+     */
+    @Override
+    protected final void replaceCharacter(StringBuilder escaped, char c) {
+        escaped.append("_");
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/OracleConnectionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java Wed Mar 12 11:05:06 2014
@@ -1,35 +1,35 @@
-/*
- * 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.core.util.db;
-
-import javax.sql.DataSource;
-
-
-/**
- * The connection helper for PSQL databases. It has special fetch size handling.
- */
-public final class PostgreSQLConnectionHelper extends ConnectionHelper {
-
-    /**
-     * @param dataSrc the {@code DataSource} on which this helper acts
-     * @param block whether to block on connection loss until the db is up again
-     */
-    public PostgreSQLConnectionHelper(DataSource dataSrc, boolean block) {
-        super(dataSrc, false, block, 10000);
-    }
-
-}
+/*
+ * 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.core.util.db;
+
+import javax.sql.DataSource;
+
+
+/**
+ * The connection helper for PSQL databases. It has special fetch size handling.
+ */
+public final class PostgreSQLConnectionHelper extends ConnectionHelper {
+
+    /**
+     * @param dataSrc the {@code DataSource} on which this helper acts
+     * @param block whether to block on connection loss until the db is up again
+     */
+    public PostgreSQLConnectionHelper(DataSource dataSrc, boolean block) {
+        super(dataSrc, false, block, 10000);
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java Wed Mar 12 11:05:06 2014
@@ -1,70 +1,70 @@
-/*
- * 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.core.util.db;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-
-/**
- * This is a dynamic proxy in order to support both Java 5 and 6.
- */
-public final class ResultSetWrapper implements InvocationHandler {
-
-    private final Connection connection;
-
-    private final Statement statement;
-
-    private final ResultSet resultSet;
-
-    /**
-     * Creates a new {@code ResultSet} proxy which closes the given {@code Connection} and
-     * {@code Statement} if it is closed.
-     * 
-     * @param con the associated {@code Connection}
-     * @param stmt the associated {@code Statement}
-     * @param rs the {@code ResultSet} which backs the proxy
-     * @return a {@code ResultSet} proxy
-     */
-    public static final ResultSet newInstance(Connection con, Statement stmt, ResultSet rs) {
-        ResultSetWrapper proxy = new ResultSetWrapper(con, stmt, rs);
-        return (ResultSet) Proxy.newProxyInstance(rs.getClass().getClassLoader(),
-            new Class<?>[]{ResultSet.class}, proxy);
-    }
-
-    private ResultSetWrapper(Connection con, Statement stmt, ResultSet rs) {
-        connection = con;
-        statement = stmt;
-        resultSet = rs;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
-        if ("close".equals(m.getName())) {
-            DbUtility.close(connection, statement, resultSet);
-            return null;
-        } else {
-            return m.invoke(resultSet, args);
-        }
-    }
-}
+/*
+ * 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.core.util.db;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+
+/**
+ * This is a dynamic proxy in order to support both Java 5 and 6.
+ */
+public final class ResultSetWrapper implements InvocationHandler {
+
+    private final Connection connection;
+
+    private final Statement statement;
+
+    private final ResultSet resultSet;
+
+    /**
+     * Creates a new {@code ResultSet} proxy which closes the given {@code Connection} and
+     * {@code Statement} if it is closed.
+     * 
+     * @param con the associated {@code Connection}
+     * @param stmt the associated {@code Statement}
+     * @param rs the {@code ResultSet} which backs the proxy
+     * @return a {@code ResultSet} proxy
+     */
+    public static final ResultSet newInstance(Connection con, Statement stmt, ResultSet rs) {
+        ResultSetWrapper proxy = new ResultSetWrapper(con, stmt, rs);
+        return (ResultSet) Proxy.newProxyInstance(rs.getClass().getClassLoader(),
+            new Class<?>[]{ResultSet.class}, proxy);
+    }
+
+    private ResultSetWrapper(Connection con, Statement stmt, ResultSet rs) {
+        connection = con;
+        statement = stmt;
+        resultSet = rs;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        if ("close".equals(m.getName())) {
+            DbUtility.close(connection, statement, resultSet);
+            return null;
+        } else {
+            return m.invoke(resultSet, args);
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ResultSetWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java Wed Mar 12 11:05:06 2014
@@ -1,96 +1,96 @@
-/*
- * 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.core.util.db;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLException;
-
-import org.apache.jackrabbit.core.data.db.TempFileInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StreamWrapper {
-
-    static Logger log = LoggerFactory.getLogger(StreamWrapper.class);
-
-    private InputStream stream;
-    private final long size;
-
-    /**
-     * Creates a wrapper for the given InputStream that can
-     * safely be passed as a parameter to the {@link ConnectionHelper#exec(String, Object...)},
-     * {@link ConnectionHelper#exec(String, Object[], boolean, int)} and
-     * {@link ConnectionHelper#update(String, Object[])} methods.
-     * If the wrapped Stream is a {@link TempFileInputStream} it will be wrapped again by a {@link BufferedInputStream}.
-     * 
-     * @param in the InputStream to wrap
-     * @param size the size of the input stream
-     */
-    public StreamWrapper(InputStream in, long size) {
-        this.stream = in;
-        this.size = size;
-    }
-    
-    public InputStream getStream() {
-        if (stream instanceof TempFileInputStream) {
-            return new BufferedInputStream(stream);
-        }
-        return stream;
-    }
-    
-    public long getSize() {
-        return size;
-    }
-
-    /**
-     * Cleans up the internal Resources
-     */
-	public void cleanupResources() {
-        if (stream instanceof TempFileInputStream) {
-        	try {
-        		stream.close();
-        		((TempFileInputStream) stream).deleteFile();
-        	} catch (IOException e) {
-        		log.warn("Unable to cleanup the TempFileInputStream");
-        	}
-        }
-	}
-
-    /**
-     * Resets the internal InputStream that it could be re-read.<br>
-     * Is used from {@link RetryManager} if a {@link SQLException} has occurred.<br>
-     * At the moment only a {@link TempFileInputStream} can be reseted.
-     * 
-     * @return returns true if it was able to reset the Stream
-     */
-    public boolean resetStream() {
-    	if (stream instanceof TempFileInputStream) {
-    		try {
-	    		TempFileInputStream tempFileInputStream = (TempFileInputStream) stream;
-	    		// Close it if it is not already closed ...
-	    		tempFileInputStream.close();
-    			stream = new TempFileInputStream(tempFileInputStream.getFile(), true);
-    			return true;
-    		} catch (Exception e) {
-    			log.warn("Failed to create a new TempFileInputStream", e);
-    		}
-    	}
-    	return false;
-	}
-}
+/*
+ * 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.core.util.db;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.SQLException;
+
+import org.apache.jackrabbit.core.data.db.TempFileInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamWrapper {
+
+    static Logger log = LoggerFactory.getLogger(StreamWrapper.class);
+
+    private InputStream stream;
+    private final long size;
+
+    /**
+     * Creates a wrapper for the given InputStream that can
+     * safely be passed as a parameter to the {@link ConnectionHelper#exec(String, Object...)},
+     * {@link ConnectionHelper#exec(String, Object[], boolean, int)} and
+     * {@link ConnectionHelper#update(String, Object[])} methods.
+     * If the wrapped Stream is a {@link TempFileInputStream} it will be wrapped again by a {@link BufferedInputStream}.
+     * 
+     * @param in the InputStream to wrap
+     * @param size the size of the input stream
+     */
+    public StreamWrapper(InputStream in, long size) {
+        this.stream = in;
+        this.size = size;
+    }
+    
+    public InputStream getStream() {
+        if (stream instanceof TempFileInputStream) {
+            return new BufferedInputStream(stream);
+        }
+        return stream;
+    }
+    
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Cleans up the internal Resources
+     */
+	public void cleanupResources() {
+        if (stream instanceof TempFileInputStream) {
+        	try {
+        		stream.close();
+        		((TempFileInputStream) stream).deleteFile();
+        	} catch (IOException e) {
+        		log.warn("Unable to cleanup the TempFileInputStream");
+        	}
+        }
+	}
+
+    /**
+     * Resets the internal InputStream that it could be re-read.<br>
+     * Is used from {@link RetryManager} if a {@link SQLException} has occurred.<br>
+     * At the moment only a {@link TempFileInputStream} can be reseted.
+     * 
+     * @return returns true if it was able to reset the Stream
+     */
+    public boolean resetStream() {
+    	if (stream instanceof TempFileInputStream) {
+    		try {
+	    		TempFileInputStream tempFileInputStream = (TempFileInputStream) stream;
+	    		// Close it if it is not already closed ...
+	    		tempFileInputStream.close();
+    			stream = new TempFileInputStream(tempFileInputStream.getFile(), true);
+    			return true;
+    		} catch (Exception e) {
+    			log.warn("Failed to create a new TempFileInputStream", e);
+    		}
+    	}
+    	return false;
+	}
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/StreamWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/InternalXAResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/InternalXAResource.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/InternalXAResource.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/InternalXAResource.java Wed Mar 12 11:05:06 2014
@@ -1,72 +1,72 @@
-/*
- * 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.data.core;
-
-
-
-/**
- * Interface implemented by resources that provide XA functionality.
- */
-public interface InternalXAResource {
-
-    /**
-     * Associate this resource with a transaction. All further operations on
-     * the object should be interpreted as part of this transaction and changes
-     * recorded in some attribute of the transaction context.
-     * @param tx transaction context, if <code>null</code> disassociate
-     */
-    void associate(TransactionContext tx);
-
-    /**
-     * Invoked before one of the {@link #prepare}, {@link #commit} or
-     * {@link #rollback} method is called.
-     * @param tx transaction context
-     */
-    void beforeOperation(TransactionContext tx);
-
-    /**
-     * Prepare transaction. The transaction is identified by a transaction
-     * context.
-     * @param tx transaction context
-     * @throws TransactionException if an error occurs
-     */
-    void prepare(TransactionContext tx) throws TransactionException;
-
-    /**
-     * Commit transaction. The transaction is identified by a transaction
-     * context. If the method throws, other resources get their changes
-     * rolled back.
-     * @param tx transaction context
-     * @throws TransactionException if an error occurs
-     */
-    void commit(TransactionContext tx) throws TransactionException;
-
-    /**
-     * Rollback transaction. The transaction is identified by a transaction
-     * context.
-     * @param tx transaction context.
-     */
-    void rollback(TransactionContext tx) throws TransactionException;
-
-    /**
-     * Invoked after one of the {@link #prepare}, {@link #commit} or
-     * {@link #rollback} method has been called.
-     * @param tx transaction context
-     */
-    void afterOperation(TransactionContext tx);
-
-}
+/*
+ * 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.data.core;
+
+
+
+/**
+ * Interface implemented by resources that provide XA functionality.
+ */
+public interface InternalXAResource {
+
+    /**
+     * Associate this resource with a transaction. All further operations on
+     * the object should be interpreted as part of this transaction and changes
+     * recorded in some attribute of the transaction context.
+     * @param tx transaction context, if <code>null</code> disassociate
+     */
+    void associate(TransactionContext tx);
+
+    /**
+     * Invoked before one of the {@link #prepare}, {@link #commit} or
+     * {@link #rollback} method is called.
+     * @param tx transaction context
+     */
+    void beforeOperation(TransactionContext tx);
+
+    /**
+     * Prepare transaction. The transaction is identified by a transaction
+     * context.
+     * @param tx transaction context
+     * @throws TransactionException if an error occurs
+     */
+    void prepare(TransactionContext tx) throws TransactionException;
+
+    /**
+     * Commit transaction. The transaction is identified by a transaction
+     * context. If the method throws, other resources get their changes
+     * rolled back.
+     * @param tx transaction context
+     * @throws TransactionException if an error occurs
+     */
+    void commit(TransactionContext tx) throws TransactionException;
+
+    /**
+     * Rollback transaction. The transaction is identified by a transaction
+     * context.
+     * @param tx transaction context.
+     */
+    void rollback(TransactionContext tx) throws TransactionException;
+
+    /**
+     * Invoked after one of the {@link #prepare}, {@link #commit} or
+     * {@link #rollback} method has been called.
+     * @param tx transaction context
+     */
+    void afterOperation(TransactionContext tx);
+
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/InternalXAResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java Wed Mar 12 11:05:06 2014
@@ -1,376 +1,376 @@
-/*
- * 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.data.core;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents the transaction on behalf of the component that wants to
- * explicitly demarcate transaction boundaries. After having been prepared,
- * schedules a task that rolls back the transaction if some time passes without
- * any further action. This will guarantee that global objects locked by one
- * of the resources' {@link InternalXAResource#prepare} method, are eventually
- * unlocked.
- */
-public class TransactionContext {
-
-    /**
-     * Logger instance.
-     */
-    private static final Logger log = LoggerFactory.getLogger(TransactionContext.class);
-
-    private static final int STATUS_PREPARING = 1;
-    private static final int STATUS_PREPARED = 2;
-    private static final int STATUS_COMMITTING = 3;
-    private static final int STATUS_COMMITTED = 4;
-    private static final int STATUS_ROLLING_BACK = 5;
-    private static final int STATUS_ROLLED_BACK = 6;
-
-    /**
-     * The per thread associated Xid
-     */
-    private static final ThreadLocal<Xid> CURRENT_XID = new ThreadLocal<Xid>();
-
-    /**
-     * Transactional resources.
-     */
-    private final InternalXAResource[] resources;
-
-    /**
-    * The Xid
-    */
-   private final Xid xid;
-
-    /**
-     * Transaction attributes.
-     */
-    private final Map<String, Object> attributes = new HashMap<String, Object>();
-
-    /**
-     * Status.
-     */
-    private int status;
-
-    /**
-     * Flag indicating whether the association is currently suspended.
-     */
-    private boolean suspended;
-
-    /**
-     * Create a new instance of this class.
-     *
-     * @param xid associated xid
-     * @param resources transactional resources
-     */
-    public TransactionContext(Xid xid, InternalXAResource[] resources) {
-        this.xid = xid;
-        this.resources = resources;
-    }
-
-    /**
-     * Set an attribute on this transaction. If the value specified is
-     * <code>null</code>, it is semantically equivalent to
-     * {@link #removeAttribute}.
-     *
-     * @param name  attribute name
-     * @param value attribute value
-     */
-    public void setAttribute(String name, Object value) {
-        if (value == null) {
-            removeAttribute(name);
-        }
-        attributes.put(name, value);
-    }
-
-    /**
-     * Return an attribute value on this transaction.
-     *
-     * @param name attribute name
-     * @return attribute value, <code>null</code> if no attribute with that
-     *         name exists
-     */
-    public Object getAttribute(String name) {
-        return attributes.get(name);
-    }
-
-    /**
-     * Remove an attribute on this transaction.
-     *
-     * @param name attribute name
-     */
-    public void removeAttribute(String name) {
-        attributes.remove(name);
-    }
-
-    /**
-     * Prepare the transaction identified by this context. Prepares changes on
-     * all resources. If some resource reports an error on prepare,
-     * automatically rollback changes on all other resources. Throw exception
-     * at the end if errors were found.
-     *
-     * @throws XAException if an error occurs
-     */
-    public synchronized void prepare() throws XAException {
-        bindCurrentXid();
-        status = STATUS_PREPARING;
-        beforeOperation();
-
-        TransactionException txe = null;
-        for (int i = 0; i < resources.length; i++) {
-            try {
-                resources[i].prepare(this);
-            } catch (TransactionException e) {
-                txe = e;
-                break;
-            } catch (Exception e) {
-                txe = new TransactionException("Error while preparing resource " + resources, e);
-                break;
-            }
-        }
-
-        afterOperation();
-        status = STATUS_PREPARED;
-
-        if (txe != null) {
-            // force immediate rollback on error.
-            try {
-                rollback();
-            } catch (XAException e) {
-                /* ignore */
-            }
-            XAException e = new XAException(XAException.XA_RBOTHER);
-            e.initCause(txe);
-            throw e;
-        }
-    }
-
-    /**
-     * Commit the transaction identified by this context. Commits changes on
-     * all resources. If some resource reports an error on commit,
-     * automatically rollback changes on all other resources. Throw
-     * exception at the end if some commit failed.
-     *
-     * @throws XAException if an error occurs
-     */
-    public synchronized void commit() throws XAException {
-        if (status == STATUS_ROLLED_BACK) {
-            throw new XAException(XAException.XA_HEURRB);
-        }
-
-        boolean heuristicCommit = false;
-        bindCurrentXid();
-        status = STATUS_COMMITTING;
-        beforeOperation();
-
-        TransactionException txe = null;
-        for (int i = 0; i < resources.length; i++) {
-            InternalXAResource resource = resources[i];
-            if (txe != null) {
-                try {
-                    resource.rollback(this);
-                } catch (Exception e) {
-                    log.warn("Unable to rollback changes on " + resource, e);
-                }
-            } else {
-                try {
-                    resource.commit(this);
-                    heuristicCommit = true;
-                } catch (TransactionException e) {
-                    txe = e;
-                } catch (Exception e) {
-                    txe = new TransactionException("Error while committing resource " + resource, e);
-                }
-            }
-        }
-        afterOperation();
-        status = STATUS_COMMITTED;
-
-        cleanCurrentXid();
-
-        if (txe != null) {
-            XAException e = null;
-            if (heuristicCommit) {
-                e = new XAException(XAException.XA_HEURMIX);
-            } else {
-                e = new XAException(XAException.XA_HEURRB);
-            }
-            e.initCause(txe);
-            throw e;
-        }
-    }
-
-    /**
-     * Rollback the transaction identified by this context. Rolls back changes
-     * on all resources. Throws exception at the end if errors were found.
-     * @throws XAException if an error occurs
-     */
-    public synchronized void rollback() throws XAException {
-        if (status == STATUS_ROLLED_BACK) {
-            throw new XAException(XAException.XA_RBOTHER);
-        }
-        bindCurrentXid();
-        status = STATUS_ROLLING_BACK;
-        beforeOperation();
-
-        int errors = 0;
-        for (int i = 0; i < resources.length; i++) {
-            InternalXAResource resource = resources[i];
-            try {
-                resource.rollback(this);
-            } catch (Exception e) {
-                log.warn("Unable to rollback changes on " + resource, e);
-                errors++;
-            }
-        }
-        afterOperation();
-        status = STATUS_ROLLED_BACK;
-
-        cleanCurrentXid();
-
-        if (errors != 0) {
-            throw new XAException(XAException.XA_RBOTHER);
-        }
-    }
-
-    /**
-     * Invoke all of the registered resources' {@link InternalXAResource#beforeOperation}
-     * methods.
-     */
-    private void beforeOperation() {
-        for (int i = 0; i < resources.length; i++) {
-            resources[i].beforeOperation(this);
-        }
-    }
-
-    /**
-     * Invoke all of the registered resources' {@link InternalXAResource#afterOperation}
-     * methods.
-     */
-    private void afterOperation() {
-        for (int i = 0; i < resources.length; i++) {
-            resources[i].afterOperation(this);
-        }
-    }
-
-    /**
-     * Return a flag indicating whether the association is suspended.
-     *
-     * @return <code>true</code> if the association is suspended;
-     *         <code>false</code> otherwise
-     */
-    public boolean isSuspended() {
-        return suspended;
-    }
-
-    /**
-     * Set a flag indicating whether the association is suspended.
-     *
-     * @param suspended flag whether that the association is suspended.
-     */
-    public void setSuspended(boolean suspended) {
-        this.suspended = suspended;
-    }
-
-    /**
-     * Helper Method to bind the {@link Xid} associated with this {@link TransactionContext}
-     * to the {@link #CURRENT_XID} ThreadLocal.
-     */
-    private void bindCurrentXid() {
-        CURRENT_XID.set(xid);
-    }
-
-    /**
-     * Helper Method to clean the {@link Xid} associated with this {@link TransactionContext}
-     * from the {@link #CURRENT_XID} ThreadLocal.
-     */
-    private void cleanCurrentXid() {
-        CURRENT_XID.set(null);
-    }
-
-    /**
-     * Returns the {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
-     * @return current Xid or null
-     */
-    private static Xid getCurrentXid() {
-        return CURRENT_XID.get();
-    }
-
-    /**
-     * Returns the current thread identifier. The identifier is either the
-     * current thread instance or the global transaction identifier wrapped 
-     * in a {@link XidWrapper}, when running under a transaction.
-     *
-     * @return current thread identifier
-     */
-    public static Object getCurrentThreadId() {
-        Xid xid = TransactionContext.getCurrentXid();
-        if (xid != null) {
-            return new XidWrapper(xid.getGlobalTransactionId());
-        } else {
-            return Thread.currentThread();
-        }
-    }
-
-    /**
-     * Compares the given thread identifiers for equality.
-     *
-     * @see #getCurrentThreadId()
-     */
-    public static boolean isSameThreadId(Object a, Object b) {
-        if (a == b) {
-            return true;
-        } else if (a != null) {
-        	return a.equals(b);
-        } else {
-            return false;
-        }
-    }
-    
-    /**
-     * Wrapper around a global transaction id (byte[]) 
-     * that handles hashCode and equals in a proper way.
-     */
-    private static class XidWrapper {
-    	private byte[] gtid;
-    	
-    	public XidWrapper(byte[] gtid) {
-    		this.gtid = gtid;
-    	}
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof XidWrapper)) {
-                return false;
-            }
-            return Arrays.equals((byte[]) gtid, ((XidWrapper)other).gtid);
-        }
-
-        @Override
-        public int hashCode() {
-            return Arrays.hashCode(gtid);
-        }
-    }
-
-}
+/*
+ * 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.data.core;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the transaction on behalf of the component that wants to
+ * explicitly demarcate transaction boundaries. After having been prepared,
+ * schedules a task that rolls back the transaction if some time passes without
+ * any further action. This will guarantee that global objects locked by one
+ * of the resources' {@link InternalXAResource#prepare} method, are eventually
+ * unlocked.
+ */
+public class TransactionContext {
+
+    /**
+     * Logger instance.
+     */
+    private static final Logger log = LoggerFactory.getLogger(TransactionContext.class);
+
+    private static final int STATUS_PREPARING = 1;
+    private static final int STATUS_PREPARED = 2;
+    private static final int STATUS_COMMITTING = 3;
+    private static final int STATUS_COMMITTED = 4;
+    private static final int STATUS_ROLLING_BACK = 5;
+    private static final int STATUS_ROLLED_BACK = 6;
+
+    /**
+     * The per thread associated Xid
+     */
+    private static final ThreadLocal<Xid> CURRENT_XID = new ThreadLocal<Xid>();
+
+    /**
+     * Transactional resources.
+     */
+    private final InternalXAResource[] resources;
+
+    /**
+    * The Xid
+    */
+   private final Xid xid;
+
+    /**
+     * Transaction attributes.
+     */
+    private final Map<String, Object> attributes = new HashMap<String, Object>();
+
+    /**
+     * Status.
+     */
+    private int status;
+
+    /**
+     * Flag indicating whether the association is currently suspended.
+     */
+    private boolean suspended;
+
+    /**
+     * Create a new instance of this class.
+     *
+     * @param xid associated xid
+     * @param resources transactional resources
+     */
+    public TransactionContext(Xid xid, InternalXAResource[] resources) {
+        this.xid = xid;
+        this.resources = resources;
+    }
+
+    /**
+     * Set an attribute on this transaction. If the value specified is
+     * <code>null</code>, it is semantically equivalent to
+     * {@link #removeAttribute}.
+     *
+     * @param name  attribute name
+     * @param value attribute value
+     */
+    public void setAttribute(String name, Object value) {
+        if (value == null) {
+            removeAttribute(name);
+        }
+        attributes.put(name, value);
+    }
+
+    /**
+     * Return an attribute value on this transaction.
+     *
+     * @param name attribute name
+     * @return attribute value, <code>null</code> if no attribute with that
+     *         name exists
+     */
+    public Object getAttribute(String name) {
+        return attributes.get(name);
+    }
+
+    /**
+     * Remove an attribute on this transaction.
+     *
+     * @param name attribute name
+     */
+    public void removeAttribute(String name) {
+        attributes.remove(name);
+    }
+
+    /**
+     * Prepare the transaction identified by this context. Prepares changes on
+     * all resources. If some resource reports an error on prepare,
+     * automatically rollback changes on all other resources. Throw exception
+     * at the end if errors were found.
+     *
+     * @throws XAException if an error occurs
+     */
+    public synchronized void prepare() throws XAException {
+        bindCurrentXid();
+        status = STATUS_PREPARING;
+        beforeOperation();
+
+        TransactionException txe = null;
+        for (int i = 0; i < resources.length; i++) {
+            try {
+                resources[i].prepare(this);
+            } catch (TransactionException e) {
+                txe = e;
+                break;
+            } catch (Exception e) {
+                txe = new TransactionException("Error while preparing resource " + resources, e);
+                break;
+            }
+        }
+
+        afterOperation();
+        status = STATUS_PREPARED;
+
+        if (txe != null) {
+            // force immediate rollback on error.
+            try {
+                rollback();
+            } catch (XAException e) {
+                /* ignore */
+            }
+            XAException e = new XAException(XAException.XA_RBOTHER);
+            e.initCause(txe);
+            throw e;
+        }
+    }
+
+    /**
+     * Commit the transaction identified by this context. Commits changes on
+     * all resources. If some resource reports an error on commit,
+     * automatically rollback changes on all other resources. Throw
+     * exception at the end if some commit failed.
+     *
+     * @throws XAException if an error occurs
+     */
+    public synchronized void commit() throws XAException {
+        if (status == STATUS_ROLLED_BACK) {
+            throw new XAException(XAException.XA_HEURRB);
+        }
+
+        boolean heuristicCommit = false;
+        bindCurrentXid();
+        status = STATUS_COMMITTING;
+        beforeOperation();
+
+        TransactionException txe = null;
+        for (int i = 0; i < resources.length; i++) {
+            InternalXAResource resource = resources[i];
+            if (txe != null) {
+                try {
+                    resource.rollback(this);
+                } catch (Exception e) {
+                    log.warn("Unable to rollback changes on " + resource, e);
+                }
+            } else {
+                try {
+                    resource.commit(this);
+                    heuristicCommit = true;
+                } catch (TransactionException e) {
+                    txe = e;
+                } catch (Exception e) {
+                    txe = new TransactionException("Error while committing resource " + resource, e);
+                }
+            }
+        }
+        afterOperation();
+        status = STATUS_COMMITTED;
+
+        cleanCurrentXid();
+
+        if (txe != null) {
+            XAException e = null;
+            if (heuristicCommit) {
+                e = new XAException(XAException.XA_HEURMIX);
+            } else {
+                e = new XAException(XAException.XA_HEURRB);
+            }
+            e.initCause(txe);
+            throw e;
+        }
+    }
+
+    /**
+     * Rollback the transaction identified by this context. Rolls back changes
+     * on all resources. Throws exception at the end if errors were found.
+     * @throws XAException if an error occurs
+     */
+    public synchronized void rollback() throws XAException {
+        if (status == STATUS_ROLLED_BACK) {
+            throw new XAException(XAException.XA_RBOTHER);
+        }
+        bindCurrentXid();
+        status = STATUS_ROLLING_BACK;
+        beforeOperation();
+
+        int errors = 0;
+        for (int i = 0; i < resources.length; i++) {
+            InternalXAResource resource = resources[i];
+            try {
+                resource.rollback(this);
+            } catch (Exception e) {
+                log.warn("Unable to rollback changes on " + resource, e);
+                errors++;
+            }
+        }
+        afterOperation();
+        status = STATUS_ROLLED_BACK;
+
+        cleanCurrentXid();
+
+        if (errors != 0) {
+            throw new XAException(XAException.XA_RBOTHER);
+        }
+    }
+
+    /**
+     * Invoke all of the registered resources' {@link InternalXAResource#beforeOperation}
+     * methods.
+     */
+    private void beforeOperation() {
+        for (int i = 0; i < resources.length; i++) {
+            resources[i].beforeOperation(this);
+        }
+    }
+
+    /**
+     * Invoke all of the registered resources' {@link InternalXAResource#afterOperation}
+     * methods.
+     */
+    private void afterOperation() {
+        for (int i = 0; i < resources.length; i++) {
+            resources[i].afterOperation(this);
+        }
+    }
+
+    /**
+     * Return a flag indicating whether the association is suspended.
+     *
+     * @return <code>true</code> if the association is suspended;
+     *         <code>false</code> otherwise
+     */
+    public boolean isSuspended() {
+        return suspended;
+    }
+
+    /**
+     * Set a flag indicating whether the association is suspended.
+     *
+     * @param suspended flag whether that the association is suspended.
+     */
+    public void setSuspended(boolean suspended) {
+        this.suspended = suspended;
+    }
+
+    /**
+     * Helper Method to bind the {@link Xid} associated with this {@link TransactionContext}
+     * to the {@link #CURRENT_XID} ThreadLocal.
+     */
+    private void bindCurrentXid() {
+        CURRENT_XID.set(xid);
+    }
+
+    /**
+     * Helper Method to clean the {@link Xid} associated with this {@link TransactionContext}
+     * from the {@link #CURRENT_XID} ThreadLocal.
+     */
+    private void cleanCurrentXid() {
+        CURRENT_XID.set(null);
+    }
+
+    /**
+     * Returns the {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
+     * @return current Xid or null
+     */
+    private static Xid getCurrentXid() {
+        return CURRENT_XID.get();
+    }
+
+    /**
+     * Returns the current thread identifier. The identifier is either the
+     * current thread instance or the global transaction identifier wrapped 
+     * in a {@link XidWrapper}, when running under a transaction.
+     *
+     * @return current thread identifier
+     */
+    public static Object getCurrentThreadId() {
+        Xid xid = TransactionContext.getCurrentXid();
+        if (xid != null) {
+            return new XidWrapper(xid.getGlobalTransactionId());
+        } else {
+            return Thread.currentThread();
+        }
+    }
+
+    /**
+     * Compares the given thread identifiers for equality.
+     *
+     * @see #getCurrentThreadId()
+     */
+    public static boolean isSameThreadId(Object a, Object b) {
+        if (a == b) {
+            return true;
+        } else if (a != null) {
+        	return a.equals(b);
+        } else {
+            return false;
+        }
+    }
+    
+    /**
+     * Wrapper around a global transaction id (byte[]) 
+     * that handles hashCode and equals in a proper way.
+     */
+    private static class XidWrapper {
+    	private byte[] gtid;
+    	
+    	public XidWrapper(byte[] gtid) {
+    		this.gtid = gtid;
+    	}
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof XidWrapper)) {
+                return false;
+            }
+            return Arrays.equals((byte[]) gtid, ((XidWrapper)other).gtid);
+        }
+
+        @Override
+        public int hashCode() {
+            return Arrays.hashCode(gtid);
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionException.java?rev=1576690&r1=1576689&r2=1576690&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionException.java (original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionException.java Wed Mar 12 11:05:06 2014
@@ -1,44 +1,44 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.data.core;
-
-/**
- * TransactionException is thrown when some operation inside the transaction
- * fails.
- */
-public class TransactionException extends Exception {
-
-    /**
-     * Creates an instance of this class. Takes a detail message as parameter.
-     *
-     * @param message message
-     */
-    public TransactionException(String message) {
-        super(message);
-    }
-
-    /**
-     * Creates an instance of this class. Takes a message and a root throwable
-     * as parameter.
-     *
-     * @param message   message
-     * @param rootCause root throwable
-     */
-    public TransactionException(String message, Throwable rootCause) {
-        super(message, rootCause);
-    }
-}
+/*
+ * 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.data.core;
+
+/**
+ * TransactionException is thrown when some operation inside the transaction
+ * fails.
+ */
+public class TransactionException extends Exception {
+
+    /**
+     * Creates an instance of this class. Takes a detail message as parameter.
+     *
+     * @param message message
+     */
+    public TransactionException(String message) {
+        super(message);
+    }
+
+    /**
+     * Creates an instance of this class. Takes a message and a root throwable
+     * as parameter.
+     *
+     * @param message   message
+     * @param rootCause root throwable
+     */
+    public TransactionException(String message, Throwable rootCause) {
+        super(message, rootCause);
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/stats/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/logback-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/privilege/readtest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/privilege/writetest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/base/src/main/resources/deepTree.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit23/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit23/src/test/resources/btree-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit23/src/test/resources/default-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit24/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit24/src/test/resources/btree-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit24/src/test/resources/default-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit26/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit26/src/test/resources/btree-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/test/performance/jackrabbit26/src/test/resources/default-usermanager-repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message