List of usage examples for java.util Collections unmodifiableMap
public static <K, V> Map<K, V> unmodifiableMap(Map<? extends K, ? extends V> m)
From source file:org.hydracache.server.httpd.handler.HttpGetMethodHandler.java
public synchronized void setServiceActions(Set<HttpServiceAction> actions) { Map<String, HttpServiceAction> tmpActionMap = new HashMap<String, HttpServiceAction>(); for (HttpServiceAction httpServiceAction : actions) { tmpActionMap.put(httpServiceAction.getName(), httpServiceAction); }//from w ww. j a va2 s . c o m serviceActionMap = Collections.unmodifiableMap(tmpActionMap); }
From source file:com.impetus.kundera.persistence.EntityManagerFactoryBuilder.java
/** * Builds up EntityManagerFactory for a given persistenceUnitName and * overriding properties./* w w w .j a v a 2 s . c om*/ * * @param persistenceUnitName * the persistence unit name * @param override * the override * @return the entity manager factory */ public EntityManagerFactory buildEntityManagerFactory(String persistenceUnitName, Map<Object, Object> override) { Properties props = new Properties(); // Override properties KunderaMetadata kunderaMetadata = KunderaMetadata.INSTANCE; PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata() .getPersistenceUnitMetadata(persistenceUnitName); Properties metadataProperties = puMetadata.getProperties(); // Make sure, it's empty or Unmodifiable override = override == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(override); // Take all from Metadata and override with supplied map for (Map.Entry<Object, Object> entry : metadataProperties.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (override.containsKey(key)) { value = override.get(key); } props.put(key, value); } // Now take all the remaining ones from override for (Map.Entry<Object, Object> entry : override.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (!props.containsKey(key)) { props.put(key, value); } } LOG.info("Building EntityManagerFactory for name: " + puMetadata.getPersistenceUnitName() + ", and Properties:" + props); return new EntityManagerFactoryImpl(puMetadata, props); }
From source file:Fetch5.java
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { StringBuilder cookies = new StringBuilder(); for (Cookie cookie : cookieJar) { // Remove cookies that have expired if (cookie.hasExpired()) { cookieJar.remove(cookie);/*from w ww .j a v a2s . c o m*/ } else if (cookie.matches(uri)) { if (cookies.length() > 0) { cookies.append(", "); } cookies.append(cookie.toString()); } } Map<String, List<String>> cookieMap = new HashMap<String, List<String>>(requestHeaders); if (cookies.length() > 0) { List<String> list = Collections.singletonList(cookies.toString()); cookieMap.put("Cookie", list); } System.out.println("CookieMap: " + cookieMap); return Collections.unmodifiableMap(cookieMap); }
From source file:de.acosix.alfresco.utility.share.surf.StateSafeCssThemeHandler.java
/** * * {@inheritDoc}//from w w w. j ava2 s. c om */ @Override public Map<String, String> getTokenMap() { Map<String, String> cssTokens; // tokensMap keyed by request context which may have different customizations applied to it than previous contexts final RequestContext rc = ThreadLocalRequestContext.getRequestContext(); cssTokens = this.tokensMap.get(rc); if (cssTokens == null) { Theme currentTheme = rc.getTheme(); if (currentTheme == null) { currentTheme = rc.getObjectService().getTheme("default"); } // obtain theme tokens (previously handled by determineThemeTokens in base class) cssTokens = currentTheme.getCssTokens(); this.tokensMap.put(rc, cssTokens); } // do not expose modifiable internal state return Collections.unmodifiableMap(cssTokens); }
From source file:com.amazon.speech.slu.Intent.java
/** * Private constructor used for JSON serialization. * * @param name//from w w w . j a va 2s. c om * the intent name * @param slots * the slots associated with the intent */ private Intent(@JsonProperty("name") final String name, @JsonProperty("slots") final Map<String, Slot> slots) { this.name = name; if (slots != null) { this.slots = Collections.unmodifiableMap(slots); } else { this.slots = Collections.emptyMap(); } }
From source file:edu.cornell.mannlib.oce.startup.StartupListener.java
/** * The System Property must point to a settings file, and we must be able to * read it, and it must be a valid properties file. *//*from w w w . j ava 2 s . co m*/ private void readSettings() throws IOException { String path = System.getProperty(PROPERTY_NAME); if (path == null) { throw new IllegalStateException("No System property for '" + PROPERTY_NAME + "'"); } File file = new File(path); if (!file.exists()) { throw new IllegalStateException("Settings file '" + path + "' does not exist."); } if (!file.isFile()) { throw new IllegalStateException("Settings file '" + path + "' is not a proper file."); } if (!file.canRead()) { throw new IllegalStateException("Cannot read settings file '" + path + "'."); } Properties props = new Properties(); props.load(new FileReader(file)); Map<String, String> map = new HashMap<>(); for (String name : props.stringPropertyNames()) { map.put(name, props.getProperty(name)); } settings = Collections.unmodifiableMap(map); }
From source file:eu.openanalytics.rsb.rservi.CircularRServiUriSelector.java
@PostConstruct public void initialize() { final Map<String, Deque<URI>> newCircularApplicationUris = new HashMap<String, Deque<URI>>(); final Map<String, Set<URI>> applicationSpecificRserviPoolUris = configuration .getApplicationSpecificRserviPoolUris(); if ((applicationSpecificRserviPoolUris != null) && (!applicationSpecificRserviPoolUris.isEmpty())) { for (final Entry<String, Set<URI>> applicationSpecificRserviPoolUri : applicationSpecificRserviPoolUris .entrySet()) {/*from w w w. j av a 2 s.c om*/ newCircularApplicationUris.put(applicationSpecificRserviPoolUri.getKey(), new ArrayDeque<URI>(applicationSpecificRserviPoolUri.getValue())); } } circularApplicationUris = Collections.unmodifiableMap(newCircularApplicationUris); }
From source file:org.metis.cassandra.ClientMapper.java
/** * Return the registered handlers as an unmodifiable Map, with the * registered path as key and the handler object (or handler bean name in * case of a lazy-init handler) as value. * //from www . j a va 2 s . c o m * @see #getDefaultHandler() */ public final Map<String, Object> getHandlerMap() { return Collections.unmodifiableMap(this.handlerMap); }
From source file:com.metamx.emitter.service.AlertEvent.java
public Map<String, Object> getDataMap() { return Collections.unmodifiableMap(dataMap); }
From source file:ru.jts_dev.gameserver.parser.impl.SettingsHolder.java
public final Map<CharacterClass, List<Vector3D>> getInitialStartPoints() { return Collections.unmodifiableMap(initialStartPoints); }