Java 类javax.enterprise.inject.New 实例源码

项目:jube    文件:CuratorServiceFactory.java   
@Produces
@Singleton
public CuratorFramework create(@ServiceName("ZOOKEEPER") String url, @New CuratorConfig config) throws IOException, InterruptedException {
    LOG.info("Connecting to ZooKeeper URL: {}", url);
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .connectString(url)
            .connectionTimeoutMs(config.getConnectionTimeOut())
            .sessionTimeoutMs(config.getSessionTimeout())
            .retryPolicy(new RetryNTimes(config.getRetryMax(), config.getRetryInterval()));

    if (!Strings.isNullOrBlank(config.getPassword())) {
        byte[] auth = (DEFAULT_AUTH_USER + ":" + PasswordEncoder.decode(config.getPassword())).getBytes();
        builder = builder.authorization(DEFAULT_AUTH_SCHEME, auth);
    }
    CuratorFramework curatorFramework = builder.build();
    curatorFramework.start();
    return curatorFramework;
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces
@ApplicationScoped
public static IStorage provideStorage(ManagerApiMicroServiceConfig config, @New JpaStorage jpaStorage,
        @New EsStorage esStorage, IPluginRegistry pluginRegistry) {
    IStorage storage;
    if ("jpa".equals(config.getStorageType())) { //$NON-NLS-1$
        storage = initJpaStorage(config, jpaStorage);
    } else if ("es".equals(config.getStorageType())) { //$NON-NLS-1$
        storage = initES(config, esStorage);
    } else {
        try {
            storage = createCustomComponent(IStorage.class, config.getStorageType(),
                    config.getStorageProperties(), pluginRegistry);
        } catch (Throwable t) {
            throw new RuntimeException("Error or unknown storage type: " + config.getStorageType(), t); //$NON-NLS-1$
        }
    }
    return storage;
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces @ApplicationScoped
public static IStorageQuery provideStorageQuery(ManagerApiMicroServiceConfig config, @New JpaStorage jpaStorage,
        @New EsStorage esStorage, IPluginRegistry pluginRegistry) {
    if ("jpa".equals(config.getStorageQueryType())) { //$NON-NLS-1$
        return initJpaStorage(config, jpaStorage);
    } else if ("es".equals(config.getStorageQueryType())) { //$NON-NLS-1$
        return initES(config, esStorage);
    } else {
        try {
            return createCustomComponent(IStorageQuery.class, config.getStorageQueryType(),
                    config.getStorageQueryProperties(), pluginRegistry);
        } catch (Throwable t) {
            throw new RuntimeException("Error or unknown storage query type: " + config.getStorageType(), t); //$NON-NLS-1$
        }
    }
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces @ApplicationScoped
public static IMetricsAccessor provideMetricsAccessor(ManagerApiMicroServiceConfig config,
        @New NoOpMetricsAccessor noopMetrics, @New ESMetricsAccessor esMetrics, IPluginRegistry pluginRegistry) {
    IMetricsAccessor metrics;
    if ("es".equals(config.getMetricsType())) { //$NON-NLS-1$
        metrics = esMetrics;
    } else {
        try {
            metrics = createCustomComponent(IMetricsAccessor.class, config.getMetricsType(),
                    config.getMetricsProperties(), pluginRegistry);
        } catch (Throwable t) {
            System.err.println("Unknown apiman metrics accessor type: " + config.getMetricsType()); //$NON-NLS-1$
            metrics = noopMetrics;
        }
    }
    return metrics;
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces @ApplicationScoped
public static IApiKeyGenerator provideApiKeyGenerator(ManagerApiMicroServiceConfig config,
        IPluginRegistry pluginRegistry, @New UuidApiKeyGenerator uuidApiKeyGen) {
    IApiKeyGenerator apiKeyGenerator;
    String type = config.getApiKeyGeneratorType();
    if ("uuid".equals(type)) { //$NON-NLS-1$
        apiKeyGenerator = uuidApiKeyGen;
    } else {
        try {
            apiKeyGenerator = createCustomComponent(IApiKeyGenerator.class, type,
                    config.getApiKeyGeneratorProperties(), pluginRegistry);
        } catch (Exception e) {
            System.err.println("Unknown apiman API key generator type: " + type); //$NON-NLS-1$
            System.err.println("Automatically falling back to UUID style API Keys."); //$NON-NLS-1$
            apiKeyGenerator = uuidApiKeyGen;
        }
    }
    return apiKeyGenerator;
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static IStorage provideStorage(WarApiManagerConfig config, @New JpaStorage jpaStorage,
        @New EsStorage esStorage, IPluginRegistry pluginRegistry) {
    IStorage storage;
    if ("jpa".equals(config.getStorageType())) { //$NON-NLS-1$
        storage = initJpaStorage(config, jpaStorage);
    } else if ("es".equals(config.getStorageType())) { //$NON-NLS-1$
        storage = initEsStorage(config, esStorage);
    } else {
        try {
            storage = createCustomComponent(IStorage.class, config.getStorageType(),
                    config.getStorageProperties(), pluginRegistry);
        } catch (Throwable t) {
            throw new RuntimeException("Error or unknown storage type: " + config.getStorageType(), t); //$NON-NLS-1$
        }
    }
    return storage;
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static IStorageQuery provideStorageQuery(WarApiManagerConfig config, @New JpaStorage jpaStorage,
        @New EsStorage esStorage, IStorage storage, IPluginRegistry pluginRegistry) {
    if ("jpa".equals(config.getStorageType())) { //$NON-NLS-1$
        return initJpaStorage(config, jpaStorage);
    } else if ("es".equals(config.getStorageType())) { //$NON-NLS-1$
        return initEsStorage(config, esStorage);
    } else if (storage != null && storage instanceof IStorageQuery) {
        return (IStorageQuery) storage;
    } else {
        try {
            return createCustomComponent(IStorageQuery.class, config.getStorageQueryType(),
                    config.getStorageQueryProperties(), pluginRegistry);
        } catch (Throwable t) {
            throw new RuntimeException("Error or unknown storage query type: " + config.getStorageType(), t); //$NON-NLS-1$
        }
    }
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static IMetricsAccessor provideMetricsAccessor(WarApiManagerConfig config,
        @New NoOpMetricsAccessor noopMetrics, @New ESMetricsAccessor esMetrics, IPluginRegistry pluginRegistry) {
    IMetricsAccessor metrics;
    if ("es".equals(config.getMetricsType())) { //$NON-NLS-1$
        metrics = esMetrics;
    } else if (config.getMetricsType().equals(ESMetricsAccessor.class.getName())) {
        metrics = esMetrics;
    } else if ("noop".equals(config.getMetricsType())) { //$NON-NLS-1$
        metrics = noopMetrics;
    } else if (config.getMetricsType().equals(NoOpMetricsAccessor.class.getName())) {
        metrics = noopMetrics;
    } else {
        try {
            metrics = createCustomComponent(IMetricsAccessor.class, config.getMetricsType(),
                    config.getMetricsProperties(), pluginRegistry);
        } catch (Throwable t) {
            System.err.println("Unknown apiman metrics accessor type: " + config.getMetricsType()); //$NON-NLS-1$
            metrics = noopMetrics;
        }
    }
    return metrics;
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static IApiKeyGenerator provideApiKeyGenerator(WarApiManagerConfig config,
        @New UuidApiKeyGenerator uuidApiKeyGen, IPluginRegistry pluginRegistry) {
    IApiKeyGenerator apiKeyGenerator;
    String type = config.getApiKeyGeneratorType();
    if ("uuid".equals(type)) { //$NON-NLS-1$
        apiKeyGenerator = uuidApiKeyGen;
    } else {
        try {
            apiKeyGenerator = createCustomComponent(IApiKeyGenerator.class, type,
                    config.getApiKeyGeneratorProperties(), pluginRegistry);
        } catch (Exception e) {
            System.err.println("Unknown apiman API key generator type: " + type); //$NON-NLS-1$
            System.err.println("Automatically falling back to UUID style API Keys."); //$NON-NLS-1$
            apiKeyGenerator = uuidApiKeyGen;
        }
    }
    return apiKeyGenerator;
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@DAO
@SuppressWarnings("unchecked")
public <T> IDAO<T> produceDaoWithIntegerId(@TransientReference InjectionPoint ip,
                                           @TransientReference BeanManager bm,
                                           @New @TransientReference IDAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (IDAOFactory<T>) f);
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@DAO
@SuppressWarnings("unchecked")
public <T> LDAO<T> produceDaoWithLongId(@TransientReference InjectionPoint ip,
                                        @TransientReference BeanManager bm,
                                        @New @TransientReference LDAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (LDAOFactory<T>) f);
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@Default
@SuppressWarnings("unchecked")
public <T> IDAO<T> produceUnqualifiedDaoWithIntegerId(@TransientReference InjectionPoint ip,
                                                      @TransientReference BeanManager bm,
                                                      @New @TransientReference IDAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (IDAOFactory<T>) f);
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@Default
@SuppressWarnings("unchecked")
public <T> LDAO<T> produceUnqualifiedDaoWithLongId(@TransientReference InjectionPoint ip,
                                                   @TransientReference BeanManager bm,
                                                   @New @TransientReference LDAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (LDAOFactory<T>) f);
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@DAO
@SuppressWarnings("unchecked")
public <T> DaoWithoutId<T> produceDaoWithoutId(@TransientReference InjectionPoint ip,
                                               @TransientReference BeanManager bm,
                                               @New @TransientReference DAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (DAOFactory<T>) f);
}
项目:javaee-samples    文件:DaoProducer.java   
@Produces
@Dependent
@Default
@SuppressWarnings("unchecked")
public <T> DaoWithoutId<T> produceUnqualifiedDaoWithoutId(@TransientReference InjectionPoint ip,
                                                          @TransientReference BeanManager bm,
                                                          @New @TransientReference DAOFactory f) {
    return buildDaoWithOneGenericType(ip, bm, (DAOFactory<T>) f);
}
项目:actframework    文件:ParamValueLoaderService.java   
private static ScopeCacheSupport scopeCacheSupport(Annotation[] annotations) {
    if (null != filter(annotations, RequestScoped.class) ||
            null != filter(annotations, org.osgl.inject.annotation.RequestScoped.class)) {
        return RequestScope.INSTANCE;
    } else if (sessionScoped(annotations)) {
        return SessionScope.INSTANCE;
    } else if (null != filter(annotations, Dependent.class) ||
            null != filter(annotations, New.class)) {
        return DependentScope.INSTANCE;
    }
    // Default to Request Scope
    return RequestScope.INSTANCE;
}
项目:jube    文件:ZooKeeperUrlProducer.java   
@Produces
@ServiceName("ZOOKEEPER")
public String create(@New ZooKeeperServerConfig serverConfig) throws IOException, InterruptedException {
    String providedUrl = Systems.getEnvVarOrSystemProperty("ZOOKEEPER_URL", "");
    if (Strings.isNullOrEmpty(providedUrl)) {
        ZooKeeperServerFactory factory =  new ZooKeeperServerFactory(serverConfig);
        return factory.getZooKeeperUrl();
    } else {
        return providedUrl;
    }
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces @ApplicationScoped
public static IDataEncrypter provideDataEncrypter(ManagerApiMicroServiceConfig config,
        IPluginRegistry pluginRegistry, @New DefaultDataEncrypter defaultEncrypter) {
    try {
        IDataEncrypter encrypter = createCustomComponent(IDataEncrypter.class, config.getDataEncrypterType(),
                config.getDataEncrypterProperties(), pluginRegistry, defaultEncrypter);
        CurrentDataEncrypter.instance = encrypter;
        return encrypter;
    } catch (Throwable t) {
        throw new RuntimeException("Error or unknown data encrypter type: " + config.getDataEncrypterType(), t); //$NON-NLS-1$
    }
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static ISecurityContext provideSecurityContext(WarApiManagerConfig config,
        @New DefaultSecurityContext defaultSC, @New KeycloakSecurityContext keycloakSC) {
    if ("default".equals(config.getSecurityContextType())) { //$NON-NLS-1$
        return defaultSC;
    } else if ("keycloak".equals(config.getSecurityContextType())) { //$NON-NLS-1$
        return keycloakSC;
    } else {
        throw new RuntimeException("Unknown security context type: " + config.getSecurityContextType()); //$NON-NLS-1$
    }
}
项目:apiman    文件:WarCdiFactory.java   
@Produces @ApplicationScoped
public static IDataEncrypter provideDataEncrypter(@New DefaultDataEncrypter defaultEncrypter,
        WarApiManagerConfig config, IPluginRegistry pluginRegistry) {
    try {
        IDataEncrypter encrypter = createCustomComponent(IDataEncrypter.class, config.getDataEncrypterType(),
                config.getDataEncrypterProperties(), pluginRegistry, defaultEncrypter);
        CurrentDataEncrypter.instance = encrypter;
        return encrypter;
    } catch (Throwable t) {
        throw new RuntimeException("Error or unknown data encrypter type: " + config.getDataEncrypterType(), t); //$NON-NLS-1$
    }
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static IStorage provideStorage(@New JpaStorage jpaStorage, @New EsStorage esStorage) {
    TestType testType = ManagerTestUtils.getTestType();
    if (testType == TestType.jpa) {
        return jpaStorage;
    } else if (testType == TestType.es) {
        esStorage.initialize();
        return new TestEsStorageWrapper(ManagerApiTestServer.ES_CLIENT, esStorage);
    } else {
        throw new RuntimeException("Unexpected test type: " + testType);
    }
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static IStorageQuery provideStorageQuery(@New JpaStorage jpaStorage, @New EsStorage esStorage) {
    TestType testType = ManagerTestUtils.getTestType();
    if (testType == TestType.jpa) {
        return jpaStorage;
    } else if (testType == TestType.es) {
        esStorage.initialize();
        return new TestEsStorageQueryWrapper(ManagerApiTestServer.ES_CLIENT, esStorage);
    } else {
        throw new RuntimeException("Unexpected test type: " + testType);
    }
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static IMetricsAccessor provideMetricsAccessor(@New TestMetricsAccessor testMetrics, @New ESMetricsAccessor esMetrics) {
    boolean enableESMetrics = "true".equals(System.getProperty("apiman-test.es-metrics", "false"));
    if (enableESMetrics) {
        return esMetrics;
    } else {
        return testMetrics;
    }
}
项目:standards.jsr352.jbatch    文件:WeldArtifactFactoryBatchlet.java   
@Produces
@Named("weldArtifactFactoryBatchlet")
public WeldArtifactFactoryBatchlet produce(final @New WeldArtifactFactoryBatchlet that) {
    produced = true;
    return that;
}
项目:apiman    文件:ManagerApiMicroServiceCdiFactory.java   
@Produces @ApplicationScoped
public static ISecurityContext provideSecurityContext(@New DefaultSecurityContext defaultSC) {
    return defaultSC;
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static ISecurityContext provideSecurityContext(@New DefaultSecurityContext defaultSC) {
    return defaultSC;
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static IApiKeyGenerator provideApiKeyGenerator(@New UuidApiKeyGenerator uuidApiKeyGen) {
    return uuidApiKeyGen;
}
项目:apiman    文件:TestCdiFactory.java   
@Produces @ApplicationScoped
public static IDataEncrypter provideDataEncrypter(@New DefaultDataEncrypter defaultEncrypter) {
    CurrentDataEncrypter.instance = defaultEncrypter;
    return defaultEncrypter;
}
项目:deltaspike    文件:NewLiteral.java   
public NewLiteral()
{
    this(New.class);
}