本文整理汇总了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();
}
}
示例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;
}
});
}
示例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);
}
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
示例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;
}
});
}
示例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();
}
});
}
示例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;
}
});
}