Author: lhein
Date: Fri Jul 4 04:59:17 2008
New Revision: 674021
URL: http://svn.apache.org/viewvc?rev=674021&view=rev
Log:
created a simplified lock object
updated the simplelockmanager to use the new simplelock
(SM-1441)
Added:
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
(with props)
Modified:
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
Added:
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
URL:
http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java?rev=674021&view=auto
==============================================================================
---
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
(added)
+++
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
Fri Jul 4 04:59:17 2008
@@ -0,0 +1,79 @@
+/*
+ * 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.servicemix.locks.impl;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * @author lhein
+ */
+public class SimpleLock implements Lock {
+
+ private AtomicBoolean lock;
+
+ /**
+ * default constructor
+ */
+ public SimpleLock() {
+ this.lock = new AtomicBoolean(false);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#lock()
+ */
+ public void lock() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#lockInterruptibly()
+ */
+ public void lockInterruptibly() throws InterruptedException {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#newCondition()
+ */
+ public Condition newCondition() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#tryLock()
+ */
+ public boolean tryLock() {
+ return this.lock.compareAndSet(false, true);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#tryLock(long,
java.util.concurrent.TimeUnit)
+ */
+ public boolean tryLock(long time, TimeUnit unit) throws
InterruptedException {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.concurrent.locks.Lock#unlock()
+ */
+ public void unlock() {
+ this.lock.compareAndSet(true, false);
+ }
+}
Propchange:
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
URL:
http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java?rev=674021&r1=674020&r2=674021&view=diff
==============================================================================
---
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
(original)
+++
servicemix/smx3/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
Fri Jul 4 04:59:17 2008
@@ -19,7 +19,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.servicemix.locks.LockManager;
@@ -30,7 +29,7 @@
public Lock getLock(String id) {
Lock lock = locks.get(id);
if (lock == null) {
- lock = new ReentrantLock();
+ lock = new SimpleLock();
Lock oldLock = locks.putIfAbsent(id, lock);
if (oldLock != null) {
lock = oldLock;