You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/11/02 18:24:59 UTC

svn commit: r1538235 - /karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java

Author: jbonofre
Date: Sat Nov  2 17:24:58 2013
New Revision: 1538235

URL: http://svn.apache.org/r1538235
Log:
[KARAF-2523] Add SQLServer JDBC lock support

Added:
    karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java

Added: karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java?rev=1538235&view=auto
==============================================================================
--- karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java (added)
+++ karaf/branches/karaf-2.x/main/src/main/java/org/apache/karaf/main/SQLServerJDBCLock.java Sat Nov  2 17:24:58 2013
@@ -0,0 +1,49 @@
+/*
+ * 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.karaf.main;
+
+import java.util.Properties;
+
+/**
+ * Represents an exclusive lock on a database,
+ * used to avoid multiple Karaf instances attempting
+ * to become master.
+ */
+public class SQLServerJDBCLock extends DefaultJDBCLock {
+
+    public SQLServerJDBCLock(Properties properties) {
+        super(properties);
+    }
+
+    @Override
+    Statements createStatements() {
+        Statements statements = new MsSQLServerStatements();
+        return statements;
+    }
+
+    private class MsSQLServerStatements extends Statements {
+
+        @Override
+        public String getLockCreateStatement() {
+            return "SELECT * FROM " + getFullLockTableName();
+        }
+
+    }
+
+}