当前位置: 首页>>代码示例>>Java>>正文


Java ComponentScope类代码示例

本文整理汇总了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;
        }
    });
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:26,代码来源:GuiceComponentProviderFactory.java

示例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));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:8,代码来源:TestUserProvider.java

示例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;
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:8,代码来源:GuiceContainer.java

示例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);
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:40,代码来源:GuiceComponentProviderFactory.java

示例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;
}
 
开发者ID:rridgley1,项目名称:agon,代码行数:12,代码来源:GuiceComponentProviderFactory.java

示例6: getScope

import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
  return ComponentScope.PerRequest;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:ParametersProvider.java

示例7: getScope

import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
	return ComponentScope.PerRequest;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:5,代码来源:BasicAuthenticationProvider.java

示例8: getScope

import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
    return ComponentScope.PerRequest;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:5,代码来源:AuthenticatedSubjectProvider.java

示例9: getScope

import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
    return ComponentScope.Undefined;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:5,代码来源:ModelInjectableProvider.java

示例10: getScope

import com.sun.jersey.core.spi.component.ComponentScope; //导入依赖的package包/类
@Override
public ComponentScope getScope() {
  return ComponentScope.Singleton;
}
 
开发者ID:soulrebel,项目名称:dropwizard-jaxb,代码行数:5,代码来源:ValidatorProvider.java


注:本文中的com.sun.jersey.core.spi.component.ComponentScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。