Search in sources :

Example 11 with PostConstruct

use of jakarta.annotation.PostConstruct in project spring-batch by spring-projects.

the class PrometheusConfiguration method init.

@PostConstruct
public void init() {
    pushGateway = new PushGateway(prometheusPushGatewayUrl);
    groupingKey.put(prometheusGroupingKey, prometheusJobName);
    PrometheusMeterRegistry prometheusMeterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    collectorRegistry = prometheusMeterRegistry.getPrometheusRegistry();
    Metrics.globalRegistry.add(prometheusMeterRegistry);
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) PushGateway(io.prometheus.client.exporter.PushGateway) PostConstruct(jakarta.annotation.PostConstruct)

Example 12 with PostConstruct

use of jakarta.annotation.PostConstruct in project helidon by oracle.

the class MpTracingFilter method postConstruct.

/**
 * Post construct method, initialization procedures.
 */
@PostConstruct
public void postConstruct() {
    this.utils = MpTracingHelper.create();
    // use skip pattern first
    Config config = ConfigProvider.getConfig();
    Optional<String> skipPattern = config.getOptionalValue("mp.opentracing.server.skip-pattern", String.class);
    this.skipPatternFunction = skipPattern.map(Pattern::compile).map(pattern -> (Function<String, Boolean>) path -> pattern.matcher(path).matches()).orElse(path -> false);
}
Also used : InvokedResource(io.helidon.jersey.common.InvokedResource) Traced(org.eclipse.microprofile.opentracing.Traced) AbstractTracingFilter(io.helidon.tracing.jersey.AbstractTracingFilter) Context(jakarta.ws.rs.core.Context) Tracer(io.opentracing.Tracer) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) RuntimeType(jakarta.ws.rs.RuntimeType) PostConstruct(jakarta.annotation.PostConstruct) Config(org.eclipse.microprofile.config.Config) Function(java.util.function.Function) Matcher(java.util.regex.Matcher) ContainerRequestContext(jakarta.ws.rs.container.ContainerRequestContext) ConfigProvider(org.eclipse.microprofile.config.ConfigProvider) ConstrainedTo(jakarta.ws.rs.ConstrainedTo) ResourceInfo(jakarta.ws.rs.container.ResourceInfo) Optional(java.util.Optional) URI(java.net.URI) Pattern(java.util.regex.Pattern) Priority(jakarta.annotation.Priority) Config(org.eclipse.microprofile.config.Config) PostConstruct(jakarta.annotation.PostConstruct)

Example 13 with PostConstruct

use of jakarta.annotation.PostConstruct in project OpenGrok by OpenGrok.

the class IncomingFilter method init.

@PostConstruct
public void init() {
    try {
        localAddresses.add(InetAddress.getLocalHost().getHostAddress());
        for (InetAddress inetAddress : InetAddress.getAllByName("localhost")) {
            localAddresses.add(inetAddress.getHostAddress());
        }
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Could not get localhost addresses", e);
    }
    // Cache the tokens to avoid locking.
    setTokens(RuntimeEnvironment.getInstance().getAuthenticationTokens());
    RuntimeEnvironment.getInstance().registerListener(this);
}
Also used : IOException(java.io.IOException) InetAddress(java.net.InetAddress) PostConstruct(jakarta.annotation.PostConstruct)

Example 14 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewMyForumsMain method execute.

/**
 */
@PostConstruct
public void execute() {
    try {
        super.execute();
        Collection<ForumBean> forums = getWatchedForums();
        Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
        for (ForumBean currentForum : forums) {
            // setup folderLook based on whats specified in the theme
            String folderImage = themeHelper.getResourceForumURL();
            // bundle key
            String folderAlt = "No_new_posts";
            if (forumsLastPosts != null && forumsLastPosts.containsKey(currentForum.getId())) {
                PostBean lastPost = forumsLastPosts.get(currentForum.getId());
                Date lastPostDate = lastPost.getCreateDate();
                if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
                    // bundle key
                    folderAlt = "New_posts";
                    folderImage = themeHelper.getResourceForumNewURL();
                }
            }
            if (currentForum.getStatus() == Constants.FORUM_LOCKED) {
                folderImage = themeHelper.getResourceForumLockedURL();
                // bundle key
                folderAlt = "Forum_locked";
            }
            getForumImages().put(currentForum.getId(), folderImage);
            getForumImageDescriptions().put(currentForum.getId(), folderAlt);
        }
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) ForumBean(it.vige.rubia.dto.ForumBean) Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) PostConstruct(jakarta.annotation.PostConstruct)

Example 15 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewTopic method execute.

/**
 * This method gets topicId from parameters and tries to find topic with that
 * id.
 */
@PostConstruct
public void execute() {
    // parse input data
    int topicId = -1;
    Integer postId = -1;
    String t = getParameter(p_topicId);
    String p = getParameter(p_postId);
    if (t != null && t.trim().length() > 0) {
        topicId = parseInt(t);
    }
    try {
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
            PostBean post = forumsModule.findPostById(postId);
            topicId = post.getTopic().getId().intValue();
            topic = post.getTopic();
        }
        refreshTopic(topicId);
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) PostConstruct(jakarta.annotation.PostConstruct)

Aggregations

PostConstruct (jakarta.annotation.PostConstruct)76 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 IOException (java.io.IOException)6 Date (java.util.Date)6 PostBean (it.vige.rubia.dto.PostBean)4 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)4 ArrayList (java.util.ArrayList)4 ForumBean (it.vige.rubia.dto.ForumBean)3 FacesContext (jakarta.faces.context.FacesContext)3 Method (java.lang.reflect.Method)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ApplicationAssociate (com.sun.faces.application.ApplicationAssociate)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 ModuleException (it.vige.rubia.ModuleException)2 CategoryBean (it.vige.rubia.dto.CategoryBean)2 TopicBean (it.vige.rubia.dto.TopicBean)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 Typed (jakarta.enterprise.inject.Typed)2 ClientWindow (jakarta.faces.lifecycle.ClientWindow)2 Serializable (java.io.Serializable)2