use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class JobSubsystem method activate.
@Activate
public synchronized void activate() {
jobStorage = new InMemoryJobStorage();
messageSender = new OutboundJobUpdateListener(topicManager, queueManager);
manager = new JobManagerImpl(jobStorage, messageSender);
}
use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class SlingMainServlet method activate.
// ---------- Property Setter for SCR --------------------------------------
@Activate
protected void activate(final BundleContext bundleContext, final Map<String, Object> componentConfig, final Config config) {
final String[] props = config.sling_additional_response_headers();
if (props != null) {
final ArrayList<StaticResponseHeader> mappings = new ArrayList<>(props.length);
for (final String prop : props) {
if (prop != null && prop.trim().length() > 0) {
try {
final StaticResponseHeader mapping = new StaticResponseHeader(prop.trim());
mappings.add(mapping);
} catch (final IllegalArgumentException iae) {
log.info("configure: Ignoring '{}': {}", prop, iae.getMessage());
}
}
}
RequestData.setAdditionalResponseHeaders(mappings);
}
configuredServerInfo = config.sling_serverinfo();
// setup server info
setProductInfo(bundleContext);
// prepare the servlet configuration from the component config
final Hashtable<String, Object> configuration = new Hashtable<>(componentConfig);
// ensure the servlet name
if (!(configuration.get("servlet-name") instanceof String)) {
configuration.put("servlet-name", this.productInfo);
}
// configure method filter
allowTrace = config.sling_trace_allow();
// configure the request limits
RequestData.setMaxIncludeCounter(config.sling_max_inclusions());
RequestData.setMaxCallCounter(config.sling_max_calls());
RequestData.setSlingMainServlet(this);
// Warn about the obsolete parameter encoding configuration
if (componentConfig.get(DEPRECATED_ENCODING_PROPERTY) != null) {
log.warn("Please configure the default request parameter encoding using " + "the 'org.apache.sling.engine.parameters' configuration PID; the property " + DEPRECATED_ENCODING_PROPERTY + "=" + componentConfig.get(DEPRECATED_ENCODING_PROPERTY) + " is obsolete and ignored");
}
// register the servlet context
final Dictionary<String, String> contextProperties = new Hashtable<>();
contextProperties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, SERVLET_CONTEXT_NAME);
contextProperties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, SLING_ROOT);
contextProperties.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Engine Servlet Context Helper");
contextProperties.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
this.contextRegistration = bundleContext.registerService(ServletContextHelper.class, this.slingHttpContext, contextProperties);
// register the servlet
final Dictionary<String, String> servletConfig = toStringConfig(configuration);
servletConfig.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + SERVLET_CONTEXT_NAME + ")");
servletConfig.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, SLING_ROOT);
servletConfig.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Engine Main Servlet");
servletConfig.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
this.servletRegistration = bundleContext.registerService(Servlet.class, this, servletConfig);
log.info("{} ready to serve requests", this.getServerInfo());
// now that the sling main servlet is registered with the HttpService
// and initialized we can register the servlet context
slingServletContext = new SlingServletContext(bundleContext, this);
// register render filters already registered after registration with
// the HttpService as filter initialization may cause the servlet
// context to be required (see SLING-42)
filterManager = new ServletFilterManager(bundleContext, slingServletContext);
filterManager.open();
requestProcessor.setFilterManager(filterManager);
// initialize requestListenerManager
requestListenerManager = new RequestListenerManager(bundleContext, slingServletContext);
// Setup configuration printer
this.printerRegistration = WebConsoleConfigPrinter.register(bundleContext, filterManager);
// setup the request info recorder
try {
int maxRequests = config.sling_max_record_requests();
String[] patterns = config.sling_store_pattern_requests();
if (patterns == null)
patterns = new String[0];
List<Pattern> compiledPatterns = new ArrayList<>(patterns.length);
for (String pattern : patterns) {
if (pattern != null && pattern.trim().length() > 0) {
compiledPatterns.add(Pattern.compile(pattern));
}
}
RequestHistoryConsolePlugin.initPlugin(bundleContext, maxRequests, compiledPatterns);
} catch (Throwable t) {
log.debug("Unable to register web console request recorder plugin.", t);
}
try {
Dictionary<String, String> mbeanProps = new Hashtable<>();
mbeanProps.put("jmx.objectname", "org.apache.sling:type=engine,service=RequestProcessor");
RequestProcessorMBeanImpl mbean = new RequestProcessorMBeanImpl();
requestProcessorMBeanRegistration = bundleContext.registerService(RequestProcessorMBean.class, mbean, mbeanProps);
requestProcessor.setMBean(mbean);
} catch (Throwable t) {
log.debug("Unable to register mbean");
}
// provide the SlingRequestProcessor service
Hashtable<String, String> srpProps = new Hashtable<>();
srpProps.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
srpProps.put(Constants.SERVICE_DESCRIPTION, "Sling Request Processor");
requestProcessorRegistration = bundleContext.registerService(SlingRequestProcessor.class, requestProcessor, srpProps);
}
use of org.osgi.service.component.annotations.Activate in project com-liferay-apio-architect by liferay.
the class ApioApplicationRegistrar method activate.
@Activate
public void activate(BundleContext bundleContext) {
Application application = bundleContext.getService(_serviceReference);
Dictionary<String, Object> properties = new Hashtable<>();
String[] propertyKeys = _serviceReference.getPropertyKeys();
for (String key : propertyKeys) {
Object value = _serviceReference.getProperty(key);
properties.put(key, value);
}
properties.put("osgi.jaxrs.application.base", "/");
properties.put("osgi.jaxrs.name", ".default");
_serviceRegistration = bundleContext.registerService(Application.class, application, properties);
PersonModel.compute();
BlogPostingModel.compute();
BlogPostingCommentModel.compute();
}
use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class SecondaryStoreCacheService method activate.
@Activate
private void activate(BundleContext context, Configuration config) {
bundleContext = context;
whiteboard = new OsgiWhiteboard(context);
String[] includedPaths = config.includedPaths();
// TODO Support for exclude is not possible as once a NodeState is loaded from secondary
// store it assumes that complete subtree is in same store. With exclude it would need to
// check for each child access and route to primary
pathFilter = new PathFilter(asList(includedPaths), Collections.<String>emptyList());
SecondaryStoreBuilder builder = new SecondaryStoreBuilder(secondaryStoreProvider.getNodeStore()).differ(differ).metaPropNames(DocumentNodeStore.META_PROP_NAMES).statisticsProvider(statisticsProvider).pathFilter(pathFilter);
SecondaryStoreCache cache = builder.buildCache();
SecondaryStoreObserver observer = builder.buildObserver(cache);
registerObserver(observer, config);
regs.add(bundleContext.registerService(DocumentNodeStateCache.class.getName(), cache, null));
// TODO Need to see OSGi dynamics. Its possible that DocumentNodeStore works after the cache
// gets deregistered but the SegmentNodeState instances might still be in use and that would cause
// failure
}
use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class IndexerMBeanImpl method activate.
// ~---------------------------------------< OSGi >
@Activate
private void activate(BundleContext context) {
Whiteboard wb = new OsgiWhiteboard(context);
editorProvider.start(wb);
mbeanReg = registerMBean(wb, IndexerMBean.class, this, IndexerMBean.TYPE, "Indexer operations related MBean");
providerTracker = wb.track(IndexImporterProvider.class);
}
Aggregations