Search in sources :

Example 96 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class ZooKeeperUtils method setProperties.

public static void setProperties(CuratorFramework curator, String path, Properties properties) throws Exception {
    try {
        org.apache.felix.utils.properties.Properties p = new org.apache.felix.utils.properties.Properties();
        if (curator.checkExists().forPath(path) == null) {
            create(curator, path);
        }
        String org = getStringData(curator, path);
        if (org != null) {
            p.load(new StringReader(org));
        }
        List<String> keys = new ArrayList<String>();
        for (String key : properties.stringPropertyNames()) {
            p.put(key, properties.getProperty(key));
            keys.add(key);
        }
        List<String> deleted = new ArrayList<String>(p.keySet());
        deleted.removeAll(keys);
        for (String key : deleted) {
            p.remove(key);
        }
        StringWriter writer = new StringWriter();
        p.save(writer);
        setData(curator, path, writer.toString());
    } catch (IOException e) {
    // ignore
    }
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(java.util.Properties) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader)

Example 97 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class ZooKeeperUtils method getPropertiesAsMap.

public static Map<String, String> getPropertiesAsMap(TreeCacheExtended cache, String path) throws Exception {
    Properties properties = getProperties(cache, path);
    Map<String, String> map = new HashMap<String, String>();
    for (String key : properties.stringPropertyNames()) {
        map.put(key, properties.getProperty(key));
    }
    return map;
}
Also used : HashMap(java.util.HashMap) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(java.util.Properties)

Example 98 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class ZooKeeperUtils method getPropertiesAsMap.

public static Map<String, String> getPropertiesAsMap(CuratorFramework curator, String path) throws Exception {
    Properties properties = getProperties(curator, path);
    Map<String, String> map = new HashMap<String, String>();
    for (String key : properties.stringPropertyNames()) {
        map.put(key, properties.getProperty(key));
    }
    return map;
}
Also used : HashMap(java.util.HashMap) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(java.util.Properties)

Example 99 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class FileWatcherDynamicCompiler method addCompilePath.

// Implementation
// -------------------------------------------------------------------------
protected void addCompilePath(Path path) {
    try {
        String url = toUrlString(path);
        Path old = urlMap.put(url, path);
        if (old == null) {
            scheduleRecompile();
        }
    } catch (MalformedURLException e) {
        LOG.warn("Ignored path " + path + " due to: " + e, e);
    }
}
Also used : Path(java.nio.file.Path) MalformedURLException(java.net.MalformedURLException) PathHelper.toUrlString(io.fabric8.watcher.PathHelper.toUrlString)

Example 100 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class WatcherSpringContext method removePath.

protected void removePath(Path path) {
    try {
        String url = toUrlString(path);
        FileSystemXmlApplicationContext context = contextMap.remove(url);
        closeContext(url, context);
    } catch (MalformedURLException e) {
        LOG.warn("Ignored path " + path + " due to: " + e, e);
    }
}
Also used : FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) MalformedURLException(java.net.MalformedURLException) PathHelper.toUrlString(io.fabric8.watcher.PathHelper.toUrlString)

Aggregations

Test (org.junit.Test)45 File (java.io.File)41 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)18 PathTestUtil.createTmpFile (io.fabric8.maven.docker.util.PathTestUtil.createTmpFile)17 HashMap (java.util.HashMap)12 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)11 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)11 Path (java.nio.file.Path)11 FabricService (io.fabric8.api.FabricService)10 RuntimeProperties (io.fabric8.api.RuntimeProperties)9 Properties (java.util.Properties)9 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)8 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)8 InputStream (java.io.InputStream)8 Path (javax.ws.rs.Path)8 HttpProxyRule (io.fabric8.gateway.model.HttpProxyRule)7 NodeState (io.fabric8.groups.NodeState)7 URISyntaxException (java.net.URISyntaxException)7 List (java.util.List)6