public static void main (String[] args) { //Create the registry object RegistryInterface theRegistry = new Registry(); //Display the menu theRegistry.doMenu(); //etc...
class Bean{ Registry registry = new Registry(); public Registry getRegistry() { return registry; } }
private void setupJmx(final boolean skip) { try { final Field registry = Registry.class.getDeclaredField("registry"); registry.setAccessible(true); registry.set(null, skip ? new NoDescriptorRegistry() : new Registry()); } catch (final Exception e) { throw new IllegalStateException(e); } }
private final Registry registry = new Registry(); private final Serializer serializer = new Persister(new RegistryStrategy(registry)); .... registry.bind(XMLEvents.class, new XMLEventsConverter(serializer));
private void setupJmx(final boolean skip) { try { final Field registry = Registry.class.getDeclaredField("registry"); registry.setAccessible(true); registry.set(null, skip ? new NoDescriptorRegistry() : new Registry()); } catch (final Exception e) { throw new IllegalStateException(e); } }
private < T extends Box > void getParserAndParse( Registry registry, Class< T > clazz, Object box ) { registry.get( clazz ).parse( clazz.cast( box ) ); } public void runTest() { Registry registry = new Registry(); registry.add( BoxA.class, new ParserA() ); registry.add( BoxB.class, new ParserB() ); List<Box> boxes = new ArrayList< Box >(); boxes.add( new BoxA( "Silly" ) ); boxes.add( new BoxB( "Funny" ) ); boxes.add( new BoxB( "Foo" ) ); boxes.add( new BoxA( "Bar" ) ); for ( Box box : boxes ) { Class< ? extends Box > clazz = box.getClass(); getParserAndParse( registry, clazz, box ); // compiles } }
Registry reg = new Registry(); RegistryKey topKey = Registry.HKEY_CURRENT_USER; RegistryKey rk = topKey.openSubKey("Software\\Sparx Systems\\EA400\\EA"); String path = rk.getStringValue("Install Path");
public class TestArrayList { public static void main(String[] args){ Registry reg = new Registry(); reg.addNum(11); reg.addNum(22); } }
Registry registry = new Registry();