|
Java example source code file (ProvisionListenerCallbackStore.java)
The ProvisionListenerCallbackStore.java Java example source code
/**
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.inject.internal;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.inject.Binding;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Stage;
import com.google.inject.spi.ProvisionListener;
import com.google.inject.spi.ProvisionListenerBinding;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
/**
* {@link ProvisionListenerStackCallback} for each key.
*
* @author sameb@google.com (Sam Berlin)
*/
final class ProvisionListenerCallbackStore {
// TODO(sameb): Consider exposing this in the API somehow? Maybe?
// Lots of code often want to skip over the internal stuffs.
private static final Set<Key>> INTERNAL_BINDINGS =
ImmutableSet.of(Key.get(Injector.class), Key.get(Stage.class), Key.get(Logger.class));
private final ImmutableList<ProvisionListenerBinding> listenerBindings;
private final LoadingCache<KeyBinding, ProvisionListenerStackCallback>> cache
= CacheBuilder.newBuilder().build(
new CacheLoader<KeyBinding, ProvisionListenerStackCallback>>() {
public ProvisionListenerStackCallback<?> load(KeyBinding key) {
return create(key.binding);
}
});
ProvisionListenerCallbackStore(List<ProvisionListenerBinding> listenerBindings) {
this.listenerBindings = ImmutableList.copyOf(listenerBindings);
}
/** Returns a new {@link ProvisionListenerStackCallback} for the key.
*/
@SuppressWarnings("unchecked") // the ProvisionListenerStackCallback type always agrees with the passed type
public <T> ProvisionListenerStackCallback
Other Java examples (source code examples)Here is a short list of links related to this Java ProvisionListenerCallbackStore.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.