本文整理汇总了Java中org.xwiki.component.manager.ComponentManager类的典型用法代码示例。如果您正苦于以下问题:Java ComponentManager类的具体用法?Java ComponentManager怎么用?Java ComponentManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentManager类属于org.xwiki.component.manager包,在下文中一共展示了ComponentManager类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultPatientGenotype
import org.xwiki.component.manager.ComponentManager; //导入依赖的package包/类
/**
* Constructor for a {@link PatientGenotype} object, representing the candidate genes and exome sequence data for
* the given {@link Patient}.
*
* @param patient the patient object
*/
public DefaultPatientGenotype(Patient patient)
{
// Initialize static exome manager
if (exomeManager == null) {
ComponentManager componentManager = ComponentManagerRegistry.getContextComponentManager();
try {
exomeManager = componentManager.getInstance(ExomeManager.class, "exomiser");
} catch (ComponentLookupException e) {
LOGGER.error("Unable to look up ExomeManager: " + e.toString());
}
}
if (exomeManager != null) {
this.exome = exomeManager.getExome(patient);
}
this.genesStatus = STATUS_SOLVED;
this.candidateGenes = new HashSet<>();
this.candidateGenes.addAll(getManualGeneNames(patient));
// Score all genes
for (String gene : this.getGenes()) {
this.geneScores.put(gene, this.getGeneScore(gene));
}
}
示例2: PairCache
import org.xwiki.component.manager.ComponentManager; //导入依赖的package包/类
/**
* Create a cache that associates a pair of IDs with each cache entry.
*
* @throws CacheException if the cache cannot be created.
*/
public PairCache() throws CacheException
{
this.idEntries = new HashMap<>();
try {
ComponentManager componentManager = ComponentManagerRegistry.getContextComponentManager();
CacheManager cacheManager = componentManager.getInstance(CacheManager.class);
this.cache = cacheManager.createNewLocalCache(new CacheConfiguration());
} catch (ComponentLookupException e) {
this.cache = null;
}
if (this.cache == null) {
throw new CacheException("Error getting local cache factory");
}
}
示例3: getPatient
import org.xwiki.component.manager.ComponentManager; //导入依赖的package包/类
private static Patient getPatient(String patientId)
{
PatientRepository patientRepository = null;
try {
ComponentManager ccm = ComponentManagerRegistry.getContextComponentManager();
patientRepository = ccm.getInstance(PatientRepository.class);
} catch (ComponentLookupException e) {
return null;
}
return patientRepository.get(patientId);
}
示例4: setupComponents
import org.xwiki.component.manager.ComponentManager; //导入依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public static void setupComponents() throws ComponentLookupException, CacheException
{
ComponentManager componentManager = mock(ComponentManager.class);
Provider<ComponentManager> mockProvider = mock(Provider.class);
// This is a bit fragile, let's hope the field name doesn't change
ReflectionUtils.setFieldValue(new ComponentManagerRegistry(), "cmProvider", mockProvider);
when(mockProvider.get()).thenReturn(componentManager);
CacheManager cacheManager = mock(CacheManager.class);
when(componentManager.getInstance(CacheManager.class)).thenReturn(cacheManager);
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getLocalCacheFactory()).thenReturn(cacheFactory);
Cache<Exome> cache = mock(Cache.class);
doReturn(cache).when(cacheFactory).newCache(Matchers.any(CacheConfiguration.class));
doReturn(null).when(cache).get(Matchers.anyString());
// Wire up mocked genetics
exomeManager = mock(ExomeManager.class);
when(componentManager.getInstance(ExomeManager.class, "exomiser")).thenReturn(exomeManager);
// Use a real GenotypeManager
PatientGenotypeManager genotypeManager = new DefaultPatientGenotypeManager();
when(componentManager.getInstance(PatientGenotypeManager.class)).thenReturn(genotypeManager);
}
示例5: setUp
import org.xwiki.component.manager.ComponentManager; //导入依赖的package包/类
@Before
public void setUp() throws ComponentLookupException
{
MockitoAnnotations.initMocks(this);
final Execution execution = mock(Execution.class);
final ExecutionContext executionContext = mock(ExecutionContext.class);
final ComponentManager compManager = this.mocker.getInstance(ComponentManager.class, "context");
final Provider<XWikiContext> provider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER);
final XWikiContext context = provider.get();
when(compManager.getInstance(Execution.class)).thenReturn(execution);
when(execution.getContext()).thenReturn(executionContext);
when(executionContext.getProperty("xwikicontext")).thenReturn(context);
this.component = this.mocker.getComponentUnderTest();
// Set up all injected classes.
this.logger = this.mocker.getMockedLogger();
this.repository = this.mocker.getInstance(PatientRepository.class, SECURE);
this.similarPatientsFinder = this.mocker.getInstance(SimilarPatientsFinder.class);
// Mock the reference patient.
when(this.repository.get(REFERENCE)).thenReturn(this.reference);
when(this.reference.toJSON()).thenReturn(new JSONObject().put(ID, REFERENCE));
// Mock similar patient search.
final List<PatientSimilarityView> matches = Arrays.asList(this.match1, this.match2, this.match3);
when(this.similarPatientsFinder.findSimilarPatients(this.reference)).thenReturn(matches);
// Mock container interactions.
final Container container = this.mocker.getInstance(Container.class);
when(container.getRequest()).thenReturn(this.request);
// Mock individual match data.
when(this.match1.toJSON()).thenReturn(new JSONObject().put(ID, MATCH_1)
.put(OWNER, new JSONObject()
.put(EMAIL, MATCH_1)));
when(this.match2.toJSON()).thenReturn(new JSONObject().put(ID, MATCH_2)
.put(OWNER, new JSONObject()
.put(EMAIL, MATCH_2)));
when(this.match3.toJSON()).thenReturn(new JSONObject().put(ID, MATCH_3)
.put(OWNER, new JSONObject()
.put(EMAIL, MATCH_3)));
this.expectedAll = constructAllMatchesJSON();
}