コード例 #1
0
  private synchronized void init() {
    // switch into paranoia mode
    if (this.initialized == null) {
      this.beanManager = BeanManagerProvider.getInstance().getBeanManager();
      this.jsfModuleConfig =
          BeanProvider.getContextualReference(this.beanManager, JsfModuleConfig.class, false);

      if (ClassDeactivationUtils.isActivated(JsfRequestBroadcaster.class)) {
        this.jsfRequestBroadcaster =
            BeanProvider.getContextualReference(JsfRequestBroadcaster.class, true);
      }

      ViewConfigResolver viewConfigResolver =
          BeanProvider.getContextualReference(ViewConfigResolver.class);

      // deactivate it, if there is no default-error-view available
      this.defaultErrorViewExceptionHandlerActivated =
          viewConfigResolver.getDefaultErrorViewConfigDescriptor() != null
              && ClassDeactivationUtils.isActivated(
                  DefaultErrorViewAwareExceptionHandlerWrapper.class);

      this.bridgeExceptionHandlerActivated =
          ClassDeactivationUtils.isActivated(BridgeExceptionHandlerWrapper.class);

      this.bridgeExceptionQualifier =
          AnnotationInstanceProvider.of(jsfModuleConfig.getExceptionQualifier());

      this.preDestroyViewMapEventFilterMode =
          ClassDeactivationUtils.isActivated(SecurityAwareViewHandler.class);
      this.isNavigationAwareApplicationWrapperActivated =
          ClassDeactivationUtils.isActivated(NavigationHandlerAwareApplication.class);
      this.initialized = true;
    }
  }
コード例 #2
0
  /** beans de-/activated via expressions */
  @Test
  public void excludedIfExpressionMatch() {
    ProdDbBean prodDbBean = BeanProvider.getContextualReference(ProdDbBean.class, true);

    Assert.assertNull(prodDbBean);

    IntegrationTestDbBean integrationTestDbBean =
        BeanProvider.getContextualReference(IntegrationTestDbBean.class, true);

    Assert.assertNotNull(integrationTestDbBean);
  }
コード例 #3
0
  protected void dbUnitSetup() {
    List<EntityManager> entityManagerList =
        BeanProvider.getContextualReferences(EntityManager.class, true, false);
    for (EntityManager entityManager : entityManagerList) {
      if (entityManager.getTransaction().isActive()) {
        em = entityManager;
        break;
      }
    }
    if (em == null) {
      throw new IllegalStateException("Entity Manager == null");
    }

    Connection conn = DbConnectionProvider.unwrap(em);
    if (conn == null) {
      throw new IllegalStateException("Connection == null");
    }
    this.connection = conn;

    try {
      databaseTester = new JdbcConnectionDatabaseTester(connection);
      databaseTester.setOperationListener(new NoOpOperationListener());
      dbUnitConnection = databaseTester.getConnection();
      dbUnitRunner = new DbUnitRunner(dbUnitConnection);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
コード例 #4
0
  /** bean included based on a custom expression syntax */
  @Test
  public void includedBasedOnCustomExpressionSyntax() {
    CustomExpressionBasedBean bean =
        BeanProvider.getContextualReference(CustomExpressionBasedBean.class, true);

    Assert.assertNotNull(bean);
  }
コード例 #5
0
ファイル: CMDBuildUtils.java プロジェクト: ossbase/p1
  public static Webservices getProxy() {

    final JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setServiceClass(Webservices.class);
    SettingsDataProvider settings = BeanProvider.getContextualReference(SettingsDataProvider.class);
    proxyFactory.setAddress(settings.getSetting("cmdbuild_url"));
    Object proxy = proxyFactory.create();

    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.USER, settings.getSetting("cmdbuild_login"));
    outProps.put(
        WSHandlerConstants.PW_CALLBACK_REF,
        new ClientPasswordCallback(settings.getSetting("cmdbuild_pwd")));

    final Client client = ClientProxy.getClient(proxy);
    final Endpoint cxfEndpoint = client.getEndpoint();
    long timeout = 9000000000L;
    if (client != null) {
      HTTPConduit conduit = (HTTPConduit) client.getConduit();
      HTTPClientPolicy policy = new HTTPClientPolicy();
      policy.setConnectionTimeout(timeout);
      policy.setReceiveTimeout(timeout);
      conduit.setClient(policy);
    }
    cxfEndpoint.getOutInterceptors().add(new WSS4JOutInterceptorWOExpire(outProps));

    return (Webservices) proxy;
  }
コード例 #6
0
  /** bean included in case of project-stage integration-test */
  @Test
  public void includedInCaseOfProjectStageIntegrationTest() {
    IntegrationTestBean integrationTestBean =
        BeanProvider.getContextualReference(IntegrationTestBean.class, true);

    Assert.assertNotNull(integrationTestBean);
  }
コード例 #7
0
 private TransactionBeanStorage getBeanStorage() {
   if (beanStorage == null) {
     synchronized (this) {
       beanStorage = BeanProvider.getContextualReference(TransactionBeanStorage.class);
     }
   }
   return beanStorage;
 }
コード例 #8
0
 private GroupedConversationManager getConversationManager() {
   if (this.conversationManager == null) {
     this.conversationManager =
         BeanProvider.getContextualReference(DeltaSpikeContextExtension.class)
             .getConversationContext();
   }
   return conversationManager;
 }
コード例 #9
0
ファイル: Smokestack.java プロジェクト: karlkilden/smokestack
  public static void main(String[] args) {

    CdiContainer cdiContainer = startContainer();

    BeanProvider.getContextualReference(BirdmanStartup.class).start(args);

    cdiContainer.shutdown();
    LOG.info("shutting down");
  }
コード例 #10
0
 public void logout() {
   log.debug("explicit logout");
   fireLogoutEvent();
   if (isLoggedIn()) {
     unAuthenticate();
     HttpSession session =
         BeanProvider.getContextualReference(
             HttpSession.class, new AnnotationLiteral<DeltaSpike>() {});
     session.invalidate();
     urlUtil.redirectToInternal(urlUtil.home());
   }
 }
コード例 #11
0
  @Override
  public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    String username = authentication.getName();
    String password = (String) authentication.getCredentials();
    UsuarioService usuarioService =
        (UsuarioService) BeanProvider.getContextualReference("usuarioService");
    Usuario user = null;
    try {
      user = usuarioService.login(username, password);

      if (user == null) {
        throw new BadCredentialsException("Erro ao efetuar login: "******"Erro ao efetuar login: " + e.getMessage());
    }
    Collection<? extends GrantedAuthority> authorities = user.getAuthorities();
    return new UsernamePasswordAuthenticationToken(user, password, authorities);
  }
コード例 #12
0
 protected Object getTargetObjectByName(String beanName) {
   return BeanProvider.getContextualReference(beanName, true);
 }
コード例 #13
0
 protected <T> T getTargetObject(Class<T> targetType) {
   return BeanProvider.getContextualReference(targetType, true);
 }
コード例 #14
0
  /** bean is excluded in any case */
  @Test
  public void excludeWithoutCondition() {
    NoBean noBean = BeanProvider.getContextualReference(NoBean.class, true);

    Assert.assertNull(noBean);
  }
コード例 #15
0
  /** bean excluded in case of project-stage integration-test */
  @Test
  public void excludeInCaseOfProjectStageIntegrationTest() {
    StdBean stdBean = BeanProvider.getContextualReference(StdBean.class, true);

    Assert.assertNull(stdBean);
  }
  /** bean included in case of project-stage development */
  @Test
  public void includeInCaseOfProjectStageDevelopment() {
    DevBean devBean = BeanProvider.getContextualReference(DevBean.class, true);

    Assert.assertNotNull(devBean);
  }
コード例 #17
0
 public static TransactionHelper getInstance() {
   return BeanProvider.getContextualReference(TransactionHelper.class);
 }
コード例 #18
0
  /** check if this package is included at all */
  @Test
  public void simpleCheckOfBeansInPackage() {
    AlwaysActiveBean testBean = BeanProvider.getContextualReference(AlwaysActiveBean.class, true);

    Assert.assertNotNull(testBean);
  }