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;
    }
  }
  /** 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);
  }
  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);
    }
  }
  /** bean included based on a custom expression syntax */
  @Test
  public void includedBasedOnCustomExpressionSyntax() {
    CustomExpressionBasedBean bean =
        BeanProvider.getContextualReference(CustomExpressionBasedBean.class, true);

    Assert.assertNotNull(bean);
  }
Пример #5
0
  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;
  }
  /** bean included in case of project-stage integration-test */
  @Test
  public void includedInCaseOfProjectStageIntegrationTest() {
    IntegrationTestBean integrationTestBean =
        BeanProvider.getContextualReference(IntegrationTestBean.class, true);

    Assert.assertNotNull(integrationTestBean);
  }
 private TransactionBeanStorage getBeanStorage() {
   if (beanStorage == null) {
     synchronized (this) {
       beanStorage = BeanProvider.getContextualReference(TransactionBeanStorage.class);
     }
   }
   return beanStorage;
 }
 private GroupedConversationManager getConversationManager() {
   if (this.conversationManager == null) {
     this.conversationManager =
         BeanProvider.getContextualReference(DeltaSpikeContextExtension.class)
             .getConversationContext();
   }
   return conversationManager;
 }
Пример #9
0
  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);
 }
  /** bean is excluded in any case */
  @Test
  public void excludeWithoutCondition() {
    NoBean noBean = BeanProvider.getContextualReference(NoBean.class, true);

    Assert.assertNull(noBean);
  }
  /** 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);
  }
 public static TransactionHelper getInstance() {
   return BeanProvider.getContextualReference(TransactionHelper.class);
 }
  /** check if this package is included at all */
  @Test
  public void simpleCheckOfBeansInPackage() {
    AlwaysActiveBean testBean = BeanProvider.getContextualReference(AlwaysActiveBean.class, true);

    Assert.assertNotNull(testBean);
  }