code
stringlengths
73
34.1k
label
stringclasses
1 value
Diagnostic createDiagnostic( Instance instance ) { Diagnostic result = new Diagnostic( InstanceHelpers.computeInstancePath( instance )); for( Map.Entry<String,Boolean> entry : ComponentHelpers.findComponentDependenciesFor( instance.getComponent()).entrySet()) { String facetOrComponentName = entry.getKey(); ...
java
public static Map<String,ExportedVariable> parseExportedVariables( String line ) { Pattern randomPattern = Pattern.compile( ParsingConstants.PROPERTY_GRAPH_RANDOM_PATTERN, Pattern.CASE_INSENSITIVE ); Pattern varPattern = Pattern.compile( "([^,=]+)(\\s*=\\s*(\"([^\",]+)\"|([^,]+)))?" ); Map<String,ExportedVariab...
java
public static Set<String> findPrefixesForExportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( String exportedVariableName : InstanceHelpers.findAllExportedVariables( instance ).keySet()) result.add( VariableHelpers.parseVariableName( exportedVariableName ).getKey()); return re...
java
public static Set<String> findPrefixesForImportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( instance.getComponent()).values()) result.add( VariableHelpers.parseVariableName( var.getName()).getKey()); return re...
java
public void setDescription( String applicationName, String newDesc ) throws ApplicationWsException { this.logger.finer( "Updating the description of application " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "description" ); ClientResponse r...
java
public void undeployAll( String applicationName, String instancePath ) throws ApplicationWsException { this.logger.finer( "Undeploying instances in " + applicationName + " from instance = " + instancePath ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "undeploy-all" )...
java
public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ...
java
public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances...
java
public void removeInstance( String applicationName, String instancePath ) { this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...", instancePath, applicationName ) ); WebResource path = this.resource .path( UrlConstants.APP ) .path( applicationName ) .path( "instanc...
java
public void bindApplication( String applicationName, String boundTplName, String boundApp ) throws ApplicationWsException { this.logger.finer( "Creating a binding for external exports in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "b...
java
public List<String> listAllCommands( String applicationName ) { this.logger.finer( "Listing commands in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "commands" ); List<String> result = this.wsClient.createBuilder( path ) .accep...
java
public PluginInterface findPlugin( Instance instance ) { // Find a plug-in PluginInterface result = null; if( this.simulatePlugins ) { this.logger.finer( "Simulating plugins..." ); result = new PluginMock(); } else { String installerName = null; if( instance.getComponent() != null ) installerN...
java
public void listPlugins() { if( this.plugins.isEmpty()) { this.logger.info( "No plug-in was found for Roboconf's agent." ); } else { StringBuilder sb = new StringBuilder( "Available plug-ins in Roboconf's agent: " ); for( Iterator<PluginInterface> it = this.plugins.iterator(); it.hasNext(); ) { sb.ap...
java
public void pluginAppears( PluginInterface pi ) { if( pi != null ) { this.logger.info( "Plugin '" + pi.getPluginName() + "' is now available in Roboconf's agent." ); this.plugins.add( pi ); listPlugins(); } }
java
public void pluginDisappears( PluginInterface pi ) { // May happen if a plug-in could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( pi == null ) { this.logger.info( "An invalid plugin is removed." ); } else { this.plugins.remove( pi ); this.logger.info( "Plug...
java
void reloadUserData() { if( Utils.isEmptyOrWhitespaces( this.parameters )) { this.logger.warning( "No parameters were specified in the agent configuration. No user data will be retrieved." ); } else if( ! this.overrideProperties ) { this.logger.fine( "User data are NOT supposed to be used." ); } else if(...
java
@Override public boolean checkParameter(String key, String value) { if (null == value) { return true; } value = value.toLowerCase(); if (value.contains("'")) { return false; } if (value.contains("--")) { return false; } if (value.contains("d...
java
public String createOrUpdateJob( String jobId, String jobName, String appName, String cmdName, String cron ) throws SchedulerWsException { if( jobId == null ) this.logger.finer( "Creating a new scheduled job." ); else this.logger.finer( "Updating the following scheduled job: " + jobId ); WebResource pat...
java
public void deleteJob( String jobId ) throws SchedulerWsException { this.logger.finer( "Deleting scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) ...
java
public ScheduledJob getJobProperties( String jobId ) throws SchedulerWsException { this.logger.finer( "Getting the properties of a scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .acce...
java
public static synchronized Process getProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.get(toAgentId(applicationName, scopedInstancePath)); }
java
public static synchronized Process clearProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.remove(toAgentId(applicationName, scopedInstancePath)); }
java
public static Object getAttribute(UIComponent component, String attributeName) { Object value = component.getPassThroughAttributes().get(attributeName); if (null == value) { value = component.getAttributes().get(attributeName); } if (null == value) { if (!attributeName.equals(attributeName.toLowerCase()))...
java
public static String getAttributeAsString(UIComponent component, String attributeName) { try { Object attribute = getAttribute(component, attributeName); if (null != attribute) { if (attribute instanceof ValueExpression) { return (String) ((ValueExpression) attribute) .getValue(FacesContext.getC...
java
protected File generateTemplate(File template, Instance instance) throws IOException { String scriptName = instance.getName().replace( "\\s+", "_" ); File generated = File.createTempFile( scriptName, ".script"); InstanceTemplateHelper.injectInstanceImports(instance, template, generated); return generated; }
java
public static StringBuilder formatErrors( Collection<? extends RoboconfError> errors, Log log ) { StringBuilder result = new StringBuilder(); for( Map.Entry<RoboconfError,String> entry : RoboconfErrorHelpers.formatErrors( errors, null, true ).entrySet()) { if( entry.getKey().getErrorCode().getLevel() == ErrorLe...
java
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { long timer = System.nanoTime(); long random = (long) (Math.random() * Integer.MAX_VALUE); long token = timer ^ random; NGSecureUtilities.setSecurityToken(String.valueOf(token), compone...
java
public static DockerClient createDockerClient( Map<String,String> targetProperties ) throws TargetException { // Validate what needs to be validated. Logger logger = Logger.getLogger( DockerHandler.class.getName()); logger.fine( "Setting the target properties." ); String edpt = targetProperties.get( DockerHan...
java
public static void deleteImageIfItExists( String imageId, DockerClient dockerClient ) { if( imageId != null ) { List<Image> images = dockerClient.listImagesCmd().exec(); if( findImageById( imageId, images ) != null ) dockerClient.removeImageCmd( imageId ).withForce( true ).exec(); } }
java
public static Image findImageByIdOrByTag( String name, DockerClient dockerClient ) { Image image = null; if( ! Utils.isEmptyOrWhitespaces( name )) { Logger logger = Logger.getLogger( DockerUtils.class.getName()); List<Image> images = dockerClient.listImagesCmd().exec(); if(( image = DockerUtils.findImage...
java
public static Image findImageById( String imageId, List<Image> images ) { Image result = null; for( Image img : images ) { if( img.getId().equals(imageId)) { result = img; break; } } return result; }
java
public static Image findImageByTag( String imageTag, List<Image> images ) { Image result = null; for( Image img : images ) { String[] tags = img.getRepoTags(); if( tags == null ) continue; for( String s : tags ) { if( s.contains( imageTag )) { result = img; break; } } } retu...
java
public static Container findContainerByIdOrByName( String name, DockerClient dockerClient ) { Container result = null; List<Container> containers = dockerClient.listContainersCmd().withShowAll( true ).exec(); for( Container container : containers ) { List<String> names = Arrays.asList( container.getNames()); ...
java
public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) { ContainerState result = null; try { InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec(); if( resp != null ) result = resp.getState(); } catch( Exception e ) { // noth...
java
public static void configureOptions( Map<String,String> options, CreateContainerCmd cmd ) throws TargetException { Logger logger = Logger.getLogger( DockerUtils.class.getName()); // Basically, we had two choices: // 1. Map our properties to the Java REST API. // 2. By-pass it and send our custom JSon object....
java
public static Object prepareParameter( String rawValue, Class<?> clazz ) throws TargetException { // Simple types Object result; if( clazz == int.class || clazz == Integer.class ) result = Integer.parseInt( rawValue ); else if( clazz == long.class || clazz == Long.class ) result = Long.parseLong( rawValu...
java
public static String findDefaultImageVersion( String rawVersion ) { String rbcfVersion = rawVersion; if( rbcfVersion == null || rbcfVersion.toLowerCase().endsWith( "snapshot" )) rbcfVersion = LATEST; return rbcfVersion; }
java
public static String buildContainerNameFrom( String scopedInstancePath, String applicationName ) { String containerName = scopedInstancePath + "_from_" + applicationName; containerName = containerName.replaceFirst( "^/", "" ).replace( "/", "-" ).replaceAll( "\\s+", "_" ); // Prevent container names from being t...
java
public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an ...
java
Properties readProperties( Instance instance ) throws PluginException { Properties result = null; File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File file = new File( instanceDirectory, FILE_NAME ); try { if( file.exists()) { result = Utils.readPropertiesFile( file )...
java
SortedSet<Action> findActions( String actionName, Properties properties ) { Pattern pattern = Pattern.compile( actionName + "\\.(\\d)+\\.(.*)", Pattern.CASE_INSENSITIVE ); SortedSet<Action> result = new TreeSet<Action>( new ActionComparator()); for( Map.Entry<Object,Object> entry : properties.entrySet()) { St...
java
void executeAction( Action action ) throws PluginException { try { switch( action.actionType ) { case DELETE: this.logger.fine( "Deleting " + action.parameter + "..." ); File f = new File( action.parameter ); Utils.deleteFilesRecursively( f ); break; case DOWNLOAD: this.logger.fine( "Do...
java
private void send( String message ) { if( ! this.enabled.get()) { this.logger.finest( "Notifications were disabled by the DM." ); } else if( message == null ) { this.logger.finest( "No message to send to web socket clients." ); } else synchronized( SESSIONS ) { for( Session session : SESSIONS ) { ...
java
public String login( String username, String password ) throws DebugWsException { this.logger.finer( "Logging in as " + username ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "e" ); ClientResponse response = path .header( "u", username ) .header( "p", password ) ...
java
public void logout( String sessionId ) throws DebugWsException { this.logger.finer( "Logging out... Session ID = " + sessionId ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "s" ); ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class ); this.log...
java
private void cancelRecipe(String applicationName, String scopedInstancePath) { if(Utils.isEmptyOrWhitespaces(applicationName)) applicationName = ""; if(Utils.isEmptyOrWhitespaces(scopedInstancePath)) scopedInstancePath = ""; this.out.println("looking up [" + applicationName + "] [" + scopedInstancePath + "]"); ...
java
private String httpsQuery() { String response = null; try { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new LocalX509TrustManager()}; // Install the all-trusting trust manager final SSLContext sc = SSLContext.getInstance("SSL"...
java
private String httpQuery() { String response = null; try { URL restUrl = new URL( this.url ); HttpURLConnection conn = (HttpURLConnection) restUrl.openConnection(); response = query( conn ); } catch( Exception e ) { this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notificati...
java
public static Set<String> findGraphFilesToImport( File appDirectory, File editedFile, String fileContent ) { File graphDir = new File( appDirectory, Constants.PROJECT_DIR_GRAPH ); return findFilesToImport( graphDir, Constants.FILE_EXT_GRAPH, editedFile, fileContent ); }
java
public static Set<String> findInstancesFilesToImport( File appDirectory, File editedFile, String fileContent ) { File instancesDir = new File( appDirectory, Constants.PROJECT_DIR_INSTANCES ); return findFilesToImport( instancesDir, Constants.FILE_EXT_INSTANCES, editedFile, fileContent ); }
java
static Set<String> findFilesToImport( File searchDirectory, String fileExtension, File editedFile, String fileContent ) { // Find all the files Set<String> result = new TreeSet<> (); if( searchDirectory.exists()) { for( File f : Utils.listAllFiles( searchDirectory, fileExtension )) { if( f.eq...
java
public static RoboconfCompletionProposal basicProposal( String s, String lastWord, boolean trim ) { return new RoboconfCompletionProposal( s, trim ? s.trim() : s, null, lastWord.length()); }
java
public static Map<String,RoboconfTypeBean> findAllTypes( File appDirectory ) { List<File> graphFiles = new ArrayList<> (); File graphDirectory = appDirectory; if( graphDirectory != null && graphDirectory.exists()) graphFiles = Utils.listAllFiles( graphDirectory, Constants.FILE_EXT_GRAPH ); Map<String,R...
java
public static String resolveStringDescription( String variableName, String defaultValue ) { String result = null; if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( variableName ) || variableName.toLowerCase().endsWith( "." + Constants.SPECIFIC_VARIABLE_IP )) result = SET_BY_ROBOCONF; else if( ! Utils.i...
java
@Override public Object getValue() { final List<String> tokens = NGSecureUtilities.getSecurityToken(); return tokens.get(tokens.size() - 1); }
java
public String checkMessagingConnectionForTheDm( String message ) throws DebugWsException { this.logger.finer( "Checking messaging connection with the DM: message=" + message ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "check-dm" ); if( message != null ) path = path.queryParam( "mess...
java
public Diagnostic diagnoseInstance( String applicationName, String instancePath ) throws DebugWsException { this.logger.finer( "Diagnosing instance " + instancePath + " in application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-instance" ); path = path.que...
java
public List<Diagnostic> diagnoseApplication( String applicationName ) { this.logger.finer( "Diagnosing application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-application" ); path = path.queryParam( "application-name", applicationName ); List<Diagnostic> ...
java
public void addTargetHandler( TargetHandler targetItf ) { if( targetItf != null ) { this.logger.info( "Target handler '" + targetItf.getTargetId() + "' is now available in Roboconf's DM." ); synchronized( this.targetHandlers ) { this.targetHandlers.add( targetItf ); } listTargets( this.targetHandle...
java
public void removeTargetHandler( TargetHandler targetItf ) { // May happen if a target could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( targetItf == null ) { this.logger.info( "An invalid target handler is removed." ); } else { synchronized( this.targetHandl...
java
public static void listTargets( List<TargetHandler> targetHandlers, Logger logger ) { if( targetHandlers.isEmpty()) { logger.info( "No target was found for Roboconf's DM." ); } else { StringBuilder sb = new StringBuilder( "Available target in Roboconf's DM: " ); for( Iterator<TargetHandler> it = targetHa...
java
public static String capitalize( String s ) { String result = s; if( ! Utils.isEmptyOrWhitespaces( s )) result = Character.toUpperCase( s.charAt( 0 )) + s.substring( 1 ).toLowerCase(); return result; }
java
public static String removeFileExtension( String filename ) { String result = filename; int index = filename.lastIndexOf( '.' ); if( index != -1 ) result= filename.substring( 0, index ); return result; }
java
public static List<String> filterEmptyValues( List<String> values ) { List<String> result = new ArrayList<> (); for( String s : values ) { if( ! Utils.isEmptyOrWhitespaces( s )) result.add( s ); } return result; }
java
public static String format( Collection<String> items, String separator ) { StringBuilder sb = new StringBuilder(); for( Iterator<String> it = items.iterator(); it.hasNext(); ) { sb.append( it.next()); if( it.hasNext()) sb.append( separator ); } return sb.toString(); }
java
public static void copyStream( File inputFile, File outputFile ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStream( is, outputFile ); } finally { is.close(); } }
java
public static void copyStream( File inputFile, OutputStream os ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStreamUnsafelyUseWithCaution( is, os ); } finally { is.close(); } }
java
public static void appendStringInto( String s, File outputFile ) throws IOException { OutputStreamWriter fw = null; try { fw = new OutputStreamWriter( new FileOutputStream( outputFile, true ), StandardCharsets.UTF_8 ); fw.append( s ); } finally { Utils.closeQuietly( fw ); } }
java
public static Properties readPropertiesFile( File file ) throws IOException { Properties result = new Properties(); InputStream in = null; try { in = new FileInputStream( file ); result.load( in ); } finally { closeQuietly( in ); } return result; }
java
public static Properties readPropertiesFileQuietly( File file, Logger logger ) { Properties result = new Properties(); try { if( file != null && file.exists()) result = readPropertiesFile( file ); } catch( Exception e ) { logger.severe( "Properties file " + file + " could not be read." ); logExcept...
java
public static Properties readPropertiesQuietly( String fileContent, Logger logger ) { Properties result = new Properties(); try { if( fileContent != null ) { InputStream in = new ByteArrayInputStream( fileContent.getBytes( StandardCharsets.UTF_8 )); result.load( in ); } } catch( Exception e ) { ...
java
public static void writePropertiesFile( Properties properties, File file ) throws IOException { OutputStream out = null; try { out = new FileOutputStream( file ); properties.store( out, "" ); } finally { closeQuietly( out ); } }
java
public static String cleanNameWithAccents( String name ) { String temp = Normalizer.normalize( name, Normalizer.Form.NFD ); Pattern pattern = Pattern.compile( "\\p{InCombiningDiacriticalMarks}+" ); return pattern.matcher( temp ).replaceAll( "" ).trim(); }
java
public static String updateProperties( String propertiesContent, Map<String,String> keyToNewValue ) { for( Map.Entry<String,String> entry : keyToNewValue.entrySet()) { propertiesContent = propertiesContent.replaceFirst( "(?mi)^\\s*" + entry.getKey() + "\\s*[:=][^\n]*$", entry.getKey() + " = " + entry.ge...
java
public static List<File> listDirectories( File root ) { List<File> result = new ArrayList<> (); File[] files = root.listFiles( new DirectoryFileFilter()); if( files != null ) result.addAll( Arrays.asList( files )); Collections.sort( result, new FileNameComparator()); return result; }
java
public static String computeFileRelativeLocation( File rootDirectory, File subFile ) { String rootPath = rootDirectory.getAbsolutePath(); String subPath = subFile.getAbsolutePath(); if( ! subPath.startsWith( rootPath )) throw new IllegalArgumentException( "The sub-file must be contained in the directory." );...
java
public static void extractZipArchive( File zipFile, File targetDirectory ) throws IOException { extractZipArchive( zipFile, targetDirectory, null, null ); }
java
public static boolean isAncestor( File ancestorCandidate, File file ) { String path = ancestorCandidate.getAbsolutePath(); if( ! path.endsWith( "/" )) path += "/"; return file.getAbsolutePath().startsWith( path ); }
java
public static void deleteFilesRecursively( File... files ) throws IOException { if( files == null ) return; List<File> filesToDelete = new ArrayList<> (); filesToDelete.addAll( Arrays.asList( files )); while( ! filesToDelete.isEmpty()) { File currentFile = filesToDelete.remove( 0 ); if( currentFile =...
java
public static void deleteFilesRecursivelyAndQuietly( File... files ) { try { deleteFilesRecursively( files ); } catch( IOException e ) { Logger logger = Logger.getLogger( Utils.class.getName()); logException( logger, e ); } }
java
public static void logException( Logger logger, Throwable t ) { logException( logger, Level.FINEST, t ); }
java
public static void closeStatement( PreparedStatement ps, Logger logger ) { try { if( ps != null ) ps.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeStatement( Statement st, Logger logger ) { try { if( st != null ) st.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeResultSet( ResultSet resultSet, Logger logger ) { try { if( resultSet != null ) resultSet.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeConnection( Connection conn, Logger logger ) { try { if( conn != null ) conn.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static Map.Entry<String,Integer> findUrlAndPort( String url ) { Matcher m = Pattern.compile( ".*(:\\d+).*" ).matcher( url ); String portAsString = m.find() ? m.group( 1 ).substring( 1 ) : null; Integer port = portAsString == null ? - 1 : Integer.parseInt( portAsString ); String address = portAsString ==...
java
public static String getValue(Map<String,String> map, String key, String defaultValue) { return map.containsKey( key ) ? map.get( key ) : defaultValue; }
java
public static String findApplicationName( final File templateDir, final File templateFile ) { final File parentDir = templateFile.getParentFile(); final String appName; // No intermediate directory, the template is global! if( templateDir.equals( parentDir )) appName = null; // One intermediate director...
java
public static void deleteGeneratedFiles( Application app, File outputDirectory ) { File target = new File( outputDirectory, app.getName()); Utils.deleteFilesRecursivelyAndQuietly( target ); }
java
public static Collection<TemplateEntry> findTemplatesForApplication( String appName, Collection<TemplateEntry> templates ) { final Collection<TemplateEntry> result = new ArrayList<> (); for( TemplateEntry te : templates ) { // TE.appName == null => OK. It applies to this application. // TE.appName == appName...
java
void installPuppetModules( Instance instance ) throws IOException, InterruptedException { // Load the modules names File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File modulesFile = new File( instanceDirectory, "modules.properties" ); if( ! modulesFile.exists()) return; ...
java
String generateCodeToExecute( String className, Instance instance, PuppetState puppetState, Import importChanged, boolean importAdded ) { // When executed by hand, the "apply" command would expect // this string to be returned to be between double quotes. // Example: "class{ 'roboconf_redis': ... ...
java
public static void verifyTargets( ITargetHandlerResolver targetHandlerResolver, ManagedApplication ma, ITargetsMngr targetsMngr ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); for( Instance inst : InstanceHelpers.getAllInstances( ma.getApplication())) { if( ! InstanceHelpers.isTar...
java
public FileDefinition buildFileDefinition( Graphs graphs, File targetFile, boolean addComment ) { // Build the global structure FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.GRAPH ); if( addComment ) { String s = "# File created from an in-memory model,\n# with...
java
public static Map<String,byte[]> storeInstanceResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Recipes Map<String,byte[]> result = new HashMap<> (); File instanceResourcesDirectory = findInstanceResourcesDirectory( applicationFilesDirectory, instance ); if( instanceResourc...
java
public static Map<String,byte[]> storeInstanceProbeResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Measure files (are not located with recipes, so no trouble with component inheritance). // There can also be a properties file to inject values. String[] exts = { Constant...
java
public static File findInstanceResourcesDirectory( File applicationFilesDirectory, Instance instance ) { return findInstanceResourcesDirectory( applicationFilesDirectory, instance.getComponent()); }
java
public static Map<Component,File> findScopedInstancesDirectories( AbstractApplication absApp ) { Map<Component,File> result = new HashMap<> (); for( Component c : ComponentHelpers.findAllComponents( absApp.getGraphs())) { // Target? if( ! ComponentHelpers.isTarget( c )) continue; // Is there a resou...
java
protected void subscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub == null ) { sub = new HashSet<> (); this.routingContext.subscriptions.put( id, sub ); } sub.add( ctx ); }
java
protected void unsubscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub != null ) { sub.remove( ctx ); if( sub.isEmpty()) this.routingContext.subscriptions.remove( id ); } }
java