@Override public Version getVersion() { return super.getVersion(); }
@Override public Version getVersion() { return super.getVersion(); }
@Override public int hashCode() { int hashCode = 17; if (getName() != null) { hashCode *= 31 * getName().hashCode(); } if (getRole() != null) { hashCode *= 31 * getRole().hashCode(); } if (getVersion() != null) { hashCode *= 31 * getVersion().hashCode(); } return hashCode; }
@Override public int hashCode() { int hashCode = 17; if (getName() != null) { hashCode *= 31 * getName().hashCode(); } if (getRole() != null) { hashCode *= 31 * getRole().hashCode(); } if (getVersion() != null) { hashCode *= 31 * getVersion().hashCode(); } return hashCode; }
private static Map<String,List<ServiceDeploymentContributor>> selectContextServices( Topology topology ) { Map<String,List<ServiceDeploymentContributor>> defaults = new HashMap<>(); for( Service service : topology.getServices() ) { String role = service.getRole(); ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName(), service.getVersion() ); if( contributor != null ) { List<ServiceDeploymentContributor> list = defaults.get( role ); if( list == null ) { list = new ArrayList<>( 1 ); defaults.put( role, list ); } if( !list.contains( contributor ) ) { list.add( contributor ); } } } return defaults; }
private static Map<String,List<ServiceDeploymentContributor>> selectContextServices( Topology topology ) { Map<String,List<ServiceDeploymentContributor>> defaults = new HashMap<>(); for( Service service : topology.getServices() ) { String role = service.getRole(); ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName(), service.getVersion() ); if( contributor != null ) { List<ServiceDeploymentContributor> list = defaults.get( role ); if( list == null ) { list = new ArrayList<>( 1 ); defaults.put( role, list ); } if( !list.contains( contributor ) ) { list.add( contributor ); } } } return defaults; }
public void addService( Service service ) { services.add( service ); serviceMap.put(service.getRole(), service.getName(), service.getVersion(), service); }
public void addService( Service service ) { services.add( service ); serviceMap.put(service.getRole(), service.getName(), service.getVersion(), service); }
@Override public boolean equals(Object object) { if (!(object instanceof Service)) { return false; } Service that = (Service) object; String thatName = that.getName(); if (thatName != null && !(thatName.equals(name))) { return false; } String thatRole = that.getRole(); if (thatRole != null && !thatRole.equals(role)) { return false; } Version thatVersion = that.getVersion(); if (thatVersion != null && !(thatVersion.equals(version))) { return false; } return true; }
@Override public boolean equals(Object object) { if (!(object instanceof Service)) { return false; } Service that = (Service) object; String thatName = that.getName(); if (thatName != null && !(thatName.equals(name))) { return false; } String thatRole = that.getRole(); if (thatRole != null && !thatRole.equals(role)) { return false; } Version thatVersion = that.getVersion(); if (thatVersion != null && !(thatVersion.equals(version))) { return false; } return true; }
private static Service getService( org.apache.knox.gateway.topology.Service service) { Service serviceResource = new Service(); serviceResource.setRole(service.getRole()); serviceResource.setName(service.getName()); Version version = service.getVersion(); if (version != null) { serviceResource.setVersion(version.toString()); } Collection<org.apache.knox.gateway.topology.Param> paramsList = service.getParamsList(); if (paramsList != null && !paramsList.isEmpty()) { for ( org.apache.knox.gateway.topology.Param param : paramsList ) { serviceResource.getParams().add(getParam(param)); } } for ( String url : service.getUrls() ) { serviceResource.getUrls().add( url ); } return serviceResource; }
private static void contributeServices( DeploymentContext context, Topology topology, Map<String, List<ServiceDeploymentContributor>> services ) { if( services != null ) { for( Service service : topology.getServices() ) { ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), service.getName(), service.getVersion() ); if( contributor != null ) { try { log.contributeService( service.getName(), service.getRole() ); contributor.contributeService( context, service ); if( gatewayServices != null ) { ServiceRegistry sr = gatewayServices.getService( GatewayServices.SERVICE_REGISTRY_SERVICE ); if( sr != null ) { String regCode = sr.getRegistrationCode( topology.getName() ); sr.registerService( regCode, topology.getName(), service.getRole(), service.getUrls() ); } } } catch( Exception e ) { // Maybe it makes sense to throw exception log.failedToContributeService( service.getName(), service.getRole(), e ); throw new DeploymentException( "Failed to contribute service.", e ); } } } } }
private static void contributeServices( DeploymentContext context, Topology topology, Map<String, List<ServiceDeploymentContributor>> services ) { if( services != null ) { for( Service service : topology.getServices() ) { ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), service.getName(), service.getVersion() ); if( contributor != null ) { try { log.contributeService( service.getName(), service.getRole() ); contributor.contributeService( context, service ); if( gatewayServices != null ) { ServiceRegistry sr = gatewayServices.getService( GatewayServices.SERVICE_REGISTRY_SERVICE ); if( sr != null ) { String regCode = sr.getRegistrationCode( topology.getName() ); sr.registerService( regCode, topology.getName(), service.getRole(), service.getUrls() ); } } } catch( Exception e ) { // Maybe it makes sense to throw exception log.failedToContributeService( service.getName(), service.getRole(), e ); throw new DeploymentException( "Failed to contribute service.", e ); } } } } }