use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class SightlyScriptEngineFactory method activate.
@Activate
protected void activate() {
InputStream is;
boolean newVersion = true;
String versionInfo = null;
String newVersionString = sightlyEngineConfiguration.getEngineVersion();
try {
is = classLoaderWriter.getInputStream(SIGHTLY_CONFIG_FILE);
if (is != null) {
versionInfo = IOUtils.toString(is, "UTF-8");
if (newVersionString.equals(versionInfo)) {
newVersion = false;
} else {
LOGGER.info("Detected stale classes generated by Apache Sling Scripting HTL engine version {}.", versionInfo);
}
IOUtils.closeQuietly(is);
}
} catch (IOException e) {
// do nothing; if we didn't find any previous version information we're considering our version to be new
}
if (newVersion) {
OutputStream os = classLoaderWriter.getOutputStream(SIGHTLY_CONFIG_FILE);
try {
IOUtils.write(sightlyEngineConfiguration.getEngineVersion(), os, "UTF-8");
} catch (IOException e) {
// ignore
} finally {
IOUtils.closeQuietly(os);
}
String scratchFolder = sightlyEngineConfiguration.getScratchFolder();
boolean scratchFolderDeleted = classLoaderWriter.delete(scratchFolder);
if (scratchFolderDeleted) {
if (StringUtils.isNotEmpty(versionInfo)) {
LOGGER.info("Deleted stale classes generated by Apache Sling Scripting HTL engine version {}.", versionInfo);
}
}
}
}
use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class SettingsSupport method activate.
/**
* Start the component.
* @param bc Bundle context
*/
@Activate
protected void activate(final BundleContext bc) {
this.settingsListener = new Listener(bc);
this.settingsListener.start();
}
use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class FsResourceProvider method activate.
// ---------- SCR Integration
@Activate
protected void activate(BundleContext bundleContext, final Config config) {
fsMode = config.provider_fs_mode();
String providerRoot = config.provider_root();
if (StringUtils.isBlank(providerRoot)) {
throw new IllegalArgumentException("provider.root property must be set");
}
String providerFileName = config.provider_file();
if (StringUtils.isBlank(providerFileName)) {
throw new IllegalArgumentException("provider.file property must be set");
}
this.providerRoot = providerRoot;
this.providerFile = getProviderFile(providerFileName, bundleContext);
this.overlayParentResourceProvider = false;
InitialContentImportOptions options = new InitialContentImportOptions(config.provider_initial_content_import_options());
File filterXmlFile = null;
List<String> contentFileSuffixes = new ArrayList<>();
if (fsMode == FsMode.FILEVAULT_XML) {
contentFileSuffixes.add("/" + DOT_CONTENT_XML);
if (StringUtils.isNotBlank(config.provider_filevault_filterxml_path())) {
filterXmlFile = new File(config.provider_filevault_filterxml_path());
}
} else if (fsMode == FsMode.FILES_FOLDERS) {
overlayParentResourceProvider = true;
} else if (fsMode == FsMode.INITIAL_CONTENT) {
overlayParentResourceProvider = !options.isOverwrite();
if (!options.getIgnoreImportProviders().contains(ContentType.JSON.getExtension())) {
contentFileSuffixes.add(ContentFileTypes.JSON_SUFFIX);
}
if (!options.getIgnoreImportProviders().contains(ContentType.JCR_XML.getExtension())) {
contentFileSuffixes.add(ContentFileTypes.JCR_XML_SUFFIX);
}
if (!options.getIgnoreImportProviders().contains(ContentType.XML.getExtension())) {
contentFileSuffixes.add(ContentFileTypes.XML_SUFFIX);
}
}
ContentFileExtensions contentFileExtensions = new ContentFileExtensions(contentFileSuffixes);
this.contentFileCache = new ContentFileCache(config.provider_cache_size());
if (fsMode == FsMode.FILEVAULT_XML) {
this.fileVaultMapper = new FileVaultResourceMapper(this.providerFile, filterXmlFile, this.contentFileCache);
} else {
this.fileMapper = new FileResourceMapper(this.providerRoot, this.providerFile, contentFileExtensions, this.contentFileCache);
this.contentFileMapper = new ContentFileResourceMapper(this.providerRoot, this.providerFile, contentFileExtensions, this.contentFileCache);
}
// start background monitor if check interval is higher than 100
if (config.provider_checkinterval() > 100) {
this.monitor = new FileMonitor(this, config.provider_checkinterval(), fsMode, contentFileExtensions, this.contentFileCache);
}
}
use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class OakSlingRepositoryManager method activate.
@Activate
private void activate(final OakSlingRepositoryManagerConfiguration configuration, final ComponentContext componentContext) {
this.configuration = configuration;
this.componentContext = componentContext;
final BundleContext bundleContext = componentContext.getBundleContext();
final String defaultWorkspace = configuration.defaultWorkspace();
final boolean disableLoginAdministrative = !configuration.admin_login_enabled();
if (configuration.oak_observation_limitCommitRate()) {
commitRateLimiter = new CommitRateLimiter();
}
this.threadPool = threadPoolManager.get("oak-observation");
this.nodeAggregatorRegistration = bundleContext.registerService(NodeAggregator.class.getName(), getNodeAggregator(), null);
super.start(bundleContext, new Config(defaultWorkspace, disableLoginAdministrative));
}
use of org.osgi.service.component.annotations.Activate in project sling by apache.
the class JcrResourceProvider method activate.
@Activate
protected void activate(final ComponentContext context) throws RepositoryException {
SlingRepository repository = context.locateService(REPOSITORY_REFERNENCE_NAME, this.repositoryReference);
if (repository == null) {
// concurrent unregistration of SlingRepository service
// don't care, this component is going to be deactivated
// so we just stop working
logger.warn("activate: Activation failed because SlingRepository may have been unregistered concurrently");
return;
}
this.repository = repository;
this.stateFactory = new JcrProviderStateFactory(repositoryReference, repository, classLoaderManagerReference);
}
Aggregations