public BeanManagerProxy(BeanManagerImpl manager) { this.manager = manager; this.nonPortableMode = manager.getServices().get(WeldConfiguration.class).getBooleanProperty(ConfigurationKey.NON_PORTABLE_MODE); }
static Object getValue(ConfigurationKey key, WeldConfiguration configuration) { Object defaultValue = key.getDefaultValue(); Object value = null; if (defaultValue instanceof Boolean) { value = configuration.getBooleanProperty(key); } else if (defaultValue instanceof Long) { value = configuration.getLongProperty(key); } else if (defaultValue instanceof Integer) { value = configuration.getIntegerProperty(key); } else if (defaultValue instanceof String) { value = configuration.getStringProperty(key); } return value; }
@SuppressWarnings("unchecked") private <T> T initSystemProperty(ConfigurationKey key, Class<T> requiredType) { checkRequiredType(key, requiredType); String property = getSystemProperty(key.get()); return (T) (property != null ? key.convertValue(property) : key.getDefaultValue()); }
@Override public void init(FilterConfig filterConfig) throws ServletException { if (beanManager == null) { beanManager = BeanManagerProxy.tryUnwrap(filterConfig.getServletContext().getAttribute(WELD_SERVLET_BEAN_MANAGER_KEY)); if (beanManager == null) { throw ProbeLogger.LOG.probeFilterUnableToOperate(BeanManagerImpl.class); } } ProbeExtension probeExtension = beanManager.getExtension(ProbeExtension.class); if (probeExtension == null) { throw ProbeLogger.LOG.probeFilterUnableToOperate(ProbeExtension.class); } probe = probeExtension.getProbe(); if (!probe.isInitialized()) { throw ProbeLogger.LOG.probeNotInitialized(); } jsonDataProvider = probeExtension.getJsonDataProvider(); WeldConfiguration configuration = beanManager.getServices().get(WeldConfiguration.class); if (configuration.getBooleanProperty(ConfigurationKey.PROBE_EMBED_INFO_SNIPPET)) { snippetBase = initSnippetBase(filterConfig.getServletContext()); } String exclude = configuration.getStringProperty(ConfigurationKey.PROBE_INVOCATION_MONITOR_EXCLUDE_TYPE); skipMonitoring = !exclude.isEmpty() && Pattern.compile(exclude).matcher(ProbeFilter.class.getName()).matches(); String allowRemoteAddress = configuration.getStringProperty(ConfigurationKey.PROBE_ALLOW_REMOTE_ADDRESS); allowRemoteAddressPattern = allowRemoteAddress.isEmpty() ? null : Pattern.compile(allowRemoteAddress); }
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager beanManager) { ProbeLogger.LOG.developmentModeEnabled(); final BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager); manager.addValidationFailureCallback(new BiConsumer<Exception, Environment>() { @Override public void accept(Exception exception, Environment environment) { // Note that eventual problems are ignored during callback invocation probe.init(manager); Reports.generateValidationReport(probe, exception, environment, manager); } }); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(Monitored.class, beanManager), Monitored.class.getName()); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(MonitoredComponent.class, beanManager), MonitoredComponent.class.getName()); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(InvocationMonitor.class, beanManager), InvocationMonitor.class.getName()); WeldConfiguration configuration = manager.getServices().get(WeldConfiguration.class); String exclude = configuration.getStringProperty(ConfigurationKey.PROBE_INVOCATION_MONITOR_EXCLUDE_TYPE); this.invocationMonitorExcludePattern = exclude.isEmpty() ? null : Pattern.compile(exclude); this.jsonDataProvider = new DefaultJsonDataProvider(probe, manager); this.eventMonitorContainerLifecycleEvents = configuration.getBooleanProperty(ConfigurationKey.PROBE_EVENT_MONITOR_CONTAINER_LIFECYCLE_EVENTS); addContainerLifecycleEvent(event, null, beanManager); }
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) { BeanManagerImpl weldManager = BeanManagerProxy.unwrap(beanManager); String exclude = weldManager.getServices().get(WeldConfiguration.class).getStringProperty(ConfigurationKey.PROBE_EVENT_MONITOR_EXCLUDE_TYPE); event.addObserverMethod(new ProbeObserver(weldManager, exclude.isEmpty() ? null : Pattern.compile(exclude), probe)); addContainerLifecycleEvent(event, null, beanManager); }
private Pattern initProxyIgnoreFinalMethodsPattern() { String ignore = getStringProperty(ConfigurationKey.PROXY_IGNORE_FINAL_METHODS); if (!ignore.isEmpty()) { return Pattern.compile(ignore); } return null; }
if (!registry.contains(ResourceLoader.class)) { registry.add(ResourceLoader.class, DefaultResourceLoader.INSTANCE); WeldConfiguration configuration = new WeldConfiguration(registry, deployment); registry.add(WeldConfiguration.class, configuration); registry.get(WeldConfiguration.class).getStringProperty(ROLLING_UPGRADES_ID_DELIMITER)); this.contextId = finalContextId; this.deployment = deployment; String vetoTypeRegex = configuration.getStringProperty(ConfigurationKey.VETO_TYPES_WITHOUT_BEAN_DEFINING_ANNOTATION); if (!vetoTypeRegex.isEmpty()) { this.extensions.add(MetadataImpl.from(new WeldVetoExtension(vetoTypeRegex))); this.deploymentManager = BeanManagerImpl.newRootManager(finalContextId, "deployment", registry); Container.initialize(finalContextId, deploymentManager, ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices())); getContainer().setState(ContainerState.STARTING);
body.add(HtmlTag.div(EXCEPTION).add(HtmlTag.pre(stackWriter.toString()))); Map<BeanDeploymentArchive, BeanManagerImpl> beanDeploymentArchivesMap = Container.instance(manager).beanDeploymentArchives(); List<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>(beanDeploymentArchivesMap.keySet()); Collections.sort(bdas, probe.getBdaComparator()); addConfiguration(body, manager); String export = manager.getServices().get(WeldConfiguration.class).getStringProperty(ConfigurationKey.PROBE_EXPORT_DATA_AFTER_DEPLOYMENT); File exportPath; if (!export.isEmpty()) {
public AbstractConversationContext(String contextId, ServiceRegistry services) { super(contextId, true); this.parameterName = new AtomicReference<String>(PARAMETER_NAME); WeldConfiguration configuration = services.get(WeldConfiguration.class); this.defaultTimeout = new AtomicLong(configuration.getLongProperty(ConfigurationKey.CONVERSATION_TIMEOUT)); this.concurrentAccessTimeout = new AtomicLong(configuration.getLongProperty(ConfigurationKey.CONVERSATION_CONCURRENT_ACCESS_TIMEOUT)); this.associated = new ThreadLocal<R>(); this.manager = Container.instance(contextId).deploymentManager(); this.beanIdentifierIndex = services.get(BeanIdentifierIndex.class); }
Map<ConfigurationKey, Object> properties = readFileProperties(findPropertiesFiles(deployment, CONFIGURATION_FILE)); merge(properties, readObsoleteFileProperties( findPropertiesFiles(deployment, BOOTSTRAP_CONFIGURATION_FILE), ImmutableMap.<String, ConfigurationKey> builder().put("concurrentDeployment", ConfigurationKey.CONCURRENT_DEPLOYMENT) .put("preloaderThreadPoolSize", ConfigurationKey.PRELOADER_THREAD_POOL_SIZE).build()), BOOTSTRAP_CONFIGURATION_FILE); merge(properties, readObsoleteFileProperties( findPropertiesFiles(deployment, EXECUTOR_CONFIGURATION_FILE), ImmutableMap.<String, ConfigurationKey> builder().put("threadPoolSize", ConfigurationKey.EXECUTOR_THREAD_POOL_SIZE) .put("threadPoolDebug", ConfigurationKey.EXECUTOR_THREAD_POOL_DEBUG) if (!findPropertiesFiles(deployment, UNSAFE_PROXIES_MARKER).isEmpty()) { merge(properties, ImmutableMap.<ConfigurationKey, Object>of(ConfigurationKey.RELAXED_CONSTRUCTION, true), UNSAFE_PROXIES_MARKER); merge(properties, getSystemProperties(), SYSTEM_PROPETIES); merge(properties, getObsoleteSystemProperties(), OBSOLETE_SYSTEM_PROPETIES); merge(properties, processExternalConfiguration(getExternalConfigurationOptions(services)), "ExternalConfiguration"); merge(properties, processBootstrapConfiguration(services.get(BootstrapConfiguration.class)), BootstrapConfiguration.class.getSimpleName());
private void addImplementationServices(ServiceRegistry services) { final WeldConfiguration configuration = services.get(WeldConfiguration.class); services.add(SlimAnnotatedTypeStore.class, new SlimAnnotatedTypeStoreImpl()); if (services.get(ClassTransformer.class) == null) { throw new IllegalStateException(ClassTransformer.class.getSimpleName() + " not installed."); if (configuration.getBooleanProperty(ConfigurationKey.BEAN_IDENTIFIER_INDEX_OPTIMIZATION)) { beanIdentifierIndex = new BeanIdentifierIndex(); services.add(BeanIdentifierIndex.class, beanIdentifierIndex); if (configuration.getBooleanProperty(ConfigurationKey.CONCURRENT_DEPLOYMENT) && services.contains(ExecutorServices.class)) { services.add(Validator.class, new ConcurrentValidator(executor)); } else { int preloaderThreadPoolSize = configuration.getIntegerProperty(ConfigurationKey.PRELOADER_THREAD_POOL_SIZE); if (preloaderThreadPoolSize > 0 && Permissions.hasPermission(Permissions.MODIFY_THREAD_GROUP)) { preloader = new ContainerLifecycleEventPreloader(preloaderThreadPoolSize, observerNotificationService.getGlobalLenientObserverNotifier());
public static ExecutorServices create(ResourceLoader loader, WeldConfiguration configuration) { final int threadPoolSize = configuration.getIntegerProperty(ConfigurationKey.EXECUTOR_THREAD_POOL_SIZE); final boolean debug = configuration.getBooleanProperty(ConfigurationKey.EXECUTOR_THREAD_POOL_DEBUG); final ThreadPoolType threadPoolType = initThreadPoolType(configuration); final long threadPoolKeepAliveTime = configuration.getLongProperty(ConfigurationKey.EXECUTOR_THREAD_POOL_KEEP_ALIVE_TIME); if (debug) { return enableDebugMode(constructExecutorServices(threadPoolType, threadPoolSize, threadPoolKeepAliveTime)); } else { return constructExecutorServices(threadPoolType, threadPoolSize, threadPoolKeepAliveTime); } }
/** * * @param namingScheme * @param attributeLazyFetchingEnabled */ public AbstractSessionBeanStore(NamingScheme namingScheme, boolean attributeLazyFetchingEnabled, ServiceRegistry serviceRegistry) { super(namingScheme, attributeLazyFetchingEnabled); this.resetHttpSessionAttributeOnBeanAccess = serviceRegistry.get(WeldConfiguration.class).getBooleanProperty(ConfigurationKey.RESET_HTTP_SESSION_ATTR_ON_BEAN_ACCESS); }
@SuppressWarnings("unchecked") private <T> T getProperty(ConfigurationKey key, Class<T> requiredType) { checkRequiredType(key, requiredType); Object property = properties.get(key); return (T) (property != null ? property : key.getDefaultValue()); }
public boolean associate(HttpServletRequest request) { // At this point the bean store should never be set - see also HttpContextLifecycle.nestedInvocationGuard if (getBeanStore() != null) { ContextLogger.LOG.beanStoreLeakDuringAssociation(this.getClass().getName(), request); } // We always associate a new bean store to avoid possible leaks (security threats) setBeanStore(new LazySessionBeanStore(request, namingScheme, getServiceRegistry().getRequired(WeldConfiguration.class).getBooleanProperty( ConfigurationKey.CONTEXT_ATTRIBUTES_LAZY_FETCH), getServiceRegistry())); checkBeanIdentifierIndexConsistency(request); return true; }
/** * * @param key * @return the property for the given key * @throws IllegalStateException If the property type does not match the required type */ public Long getLongProperty(ConfigurationKey key) { return getProperty(key, Long.class); }
/** * Constructor */ public TypeSafeResolver(Iterable<? extends T> allBeans, WeldConfiguration configuration) { this.resolverFunction = new ResolvableToBeanCollection<R, T, C, F>(this); this.resolved = ComputingCacheBuilder.newBuilder().setMaxSize(configuration.getLongProperty(ConfigurationKey.RESOLUTION_CACHE_SIZE)).build(resolverFunction); this.allBeans = allBeans; }
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager beanManager) { ProbeLogger.LOG.developmentModeEnabled(); BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager); manager.addValidationFailureCallback((exception, environment) -> { // Note that eventual problems are ignored during callback invocation probe.init(manager); Reports.generateValidationReport(probe, exception, environment, manager); }); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(Monitored.class, beanManager), Monitored.class.getName()); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(MonitoredComponent.class, beanManager), MonitoredComponent.class.getName()); event.addAnnotatedType(VetoedSuppressedAnnotatedType.from(InvocationMonitor.class, beanManager), InvocationMonitor.class.getName()); WeldConfiguration configuration = manager.getServices().get(WeldConfiguration.class); String exclude = configuration.getStringProperty(ConfigurationKey.PROBE_INVOCATION_MONITOR_EXCLUDE_TYPE); this.invocationMonitorExcludePattern = exclude.isEmpty() ? null : Pattern.compile(exclude); this.jsonDataProvider = new DefaultJsonDataProvider(probe, manager); this.eventMonitorContainerLifecycleEvents = configuration.getBooleanProperty(ConfigurationKey.PROBE_EVENT_MONITOR_CONTAINER_LIFECYCLE_EVENTS); addContainerLifecycleEvent(event, null, beanManager); }
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) { BeanManagerImpl weldManager = BeanManagerProxy.unwrap(beanManager); String exclude = weldManager.getServices().get(WeldConfiguration.class).getStringProperty(ConfigurationKey.PROBE_EVENT_MONITOR_EXCLUDE_TYPE); event.addObserverMethod(new ProbeObserver(weldManager, exclude.isEmpty() ? null : Pattern.compile(exclude), probe)); addContainerLifecycleEvent(event, null, beanManager); }