當前位置: 首頁>>代碼示例>>Java>>正文


Java LockMode類代碼示例

本文整理匯總了Java中org.jboss.forge.furnace.lock.LockMode的典型用法代碼示例。如果您正苦於以下問題:Java LockMode類的具體用法?Java LockMode怎麽用?Java LockMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LockMode類屬於org.jboss.forge.furnace.lock包,在下文中一共展示了LockMode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: obtainLock

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
private synchronized Lock obtainLock(LockMode mode)
{
   if (readWriteLock == null)
      readWriteLock = new ReentrantReadWriteLock(true);

   if (LockMode.READ.equals(mode))
   {
      return readWriteLock.readLock();
   }
   else
   {
      if (readWriteLock.getReadHoldCount() > 0)
         throw new DeadlockError(
                  "Thread with READ lock attempted to obtain a WRITE lock (This is never allowed.)");
      return readWriteLock.writeLock();
   }
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:18,代碼來源:LockManagerImpl.java

示例2: fireEvent

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public void fireEvent(final Object event, final Annotation... qualifiers) throws EventException
{
   lockManager.performLocked(LockMode.READ, new Callable<Void>()
   {
      @Override
      public Void call() throws Exception
      {
         for (Addon addon : addonView.getAddons())
         {
            if (addon.getStatus().isStarted())
            {
               EventManager eventManager = addon.getEventManager();
               eventManager.fireEvent(event, qualifiers);
            }
         }
         return null;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:21,代碼來源:AddonViewEventManager.java

示例3: getRepositoryRegistryFile

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
private File getRepositoryRegistryFile()
{
   return lock.performLocked(LockMode.READ, new Callable<File>()
   {
      @Override
      public File call() throws Exception
      {
         File registryFile = new File(getRootDirectory(), REGISTRY_DESCRIPTOR_NAME);
         try
         {
            if (!registryFile.exists())
            {
               java.nio.file.Files.write(registryFile.toPath(), "<installed/>".getBytes(),
                        StandardOpenOption.CREATE_NEW);
            }
            return registryFile;
         }
         catch (Exception e)
         {
            throw new RuntimeException("Error initializing addon registry file [" + registryFile + "]", e);
         }
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:25,代碼來源:AddonRepositoryStateStrategyImpl.java

示例4: listEnabled

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public List<AddonId> listEnabled()
{
   final AddonCompatibilityStrategy strategy = furnace.getAddonCompatibilityStrategy();
   return lock.performLocked(LockMode.READ, new Callable<List<AddonId>>()
   {
      @Override
      public List<AddonId> call() throws Exception
      {
         List<AddonId> list = listAll();
         List<AddonId> result = new ArrayList<>();
         for (AddonId entry : list)
         {
            if (strategy.isCompatible(furnace, entry))
            {
               result.add(entry);
            }
         }
         return result;
      }
   });

}
 
開發者ID:forge,項目名稱:furnace,代碼行數:24,代碼來源:AddonRepositoryStateStrategyImpl.java

示例5: listEnabledCompatibleWithVersion

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public List<AddonId> listEnabledCompatibleWithVersion(final Version version)
{
   return lock.performLocked(LockMode.READ, new Callable<List<AddonId>>()
   {
      @Override
      public List<AddonId> call() throws Exception
      {
         List<AddonId> list = listAll();
         List<AddonId> result = new ArrayList<>();
         for (AddonId entry : list)
         {
            if (version == null || entry.getApiVersion() == null
                     || Versions.isApiCompatible(version, entry.getApiVersion()))
            {
               result.add(entry);
            }
         }
         return result;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:23,代碼來源:AddonRepositoryStateStrategyImpl.java

示例6: getAddon

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public Addon getAddon(final AddonId id)
{
   Assert.notNull(id, "AddonId must not be null.");
   return lock.performLocked(LockMode.WRITE, new Callable<Addon>()
   {
      @Override
      public Addon call() throws Exception
      {
         Addon result = null;
         while (result == null)
         {
            result = manager.getAddon(AddonRegistryImpl.this, id);
            if (result == null)
               Thread.sleep(10);
         }
         return result;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:21,代碼來源:AddonRegistryImpl.java

示例7: getAddons

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public Set<Addon> getAddons(final AddonFilter filter)
{
   return lock.performLocked(LockMode.READ, new Callable<Set<Addon>>()
   {
      @Override
      public Set<Addon> call() throws Exception
      {
         HashSet<Addon> result = new HashSet<>();

         for (Addon addon : manager.getAddons(AddonRegistryImpl.this))
         {
            if (filter.accept(addon))
               result.add(addon);
         }

         return result;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:21,代碼來源:AddonRegistryImpl.java

示例8: getExportedTypes

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public Set<Class<?>> getExportedTypes()
{
   return lock.performLocked(LockMode.READ, new Callable<Set<Class<?>>>()
   {
      @Override
      public Set<Class<?>> call() throws Exception
      {
         Set<Class<?>> result = new HashSet<>();
         for (Addon addon : getAddons())
         {
            if (addon.getStatus().isStarted())
            {
               ServiceRegistry serviceRegistry = addon.getServiceRegistry();
               result.addAll(serviceRegistry.getExportedTypes());
            }
         }
         return result;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:22,代碼來源:AddonRegistryImpl.java

示例9: getOrphanAddons

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
public Set<Addon> getOrphanAddons(final AddonId id)
{
   return lock.performLocked(LockMode.READ, new Callable<Set<Addon>>()
   {
      @Override
      public Set<Addon> call() throws Exception
      {
         Set<Addon> result = new HashSet<Addon>();
         for (Entry<AddonView, Set<Addon>> entry : addonViews.entrySet())
         {
            for (Addon addon : entry.getValue())
            {
               if (addon.getId().equals(id) && stateManager.getViewsOf(addon).isEmpty())
               {
                  result.add(addon);
               }
            }
         }
         return result;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:23,代碼來源:AddonLifecycleManager.java

示例10: getAddons

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
public Set<Addon> getAddons(final AddonView view, final AddonFilter filter)
{
   return lock.performLocked(LockMode.READ, new Callable<Set<Addon>>()
   {
      @Override
      public Set<Addon> call() throws Exception
      {
         HashSet<Addon> result = new HashSet<Addon>();

         for (Addon addon : _getAddonsForView(view))
         {
            if (filter.accept(addon))
               result.add(addon);
         }

         return result;
      }

   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:21,代碼來源:AddonLifecycleManager.java

示例11: stopAll

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
public void stopAll()
{
   lock.performLocked(LockMode.WRITE, new Callable<Void>()
   {
      @Override
      public Void call() throws Exception
      {
         for (Entry<AddonView, Set<Addon>> entry : addonViews.entrySet())
         {
            for (Addon addon : entry.getValue())
            {
               stopAddon(addon);
            }
         }

         List<Runnable> waiting = executor.shutdownNow();
         if (waiting != null && !waiting.isEmpty())
            logger.info("(" + waiting.size() + ") addons were aborted while loading due to forced shutdown.");
         starting.set(-1);
         return null;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:24,代碼來源:AddonLifecycleManager.java

示例12: getRootDirectory

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
protected File getRootDirectory()
{
    if (!addonDir.exists() || !addonDir.isDirectory())
    {
        lock.performLocked(LockMode.READ, new Callable<File>()
        {
            @Override
            public File call() throws Exception
            {
                addonDir.delete();
                System.gc();
                if (!addonDir.mkdirs())
                {
                    throw new RuntimeException("Could not create Addon Directory [" + addonDir + "]");
                }
                return addonDir;
            }
        });
    }
    return addonDir;
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:22,代碼來源:AbstractFileSystemAddonRepository.java

示例13: getAddonBaseDir

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public File getAddonBaseDir(final AddonId found)
{
   Assert.notNull(found, "Addon must be specified.");
   Assert.notNull(found.getVersion(), "Addon version must be specified.");
   Assert.notNull(found.getName(), "Addon name must be specified.");

   return lock.performLocked(LockMode.READ, new Callable<File>()
   {
      @Override
      public File call() throws Exception
      {
         File addonDir = new File(getRootDirectory(), OperatingSystemUtils.getSafeFilename(found.toCoordinates()));
         return addonDir;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:18,代碼來源:AddonRepositoryStorageStrategyImpl.java

示例14: getAddonResources

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
@Override
public List<File> getAddonResources(final AddonId found)
{
   return lock.performLocked(LockMode.READ, new Callable<List<File>>()
   {
      @Override
      public List<File> call() throws Exception
      {
         File dir = getAddonBaseDir(found);
         if (dir.exists())
         {
            File[] files = dir.listFiles(new FileFilter()
            {
               @Override
               public boolean accept(File pathname)
               {
                  return pathname.isDirectory() || pathname.getName().endsWith(".jar");
               }
            });
            return Arrays.asList(files);
         }
         return Collections.emptyList();
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:26,代碼來源:AddonRepositoryStorageStrategyImpl.java

示例15: getAddonForView

import org.jboss.forge.furnace.lock.LockMode; //導入依賴的package包/類
/**
 * Return an {@link Addon} compatible with the given {@link AddonView}, if it is already registered (this occurs when
 * {@link AddonView} instances share {@link Addon} sub-graphs.
 */
public Addon getAddonForView(final AddonView view, final AddonId id)
{
   return lock.performLocked(LockMode.READ, new Callable<Addon>()
   {
      @Override
      public Addon call() throws Exception
      {
         for (AddonVertex vertex : getCurrentGraph().getGraph().vertexSet())
         {
            if (vertex.getAddonId().equals(id) && vertex.getViews().contains(view))
            {
               return vertex.getAddon();
            }
         }
         return null;
      }
   });
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:23,代碼來源:AddonStateManager.java


注:本文中的org.jboss.forge.furnace.lock.LockMode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。