jtulach commented on code in PR #6639:
URL: https://github.com/apache/netbeans/pull/6639#discussion_r4102899572


##########
java/java.lsp.server/nbcode/integration/src/META-INF/services/org.netbeans.modules.masterfs.filebasedfs.fileobjects.LockForFile$HardLockRegistry:
##########
@@ -0,0 +1,19 @@
+# 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.
+
+#suppress the file-based hard locks:
+#-org.netbeans.modules.masterfs.filebasedfs.fileobjects.LockForFile$FileBaseHardLockRegistry

Review Comment:
   I'd like the use-case to be described in `platform/masterfs/arch.xml` - e.g.
   ```
   <api group="lookup" type="export" name="Disable .LCK files" category="devel">
   To disable.... remove this class ... this is an API under development and 
may be replaced or changed in the future.
   </api>
   ```
   Also add **versioning** and a note into `apichanges.xml`.



##########
platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/LockForFile.java:
##########
@@ -292,12 +275,134 @@ private void hardLock() throws IOException {
                 if (reference != null) {
                     LockForFile lockForFile = reference.get();
                     if (lockForFile != null) {
-                        if 
(!FileChangedManager.getInstance().exists(lockForFile.getLock())) {
+                        if 
(!HardLockRegistry.getInstance().hardLockExists(lockForFile.getLock())) {
                             lockForFile.hardLock();
                         }
                     }
                 }
             }
         }
     }
+
+    public static boolean hasActiveLockFileSigns(final String filename) {
+        return filename.startsWith(PREFIX) && filename.endsWith(SUFFIX);
+    }
+
+    static final class HardLockPath {
+        public final File file;
+
+        public HardLockPath(File file) {
+            this.file = file;
+        }
+
+    }
+
+    /*not private for tests*/
+    public static interface HardLockRegistry {

Review Comment:
   - the name of the class is an API
      - one needs it to create appropriate `META-INF/services` file
   - **make the class top-level**, please!
   - I would even suggest to give it a dedicated package
      - maybe `org.netbeans.modules.masterfs.locking`?
   - **update the Javadoc** it seems out of date given the new use-case created 
by this PR



##########
platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/LockForFile.java:
##########
@@ -292,12 +275,134 @@ private void hardLock() throws IOException {
                 if (reference != null) {
                     LockForFile lockForFile = reference.get();
                     if (lockForFile != null) {
-                        if 
(!FileChangedManager.getInstance().exists(lockForFile.getLock())) {
+                        if 
(!HardLockRegistry.getInstance().hardLockExists(lockForFile.getLock())) {
                             lockForFile.hardLock();
                         }
                     }
                 }
             }
         }
     }
+
+    public static boolean hasActiveLockFileSigns(final String filename) {
+        return filename.startsWith(PREFIX) && filename.endsWith(SUFFIX);
+    }
+
+    static final class HardLockPath {
+        public final File file;
+
+        public HardLockPath(File file) {
+            this.file = file;
+        }
+
+    }
+
+    /*not private for tests*/
+    public static interface HardLockRegistry {
+        public static HardLockRegistry getInstance() {
+            return HardLockRegistryInstance.INSTANCE;
+        }
+
+        public void doHardLock(HardLockPath hardLock, String absolutePath) 
throws IOException;
+
+        public boolean doHardUnlock(HardLockPath hardLock);
+
+        public boolean hardLockExists(HardLockPath hardLock) throws 
IOException;
+
+        public String getHardLockContent(HardLockPath hardLock);
+
+    }
+
+    //init the HardLockRegistry instance lazily:
+    private static final class HardLockRegistryInstance {
+        public static final HardLockRegistry INSTANCE = 
Lookup.getDefault().lookup(HardLockRegistry.class);
+    }
+
+    @ServiceProvider(service=HardLockRegistry.class, position=100)
+    public static final class FileBaseHardLockRegistry implements 
HardLockRegistry {

Review Comment:
   - Make it a top level class, maybe? 
   - The name of the class becomes an API ... 
   - avoiding `$` in the name ... simplifies the API



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to