PDA

View Full Version : How to migrate Registry from GXT 2.2.5 to GXT 4.0



SimonTucker
22 Apr 2017, 7:33 AM
We had a product developed many years ago with GXT 2.2.5. We are trying to migrate to the latest version. Registry is heavily used in the product. GXT 4.0 removed it completely. How do we migrate to GXT 4.0 without using the Registry? Do we have to totally change the programing style? Is there an easy way to replace it with another utility? Thanks in advance!

harun
28 Jul 2017, 3:56 AM
Hi,

you can simply write your own class. Below is my solution:



public static class Registry
{
protected static Map<String, Object> map = new FastMap<Object>();

/**
* Returns the object with the given id.
*
* @param id the identifier
* @return the object or <code>null</code> if no match
*/
@SuppressWarnings( "unchecked" )
public static <X> X get( String id)
{
return (X) map.get( id );
}

/**
* Returns a map of all registered objects.
*
* @return the object map
*/
public static Map<String, Object> getAll()
{
return map;
}

/**
* Registers an object.
*
* @param id the identifier
* @param obj the object to be registered
*/
public static void register( String id, Object obj)
{
map.put( id, obj );
}

/**
* Unregisters an object.
*
* @param id the identifier
*/
public static void unregister( String id)
{
map.remove( id );
}

/**
* Unregisters all registered objects.
*/
public static void unregisterAll()
{
map.clear();
}

private Registry()
{
}
}