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


Java Instance类代码示例

本文整理汇总了Java中javax.enterprise.inject.Instance的典型用法代码示例。如果您正苦于以下问题:Java Instance类的具体用法?Java Instance怎么用?Java Instance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Instance类属于javax.enterprise.inject包,在下文中一共展示了Instance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mockEndpointFromUri

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Uri("")
@Produces
@Typed(MockEndpoint.class)
// Qualifiers are dynamically added in CdiCamelExtension
private static MockEndpoint mockEndpointFromUri(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
    Uri uri = getQualifierByType(ip, Uri.class).get();
    try {
        CamelContext context = uri.context().isEmpty()
            ? selectContext(ip, instance, extension)
            : selectContext(uri.context(), instance);
        return context.getEndpoint(uri.value(), MockEndpoint.class);
    } catch (Exception cause) {
        throw new InjectionException("Error injecting mock endpoint annotated with " + uri
            + " into " + ip, cause);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CdiCamelFactory.java

示例2: filter

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    Instance<Object> instance = CDI.current();
    User user = instance.select(User.class).get();

    List<AccountRole> roles = user.getAccountRoles();
    if (Arrays.stream(permissions.roles()).anyMatch(roles::contains)) {
        return;
    }

    Permission permission = instance.select(permissions.value()).get();
    if (permission.test(requestContext)) {
        return;
    }

    throw new ForbiddenException();
}
 
开发者ID:backpaper0,项目名称:sealion,代码行数:18,代码来源:PermissionProvider.java

示例3: prepare

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Before
public void prepare() {
    ZonedDateTimeAdapter adapter = new ZonedDateTimeAdapter();

    Instance<BoundStatement> getByIdStatement = mock(Instance.class);
    when(getByIdStatement.get())
            .thenReturn(new BoundStatement(session.prepare(BoundStatements.GET_BY_ID.getValue())));

    Instance<BoundStatement> createStatement = mock(Instance.class);
    when(createStatement.get())
            .thenReturn(new BoundStatement(session.prepare(BoundStatements.CREATE.getValue())));

    tokenService = new TokenService();
    tokenService.session = session;
    tokenService.zonedDateTimeAdapter = adapter;
    tokenService.stmtGetById = getByIdStatement;
    tokenService.stmtCreate = createStatement;
}
 
开发者ID:jpkrohling,项目名称:secret-store,代码行数:19,代码来源:TokenTest.java

示例4: PreferenceStoreImpl

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Inject
public PreferenceStoreImpl(final PreferenceStorage storage,
                           final PreferenceScopeFactory scopeFactory,
                           @Customizable final PreferenceScopeResolutionStrategy defaultScopeResolutionStrategy,
                           final Instance<PreferenceScopeResolutionStrategy> preferenceScopeResolutionStrategy,
                           final InjectionPoint ip) {
    this.storage = storage;
    this.scopeFactory = scopeFactory;

    if (preferenceScopeResolutionStrategy.isUnsatisfied()) {
        if (ip != null) {
            String componentKey = null;
            Annotation annotation = ip.getAnnotated().getAnnotation(ComponentKey.class);
            if (annotation != null) {
                componentKey = ((ComponentKey) annotation).value();
            }

            this.defaultScopeResolutionStrategy = new DefaultPreferenceScopeResolutionStrategy(scopeFactory,
                                                                                               componentKey);
        } else {
            this.defaultScopeResolutionStrategy = defaultScopeResolutionStrategy;
        }
    } else {
        this.defaultScopeResolutionStrategy = preferenceScopeResolutionStrategy.get();
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:PreferenceStoreImpl.java

示例5: Row

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Inject
public Row(View view,
           Instance<ComponentColumn> columnInstance,
           Instance<ColumnWithComponents> columnWithComponentsInstance,
           DnDManager dndManager,
           LayoutDragComponentHelper layoutDragComponentHelper,
           Event<ComponentDropEvent> componentDropEvent,
           Event<ComponentRemovedEvent> componentRemovedEvent,
           Event<RowResizeEvent> rowResizeEvent) {

    this.view = view;
    this.columnInstance = columnInstance;
    this.columnWithComponentsInstance = columnWithComponentsInstance;
    this.dndManager = dndManager;
    this.layoutDragComponentHelper = layoutDragComponentHelper;
    this.componentDropEvent = componentDropEvent;
    this.componentRemovedEvent = componentRemovedEvent;
    this.rowResizeEvent = rowResizeEvent;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:20,代码来源:Row.java

示例6: CopyServiceImpl

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Inject
public CopyServiceImpl(@Named("ioStrategy") IOService ioService,
                       User identity,
                       SessionInfo sessionInfo,
                       Instance<CopyHelper> helpers,
                       Event<ResourceCopiedEvent> resourceCopiedEvent,
                       Instance<CopyRestrictor> copyRestrictorBeans,
                       PathNamingService pathNamingService) {
    this.ioService = ioService;
    this.identity = identity;
    this.sessionInfo = sessionInfo;
    this.helpers = helpers;
    this.resourceCopiedEvent = resourceCopiedEvent;
    this.copyRestrictorBeans = copyRestrictorBeans;
    this.pathNamingService = pathNamingService;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:CopyServiceImpl.java

示例7: setup

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Before
public void setup() {
    securityConstraints = mock(Instance.class);
    event1 = generateEvent(new SocialUser("admin"));
    event2 = generateEvent(new SocialUser("dora"));
    events = new ArrayList<>();
    events.add(event1);
    events.add(event2);
    constraint1 = mock(SocialSecurityConstraint.class);
    constraint2 = mock(SocialSecurityConstraint.class);
    when(securityConstraints.iterator()).thenReturn(createSecurityConstraintsIterator());
    socialSecurityConstraintsManager = new SocialSecurityConstraintsManager() {
        @Override
        Instance<SocialSecurityConstraint> getSocialSecurityConstraints() {
            Instance<SocialSecurityConstraint> mock = mock(Instance.class);
            when(mock.iterator()).thenReturn(createSecurityConstraintsIterator());
            return mock;
        }
    };
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:SocialSecurityConstraintsManagerTest.java

示例8: PanelManagerImpl

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Inject
public PanelManagerImpl(
        Event<PlaceGainFocusEvent> placeGainFocusEvent,
        Event<PlaceLostFocusEvent> placeLostFocusEvent,
        Event<PanelFocusEvent> panelFocusEvent,
        Event<SelectPlaceEvent> selectPlaceEvent,
        Event<PlaceMaximizedEvent> placeMaximizedEvent,
        Event<PlaceMinimizedEvent> placeMinimizedEventEvent,
        Event<PlaceHiddenEvent> placeHiddenEvent,
        SyncBeanManager iocManager,
        Instance<PlaceManager> placeManager,
        LayoutSelection layoutSelection,
        BeanFactory beanFactory) {
    this.placeGainFocusEvent = placeGainFocusEvent;
    this.placeLostFocusEvent = placeLostFocusEvent;
    this.panelFocusEvent = panelFocusEvent;
    this.selectPlaceEvent = selectPlaceEvent;
    this.placeMaximizedEvent = placeMaximizedEvent;
    this.placeMinimizedEvent = placeMinimizedEventEvent;
    this.placeHiddenEvent = placeHiddenEvent;
    this.iocManager = iocManager;
    this.placeManager = placeManager;
    this.layoutSelection = layoutSelection;
    this.beanFactory = beanFactory;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:PanelManagerImpl.java

示例9: setupGuvnorM2Repository

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@Before
public void setupGuvnorM2Repository() {
    ArtifactRepositoryPreference pref = mock(ArtifactRepositoryPreference.class);
    when(pref.getGlobalM2RepoDir()).thenReturn("repositories/kie");
    when(pref.isGlobalM2RepoDirEnabled()).thenReturn(true);
    when(pref.isDistributionManagementM2RepoDirEnabled()).thenReturn(true);
    when(pref.isWorkspaceM2RepoDirEnabled()).thenReturn(false);
    WorkspaceNameResolver resolver = mock(WorkspaceNameResolver.class);
    when(resolver.getWorkspaceName()).thenReturn("global");
    ArtifactRepositoryProducer producer = new ArtifactRepositoryProducer(pref,
                                                                         resolver);
    producer.initialize();
    Instance<ArtifactRepository> repositories = new MockInstanceImpl<>(producer.produceLocalRepository(),
                                                                       producer.produceGlobalRepository(),
                                                                       producer.produceDistributionManagementRepository());
    ArtifactRepositoryService factory = new ArtifactRepositoryService(repositories);
    repository = new GuvnorM2Repository(factory);
    repository.init();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:20,代码来源:JarPathTest.java

示例10: getJsTopicMessageControllerFromJsTopicControlsTest

import javax.enterprise.inject.Instance; //导入依赖的package包/类
/**
 * Test of getJsTopicMessageControllerFromJsTopicControls method, of class.
 */
@Test
public void getJsTopicMessageControllerFromJsTopicControlsTest() {
	System.out.println("getJsTopicMessageControllerFromJsTopicControls");
	JsTopicMessageController jtmc = mock(JsTopicMessageController.class);
	Instance select = mock(Instance.class);

	when(topicMessageController.select(any(JsTopicCtrlsAnnotationLiteral.class))).thenReturn(select);
	when(select.isUnsatisfied()).thenReturn(Boolean.TRUE).thenReturn(Boolean.FALSE);
	doReturn(jtmc).when(instance).getJsTopicMessageControllerFromIterable(eq(TOPIC), any(Instance.class));

	JsTopicMessageController result = instance.getJsTopicMessageControllerFromJsTopicControls(TOPIC);
	assertThat(result).isNull();

	result = instance.getJsTopicMessageControllerFromJsTopicControls(TOPIC);
	assertThat(result).isEqualTo(jtmc);
}
 
开发者ID:ocelotds,项目名称:ocelot,代码行数:20,代码来源:MessageControllerManagerTest.java

示例11: checkAccessTopicFromJsTopicControlsTest

import javax.enterprise.inject.Instance; //导入依赖的package包/类
/**
 * Test of checkAccessTopicFromJsTopicAccessControllers method, of class.
 * @throws java.lang.IllegalAccessException
 */
@Test(expected = IllegalAccessException.class)
public void checkAccessTopicFromJsTopicControlsTest() throws IllegalAccessException {
	System.out.println("checkAccessTopicFromJsTopicControls");
	UserContext userContext = mock(UserContext.class);
	Instance instances = mock(Instance.class);
	when(topicAccessController.select(eq(new JsTopicCtrlsAnnotationLiteral()))).thenReturn(instances);
	when(instances.isUnsatisfied()).thenReturn(Boolean.TRUE).thenReturn(Boolean.FALSE);
	doReturn(Boolean.TRUE).doReturn(Boolean.FALSE).doThrow(IllegalAccessException.class).when(instance).checkAccessTopicFromJsTopicAccessControllers(eq(userContext), eq(TOPIC1), eq(instances));
	boolean result = instance.checkAccessTopicFromJsTopicControls(userContext, TOPIC1);
	assertThat(result).isFalse();
	result = instance.checkAccessTopicFromJsTopicControls(userContext, TOPIC1);
	assertThat(result).isTrue();
	result = instance.checkAccessTopicFromJsTopicControls(userContext, TOPIC1);
	assertThat(result).isFalse();
	instance.checkAccessTopicFromJsTopicControls(userContext, TOPIC1);
}
 
开发者ID:ocelotds,项目名称:ocelot,代码行数:21,代码来源:TopicAccessManagerTest.java

示例12: getTestServlet

import javax.enterprise.inject.Instance; //导入依赖的package包/类
protected AbstractLightblueProxyServlet getTestServlet(CloseableHttpClient httpClient,
                                                       LightblueClientConfiguration clientConfig, final String serviceUri,
                                                       ServletConfig servletConfig) throws ServletException {
    Instance<LightblueClientConfiguration> instance = new StubInstance<>(clientConfig);

    AbstractLightblueProxyServlet servlet;
    servlet = new AbstractLightblueProxyServlet(httpClient, instance) {
        @Override
        protected String serviceUriForRequest(HttpServletRequest request) throws ServletException {
            return serviceUri + servicePathForRequest(request);
        }
    ;
    };

    if (servletConfig == null) {
        servlet.init();
    } else {
        servlet.init(servletConfig);
    }

    return servlet;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:23,代码来源:AbstractLightblueProxyServletTest.java

示例13: asCodeGrant

import javax.enterprise.inject.Instance; //导入依赖的package包/类
public AuthorizationCodeGrant asCodeGrant(Instance<AbstractAuthorizationGrant> grantInstance) {
    AuthorizationCodeGrant grant = grantInstance.select(AuthorizationCodeGrant.class).get();
    grant.init(user, client, authenticationTime);

    grant.setAuthorizationCode(new AuthorizationCode(authorizationCodeString, authorizationCodeCreationDate, authorizationCodeExpirationDate));
    grant.setScopes(scopes);
    grant.setGrantId(grantId);
    grant.setSessionDn(sessionDn);
    grant.setCodeChallenge(codeChallenge);
    grant.setCodeChallengeMethod(codeChallengeMethod);
    grant.setAcrValues(acrValues);
    grant.setNonce(nonce);
    grant.setClaims(claims);

    return grant;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:17,代码来源:CacheGrant.java

示例14: testByDir

import javax.enterprise.inject.Instance; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Test
public void testByDir() throws TemplateProcessorException {
	Instance<ProxiedParam<String>> templateDirectory = Mockito.mock(Instance.class);
	ProxiedParam<String> pp = new ProxiedParam<>();
	
	pp.setParam(Paths.get("src/test/resources/templates/").toAbsolutePath().toString());
	
	Mockito.when(templateDirectory.isUnsatisfied()).thenReturn(Boolean.FALSE);
	Mockito.when(templateDirectory.get()).thenReturn(pp);

	TemplateConfigProducer producer = new TemplateConfigProducer(templateDirectory);

	TemplateProcessor p = new TemplateProcessor(producer.produceConfiguration());
	Assert.assertEquals("template val.", p.processTemplate("test2.ftl", null));

}
 
开发者ID:aracrown,项目名称:ara-commons,代码行数:18,代码来源:TemplateProcessorTest.java

示例15: initModules

import javax.enterprise.inject.Instance; //导入依赖的package包/类
/**
 * Initialise all statistics modules that are found in the system
 * @param modules
 */
@Inject
protected void initModules(@Any Instance<StatisticsModule> modules) {
    log.info("Apache Marmotta StatisticsService starting up ...");

    this.modules = new LinkedHashMap<String,StatisticsModule>();

    for(StatisticsModule module : modules) {
        registerModule(module.getName(),module);
    }

    if(configurationService.getBooleanConfiguration("statistics.enabled",false)) {
        enableAll();
    } else {
        disableAll();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:21,代码来源:StatisticsServiceImpl.java


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