@Test public void testComponentAncestors() throws Exception { List<Component> components = this.resource.findComponentAncestors( "inexisting", "my-comp" ); Assert.assertEquals( 0, components.size()); components = this.resource.findComponentAncestors( this.app.getName(), "my-comp" ); Assert.assertEquals( 0, components.size()); components = this.resource.findComponentAncestors( this.app.getName(), this.app.getTomcat().getComponent().getName()); Assert.assertEquals( 1, components.size()); Assert.assertTrue( components.contains( this.app.getMySqlVm().getComponent())); }
@Override public List<Component> findComponentAncestors( String applicationName, String componentName ) { this.logger.fine( "Request: find components where a " + componentName + " component could be deployed on, in " + applicationName + "." ); List<Component> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( app != null ) { Component comp = ComponentHelpers.findComponent( app.getTemplate().getGraphs(), componentName ); if( comp != null ) result.addAll( ComponentHelpers.findAllAncestors( comp )); else this.logger.fine( "No component called " + componentName + " was found in " + applicationName + "." ); } return result; }
ApplicationResource implements IApplicationResource { @Override public List<Component> findComponentAncestors( String applicationName, String componentName ) { this.logger.fine( "Request: find components where a " + componentName + " component could be deployed on, in " + applicationName + "." ); List<Component> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( app != null ) { Component comp = ComponentHelpers.findComponent( app.getTemplate().getGraphs(), componentName ); if( comp != null ) result.addAll( ComponentHelpers.findAllAncestors( comp )); else this.logger.fine( "No component called " + componentName + " was found in " + applicationName + "." ); } return result; } }
ApplicationResource implements IApplicationResource { @Override public List<Component> findComponentAncestors( String applicationName, String componentName ) { this.logger.fine( "Request: find components where a " + componentName + " component could be deployed on, in " + applicationName + "." ); List<Component> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( app != null ) { Component comp = ComponentHelpers.findComponent( app.getTemplate().getGraphs(), componentName ); if( comp != null ) result.addAll( ComponentHelpers.findAllAncestors( comp )); else this.logger.fine( "No component called " + componentName + " was found in " + applicationName + "." ); } return result; } ApplicationResource( Manager manager ); }
ApplicationResource implements IApplicationResource { @Override public List<Component> findComponentAncestors( String applicationName, String componentName ) { this.logger.fine( "Request: find components where a " + componentName + " component could be deployed on, in " + applicationName + "." ); List<Component> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( app != null ) { Component comp = ComponentHelpers.findComponent( app.getTemplate().getGraphs(), componentName ); if( comp != null ) result.addAll( ComponentHelpers.findAllAncestors( comp )); else this.logger.fine( "No component called " + componentName + " was found in " + applicationName + "." ); } return result; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags ); }
ApplicationResource implements IApplicationResource { @Override public List<Component> findComponentAncestors( String applicationName, String componentName ) { this.logger.fine( "Request: find components where a " + componentName + " component could be deployed on, in " + applicationName + "." ); List<Component> result = new ArrayList<> (); Application app = this.manager.applicationMngr().findApplicationByName( applicationName ); if( app != null ) { Component comp = ComponentHelpers.findComponent( app.getTemplate().getGraphs(), componentName ); if( comp != null ) result.addAll( ComponentHelpers.findAllAncestors( comp )); else this.logger.fine( "No component called " + componentName + " was found in " + applicationName + "." ); } return result; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags );  }