protected <T> T role( Object object, Class<T> roleType ) { return PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( (Composite) object ).newProxy( roleType ); } }
@Override public <K> K prototypeFor( Class<K> mixinType ) { // Instantiate given value type if( prototypeInstance == null ) { prototypeInstance = model.newInstance( uses, state ); } return prototypeInstance.newProxy( mixinType ); }
@Override public Object invoke( String s, Object[] objects, String[] strings ) throws MBeanException, ReflectionException { if( s.equals( "restart" ) ) { try { // Refresh and restart if( serviceRef.isActive() ) { // Refresh configuration CompositeInstance compositeInstance = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF .apply( (Composite) serviceRef.get() ); compositeInstance.newProxy( Configuration.class ).refresh(); ( (Activation) serviceRef ).passivate(); ( (Activation) serviceRef ).activate(); } return "Service restarted"; } catch( Exception e ) { return "Could not restart service:" + e.getMessage(); } } return "Unknown operation"; } }
@Override public Object invoke( String s, Object[] objects, String[] strings ) throws MBeanException, ReflectionException { if( s.equals( "restart" ) ) { try { // Refresh and restart if( serviceRef.isActive() ) { // Refresh configuration CompositeInstance compositeInstance = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF .apply( (Composite) serviceRef.get() ); compositeInstance.newProxy( Configuration.class ).refresh(); ( (Activation) serviceRef ).passivate(); ( (Activation) serviceRef ).activate(); } return "Service restarted"; } catch( Exception e ) { return "Could not restart service:" + e.getMessage(); } } return "Unknown operation"; } }
try Configuration config = compositeInstance.newProxy( Configuration.class );
try Configuration config = compositeInstance.newProxy( Configuration.class );