Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
******************************************************************************/
package org.hpccsystems.ws.client.utils;

import java.util.Observable;

import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Stub;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Observable;

public class DataSingletonCollection extends Observable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Lets remove the dependency on the Observable pattern here entirely, the functionality is no longer needed. All locations in the code base the depend on the pattern should be updated to remove the observer functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the Observable pattern entirely. Deleted Observable.java and Observer.java files, removed extends Observable from DataSingleton and DataSingletonCollection, and removed all setChanged() and notifyObservers() calls from all platform classes (commit 7a05c21)

{
Expand Down
126 changes: 126 additions & 0 deletions wsclient/src/main/java/org/hpccsystems/ws/client/utils/Observable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*******************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This class should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already removed in commit 7a05c21

* Copyright (c) 2025 HPCC Systems. All rights reserved. This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: HPCC Systems - initial API and implementation
******************************************************************************/
package org.hpccsystems.ws.client.utils;

import java.util.ArrayList;
import java.util.List;

/**
* A simple observable pattern implementation to replace the deprecated java.util.Observable.
* This class allows observers to be notified when the state of an object changes.
*/
public class Observable
{
private final List<Observer> observers = new ArrayList<>();
private boolean changed = false;

/**
* Adds an observer to the set of observers for this object.
*
* @param o the observer to be added
* @throws NullPointerException if the parameter o is null
*/
public synchronized void addObserver(Observer o)
{
if (o == null)
{
throw new NullPointerException();
}
if (!observers.contains(o))
{
observers.add(o);
}
}

/**
* Deletes an observer from the set of observers of this object.
*
* @param o the observer to be deleted
*/
public synchronized void deleteObserver(Observer o)
{
observers.remove(o);
}

/**
* Notifies all observers if this object has been marked as changed.
*/
public void notifyObservers()
{
notifyObservers(null);
}

/**
* Notifies all observers if this object has been marked as changed.
*
* @param arg an argument to pass to observers
*/
public void notifyObservers(Object arg)
{
Object[] arrLocal;

synchronized (this)
{
if (!changed)
{
return;
}
arrLocal = observers.toArray();
clearChanged();
}

for (int i = arrLocal.length - 1; i >= 0; i--)
{
((Observer) arrLocal[i]).update(this, arg);
}
}

/**
* Deletes all observers from the set of observers of this object.
*/
public synchronized void deleteObservers()
{
observers.clear();
}

/**
* Marks this Observable object as having been changed.
*/
protected synchronized void setChanged()
{
changed = true;
}

/**
* Clears the changed state of this object.
*/
protected synchronized void clearChanged()
{
changed = false;
}

/**
* Tests if this object has changed.
*
* @return true if this object has been marked as changed, false otherwise
*/
public synchronized boolean hasChanged()
{
return changed;
}

/**
* Returns the number of observers of this Observable object.
*
* @return the number of observers
*/
public synchronized int countObservers()
{
return observers.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This class should also be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already removed in commit 7a05c21

* Copyright (c) 2025 HPCC Systems. All rights reserved. This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: HPCC Systems - initial API and implementation
******************************************************************************/
package org.hpccsystems.ws.client.utils;

/**
* A simple observer interface to replace the deprecated java.util.Observer.
* An object that implements this interface can observe changes in Observable objects.
*/
public interface Observer
{
/**
* This method is called whenever the observed object is changed.
*
* @param o the observable object
* @param arg an argument passed to the notifyObservers method
*/
void update(Observable o, Object arg);
}
Loading