public static ManagedObject createExactManagedObject ( ServerConnection sc , ManagedObjectReference mor ) { if ( mor == null ) { return null ; } String moType = mor . getType ( ) ; Class moClass = null ; try { moClass = Class . forName ( moPackageName + "." + moType ) ; Constructor constructor = moClass . getConstructor ( new Class [ ] { ServerConnection . class , ManagedObjectReference . class } ) ; return ( ManagedObject ) constructor . newInstance ( new Object [ ] { sc , mor } ) ; } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException ( "vijava does not have an associated class for this mor: " + mor . getVal ( ) , e ) ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "No constructor found in vijava for class: " + moClass . getName ( ) , e ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( "vijava is unable to create a managed object from this mor: " + mor . getVal ( ) , e ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "vijava is unable to create a managed object from this mor: " + mor . getVal ( ) , e ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( "vijava is unable to create a managed object from this mor: " + mor . getVal ( ) , e ) ; } }
Given the ServerConnection and a MOR return the MO