/** * Returns the {@link Gauge} matching the criteria from the injection point. * * @param <T> type of the {@code Gauge} * @param registry metric registry * @param ip injection point being resolved * @return requested gauge */ @Produces @VendorDefined @SuppressWarnings("unchecked") private <T> Gauge<T> produceGauge(MetricRegistry registry, InjectionPoint ip) { Metric metric = ip.getAnnotated().getAnnotation(Metric.class); return (Gauge<T>) registry.getGauges().entrySet().stream() .filter(entry -> entry.getKey().equals(metric.name())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Could not produce Gauge for injection point " + ip.toString())) .getValue(); }
@Produces @Named @ApplicationScoped public HistoryService historyService() { return processEngine().getHistoryService(); }
@Produces @Named @RequestScoped public FlashContext getFlashContext() { return currentContext; }
@Produces @Named("application") @ApplicationScoped public Application getApplication() { return FacesContext.getCurrentInstance().getApplication(); }
@Produces @Named("initParam") @InitParameterMap @ApplicationScoped public Map<String, String> getInitParameterMap() { return FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap(); }
@Named @Produces @RequestScoped public ExternalContext getExternalContext(final FacesContext context) { return context.getExternalContext(); } }
/** * Creates an alias for #createScriptExecutorBean * which creates a helper which allows to use a {@link ScriptExecutor} within el-expressions * @return el-helper for the script-executor */ @Produces @Dependent @Named(SCRIPT_EXECUTOR_ALIAS) public Map<String, Object> createScriptExecutorBeanForAlias() { return createScriptExecutorBean(); }
@Produces public AtmosphereConfig getAtmosphereConfig() { return config; }
@Produces @RequestScoped public FilterChain getChain(){ return requestStarted.getChain(); } }
@Produces @Dependent @BotProperty(name = "") public String findBotProperty(InjectionPoint injectionPoint) { BotProperty prop = injectionPoint.getAnnotated().getAnnotation(BotProperty.class); String property = System.getProperty(prop.name()); log.fine("Injecting Property name: [" + prop.name() + "] value: [" + property + "] required [" + prop.required() + "]"); if (prop.required() && (null == property) || property=="") { throw new IllegalStateException("The parameter " + prop.name() + " is required!"); } return property; } }
@Produces @RequestScoped public FacesContext getFacesContext() { FacesContext ctx = FacesContext.getCurrentInstance(); if (ctx == null) { throw new ContextNotActiveException("FacesContext is not active"); } return ctx; } }
@Produces public Logger produceLogger(final InjectionPoint injectionPoint) { final String loggerName; if (injectionPoint.getAnnotated().isAnnotationPresent(NamedLogger.class)) { loggerName = injectionPoint.getAnnotated().getAnnotation(NamedLogger.class).value(); } else { loggerName = injectionPoint.getMember().getDeclaringClass().getName(); } return LoggerFactory.getLogger(loggerName); }
@Produces @RequestScoped public ExternalContext getExternalContext(final FacesContext context) { return context.getExternalContext(); } }
@Produces @TypedMessageBundle Object produceTypedMessageBundle(InjectionPoint injectionPoint) { Annotated annotated = injectionPoint.getAnnotated(); if (annotated.isAnnotationPresent(Locale.class)) { return getBundle(getRawType(injectionPoint.getType()), toLocale(annotated.getAnnotation(Locale.class).value())); } else { return getBundle(getRawType(injectionPoint.getType())); } }
@Produces @Named @ApplicationScoped public RuntimeService runtimeService() { return processEngine().getRuntimeService(); }