本文整理汇总了Java中java.util.Collections.EMPTY_SET属性的典型用法代码示例。如果您正苦于以下问题:Java Collections.EMPTY_SET属性的具体用法?Java Collections.EMPTY_SET怎么用?Java Collections.EMPTY_SET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.EMPTY_SET属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCollapsedCommenst
public Collection<Long> loadCollapsedCommenst(String repoUrl, String id) {
File file = getIssuePropertiesFile(repoUrl, id);
FileLocks.FileLock l = FileLocks.getLock(file);
try {
Properties p = load(file, repoUrl, id);
Set<Long> s = new HashSet<Long>();
for(Object k : p.keySet()) {
String key = k.toString();
if(key.startsWith(PROP_COLLAPSED_COMMENT_PREFIX) && "true".equals(p.get(key))) {
s.add(Long.parseLong(key.substring(PROP_COLLAPSED_COMMENT_PREFIX.length())));
}
}
return s;
} catch (IOException ex) {
Support.LOG.log(Level.WARNING, repoUrl + " " + id, ex);
} finally {
l.release();
}
return Collections.EMPTY_SET;
}
示例2: getCurrentServers
public Set<InetSocketAddress> getCurrentServers() {
Map<String, Pool> pools = PoolManager.getAll();
Set result = null;
for (Pool p : pools.values()) {
PoolImpl pi = (PoolImpl) p;
for (Object o : pi.getCurrentServers()) {
ServerLocation sl = (ServerLocation) o;
if (result == null) {
result = new HashSet<DistributedMember>();
}
result.add(new InetSocketAddress(sl.getHostName(), sl.getPort()));
}
}
if (result == null) {
return Collections.EMPTY_SET;
} else {
return result;
}
}
示例3: getMyAddresses
/**
* Determine all of the addresses that this host represents. An empty list will be regarded as an
* error by all who see it.
*
* @return list of addresses for this host
* @since GemFire 5.7
*/
public static Set getMyAddresses(DistributionManager dm) {
try {
Set addresses = SocketCreator.getMyAddresses();
return addresses;
} catch (IllegalArgumentException e) {
logger.fatal(e.getMessage(), e);
return Collections.EMPTY_SET;
}
}
示例4: authenticate
public Subject authenticate(Object credentials) {
Subject subject =
new Subject(true, bogusPrincipals,
Collections.EMPTY_SET, Collections.EMPTY_SET);
System.out.println("Authenticator returns: " + subject);
return subject;
}
示例5: engineGetMatches
/**
* Returns a collection of matching CRLs from the LDAP location.
* <p/>
* The selector must be a of type <code>X509CRLStoreSelector</code>. If
* it is not an empty collection is returned.
* <p/>
* The issuer should be a reasonable criteria for a selector.
*
* @param selector The selector to use for finding.
* @return A collection with the matches.
* @throws StoreException if an exception occurs while searching.
*/
public Collection engineGetMatches(Selector selector) throws StoreException
{
if (!(selector instanceof X509CRLStoreSelector))
{
return Collections.EMPTY_SET;
}
X509CRLStoreSelector xselector = (X509CRLStoreSelector)selector;
Set set = new HashSet();
// test only delta CRLs should be selected
if (xselector.isDeltaCRLIndicatorEnabled())
{
set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
}
// nothing specified
else
{
set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
set.addAll(helper.getAttributeAuthorityRevocationLists(xselector));
set
.addAll(helper
.getAttributeCertificateRevocationLists(xselector));
set.addAll(helper.getAuthorityRevocationLists(xselector));
set.addAll(helper.getCertificateRevocationLists(xselector));
}
return set;
}
示例6: authenticate
public Subject authenticate(Object credentials) {
String role = ((String[]) credentials)[0];
echo("Create principal with name = " + role);
return new Subject(true,
Collections.singleton(new JMXPrincipal(role)),
Collections.EMPTY_SET,
Collections.EMPTY_SET);
}
示例7: getCacheClosedMembers
public Set getCacheClosedMembers() {
if (this.exception != null) {
DistTxRollbackExceptionCollectingException cce =
(DistTxRollbackExceptionCollectingException) this.exception;
return cce.getCacheClosedMembers();
} else {
return Collections.EMPTY_SET;
}
}
示例8: getRegionDestroyedMembers
public Set getRegionDestroyedMembers(String regionFullPath) {
if (this.exception != null) {
DistTxPrecommitExceptionCollectingException cce =
(DistTxPrecommitExceptionCollectingException) this.exception;
return cce.getRegionDestroyedMembers(regionFullPath);
} else {
return Collections.EMPTY_SET;
}
}
示例9: main
public static void main(String[] args) throws Exception {
System.out.println("---RMIConnectorInternalMapTest starting...");
JMXConnectorServer connectorServer = null;
JMXConnector connectorClient = null;
try {
MBeanServer mserver = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL serverURL = new JMXServiceURL("rmi", "localhost", 0);
connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serverURL, null, mserver);
connectorServer.start();
JMXServiceURL serverAddr = connectorServer.getAddress();
connectorClient = JMXConnectorFactory.connect(serverAddr, null);
connectorClient.connect();
Field rmbscMapField = RMIConnector.class.getDeclaredField("rmbscMap");
rmbscMapField.setAccessible(true);
Map<Subject, WeakReference<MBeanServerConnection>> map =
(Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
if (map != null && !map.isEmpty()) { // failed
throw new RuntimeException("RMIConnector's rmbscMap must be empty at the initial time.");
}
Subject delegationSubject =
new Subject(true,
Collections.singleton(new JMXPrincipal("delegate")),
Collections.EMPTY_SET,
Collections.EMPTY_SET);
MBeanServerConnection mbsc1 =
connectorClient.getMBeanServerConnection(delegationSubject);
MBeanServerConnection mbsc2 =
connectorClient.getMBeanServerConnection(delegationSubject);
if (mbsc1 == null) {
throw new RuntimeException("Got null connection.");
}
if (mbsc1 != mbsc2) {
throw new RuntimeException("Not got same connection with a same subject.");
}
map = (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
if (map == null || map.isEmpty()) { // failed
throw new RuntimeException("RMIConnector's rmbscMap has wrong size "
+ "after creating a delegated connection.");
}
delegationSubject = null;
mbsc1 = null;
mbsc2 = null;
int i = 0;
while (!map.isEmpty() && i++ < 60) {
System.gc();
Thread.sleep(100);
}
System.out.println("---GC times: " + i);
if (!map.isEmpty()) {
throw new RuntimeException("Failed to clean RMIConnector's rmbscMap");
} else {
System.out.println("---RMIConnectorInternalMapTest: PASSED!");
}
} finally {
try {
connectorClient.close();
connectorServer.stop();
} catch (Exception e) {
}
}
}
示例10: visit
/**
* Returns Collections.EMPTY_SET
* @return Collections.EMPTY_SET
*/
@SuppressWarnings("unchecked")
public Set<T> visit(ConstantFormula constant) {
return Collections.EMPTY_SET;
}
示例11: instantiate
public Set instantiate() throws IOException {
return Collections.EMPTY_SET;
}
示例12: mcastRouteInfo
public static McastRouteInfo mcastRouteInfo(McastRoute route,
ConnectPoint sink,
ConnectPoint source) {
return new McastRouteInfo(route, sink, source, Collections.EMPTY_SET);
}
示例13: getSomeKeys
/**
* Test Method: Get a random set of keys from a randomly selected bucket using the provided
* <code>Random</code> number generator.
*
* @param rnd
* @return A set of keys from a randomly chosen bucket or {@link Collections#EMPTY_SET}
* @throws IOException
* @throws ClassNotFoundException
*/
public Set getSomeKeys(Random rnd) throws IOException, ClassNotFoundException {
InternalDistributedMember nod = null;
Integer buck = null;
Set buks = getRegionAdvisor().getBucketSet();
if (buks != null && !buks.isEmpty()) {
Object[] buksA = buks.toArray();
Set ret = null;
// Randomly pick a node to get some data from
for (int i = 0; i < buksA.length; i++) {
try {
logger.debug("getSomeKeys: iteration: {}", i);
int ind = rnd.nextInt(buksA.length);
if (ind >= buksA.length) {
// The GSRandom.nextInt(int) may return a value that includes the
// maximum.
ind = buksA.length - 1;
}
buck = (Integer) buksA[ind];
nod = getNodeForBucketRead(buck.intValue());
if (nod != null) {
logger.debug("getSomeKeys: iteration: {} for node {}", i, nod);
if (nod.equals(getMyId())) {
ret =
dataStore.handleRemoteGetKeys(buck, InterestType.REGULAR_EXPRESSION, ".*", false);
} else {
FetchKeysResponse r = FetchKeysMessage.send(nod, this, buck, false);
ret = r.waitForKeys();
}
if (ret != null && !ret.isEmpty()) {
return ret;
}
}
} catch (ForceReattemptException movinOn) {
checkReadiness();
logger.debug(
"Test hook getSomeKeys caught a ForceReattemptException for bucketId={}{}{}. Moving on to another bucket",
getPRId(), BUCKET_ID_SEPARATOR, buck, movinOn);
continue;
} catch (PRLocallyDestroyedException pde) {
logger.debug("getSomeKeys: Encountered PRLocallyDestroyedException");
checkReadiness();
continue;
}
} // nod != null
} // for
logger.debug("getSomeKeys: no keys found returning empty set");
return Collections.EMPTY_SET;
}
示例14: getMegaIncludedModels
/**
* It looks for a set of schema models, which can be visible to each others.
* The matter is, if model A includes B, then model B model's definitions
* is visible to A. But the oposite assertion is also correct because B
* logically becomes a part of A after inclusion.
*
* The method doesn't analyze models included to current. It looks only
* models to which current model is included! It is implied that the included
* models's hierarchy has checked before.
*
* Be carefull with the following use-case:
* If model A includes B and C includes B then it doesn't mean that declarations
* from model C visible in A.
*
* The problem is described in the issue http://www.netbeans.org/issues/show_bug.cgi?id=122836
*
* The task of the method is to find a set of schema models, which
* can be visible to the current model. The parameter is used as a hint
* to exclude the models from other namespace.
*
* @param soughtNs
* @return
*/
static Set<SchemaModelImpl> getMegaIncludedModels(
SchemaModelImpl sModel, String soughtNs, ResolveSession session) {
//
// if (true) {
// // For optimization tests only
// Uncomment and run tests to check how often the mega-include is called.
// throw new RuntimeException("MEGA INCLUDE");
// }
//
Schema mySchema = sModel.getSchema();
if (mySchema == null) {
return Collections.EMPTY_SET;
}
//
// If the current model has empty target namespace, then it can be included anywhere
// If the current model has not empty target namespace, then it can be included only
// to models with the same target namespace.
String myTargetNs = mySchema.getTargetNamespace();
if (myTargetNs != null && !Util.equal(soughtNs, myTargetNs)) {
return Collections.EMPTY_SET;
}
//
// The graph is lazy initialized in session and can be reused during
// the resolve session.
BidirectionalGraph<SchemaModelImpl> graph =
session.getInclusionGraph(sModel, soughtNs);
//
// Now there is forward and back inclusion graphs.
if (graph.isEmpty()) {
return Collections.EMPTY_SET;
}
//
// Look for the roots of inclusion.
// Root s the top schema model, which includes current schema recursively,
// but isn't included anywhere itself.
Set<SchemaModelImpl> inclusionRoots = graph.getRoots(sModel, false);
//
HashSet<SchemaModelImpl> result = new HashSet<SchemaModelImpl>();
for (SchemaModelImpl root : inclusionRoots) {
// The namespace of the inclusion root has to be exectly the same
// as required.
if (Util.equal(root.getSchema().getTargetNamespace(), soughtNs)) {
MultivalueMap.Utils.populateAllSubItems(graph, root, sModel, result);
}
}
//
result.remove(sModel);
//
return result;
}
示例15: testTXRecoverGrantorMessageProcessor
@Test
public void testTXRecoverGrantorMessageProcessor() throws Exception {
TXLockService.createDTLS();
checkDLockRecoverGrantorMessageProcessor();
/*
* call TXRecoverGrantorMessageProcessor.process directly to make sure that correct behavior
* occurs
*/
// get txLock and hold it
final Set participants = Collections.EMPTY_SET;
final List regionLockReqs = new ArrayList();
regionLockReqs.add(new TXRegionLockRequestImpl("/testTXRecoverGrantorMessageProcessor",
new HashSet(Arrays.asList(new String[] {"KEY-1", "KEY-2", "KEY-3", "KEY-4"}))));
TXLockService dtls = TXLockService.getDTLS();
TXLockId txLockId = dtls.txLock(regionLockReqs, participants);
// async call TXRecoverGrantorMessageProcessor.process
final DLockService dlock = ((TXLockServiceImpl) dtls).getInternalDistributedLockService();
final TestDLockRecoverGrantorProcessor testProc =
new TestDLockRecoverGrantorProcessor(dlock.getDistributionManager(), Collections.EMPTY_SET);
assertEquals("No valid processorId", true, testProc.getProcessorId() > -1);
final DLockRecoverGrantorProcessor.DLockRecoverGrantorMessage msg =
new DLockRecoverGrantorProcessor.DLockRecoverGrantorMessage();
msg.setServiceName(dlock.getName());
msg.setProcessorId(testProc.getProcessorId());
msg.setSender(dlock.getDistributionManager().getId());
Thread thread = new Thread(() -> {
TXRecoverGrantorMessageProcessor proc =
(TXRecoverGrantorMessageProcessor) dlock.getDLockRecoverGrantorMessageProcessor();
proc.processDLockRecoverGrantorMessage(dlock.getDistributionManager(), msg);
});
thread.setName("TXLockServiceDUnitTest thread");
thread.setDaemon(true);
thread.start();
await("waiting for recovery message to block").atMost(999, TimeUnit.MILLISECONDS).until(() -> {
return ((TXLockServiceImpl) dtls).isRecovering();
});
dtls.release(txLockId);
// check results to verify no locks were provided in the reply
await("waiting for thread to exit").atMost(30, TimeUnit.SECONDS).until(() -> {
return !thread.isAlive();
});
assertFalse(((TXLockServiceImpl) dtls).isRecovering());
assertEquals("testTXRecoverGrantor_replyCode_PASS is false", true,
testTXRecoverGrantor_replyCode_PASS);
assertEquals("testTXRecoverGrantor_heldLocks_PASS is false", true,
testTXRecoverGrantor_heldLocks_PASS);
}