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


Java PostConstruct类代码示例

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


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

示例1: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {
  try {
    sendEmailRequestClazz = Class.forName("com.ctrip.framework.apolloctripservice.emailservice.SendEmailRequest");

    setSendCode = sendEmailRequestClazz.getMethod("setSendCode", String.class);
    setBodyTemplateID = sendEmailRequestClazz.getMethod("setBodyTemplateID", Integer.class);
    setSender = sendEmailRequestClazz.getMethod("setSender", String.class);
    setBodyContent = sendEmailRequestClazz.getMethod("setBodyContent", String.class);
    setRecipient = sendEmailRequestClazz.getMethod("setRecipient", List.class);
    setSubject = sendEmailRequestClazz.getMethod("setSubject", String.class);
    setIsBodyHtml = sendEmailRequestClazz.getMethod("setIsBodyHtml", Boolean.class);
    setCharset = sendEmailRequestClazz.getMethod("setCharset", String.class);
    setExpiredTime = sendEmailRequestClazz.getMethod("setExpiredTime", Calendar.class);
    setAppID = sendEmailRequestClazz.getMethod("setAppID", Integer.class);

  } catch (Throwable e) {
    logger.error("init email request build failed", e);
    Tracer.logError("init email request build failed", e);
  }
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:22,代码来源:CtripEmailRequestBuilder.java

示例2: initApplication

import javax.annotation.PostConstruct; //导入依赖的package包/类
/**
 * Initializes BuenOjo.
 * <p/>
 * Spring profiles can be configured with a program arguments --spring.profiles.active=your-active-profile
 * <p/>
 * <p>
 * You can find more information on how profiles work with JHipster on <a href="http://jhipster.github.io/profiles.html">http://jhipster.github.io/profiles.html</a>.
 * </p>
 */
@PostConstruct
public void initApplication() throws IOException {
    if (env.getActiveProfiles().length == 0) {
        log.warn("No Spring profile configured, running with default configuration");
    } else {
        log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
        Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
        if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_PRODUCTION)) {
            log.error("You have misconfigured your application! " +
                "It should not run with both the 'dev' and 'prod' profiles at the same time.");
        }
        if (activeProfiles.contains(Constants.SPRING_PROFILE_PRODUCTION) && activeProfiles.contains(Constants.SPRING_PROFILE_FAST)) {
            log.error("You have misconfigured your application! " +
                "It should not run with both the 'prod' and 'fast' profiles at the same time.");
        }
        if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_CLOUD)) {
            log.error("You have misconfigured your application! " +
                "It should not run with both the 'dev' and 'cloud' profiles at the same time.");
        }
    }
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:31,代码来源:Application.java

示例3: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
private void init() {
    callbackUrl = HttpURL.build(apiDomain).append("/hooks/sync").toString();

    taskExecutor.execute(() -> {
        try {
            LOGGER.trace("Start to init agent list in thread: " + Thread.currentThread().getName());
            load();

            List<Agent> agents = agentService.list();
            for (Agent agent : agents) {
                if (agent.getStatus() == AgentStatus.OFFLINE) {
                    continue;
                }
                register(agent.getPath());
            }
        } catch (Throwable e) {
            LOGGER.warn(e.getMessage());
        }
    });
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:22,代码来源:SyncServiceImpl.java

示例4: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {
	heroes = new HashMap<>();
	
	LOGGER.info("Building heroes library");

	String heroStatsJson = steamClient.getResponseFromOpenDota("heroStats");
	Hero[] stats         = new Gson().fromJson(heroStatsJson, Hero[].class);

	for(Hero hero : stats) {
		try {
			heroes.put(hero.getLocalized_name().toLowerCase(), hero);
			LOGGER.info("Added hero : {}", hero.getLocalized_name());
		} catch(Exception e) {
			LOGGER.info("Error adding hero {}", e);
		}
	}
}
 
开发者ID:cool-mist,项目名称:DiscordConvenienceBot,代码行数:19,代码来源:HeroesLibrary.java

示例5: getRegexPassages

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public Pattern getRegexPassages() {
    if (regexPassages == null) {
        Set<String> shortcutsBooks = bibleCsvRepository.findBible(bibleCsvRepository.getDefaultBible())
                .getBooks()
                .stream()
                .map(BookDTO::getShortcuts)
                .reduce((strings, strings2) -> Stream.concat(strings.stream(), strings2.stream()).collect(Collectors.toSet()))
                .orElse(new HashSet<>());

        regexPassages = Pattern.compile("([a-zA-Z0-9])?("
                + shortcutsBooks.stream().reduce((s, s2) -> s + "|" + s2).orElse("")
                + ")\\.?\\s*(\\d{1,3})(?:\\s*[\\:\\s|\\,\\s]\\s*(\\d{1,3})(?:\\s*[\\-\\s]\\s*(\\d{1,3}))?)?");
    }
    return regexPassages;
}
 
开发者ID:sscholl,项目名称:biblebot,代码行数:17,代码来源:QueryParserService.java

示例6: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {
  properties.put("bootstrap.servers", "127.0.0.1:9092");
  properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  properties.put("acks", "-1");
  properties.put("retries", 0);
  properties.put("batch.size", 16384);
  properties.put("linger.ms", 0);
  properties.put("buffer.memory", 33554432);
  try {
    this.producer = new KafkaProducer<>(properties);
  } catch (Exception e) {
    log.error("Failed to start kafka producer", e);
    throw new RuntimeException(e);
  }
  log.info("Kafka Producer is started....");
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:19,代码来源:MsgProducer.java

示例7: start

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public final void start() {
    init();
    final String scheduledName = "scheduled_" + getName();
    ExecutorService executorService = Executors.newSingleThreadExecutor(ThreadUtils.newDaemonThreadFactory(scheduledName,
            Thread.MIN_PRIORITY));

    executorService.execute(new Runnable() {
        @Override
        public void run() {
            while (true) {
                if (!isFrequently()) {
                    ThreadUtils.sleepSeconds((long) (3600 * (Math.random() + 1)));
                }
                try {
                    AbstractIpAgentCallable.this.run();
                } catch (Exception e) {
                    LOGGER.error(" scheduledExecutorService  scheduledName {} error...", scheduledName, e);
                }
                ThreadUtils.sleepSeconds((long) (getIntervalSeconds() * (Math.random() + 1)));
            }
        }
    });
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:25,代码来源:AbstractIpAgentCallable.java

示例8: setup

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    MultipleChoiceSubjectSpecificResource multipleChoiceSubjectSpecificResource = new MultipleChoiceSubjectSpecificResource();
    ReflectionTestUtils.setField(multipleChoiceSubjectSpecificResource, "multipleChoiceSubjectSpecificRepository", multipleChoiceSubjectSpecificRepository);
    this.restMultipleChoiceSubjectSpecificMockMvc = MockMvcBuilders.standaloneSetup(multipleChoiceSubjectSpecificResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:10,代码来源:MultipleChoiceSubjectSpecificResourceIntTest.java

示例9: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {

	applications = this.appService.findAll();

	// Title
	Label title = new Label("<h2>Applications</h2>", ContentMode.HTML);

	initApplicationsGrid();

	// Build layout
	VerticalLayout leftLayout = new VerticalLayout(title, grid);
	leftLayout.setMargin(false);
	this.addComponent(leftLayout);

	// Center align layout
	this.setWidth("100%");
	this.setMargin(new MarginInfo(false, true));
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:20,代码来源:ApplicationsPage.java

示例10: buildDatabase

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
private void buildDatabase() {
	users.forEach(user -> {
		try {
			processUser(user);
		} catch (IllegalArgumentException e) {
			throw new IllegalArgumentException("error while processing user " + user.email, e);
		}
	});
}
 
开发者ID:to2mbn,项目名称:yggdrasil-mock,代码行数:11,代码来源:YggdrasilDatabase.java

示例11: initialize

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
private void initialize() {
	add(createPanel());
	// addButtonHandlers();
	/**
	 * Es necesario mostrar durante un instante el diálogo para que la
	 * configuración del tamaño y del grid se realice correctamente
	 */
	this.show();
	this.hide();
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:12,代码来源:LayerEditDialog.java

示例12: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {
    objectMapper = new ObjectMapper();
    final HttpClientBuilder clientBuilder = HttpClientBuilder.create();
    if (StringUtils.hasText(camundaUser)) {
        final BasicCredentialsProvider provider = new BasicCredentialsProvider();
        provider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(camundaUser, camundaPass));
        clientBuilder.setDefaultCredentialsProvider(provider);
    }
    httpClient = clientBuilder.build();
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:12,代码来源:ExternalTaskRestServiceImpl.java

示例13: generateTestData

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void generateTestData() {
	itemRepository.save(new Item("iPod", 42.0));
	itemRepository.save(new Item("iPod touch", 21.0));
	itemRepository.save(new Item("iPod nano", 1.0));
	itemRepository.save(new Item("Apple TV", 100.0));
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:8,代码来源:ItemTestDataGenerator.java

示例14: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
private void init() {
    kafkaProperties.put("group.id", "order-handler");
    String chef = kafkaProperties.getProperty("chef.topic");

    eventConsumer = new EventConsumer(kafkaProperties, ev -> events.fire(ev), chef);

    mes.execute(eventConsumer);
}
 
开发者ID:PacktPublishing,项目名称:Architecting-Modern-Java-EE-Applications,代码行数:10,代码来源:OrderEventHandler.java

示例15: init

import javax.annotation.PostConstruct; //导入依赖的package包/类
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:28,代码来源:MetricsConfiguration.java


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