private ArrayList<VolumeProduct> getVolumeProductsFromVhds() throws CloudException { WAPVhdsModel wapVhdsModel = new AzurePackRequester(this.getProvider(), new AzurePackVolumeRequests(this.getProvider()).listVirtualDisks().build()).withJsonProcessor(WAPVhdsModel.class).execute(); final ArrayList<VolumeProduct> volumes = new ArrayList<>(); CollectionUtils.forAllDo(wapVhdsModel.getVhds(), new Closure() { @Override public void execute(Object input) { WAPVhdModel wapVhdModel = (WAPVhdModel)input; if(wapVhdModel.getOperatingSystem().equalsIgnoreCase("none")) { volumes.add(VolumeProduct.getInstance(wapVhdModel.getId(), wapVhdModel.getName(), wapVhdModel.getName(), VolumeType.HDD, new Storage<Megabyte>(Integer.parseInt(wapVhdModel.getSize()), Storage.MEGABYTE))); } } }); return volumes; }
private ArrayList<Volume> getVolumesFromVMs() throws CloudException { WAPVirtualMachinesModel virtualMachinesModel = new AzurePackRequester(this.getProvider(), new AzurePackVolumeRequests(this.getProvider()).listVMsWithVDD().build()) .withJsonProcessor(WAPVirtualMachinesModel.class).execute(); final ArrayList<Volume> volumes = new ArrayList<>(); CollectionUtils.forAllDo(virtualMachinesModel.getVirtualMachines(), new Closure() { @Override public void execute(Object input) { WAPVirtualMachineModel virtualMachineModel = (WAPVirtualMachineModel)input; for (WAPDiskDriveModel wapDiskDriveModel : virtualMachineModel.getVirtualDiskDrives()) { volumes.add(volumeFrom(wapDiskDriveModel, virtualMachineModel.getId())); } } }); return volumes; }
@Override public @Nonnull Iterable<VLAN> listVlans() throws CloudException, InternalException { HttpUriRequest listNetworksRequest = new AzurePackNetworkRequests(provider).listVMNetworks().build(); return new AzurePackRequester(provider, listNetworksRequest).withJsonProcessor(new DriverToCoreMapper<WAPVMNetworksModel, List<VLAN>>() { @Override public List<VLAN> mapFrom(WAPVMNetworksModel entity) { final ArrayList<VLAN> vlans = new ArrayList<VLAN>(); CollectionUtils.forAllDo(entity.getVirtualMachineNetworks(), new Closure() { @Override public void execute(Object input) { vlans.add(vlanFrom((WAPVMNetworkModel) input)); } }); return vlans; } }, WAPVMNetworksModel.class).execute(); }
@Override public Collection<Region> listRegions() throws InternalException, CloudException { HttpUriRequest httpUriRequest = new AzurePackDataCenterRequests(provider).listClouds().build(); WAPCloudsModel result = new AzurePackRequester(provider, httpUriRequest).withJsonProcessor(WAPCloudsModel.class).execute(); final List<Region> regions = new ArrayList<Region>(); CollectionUtils.forAllDo(result.getClouds(), new Closure() { @Override public void execute(Object input) { WAPCloudModel cloudModel = (WAPCloudModel) input; Region region = new Region(); region.setName(cloudModel.getName()); region.setProviderRegionId(cloudModel.getId()); region.setActive(true); region.setAvailable(true); region.setJurisdiction("US"); regions.add(region); } }); return regions; }
private static void assertHttpMethod(final HttpUriRequest actualHttpRequest, String expectedHttpMethod, String expectedUrl, Header[] expectedHeaders) { assertHttpMethod(actualHttpRequest, expectedHttpMethod, expectedUrl); assertNotNull(actualHttpRequest.getAllHeaders()); CollectionUtils.forAllDo(Arrays.asList(expectedHeaders), new Closure() { @Override public void execute(Object input) { final Header expectedHeader = (Header) input; boolean headerExists = CollectionUtils.exists(Arrays.asList(actualHttpRequest.getAllHeaders()), new Predicate() { @Override public boolean evaluate(Object object) { Header actualHeader = (Header) object; return expectedHeader.getName().equals(actualHeader.getName()) && expectedHeader.getValue().equals(actualHeader.getValue()); } }); assertTrue(String.format("Expected %s header not found in the request or found with the wrong value in the request", expectedHeader.getName()), headerExists); } }); }
/** * @see DWRProviderService#findProvider(String,boolean,Integer,Integer) * @verifies return the list of providers matching the search name */ @Test public void findProvider_shouldReturnTheListOfProvidersMatchingTheSearchName() throws Exception { Vector<Object> providers = service.findProvider("provider", false, 0, 10); Assert.assertEquals(2, providers.size()); final ArrayList<String> providerNames = new ArrayList<String>(); CollectionUtils.forAllDo(providers, new Closure() { @Override public void execute(Object input) { providerNames.add(((ProviderListItem) input).getDisplayName()); } }); Assert.assertTrue(providerNames.containsAll(Arrays.asList("Bruno Otterbourg", "Hippocrates of Cos"))); }
@Test public void testGetNames() throws Exception { final InputStream is = getClass().getResourceAsStream(personalXsd); assertNotNull(is); final StreamSource source = new StreamSource(is); final XmlSchema schema = new XmlSchemaCollection().read(source); assertNotNull(schema); final Collection<QName> elements = SchemaUtil.getElements(schema); assertNotNull(elements); assertFalse(elements.isEmpty()); System.out.println("Got the following elements from schema:"); CollectionUtils.forAllDo(elements, new Closure() { @Override public void execute(Object input) { System.out.println(input); } }); }
public void onConfigChange(CruiseConfig newCruiseConfig) { LOGGER.info("[Configuration Changed] Removing jobs for pipelines that no longer exist in configuration."); synchronized (this) { List<JobPlan> jobsToRemove = new ArrayList<>(); for (JobPlan jobPlan : jobPlans) { if (!newCruiseConfig.hasBuildPlan(new CaseInsensitiveString(jobPlan.getPipelineName()), new CaseInsensitiveString(jobPlan.getStageName()), jobPlan.getName(), true)) { jobsToRemove.add(jobPlan); } } forAllDo(jobsToRemove, new Closure() { @Override public void execute(Object o) { removeJob((JobPlan) o); } }); } }
/** * Indexes a collection by creating a map that allows each element of the * specified collection to be looked up by its key. The key of each element is * determined by calling the <code>makeKey</code> Transformer on that * element. I sure miss Lisp. * * @return a Map */ public static <K, E> Map<K,E> indexCollection(Collection c, final Transformer getKey, Class<K> keyClass, Class<E> elementClass) { final Map<K,E> map = new HashMap<K,E>(c.size()); org.apache.commons.collections.CollectionUtils.forAllDo(c, new Closure() { @SuppressWarnings("unchecked") public void execute(Object e) { map.put((K) getKey.transform(e), (E) e); } }); return map; }
/** * Calls the given closure for all changes that are of one of the given types, and * then removes them from the changes collection. * * @param changes The changes * @param changeTypes The types to search for * @param closure The closure to invoke */ protected void applyForSelectedChanges(Collection changes, Class[] changeTypes, final Closure closure) { final Predicate predicate = new MultiInstanceofPredicate(changeTypes); // basically we filter the changes for all objects where the above predicate // returns true, and for these filtered objects we invoke the given closure CollectionUtils.filter(changes, new Predicate() { public boolean evaluate(Object obj) { if (predicate.evaluate(obj)) { closure.execute(obj); return false; } else { return true; } } }); }
public void setSelectAll(boolean selectAll) { this.selectAll = selectAll; if (this.triggerProcessList != null) { final boolean isSelectAll = this.isSelectAll(); CollectionUtils.forAllDo(this.triggerProcessList, new Closure() { @Override public void execute(Object tp) { ((TriggerProcess) tp).setSelected(isSelectAll); } }); } }
public RepositoryScannerInstance( ManagedRepository repository, List<KnownRepositoryContentConsumer> knownConsumerList, List<InvalidRepositoryContentConsumer> invalidConsumerList ) { this.repository = repository; this.knownConsumers = knownConsumerList; this.invalidConsumers = invalidConsumerList; consumerTimings = new HashMap<>(); consumerCounts = new HashMap<>(); this.consumerProcessFile = new ConsumerProcessFileClosure(); consumerProcessFile.setExecuteOnEntireRepo( true ); consumerProcessFile.setConsumerTimings( consumerTimings ); consumerProcessFile.setConsumerCounts( consumerCounts ); this.consumerWantsFile = new ConsumerWantsFilePredicate( repository ); stats = new RepositoryScanStatistics(); stats.setRepositoryId( repository.getId() ); Closure triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ), true ); CollectionUtils.forAllDo( knownConsumerList, triggerBeginScan ); CollectionUtils.forAllDo( invalidConsumerList, triggerBeginScan ); if ( SystemUtils.IS_OS_WINDOWS ) { consumerWantsFile.setCaseSensitive( false ); } }
@Override public void directoryWalkStep( int percentage, File file ) { log.debug( "Walk Step: {}, {}", percentage, file ); stats.increaseFileCount(); // consume files regardless - the predicate will check the timestamp BaseFile basefile = new BaseFile( repository.getLocation(), file ); // Timestamp finished points to the last successful scan, not this current one. if ( file.lastModified() >= changesSince ) { stats.increaseNewFileCount(); } consumerProcessFile.setBasefile( basefile ); consumerWantsFile.setBasefile( basefile ); Closure processIfWanted = IfClosure.getInstance( consumerWantsFile, consumerProcessFile ); CollectionUtils.forAllDo( this.knownConsumers, processIfWanted ); if ( consumerWantsFile.getWantedFileCount() <= 0 ) { // Nothing known processed this file. It is invalid! CollectionUtils.forAllDo( this.invalidConsumers, consumerProcessFile ); } }
private IntakeNode up(IntakeNode node, Closure closure) { //if(node == null) IntakeNode root = node; while (root.getParent() != null) { closure.execute(root); root = root.getParent(); } return root; }
private void down(List<IntakeNode> children, Closure closure) { for (IntakeNode child : children) { if (child != null) { closure.execute(child); down(child.getChildren(), closure); } } }
private List<MachineImage> getAllTemplates() throws CloudException { HttpUriRequest listTemplatesRequest = new AzurePackImageRequests(this.provider).listTemplates().build(); WAPTemplatesModel templatesModel = new AzurePackRequester(this.provider, listTemplatesRequest).withJsonProcessor(WAPTemplatesModel.class).execute(); final List<MachineImage> images = new ArrayList<MachineImage>(); final String regionId = this.provider.getContext().getRegionId(); CollectionUtils.forAllDo(templatesModel.getTemplates(), new Closure() { @Override public void execute(Object input) { WAPTemplateModel templateModel = (WAPTemplateModel)input; if(templateModel.getEnabled().equalsIgnoreCase("true")) { MachineImage image = MachineImage.getInstance(templateModel.getOwner().getRoleID() != null ? templateModel.getOwner().getRoleID() : "wap", regionId, templateModel.getId(), ImageClass.MACHINE, MachineImageState.ACTIVE, templateModel.getName(), templateModel.getDescription() != null ? templateModel.getDescription() : templateModel.getName(), Architecture.I64, templateModel.getOperatingSystemInstance().getOsType().toLowerCase().contains("windows") ? Platform.WINDOWS : Platform.UNIX); image.setTag("type", "template"); image.setTag("ProductKeyHasValue", templateModel.getProductKeyHasValue()); images.add(image); } } }); return images; }
private List<MachineImage> getAllVhds() throws CloudException { HttpUriRequest listVhdsRequest = new AzurePackImageRequests(this.provider).listVirtualDisks().build(); WAPVhdsModel vhds = new AzurePackRequester(this.provider, listVhdsRequest).withJsonProcessor(WAPVhdsModel.class).execute(); final List<MachineImage> images = new ArrayList<MachineImage>(); final String regionId = this.provider.getContext().getRegionId(); CollectionUtils.forAllDo(vhds.getVhds(), new Closure() { @Override public void execute(Object input) { WAPVhdModel vhd = (WAPVhdModel) input; if(vhd.getEnabled().equalsIgnoreCase("true")) { MachineImage image = MachineImage.getInstance((vhd.getOwner() != null && vhd.getOwner().getRoleID() != null) ? vhd.getOwner().getRoleID() : "wap", regionId, vhd.getId(), ImageClass.MACHINE, MachineImageState.ACTIVE, vhd.getName(), vhd.getDescription() != null ? vhd.getDescription() : vhd.getName(), Architecture.I64, vhd.getOperatingSystemInstance().getOsType().toLowerCase().contains("windows") ? Platform.WINDOWS : Platform.UNIX); image.setTag("type", "vhd"); images.add(image); } } }); return images; }
@Override public @Nonnull Iterable<IpForwardingRule> listRulesForServer(@Nonnull final String serverId) throws InternalException, CloudException{ if(serverId == null) throw new InternalException("Parameter serverId cannot be null"); String stampId = provider.getDataCenterServices().listDataCenters(provider.getContext().getRegionId()).iterator().next().getProviderDataCenterId(); WAPNatConnectionModel wapNatConnectionModel = getNatConnectionForServer(serverId, stampId); if(wapNatConnectionModel == null) return Collections.emptyList(); HttpUriRequest listRulesRequest = new AzurePackNetworkRequests(provider).listRulesForConnection(wapNatConnectionModel.getId(), stampId).build(); WAPNatRulesModel wapNatRulesModel = new AzurePackRequester(provider, listRulesRequest).withJsonProcessor(WAPNatRulesModel.class).execute(); final ArrayList<IpForwardingRule> rules = new ArrayList<IpForwardingRule>(); CollectionUtils.forAllDo(wapNatRulesModel.getRules(), new Closure() { @Override public void execute(Object input) { WAPNatRuleModel wapNatRuleModel = (WAPNatRuleModel)input; IpForwardingRule rule = new IpForwardingRule(); rule.setServerId(serverId); rule.setProviderRuleId(wapNatRuleModel.getId()); rule.setPrivatePort(Integer.valueOf(wapNatRuleModel.getInternalPort())); rule.setPublicPort(Integer.valueOf(wapNatRuleModel.getExternalPort())); if(wapNatRuleModel.getProtocol() != null) rule.setProtocol(Protocol.valueOf(wapNatRuleModel.getProtocol().toUpperCase())); rules.add(rule); } }); return rules; }
@Override public @Nonnull Iterable<Subnet> listSubnets(@Nonnull final String vlanId) throws CloudException, InternalException { List<DataCenter> dataCenters = new ArrayList(IteratorUtils.toList(this.provider.getDataCenterServices().listDataCenters(this.provider.getContext().getRegionId()).iterator())); String dataCenterId = dataCenters.get(0).getProviderDataCenterId(); HttpUriRequest listSubnetsRequest = new AzurePackNetworkRequests(provider).listSubnets(dataCenterId).build(); return new AzurePackRequester(provider, listSubnetsRequest).withJsonProcessor(new DriverToCoreMapper<WAPSubnetsModel, List<Subnet>>() { @Override public List<Subnet> mapFrom(WAPSubnetsModel entity) { final ArrayList<Subnet> subnets = new ArrayList<Subnet>(); CollectionUtils.forAllDo(entity.getSubnets(), new Closure() { @Override public void execute(Object input) { WAPSubnetModel subnetModel = (WAPSubnetModel) input; if(subnetModel.getVmNetworkId().equalsIgnoreCase(vlanId)) { subnets.add(Subnet.getInstance(provider.getContext().getAccountNumber(), provider.getContext().getRegionId(), subnetModel.getVmNetworkId(), subnetModel.getId(), SubnetState.AVAILABLE, subnetModel.getName(), subnetModel.getName(), subnetModel.getSubnet())); } } }); return subnets; } }, WAPSubnetsModel.class).execute(); }
@Nonnull @Override public Iterable<DatabaseProduct> listDatabaseProducts(@Nonnull final DatabaseEngine forEngine) throws CloudException, InternalException { if(forEngine == null) throw new InternalException("Please specify the DatabaseEngine for which you want to retrieve the products."); if(forEngine != DatabaseEngine.SQLSERVER_EE && forEngine != DatabaseEngine.MYSQL) return Arrays.asList(); if(forEngine == DatabaseEngine.SQLSERVER_EE && !hasMSSql) return Arrays.asList(); if(forEngine == DatabaseEngine.MYSQL && !hasMySql) return Arrays.asList(); List<DataCenter> dataCenters = new ArrayList(IteratorUtils.toList(this.provider.getDataCenterServices().listDataCenters(this.provider.getContext().getRegionId()).iterator())); final String dataCenterId = dataCenters.get(0).getProviderDataCenterId(); final ArrayList<DatabaseProduct> databaseProducts = new ArrayList<>(); CollectionUtils.forAllDo(getDBProductsFromFile(), new Closure() { @Override public void execute(Object input) { WAPDatabaseProducts.WAPDatabaseProduct wapDatabaseProduct = (WAPDatabaseProducts.WAPDatabaseProduct)input; if(forEngine.name().equalsIgnoreCase(wapDatabaseProduct.getEngine())) { DatabaseProduct product = new DatabaseProduct(String.format("%s:%s", forEngine.name().toString().toLowerCase(), wapDatabaseProduct.getMaxStorage()), "default"); product.setEngine(forEngine); product.setProviderDataCenterId(dataCenterId); product.setLicenseModel(getLicenseModel(wapDatabaseProduct.getLicense())); databaseProducts.add(product); } } }); return databaseProducts; }
@Override public Collection<DataCenter> listDataCenters(final String providerRegionId) throws InternalException, CloudException { HttpUriRequest httpUriRequest = new AzurePackDataCenterRequests(provider).listClouds().build(); WAPCloudsModel result = new AzurePackRequester(provider, httpUriRequest).withJsonProcessor(WAPCloudsModel.class).execute(); List<WAPCloudModel> wapClouds = result.getClouds(); CollectionUtils.filter(wapClouds, new Predicate() { @Override public boolean evaluate(Object object) { return ((WAPCloudModel) object).getId().equalsIgnoreCase(providerRegionId); } }); final List<DataCenter> dataCenters = new ArrayList<DataCenter>(); CollectionUtils.forAllDo(wapClouds, new Closure() { @Override public void execute(Object input) { WAPCloudModel cloudModel = (WAPCloudModel) input; DataCenter dataCenter = new DataCenter(); dataCenter.setName(cloudModel.getName()); dataCenter.setActive(true); dataCenter.setAvailable(true); dataCenter.setRegionId(providerRegionId); dataCenter.setProviderDataCenterId(cloudModel.getStampId()); dataCenters.add(dataCenter); } }); return dataCenters; }
/** * Creates a new <code>ClosureChain</code>. */ public ClosureChain( Closure[] closures ) { super(); closureArray = closures.clone(); if( containsNull( closureArray ) ) { throw new IllegalArgumentException( "Closure array has a null element." ); } }
/** * Creates a new <code>ClosureChain</code>. */ public ClosureChain( Collection closures ) { super(); Closure[] temp = new Closure[ closures.size() ]; closureArray = (Closure[]) closures.toArray( temp ); if( containsNull( closureArray ) ) { throw new IllegalArgumentException( "Collection argument has a null element." ); } }
/** * Creates a new <code>ClosureChain</code>. */ public ClosureChain( Closure first, Closure second ) { super(); closureArray = new Closure[] { first, second }; if( first == null ) { throw new IllegalArgumentException( "First Closure is null." ); } if( second == null ) { throw new IllegalArgumentException( "Second Closure is null." ); } }
private static void setMasterVolumeJavaSound(final float volume) { runVolumeCommand(new Closure() { public void execute(Object input) { FloatControl volumeControl = (FloatControl) input; volumeControl.setValue(volume); } }); }
private static float getMasterVolumeJavaSound() throws IOException { final Float[] volumes = new Float[1]; runVolumeCommand(new Closure() { public void execute(Object input) { FloatControl volumeControl = (FloatControl) input; volumes[0] = volumeControl.getValue(); } }); if(volumes[0]!=null) { return volumes[0]; } else { throw new IOException("Cannot determine master volume level"); } }
public PowerSet<E> each(final Operation<? super E> operation) { CollectionUtils.forAllDo(this, new Closure() { @SuppressWarnings("unchecked") public void execute(Object input) { operation.execute((E) input); } }); return this; }
@SuppressWarnings("unchecked") @Override public PowerList<E> each(final Operation<? super E> operation) { CollectionUtils.forAllDo(this, new Closure() { public void execute(Object input) { operation.execute((E) input); } }); return this; }
@Test public void testGetNamesFromSchemaWithImport() throws Exception { final InputStream is = getClass().getResourceAsStream(elementFormXsd); assertNotNull(is); final StreamSource source = new StreamSource(is); final XmlSchemaCollection schemaColl = new XmlSchemaCollection(); final URL baseUrl = SchemaUtilTest.class.getResource(elementFormXsd); final String baseUri = baseUrl.toURI().toString(); schemaColl.setBaseUri(baseUri); final XmlSchema schema = schemaColl.read(source); assertNotNull(schema); System.out.println("There are " + schemaColl.getXmlSchemas().length + " schemas present"); final Collection<QName> elements = SchemaUtil.getElements(schema); assertNotNull(elements); assertFalse(elements.isEmpty()); System.out.println("Got the following elements from schema:"); CollectionUtils.forAllDo(elements, new Closure() { @Override public void execute(Object input) { System.out.println(input); } }); }
public RepositoryScannerInstance( ManagedRepository repository, List<KnownRepositoryContentConsumer> knownConsumerList, List<InvalidRepositoryContentConsumer> invalidConsumerList ) { this.repository = repository; this.knownConsumers = knownConsumerList; this.invalidConsumers = invalidConsumerList; addFileNameIncludePattern("**/*"); consumerTimings = new HashMap<>(); consumerCounts = new HashMap<>(); this.consumerProcessFile = new ConsumerProcessFileClosure(); consumerProcessFile.setExecuteOnEntireRepo( true ); consumerProcessFile.setConsumerTimings( consumerTimings ); consumerProcessFile.setConsumerCounts( consumerCounts ); this.consumerWantsFile = new ConsumerWantsFilePredicate( repository ); stats = new RepositoryScanStatistics(); stats.setRepositoryId( repository.getId() ); Closure triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ), true ); CollectionUtils.forAllDo( knownConsumerList, triggerBeginScan ); CollectionUtils.forAllDo( invalidConsumerList, triggerBeginScan ); if ( SystemUtils.IS_OS_WINDOWS ) { consumerWantsFile.setCaseSensitive( false ); } }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (excludeMatcher.stream().noneMatch(m -> m.matches(file)) && includeMatcher.stream().allMatch(m -> m.matches(file))) { log.debug( "Walk Step: {}, {}", file ); stats.increaseFileCount(); // consume files regardless - the predicate will check the timestamp Path repoPath = PathUtil.getPathFromUri( repository.getLocation() ); BaseFile basefile = new BaseFile( repoPath.toString(), file.toFile() ); // Timestamp finished points to the last successful scan, not this current one. if ( Files.getLastModifiedTime(file).toMillis() >= changesSince ) { stats.increaseNewFileCount(); } consumerProcessFile.setBasefile( basefile ); consumerWantsFile.setBasefile( basefile ); Closure processIfWanted = IfClosure.getInstance( consumerWantsFile, consumerProcessFile ); CollectionUtils.forAllDo( this.knownConsumers, processIfWanted ); if ( consumerWantsFile.getWantedFileCount() <= 0 ) { // Nothing known processed this file. It is invalid! CollectionUtils.forAllDo( this.invalidConsumers, consumerProcessFile ); } } return FileVisitResult.CONTINUE; }
private Closure notifyPluginLoadedEvent(final GoPluginDescriptor pluginDescriptor) { return new Closure() { @Override public void execute(Object o) { PluginChangeListener pluginChangeListener = (PluginChangeListener) o; pluginChangeListener.pluginLoaded(pluginDescriptor); } }; }
private Closure notifyPluginUnLoadedEvent(final GoPluginDescriptor pluginDescriptor) { return new Closure() { @Override public void execute(Object o) { PluginChangeListener pluginChangeListener = (PluginChangeListener) o; pluginChangeListener.pluginUnLoaded(pluginDescriptor); } }; }
@Override public void pluginJarAdded(final PluginFileDetails pluginFileDetails) { doOnAllPluginJarChangeListener(new Closure() { public void execute(Object o) { ((PluginJarChangeListener) o).pluginJarAdded(pluginFileDetails); } }); }
@Override public void pluginJarUpdated(final PluginFileDetails pluginFileDetails) { doOnAllPluginJarChangeListener(new Closure() { public void execute(Object o) { ((PluginJarChangeListener) o).pluginJarUpdated(pluginFileDetails); } }); }
@Override public void pluginJarRemoved(final PluginFileDetails pluginFileDetails) { doOnAllPluginJarChangeListener(new Closure() { public void execute(Object o) { ((PluginJarChangeListener) o).pluginJarRemoved(pluginFileDetails); } }); }
private void doOnAllPluginJarChangeListener(Closure closure) { for (WeakReference<PluginJarChangeListener> listener : listeners) { PluginJarChangeListener changeListener = listener.get(); if (changeListener == null) { continue; } try { closure.execute(changeListener); } catch (Exception e) { LOGGER.warn("Plugin listener failed", e); } } }