List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:org.apache.jackrabbit.core.state.ChildNodeEntries.java
/** * Initializes the name and entries map with unmodifiable empty instances. *///ww w. j a va 2 s . co m private void init() { nameMap = Collections.EMPTY_MAP; entries = EmptyLinkedMap.INSTANCE; shared = false; }
From source file:org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.java
public Object handleAction(GroovyObject controller, Object action, HttpServletRequest request, HttpServletResponse response) {//from w w w . j a v a 2 s. c o m return handleAction(controller, action, request, response, Collections.EMPTY_MAP); }
From source file:org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.java
public Object handleAction(GroovyObject controller, Closure action, HttpServletRequest request, HttpServletResponse response) {//from ww w . java2s.c o m return handleAction(controller, action, request, response, Collections.EMPTY_MAP); }
From source file:org.openmrs.module.auditlog.api.db.hibernate.interceptor.HibernateAuditLogInterceptor.java
@Override public void onCollectionRemove(Object collection, Serializable key) throws CallbackException { //We need to get all collection elements and link their childlogs to the parent's if (collection != null) { PersistentCollection persistentColl = (PersistentCollection) collection; if (InterceptorUtil.isAudited(persistentColl.getOwner().getClass())) { Object owningObject = persistentColl.getOwner(); String role = persistentColl.getRole(); String propertyName = role.substring(role.lastIndexOf('.') + 1); ClassMetadata cmd = AuditLogUtil.getClassMetadata(AuditLogUtil.getActualType(owningObject)); Object currentCollection = cmd.getPropertyValue(owningObject, propertyName, EntityMode.POJO); //Hibernate calls onCollectionRemove whenever the underlying collection is replaced with a //new instance i.e one calls the collection's setter and passes in a new instance even if the //new collection contains some elements, we want to treat this as regular collection update, //Except if onCollectionRemove is called because the owner got purged from the DB. //I believe hibernate calls onDelete for the owner before onCollectionRemove for all its //collections so we can guarantee that the owner is already in the 'deletes' thread local boolean isOwnerDeleted = OpenmrsUtil.collectionContains(deletes.get().peek(), owningObject); if (Collection.class.isAssignableFrom(collection.getClass())) { Collection coll = (Collection) collection; if (!coll.isEmpty()) { if (isOwnerDeleted) { if (entityRemovedChildrenMap.get().peek().get(owningObject) == null) { entityRemovedChildrenMap.get().peek().put(owningObject, new HashSet<Object>()); }/*from w w w . j a va2 s . c om*/ for (Object removedItem : coll) { entityRemovedChildrenMap.get().peek().get(owningObject).add(removedItem); } } else if (!isOwnerDeleted && currentCollection == null) { Class<?> propertyClass = cmd.getPropertyType(propertyName).getReturnedClass(); if (Set.class.isAssignableFrom(propertyClass)) { currentCollection = Collections.EMPTY_SET; } else if (List.class.isAssignableFrom(propertyClass)) { currentCollection = Collections.EMPTY_LIST; } } } } else if (Map.class.isAssignableFrom(collection.getClass())) { if (!isOwnerDeleted && currentCollection == null) { currentCollection = Collections.EMPTY_MAP; } } else { //TODO: Handle other persistent collections types e.g bags } if (!isOwnerDeleted) { handleUpdatedCollection(currentCollection, collection, owningObject, role); } } } }
From source file:org.apache.jackrabbit.core.state.ChildNodeEntries.java
/** * Ensures that the {@link #nameMap} and {@link #entries} map are * modifiable.//www. j av a 2 s .co m */ private void ensureModifiable() { if (nameMap == Collections.EMPTY_MAP) { nameMap = new HashMap<Name, Object>(); entries = new LinkedMap(); } else if (shared) { entries = (LinkedMap) entries.clone(); nameMap = (Map<Name, Object>) ((HashMap<Name, Object>) nameMap).clone(); for (Iterator it = nameMap.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Object value = entry.getValue(); if (value instanceof ArrayList) { entry.setValue(((ArrayList) value).clone()); } } shared = false; } }
From source file:com.useekm.indexing.elasticsearch.ElasticSearchIndexerSettings.java
@SuppressWarnings("unchecked") //EMPTY_MAP public Map<String, String> getAnalyzers() { return analyzers == null ? (Map<String, String>) Collections.EMPTY_MAP : Collections.unmodifiableMap(analyzers); }
From source file:org.apache.jackrabbit.core.state.ChildNodeEntries.java
/** * Ensures that the {@link #nameMap} and {@link #entries} map are * modifiable./*from w w w . jav a2 s . co m*/ */ private void ensureModifiable() { if (nameMap == Collections.EMPTY_MAP) { nameMap = new HashMap(); entries = new LinkedMap(); } else if (shared) { entries = (LinkedMap) entries.clone(); nameMap = (Map) ((HashMap) nameMap).clone(); for (Iterator it = nameMap.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Object value = entry.getValue(); if (value instanceof ArrayList) { entry.setValue(((ArrayList) value).clone()); } } shared = false; } }
From source file:org.apache.geode.management.internal.cli.commands.ConfigCommandsDUnitTest.java
@Test public void testAlterRuntimeConfig() throws Exception { final String controller = "controller"; String directory = this.temporaryFolder.newFolder(controller).getAbsolutePath(); String statFilePath = new File(directory, "stat.gfs").getAbsolutePath(); setUpJmxManagerOnVm0ThenConnect(null); Properties localProps = new Properties(); localProps.setProperty(NAME, controller); localProps.setProperty(LOG_LEVEL, "error"); getSystem(localProps);//from www .j a v a 2 s . c o m final GemFireCacheImpl cache = (GemFireCacheImpl) getCache(); final DistributionConfig config = cache.getSystem().getConfig(); CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__MEMBER, controller); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "info"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, statFilePath); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true"); csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10"); CommandResult cmdResult = executeCommand(csb.getCommandString()); String resultString = commandResultToString(cmdResult); getLogWriter().info("Result\n"); getLogWriter().info(resultString); assertEquals(true, cmdResult.getStatus().equals(Status.OK)); assertEquals(LogWriterImpl.INFO_LEVEL, config.getLogLevel()); assertEquals(50, config.getLogFileSizeLimit()); assertEquals(32, config.getArchiveDiskSpaceLimit()); assertEquals(2000, config.getStatisticSampleRate()); assertEquals("stat.gfs", config.getStatisticArchiveFile().getName()); assertEquals(true, config.getStatisticSamplingEnabled()); assertEquals(10, config.getLogDiskSpaceLimit()); CommandProcessor commandProcessor = new CommandProcessor(); Result result = commandProcessor.createCommandStatement("alter runtime", Collections.EMPTY_MAP).process(); }
From source file:org.geotools.data.wfs.v1_1_0.WFS_1_1_0_Protocol.java
/** * @throws IOException//from w w w . j a va2 s .com * @see WFSProtocol#describeFeatureTypeGET(String, String) */ public WFSResponse describeFeatureTypeGET(String typeName, String outputFormat) throws IOException { if (!supportsOperation(DESCRIBE_FEATURETYPE, false)) { throw new UnsupportedOperationException( "The server does not support DescribeFeatureType for HTTP method GET"); } URL url = getDescribeFeatureTypeURLGet(typeName, outputFormat); WFSResponse response = issueGetRequest(null, url, Collections.EMPTY_MAP); return response; }
From source file:eu.openanalytics.rsb.RestJobsITCase.java
@SuppressWarnings("unchecked") @Test//from ww w. j av a 2 s . com public void submitMultipartValidZipJobAsOctetStream() throws Exception { final String applicationName = newTestApplicationName(); final Document resultDoc = doSubmitValidMultipartJob(applicationName, Collections.singletonList(new UploadedFile("r-job-sample.zip", "application/octet-stream")), Collections.EMPTY_MAP); final String resultUri = getResultUri(resultDoc); ponderRetrieveAndValidateZipResult(resultUri); }