本文整理汇总了Java中com.sun.jersey.core.spi.component.ComponentScope类的典型用法代码示例。如果您正苦于以下问题:Java ComponentScope类的具体用法?Java ComponentScope怎么用?Java ComponentScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentScope类属于com.sun.jersey.core.spi.component包,在下文中一共展示了ComponentScope类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComponentScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
private ComponentScope getComponentScope(Key<?> key, Injector i) {
return i.getBinding(key).acceptScopingVisitor(new BindingScopingVisitor<ComponentScope>() {
@Override
public ComponentScope visitEagerSingleton() {
return ComponentScope.Singleton;
}
@Override
public ComponentScope visitScope(Scope theScope) {
ComponentScope cs = scopeMap.get(theScope);
return (cs != null) ? cs : ComponentScope.Undefined;
}
@Override
public ComponentScope visitScopeAnnotation(Class scopeAnnotation) {
// This method is not invoked for Injector bindings
throw new UnsupportedOperationException();
}
@Override
public ComponentScope visitNoScoping() {
return ComponentScope.PerRequest;
}
});
}
示例2: getters
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Test
public void getters() {
UserProvider up = new UserProvider();
assertEquals(up.getScope(), ComponentScope.PerRequest);
assertEquals(up.getInjectable(null, null, Principal.class), up);
assertNull(up.getInjectable(null, null, String.class));
}
示例3: createScopeMap
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public Map<Scope, ComponentScope> createScopeMap() {
Map<Scope, ComponentScope> m = super.createScopeMap();
m.put(ServletScopes.REQUEST, ComponentScope.PerRequest);
return m;
}
示例4: getComponentProvider
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public IoCComponentProvider getComponentProvider(ComponentContext cc, Class<?> clazz) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "getComponentProvider({0})", clazz.getName());
}
Key<?> key = Key.get(clazz);
Injector i = findInjector(key);
// If there is no explicit binding
if (i == null) {
// If @Inject is explicitly declared on constructor
if (isGuiceConstructorInjected(clazz)) {
try {
// If a binding is possible
if (injector.getBinding(key) != null) {
LOGGER.log(Level.INFO, "Binding {0} to GuiceInstantiatedComponentProvider", clazz.getName());
return new GuiceInstantiatedComponentProvider(injector, clazz);
}
} catch (ConfigurationException e) {
// The class cannot be injected.
// For example, the constructor might contain parameters that
// cannot be injected
LOGGER.log(Level.SEVERE, "Cannot bind " + clazz.getName(), e);
// Guice should have picked this up. We fail-fast to prevent
// Jersey from trying to handle injection.
throw e;
}
// If @Inject is declared on field or method
} else if (isGuiceFieldOrMethodInjected(clazz)) {
LOGGER.log(Level.INFO, "Binding {0} to GuiceInjectedComponentProvider", clazz.getName());
return new GuiceInjectedComponentProvider(injector);
} else {
return null;
}
}
ComponentScope componentScope = getComponentScope(key, i);
LOGGER.log(Level.INFO, "Binding {0} to GuiceManagedComponentProvider with the scope \"{1}\"",
new Object[]{clazz.getName(), componentScope});
return new GuiceManagedComponentProvider(i, componentScope, clazz);
}
示例5: createScopeMap
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
/**
* Maps a Guice scope to a Jersey scope.
*
* @return the map
*/
public Map<Scope, ComponentScope> createScopeMap() {
Map<Scope, ComponentScope> result = new HashMap<Scope, ComponentScope>();
result.put(Scopes.SINGLETON, ComponentScope.Singleton);
result.put(Scopes.NO_SCOPE, ComponentScope.PerRequest);
return result;
}
示例6: getScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
return ComponentScope.PerRequest;
}
示例7: getScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
return ComponentScope.PerRequest;
}
示例8: getScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
return ComponentScope.PerRequest;
}
示例9: getScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
return ComponentScope.Undefined;
}
示例10: getScope
import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
return ComponentScope.Singleton;
}