Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8862575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:45:41+00:00 2026-06-14T15:45:41+00:00

I have the following requirement. Introduction The system is report/content management system. It allows

  • 0

I have the following requirement.

Introduction

The system is report/content management system. It allows user to do CRUD operations on reports.

Business Logic/UI Component

When a user is editing a report, other users can’t edit the report but view only.

It contains a page with a table that monitor the locked report for view.

Challenger

1) How should I implement this “locking” Mechanism ?
2) What are the design pattern and API that will assist me?

My current implementation

I will have a report service class
It will contain a hashmap of all the reports that are locked(with information of user for lock management)

I have completed SCJD and was considering using my lock mechanism, but I realize I do not need the wait “locking”.

The only problem I worried is concurrency issue when “locking” the report(adding the lock into map), I believe that can be easily solve by using synchronization.

For the monitoring of locked report table, I plan to implement observer pattern in the report service class. For each user/backingbean it will “subscribe” to the report service.

Any inputs? ????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:45:42+00:00Added an answer on June 14, 2026 at 3:45 pm

    Answer is simple… We can manage this problem with 2 classes.

    Features of each class is given below

    ReportUtil:
    (1) track whether any report is open in write mode
    (2) create object of report based on access mode available

    Report:
    (1) open read only or writable report based on access given
    (2) While closing, reset the flag in ReportUtil class, if the current report was open in write mode.

    Client:
    To test ReportUtil and Report classes.


    import java.util.LinkedList;
    
    public class ReportUtil {
    
        private static boolean bIsWriteLockAvaialable = true;
    
        public static synchronized Report getReport() {
            Report reportObj = new Report(bIsWriteLockAvaialable);
            if(true == bIsWriteLockAvaialable) {
                bIsWriteLockAvaialable = false;
            }
            return reportObj;
        }   
    
        public static void resetLock() {
            bIsWriteLockAvaialable = true;
        }
    }
    

    public class Report {
        private boolean bICanWrite = false;
    
        public Report(boolean WriteAccess) {
            bICanWrite = WriteAccess;
        }
    
        public void open() {
            if(bICanWrite == true) {
                //Open in write mode
                System.out.println("Report open in Write mode");
            }
            else {
                //Open in readonly mode
                System.out.println("Report open in Read only mode");
            }
        }
    
        public synchronized void close() {
            if(bICanWrite == true) {
                ReportUtil.resetLock();
            }
        }
    }
    

    public class Client {
    
        public static void main(String[] args) {
            Report report1 = ReportUtil.getReport();
            report1.open(); //First time open in writable mode
    
            Report report2 = ReportUtil.getReport();
            report2.open(); //Opens in readonly mode
    
            Report report3 = ReportUtil.getReport();
            report3.open(); //Opens in readonly mode
    
            report1.close(); //close the write mode
    
            Report report4 = ReportUtil.getReport();
            report4.open(); //Opens in writable mode since the first writeable report was closed
        }
    
    }
    

    Output:
    Report open in Write mode
    Report open in Read only mode
    Report open in Read only mode
    Report open in Write mode


    I don’t know why we want to use Hash table here. May be I didn’t understand your requirement. Also, I have used synchronized methods to escape from synchronization problems.

    If your requirement was to track all the users who are using the report, please let me know.

    Happy Learning!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I have the following requirement: Based on some user input, I need to generate
I have the following requirement for creating a user profile in my application: User
I have the following requirement. 1. save a user password converted to hash(digested) 2.
I have been presented with the following requirement: The user wants to type a
I have the following requirement, I need to expose an API where the user
I have the following requirement: In case the user push one of the paginator
I have the following requirement for a business application: (All of this could be
I have following requirement in my application. A tableView with games title After selecting
I am developing a network protocol In which I have following requirement each node

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.