Example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

List of usage examples for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList.

Prototype

public CopyOnWriteArrayList() 

Source Link

Document

Creates an empty list.

Usage

From source file:org.goko.core.execution.monitor.service.ExecutionServiceImpl.java

/**
 * Constructor//from  w w  w  .  j  ava2 s.  co  m
 */
public ExecutionServiceImpl() {
    listenerList = new CopyOnWriteArrayList<IGCodeExecutionListener<ExecutionTokenState, ExecutionToken<ExecutionTokenState>>>();
    executionQueue = new ExecutionQueue<ExecutionTokenState, ExecutionToken<ExecutionTokenState>>();
    executionQueuelistenerList = new CopyOnWriteArrayList<IExecutionQueueListener<ExecutionTokenState, ExecutionToken<ExecutionTokenState>>>();
}

From source file:org.codehaus.wadi.servicespace.basic.BasicServiceSpace.java

public BasicServiceSpace(ServiceSpaceName name, Dispatcher underlyingDispatcher,
        ClassIndexerRegistry serviceClassIndexerRegistry, Streamer streamer) {
    if (null == name) {
        throw new IllegalArgumentException("name is required");
    } else if (null == underlyingDispatcher) {
        throw new IllegalArgumentException("underlyingDispatcher is required");
    } else if (null == serviceClassIndexerRegistry) {
        throw new IllegalArgumentException("serviceClassIndexerRegistry is required");
    } else if (null == streamer) {
        throw new IllegalArgumentException("streamer is required");
    }/*from   ww  w  .j a  v  a 2s.  c  om*/
    this.serviceClassIndexerRegistry = serviceClassIndexerRegistry;
    this.name = name;
    this.underlyingDispatcher = underlyingDispatcher;

    envelopeHelper = newServiceSpaceEnvelopeHelper(streamer);

    dispatcher = newDispatcher();

    EnvelopeInterceptor transformEnvelopeInterceptor = new TransformEnvelopeInterceptor(envelopeHelper);
    dispatcher.addInterceptor(transformEnvelopeInterceptor);

    monitors = new ArrayList<ServiceMonitor>();
    hostingPeers = new HashSet<Peer>();
    listeners = new CopyOnWriteArrayList<ServiceSpaceListener>();

    localPeer = dispatcher.getCluster().getLocalPeer();

    serviceRegistry = newServiceRegistry();

    underlyingClusterListener = new UnderlyingClusterListener();

    dispatcher.register(new ServiceInvocationListener(this, serviceClassIndexerRegistry));
    dispatcher.register(new ServiceResponseListener(this));
    serviceSpaceEndpoint = new ServiceSpaceEndpoint(this, dispatcher, envelopeHelper);

    lifecycleEndpoint = new ServiceSpaceLifecycleEndpoint();
    serviceSpaceRVEndPoint = new RendezVousEndPoint(this, envelopeHelper);
}

From source file:org.apache.servicemix.jbi.itests.IntegrationTest.java

@Test
public void testServiceAssembly() throws Throwable {
    System.out.println("Waiting for NMR");
    NMR nmr = getOsgiService(NMR.class);
    assertNotNull(nmr);//from www . j av  a  2 s  .co m

    Bundle smxShared = installJbiBundle("org.apache.servicemix", "servicemix-shared", "installer", "zip");
    Bundle smxJsr181 = installJbiBundle("org.apache.servicemix", "servicemix-jsr181", "installer", "zip");
    Bundle smxHttp = installJbiBundle("org.apache.servicemix", "servicemix-http", "installer", "zip");
    Bundle saBundle = installJbiBundle("org.apache.servicemix.samples.wsdl-first", "wsdl-first-sa", null,
            "zip");

    smxShared.start();
    smxJsr181.start();
    smxHttp.start();
    saBundle.start();

    System.out.println("Waiting for JBI Service Assembly");
    ServiceAssembly sa = getOsgiService(ServiceAssembly.class);
    assertNotNull(sa);

    Thread.sleep(500);

    final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
    final int nbThreads = 2;
    final int nbMessagesPerThread = 10;
    final CountDownLatch latch = new CountDownLatch(nbThreads * nbMessagesPerThread);
    for (int i = 0; i < nbThreads; i++) {
        new Thread() {
            public void run() {
                for (int i = 0; i < nbMessagesPerThread; i++) {
                    try {
                        URL url = new URL("http://localhost:8192/PersonService/");
                        URLConnection connection = url.openConnection();
                        connection.setDoInput(true);
                        connection.setDoOutput(true);
                        connection.getOutputStream().write(
                                ("<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
                                        + "              xmlns:tns=\"http://servicemix.apache.org/samples/wsdl-first/types\">\n"
                                        + "  <env:Body>\n" + "    <tns:GetPerson>\n"
                                        + "      <tns:personId>world</tns:personId>\n"
                                        + "    </tns:GetPerson>\n" + "  </env:Body>\n" + "</env:Envelope>")
                                                .getBytes());
                        byte[] buffer = new byte[8192];
                        int len = connection.getInputStream().read(buffer);
                        if (len == -1) {
                            throw new Exception("No response available");
                        }
                        String result = new String(buffer, 0, len);
                        System.out.println(result);
                    } catch (Throwable t) {
                        errors.add(t);
                        t.printStackTrace();
                    } finally {
                        latch.countDown();
                    }
                }
            }
        }.start();
    }

    if (!latch.await(60, TimeUnit.SECONDS)) {
        fail("Test timed out");
    }
    if (!errors.isEmpty()) {
        throw errors.get(0);
    }
    //Thread.sleep(500);
    saBundle.uninstall();
    //sa.stop();
    //sa.shutDown();
}

From source file:org.dash.valid.gl.GLStringUtilities.java

public static List<Haplotype> buildHaplotypes(LinkageDisequilibriumGenotypeList linkedGlString) {
    String glString = linkedGlString.getGLString();
    List<Haplotype> knownHaplotypes = new CopyOnWriteArrayList<Haplotype>();
    HashMap<String, Locus> locusMap = new HashMap<String, Locus>();
    Locus locus = null;/*from ww w . ja  va2s  .  co  m*/

    if (StringUtils.countMatches(glString, GLStringConstants.GENE_PHASE_DELIMITER) > 1
            && StringUtils.countMatches(glString, GLStringConstants.GENE_COPY_DELIMITER) == 1) {
        List<String> genes = GLStringUtilities.parse(glString, GLStringConstants.GENE_DELIMITER);
        for (String gene : genes) {
            List<String> genotypeAmbiguities = GLStringUtilities.parse(gene,
                    GLStringConstants.GENOTYPE_AMBIGUITY_DELIMITER);
            for (String genotypeAmbiguity : genotypeAmbiguities) {
                List<String> geneCopies = GLStringUtilities.parse(genotypeAmbiguity,
                        GLStringConstants.GENE_COPY_DELIMITER);

                int i = 0;

                for (String geneCopy : geneCopies) {
                    HashMap<Locus, SingleLocusHaplotype> singleLocusHaplotypes = new HashMap<Locus, SingleLocusHaplotype>();

                    List<String> genePhases = GLStringUtilities.parse(geneCopy,
                            GLStringConstants.GENE_PHASE_DELIMITER);
                    for (String genePhase : genePhases) {
                        String[] splitString = genePhase.split(GLStringUtilities.ESCAPED_ASTERISK);
                        String locusVal = splitString[0];

                        List<String> alleleAmbiguities = GLStringUtilities.parse(genePhase,
                                GLStringConstants.ALLELE_AMBIGUITY_DELIMITER);

                        if (locusMap.containsKey(locusVal)) {
                            locus = locusMap.get(locusVal);
                        } else {
                            locus = Locus.normalizeLocus(Locus.lookup(locusVal));
                            locusMap.put(locusVal, locus);
                        }

                        SingleLocusHaplotype haplotype = new SingleLocusHaplotype(locus, alleleAmbiguities, i);
                        singleLocusHaplotypes.put(locus, haplotype);

                    }

                    MultiLocusHaplotype multiLocusHaplotype = new MultiLocusHaplotype(singleLocusHaplotypes,
                            linkedGlString.hasHomozygous(Locus.HLA_DRB345));
                    multiLocusHaplotype.setSequence(i + 1);
                    knownHaplotypes.add(multiLocusHaplotype);

                    i++;
                }
            }
        }
    }

    return knownHaplotypes;
}

From source file:com.chiorichan.site.Site.java

protected Site(File f) throws SiteException, StartupException {
    siteType = SiteType.FILE;//from   w w  w  . java  2 s . c  o m
    filePath = f;

    config = YamlConfiguration.loadConfiguration(f);

    if (config == null)
        throw new SiteException("Could not load site from YAML FileBase '" + f.getAbsolutePath() + "'");

    siteId = config.getString("site.siteId", null);
    title = config.getString("site.title",
            Loader.getConfig().getString("framework.sites.defaultTitle", "Unnamed Site"));
    domain = config.getString("site.domain", null);

    String reason = null;

    if (siteId == null)
        reason = "the provided Site Id is NULL. Check configs";
    else
        siteId = siteId.toLowerCase();

    if (domain == null)
        reason = "the provided domain is NULL. Check configs";
    else
        domain = domain.toLowerCase();

    if (Loader.getSiteManager().getSiteById(siteId) != null)
        reason = "there already exists a site by the provided Site Id '" + siteId + "'";

    if (reason != null)
        throw new SiteException(
                "Could not load site from YAML FileBase '" + f.getAbsolutePath() + "' because " + reason + ".");

    Loader.getLogger().info("Loading site '" + siteId + "' with title '" + title + "' from YAML FileBase '"
            + f.getAbsolutePath() + "'.");

    // Load protected files list
    List<?> protectedFilesPre = config.getList("protected", new CopyOnWriteArrayList<String>());

    for (Object o : protectedFilesPre) {
        if (o instanceof String)
            protectedFiles.add((String) o);
        else
            Loader.getLogger().warning("Site '" + siteId
                    + "' had an incorrect data object type under the YAML config for option 'protected', found type '"
                    + o.getClass() + "'.");
    }

    // Load sources location
    String sources = config.getString("site.source", "pages");

    if (sources == null || sources.isEmpty()) {
        source = getAbsoluteRoot();
    } else if (sources.startsWith(".")) {
        source = new File(getAbsoluteRoot() + sources);
    } else {
        source = new File(getAbsoluteRoot(), sources);
        protectedFiles.add("/" + sources);
    }

    FileUtil.directoryHealthCheck(source);

    // Load resources location
    String resources = config.getString("site.resource", "resource");

    if (resources == null || resources.isEmpty()) {
        resource = getAbsoluteRoot();
    } else if (resources.startsWith(".")) {
        resource = new File(getAbsoluteRoot() + resources);
    } else {
        resource = new File(getAbsoluteRoot(), resources);
        protectedFiles.add("/" + resources);
    }

    FileUtil.directoryHealthCheck(resource);

    // Load metatags
    List<?> metatagsPre = config.getList("metatags", new CopyOnWriteArrayList<String>());

    for (Object o : metatagsPre) {
        if (o instanceof String)
            metatags.add((String) o);
        else
            Loader.getLogger().warning("Site '" + siteId
                    + "' had an incorrect data object type under the YAML config for option 'metatags', found type '"
                    + o.getClass() + "'.");
    }

    // Load aliases map
    ConfigurationSection aliasesPre = config.getConfigurationSection("aliases");
    if (aliasesPre != null) {
        Set<String> akeys = aliasesPre.getKeys(false);

        if (akeys != null)
            for (String k : akeys) {
                if (aliasesPre.getString(k, null) != null)
                    aliases.put(k, aliasesPre.getString(k));
            }
    }

    // Loader subdomains map
    ConfigurationSection subdomainsPre = config.getConfigurationSection("subdomains");
    if (subdomainsPre != null) {
        Set<String> skeys = subdomainsPre.getKeys(false);

        if (skeys != null)
            for (String k : skeys) {
                if (subdomainsPre.getString(k, null) != null)
                    subdomains.put(k, subdomainsPre.getString(k));
            }
    }

    finishLoad();
}

From source file:com.web.server.JarDeployer.java

/**
 * This method implements the jar deployer which configures the executor services. 
 * Frequently monitors the deploy directory and configures the executor services map 
 * once the jar is deployed in deploy directory and reconfigures if the jar is modified and 
 * placed in the deploy directory./*from   w  w  w  .  j a  va2s.  c  o  m*/
 */
public void run() {

    StandardFileSystemManager fsManager = new StandardFileSystemManager();
    try {
        fsManager.init();
        DefaultFileReplicator replicator = new DefaultFileReplicator(new File(cacheDir));
        //fsManager.setReplicator(new PrivilegedFileReplicator(replicator));
        fsManager.setTemporaryFileStore(replicator);
    } catch (FileSystemException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    File file = new File(scanDirectory.split(";")[0]);
    File[] files = file.listFiles();
    CopyOnWriteArrayList<String> classList = new CopyOnWriteArrayList<String>();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory())
            continue;
        //Long lastModified=(Long) fileMap.get(files[i].getName());
        if (files[i].getName().endsWith(".jar")) {
            String filePath = files[i].getAbsolutePath();
            FileObject jarFile = null;
            try {
                jarFile = fsManager.resolveFile("jar:" + filePath);
            } catch (FileSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            //logger.info("filePath"+filePath);
            filePath = filePath.substring(0, filePath.toLowerCase().lastIndexOf(".jar"));
            WebClassLoader customClassLoader = null;
            try {
                URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader();
                URL[] urls = loader.getURLs();
                try {
                    customClassLoader = new WebClassLoader(urls);
                    System.out.println(customClassLoader.geturlS());
                    new WebServer().addURL(new URL("file:/" + files[i].getAbsolutePath()), customClassLoader);
                    CopyOnWriteArrayList<String> jarList = new CopyOnWriteArrayList();
                    getUsersJars(new File(libDir), jarList);
                    for (String jarFilePath : jarList)
                        new WebServer().addURL(new URL("file:/" + jarFilePath.replace("\\", "/")),
                                customClassLoader);
                    System.out.println("deploy=" + customClassLoader.geturlS());
                    this.urlClassLoaderMap.put(scanDirectory + "/" + files[i].getName(), customClassLoader);
                    jarsDeployed.add(files[i].getName());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println(urlClassLoaderMap);
                getChildren(jarFile, classList);
            } catch (FileSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            for (int classCount = 0; classCount < classList.size(); classCount++) {
                String classwithpackage = classList.get(classCount).substring(0,
                        classList.get(classCount).indexOf(".class"));
                classwithpackage = classwithpackage.replace("/", ".");
                System.out.println("classList:" + classwithpackage.replace("/", "."));
                try {
                    if (!classwithpackage.contains("$")) {
                        Class executorServiceClass = customClassLoader.loadClass(classwithpackage);
                        //System.out.println("executor class in ExecutorServicesConstruct"+executorServiceClass);
                        //System.out.println();
                        if (!executorServiceClass.isInterface()) {
                            Annotation[] classServicesAnnot = executorServiceClass.getDeclaredAnnotations();
                            if (classServicesAnnot != null) {
                                for (int annotcount = 0; annotcount < classServicesAnnot.length; annotcount++) {
                                    if (classServicesAnnot[annotcount] instanceof RemoteCall) {
                                        RemoteCall remoteCall = (RemoteCall) classServicesAnnot[annotcount];
                                        //registry.unbind(remoteCall.servicename());
                                        System.out.println(remoteCall.servicename().trim());
                                        try {
                                            //for(int count=0;count<500;count++){
                                            RemoteInterface reminterface = (RemoteInterface) UnicastRemoteObject
                                                    .exportObject((Remote) executorServiceClass.newInstance(),
                                                            2004);
                                            registry.rebind(remoteCall.servicename().trim(), reminterface);
                                            //}
                                        } catch (Exception ex) {
                                            ex.printStackTrace();
                                        }
                                    }
                                }
                            }
                        }

                        Method[] methods = executorServiceClass.getDeclaredMethods();
                        for (Method method : methods) {
                            Annotation[] annotations = method.getDeclaredAnnotations();
                            for (Annotation annotation : annotations) {
                                if (annotation instanceof ExecutorServiceAnnot) {
                                    ExecutorServiceAnnot executorServiceAnnot = (ExecutorServiceAnnot) annotation;
                                    ExecutorServiceInfo executorServiceInfo = new ExecutorServiceInfo();
                                    executorServiceInfo.setExecutorServicesClass(executorServiceClass);
                                    executorServiceInfo.setMethod(method);
                                    executorServiceInfo.setMethodParams(method.getParameterTypes());
                                    //System.out.println("method="+executorServiceAnnot.servicename());
                                    //System.out.println("method info="+executorServiceInfo);
                                    //if(servicesMap.get(executorServiceAnnot.servicename())==null)throw new Exception();
                                    executorServiceMap.put(executorServiceAnnot.servicename(),
                                            executorServiceInfo);
                                }
                            }
                        }

                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            ClassLoaderUtil.closeClassLoader(customClassLoader);
            try {
                jarFile.close();
            } catch (FileSystemException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            fsManager.closeFileSystem(jarFile.getFileSystem());
        }
    }
    fsManager.close();
    fsManager = new StandardFileSystemManager();
    try {
        DefaultFileReplicator replicator = new DefaultFileReplicator(new File(cacheDir));
        //fsManager.setReplicator(new PrivilegedFileReplicator(replicator));
        fsManager.setTemporaryFileStore(replicator);
    } catch (FileSystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    JarFileListener jarFileListener = new JarFileListener(executorServiceMap, libDir, urlClassLoaderMap,
            jarsDeployed);
    DefaultFileMonitor fm = new DefaultFileMonitor(jarFileListener);
    jarFileListener.setFm(fm);
    FileObject listendir = null;
    String[] dirsToScan = scanDirectory.split(";");
    try {
        FileSystemOptions opts = new FileSystemOptions();
        FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
        fsManager.init();
        for (String dir : dirsToScan) {
            if (dir.startsWith("ftp://")) {
                listendir = fsManager.resolveFile(dir, opts);
            } else {
                listendir = fsManager.resolveFile(dir);
            }
            fm.addFile(listendir);
        }
    } catch (FileSystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    fm.setRecursive(true);
    fm.setDelay(3000);
    fm.start();
    //fsManager.close();
}

From source file:com.app.server.JarDeployer.java

/**
 * This method implements the jar deployer which configures the executor services. 
 * Frequently monitors the deploy directory and configures the executor services map 
 * once the jar is deployed in deploy directory and reconfigures if the jar is modified and 
 * placed in the deploy directory./*ww  w . ja  v  a  2  s. c o m*/
 */
public void run() {

    StandardFileSystemManager fsManager = new StandardFileSystemManager();
    try {
        fsManager.init();
        DefaultFileReplicator replicator = new DefaultFileReplicator(new File(cacheDir));
        //fsManager.setReplicator(new PrivilegedFileReplicator(replicator));
        fsManager.setTemporaryFileStore(replicator);
    } catch (FileSystemException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    File file = new File(scanDirectory.split(";")[0]);
    File[] files = file.listFiles();
    CopyOnWriteArrayList<String> classList = new CopyOnWriteArrayList<String>();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory())
            continue;
        //Long lastModified=(Long) fileMap.get(files[i].getName());
        if (files[i].getName().endsWith(".jar")) {
            String filePath = files[i].getAbsolutePath();
            FileObject jarFile = null;
            try {
                jarFile = fsManager.resolveFile("jar:" + filePath);
            } catch (FileSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            //logger.info("filePath"+filePath);
            filePath = filePath.substring(0, filePath.toLowerCase().lastIndexOf(".jar"));
            WebClassLoader customClassLoader = null;
            try {
                URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader();
                URL[] urls = loader.getURLs();
                try {
                    customClassLoader = new WebClassLoader(urls);
                    log.info(customClassLoader.geturlS());
                    customClassLoader.addURL(new URL("file:/" + files[i].getAbsolutePath()));
                    CopyOnWriteArrayList<String> jarList = new CopyOnWriteArrayList();
                    getUsersJars(new File(libDir), jarList);
                    for (String jarFilePath : jarList)
                        customClassLoader.addURL(new URL("file:/" + jarFilePath.replace("\\", "/")));
                    log.info("deploy=" + customClassLoader.geturlS());
                    this.urlClassLoaderMap.put(scanDirectory + "/" + files[i].getName(), customClassLoader);
                    jarsDeployed.add(files[i].getName());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                log.info(urlClassLoaderMap);
                getChildren(jarFile, classList);
            } catch (FileSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            for (int classCount = 0; classCount < classList.size(); classCount++) {
                String classwithpackage = classList.get(classCount).substring(0,
                        classList.get(classCount).indexOf(".class"));
                classwithpackage = classwithpackage.replace("/", ".");
                log.info("classList:" + classwithpackage.replace("/", "."));
                try {
                    if (!classwithpackage.contains("$")) {
                        Class executorServiceClass = customClassLoader.loadClass(classwithpackage);
                        //log.info("executor class in ExecutorServicesConstruct"+executorServiceClass);
                        //log.info();
                        if (!executorServiceClass.isInterface()) {
                            Annotation[] classServicesAnnot = executorServiceClass.getDeclaredAnnotations();
                            if (classServicesAnnot != null) {
                                for (int annotcount = 0; annotcount < classServicesAnnot.length; annotcount++) {
                                    if (classServicesAnnot[annotcount] instanceof RemoteCall) {
                                        RemoteCall remoteCall = (RemoteCall) classServicesAnnot[annotcount];
                                        //registry.unbind(remoteCall.servicename());
                                        log.info(remoteCall.servicename().trim());
                                        try {
                                            //for(int count=0;count<500;count++){
                                            RemoteInterface reminterface = (RemoteInterface) UnicastRemoteObject
                                                    .exportObject((Remote) executorServiceClass.newInstance(),
                                                            2004);
                                            registry.rebind(remoteCall.servicename().trim(), reminterface);
                                            //}
                                        } catch (Exception ex) {
                                            ex.printStackTrace();
                                        }
                                    }
                                }
                            }
                        }

                        Method[] methods = executorServiceClass.getDeclaredMethods();
                        for (Method method : methods) {
                            Annotation[] annotations = method.getDeclaredAnnotations();
                            for (Annotation annotation : annotations) {
                                if (annotation instanceof ExecutorServiceAnnot) {
                                    ExecutorServiceAnnot executorServiceAnnot = (ExecutorServiceAnnot) annotation;
                                    ExecutorServiceInfo executorServiceInfo = new ExecutorServiceInfo();
                                    executorServiceInfo.setExecutorServicesClass(executorServiceClass);
                                    executorServiceInfo.setMethod(method);
                                    executorServiceInfo.setMethodParams(method.getParameterTypes());
                                    //log.info("method="+executorServiceAnnot.servicename());
                                    //log.info("method info="+executorServiceInfo);
                                    //if(servicesMap.get(executorServiceAnnot.servicename())==null)throw new Exception();
                                    executorServiceMap.put(executorServiceAnnot.servicename(),
                                            executorServiceInfo);
                                }
                            }
                        }

                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            ClassLoaderUtil.closeClassLoader(customClassLoader);
            try {
                jarFile.close();
            } catch (FileSystemException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            fsManager.closeFileSystem(jarFile.getFileSystem());
        }
    }
    fsManager.close();
    fsManager = new StandardFileSystemManager();
    try {
        DefaultFileReplicator replicator = new DefaultFileReplicator(new File(cacheDir));
        //fsManager.setReplicator(new PrivilegedFileReplicator(replicator));
        fsManager.setTemporaryFileStore(replicator);
    } catch (FileSystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    JarFileListener jarFileListener = new JarFileListener(executorServiceMap, libDir, urlClassLoaderMap,
            jarsDeployed);
    DefaultFileMonitor fm = new DefaultFileMonitor(jarFileListener);
    jarFileListener.setFm(fm);
    FileObject listendir = null;
    String[] dirsToScan = scanDirectory.split(";");
    try {
        FileSystemOptions opts = new FileSystemOptions();
        FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
        fsManager.init();
        for (String dir : dirsToScan) {
            if (dir.startsWith("ftp://")) {
                listendir = fsManager.resolveFile(dir, opts);
            } else {
                listendir = fsManager.resolveFile(dir);
            }
            fm.addFile(listendir);
        }
    } catch (FileSystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    fm.setRecursive(true);
    fm.setDelay(3000);
    fm.start();
    //fsManager.close();
}

From source file:eu.hansolo.tilesfx.tools.Location.java

public Location(final double LATITUDE, final double LONGITUDE, final double ALTITUDE, final Instant TIMESTAMP,
        final String NAME, final String INFO, final TileColor COLOR) {
    name = NAME;// w  w  w.  j  ava  2s .  c  om
    latitude = LATITUDE;
    longitude = LONGITUDE;
    altitude = ALTITUDE;
    timestamp = TIMESTAMP;
    info = INFO;
    color = COLOR;
    zoomLevel = 15;
    listenerList = new CopyOnWriteArrayList<>();
}

From source file:io.pivotal.xd.chaoslemur.Destroyer.java

private void doDestroy(Task task) {
    List<Member> destroyedMembers = new CopyOnWriteArrayList<>();
    UUID identifier = UUID.randomUUID();

    this.logger.info("{} Beginning run...", identifier);

    this.infrastructure.getMembers().stream().map(member -> {
        return this.executorService.submit(() -> {
            if (this.fateEngine.shouldDie(member)) {
                try {
                    this.logger.debug("{} Destroying: {}", identifier, member);

                    if (this.dryRun) {
                        this.logger.info("{} Destroyed (Dry Run): {}", identifier, member);
                    } else {
                        this.infrastructure.destroy(member);
                        this.logger.info("{} Destroyed: {}", identifier, member);
                    }//from   w  w w  .  j av a  2 s  .c  o  m

                    destroyedMembers.add(member);
                } catch (DestructionException e) {
                    this.logger.warn("{} Destroy failed: {} ({})", identifier, member, e.getMessage());
                }
            }
        });
    }).forEach(future -> {
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            this.logger.error(e.getMessage());
        }
    });

    this.reporter.sendEvent(title(identifier), message(destroyedMembers));

    task.stop();
}

From source file:com.netflix.config.ConcurrentMapConfiguration.java

protected void addPropertyDirect(String key, Object value) {
    ReentrantLock lock = locks[Math.abs(key.hashCode()) % NUM_LOCKS];
    lock.lock();/*w ww  .  j  av a 2s .c  o  m*/
    try {
        Object previousValue = map.putIfAbsent(key, value);
        if (previousValue == null) {
            return;
        }
        if (previousValue instanceof List) {
            // the value is added to the existing list
            ((List) previousValue).add(value);
        } else {
            // the previous value is replaced by a list containing the previous value and the new value
            List<Object> list = new CopyOnWriteArrayList<Object>();
            list.add(previousValue);
            list.add(value);
            map.put(key, list);
        }
    } finally {
        lock.unlock();
    }
}