use of org.apache.felix.scr.annotations.Activate in project sling by apache.
the class JobManagerTestComponent method activate.
@Activate
public void activate(Map<String, Object> props) {
for (int i = 0; i < 10; i++) {
Job job = jobManager.newJobBuilder(Types.jobQueue(TOPIC), Types.jobType(AsyncJobConsumer.JOB_TYPE)).addProperties(Collections.singletonMap("jobtest", (Object) "jobtest")).add();
assertNotNull(job);
LOGGER.info("Started Job {} ", job.getId());
}
// then start 10 sync jobs.
for (int i = 0; i < 10; i++) {
Job job = jobManager.newJobBuilder(Types.jobQueue(TOPIC), Types.jobType(FullySyncJob.JOB_TYPE)).addProperties(Collections.singletonMap("jobtest", (Object) "jobtest")).add();
assertNotNull(job);
LOGGER.info("Started Job {} ", job.getId());
}
}
use of org.apache.felix.scr.annotations.Activate in project sling by apache.
the class Init method activate.
@Activate
public void activate() throws Exception {
try {
final String defaultAgentUserName = "distribution-agent-user";
final String serviceUserName = "testDistributionUser";
final String distributorUserName = "testDistributorUser";
Session session = slingRepository.login(new SimpleCredentials("admin", "admin".toCharArray()));
JackrabbitSession jackrabittSession = (JackrabbitSession) session;
UserManager userManager = jackrabittSession.getUserManager();
User serviceUser = createOrGetServiceUser(userManager, serviceUserName);
if (serviceUser != null) {
AccessControlUtils.addAccessControlEntry(session, "/var/sling/distribution/packages", serviceUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, "/content", serviceUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, null, serviceUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
}
Authorizable distributorUser = createOrGetRegularUser(userManager, distributorUserName);
JcrUtils.getOrCreateByPath("/content", "sling:Folder", session);
if (distributorUser != null) {
AccessControlUtils.addAccessControlEntry(session, "/var/sling/distribution/packages", distributorUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, "/content", distributorUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, "/libs/sling/distribution", distributorUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, "/etc/distribution", distributorUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
AccessControlUtils.addAccessControlEntry(session, null, distributorUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
}
User defaultAgentUser = createOrGetServiceUser(userManager, defaultAgentUserName);
if (defaultAgentUser != null) {
AccessControlUtils.addAccessControlEntry(session, "/var/sling/distribution/packages", defaultAgentUser.getPrincipal(), new String[] { Privilege.JCR_ALL }, true);
((User) distributorUser).getImpersonation().grantImpersonation(defaultAgentUser.getPrincipal());
serviceUser.getImpersonation().grantImpersonation(defaultAgentUser.getPrincipal());
}
session.save();
session.logout();
} catch (Throwable t) {
log.error("cannot create user", t);
}
}
use of org.apache.felix.scr.annotations.Activate in project sling by apache.
the class TenantProviderImpl method activate.
@Activate
protected void activate(final BundleContext bundleContext, final Map<String, Object> properties) {
this.tenantRootPath = PropertiesUtil.toString(properties.get(TENANT_ROOT), RESOURCE_TENANT_ROOT);
this.adapterFactory = new TenantAdapterFactory(bundleContext, this, PropertiesUtil.toStringArray(properties.get(TENANT_PATH_MATCHER), DEFAULT_PATH_MATCHER));
this.plugin = new WebConsolePlugin(bundleContext, this);
}
use of org.apache.felix.scr.annotations.Activate in project sling by apache.
the class StartupFilterImpl method activate.
@Activate
protected void activate(final BundleContext ctx, final Map<String, Object> properties) throws InterruptedException {
bundleContext = ctx;
providersTracker = new ServiceTracker(bundleContext, StartupInfoProvider.class, null);
providersTracker.open();
Object prop = properties.get(DEFAULT_MESSAGE_PROP);
defaultMessage = prop == null ? DEFAULT_MESSAGE : prop.toString();
prop = properties.get(ACTIVE_BY_DEFAULT_PROP);
defaultFilterActive = (prop instanceof Boolean ? (Boolean) prop : false);
prop = bundleContext.getProperty(FRAMEWORK_PROP_MANAGER_ROOT);
managerRoot = prop == null ? DEFAULT_MANAGER_ROOT : prop.toString();
if (defaultFilterActive) {
enable();
}
log.info("Activated, enabled={}, managerRoot={}", isEnabled(), managerRoot);
}
use of org.apache.felix.scr.annotations.Activate in project sling by apache.
the class SuperimposingManagerImpl method activate.
// ---------- SCR Integration
@Activate
protected synchronized void activate(final ComponentContext ctx) throws LoginException, RepositoryException {
// check enabled state
@SuppressWarnings("unchecked") final Dictionary<String, Object> props = ctx.getProperties();
this.enabled = PropertiesUtil.toBoolean(props.get(ENABLED_PROPERTY), ENABLED_DEFAULT);
log.debug("Config: " + "Enabled={} ", enabled);
if (!isEnabled()) {
return;
}
// get "find all" queries
this.findAllQueries = PropertiesUtil.toStringArray(props.get(FINDALLQUERIES_PROPERTY), new String[] { FINDALLQUERIES_DEFAULT });
this.obervationPaths = PropertiesUtil.toStringArray(props.get(OBSERVATION_PATHS_PROPERTY), new String[] { OBSERVATION_PATHS_DEFAULT });
if (null == resolver) {
bundleContext = ctx.getBundleContext();
resolver = resolverFactory.getAdministrativeResourceResolver(null);
// Watch for events on the root to register/deregister superimposings at runtime
// For each observed path create an event listener object which redirects the event to the main class
final Session session = resolver.adaptTo(Session.class);
if (session != null) {
this.observationEventListeners = new EventListener[this.obervationPaths.length];
for (int i = 0; i < this.obervationPaths.length; i++) {
this.observationEventListeners[i] = new EventListener() {
public void onEvent(EventIterator events) {
SuperimposingManagerImpl.this.onEvent(events);
}
};
session.getWorkspace().getObservationManager().addEventListener(this.observationEventListeners[i], Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED, // absolute path
this.obervationPaths[i], // isDeep
true, // uuids
null, // node types
null, // noLocal
true);
}
}
// register all superimposing definitions that already exist
initialization = Executors.newSingleThreadExecutor().submit(new Runnable() {
public void run() {
try {
registerAllSuperimposings();
} catch (Throwable ex) {
log.warn("Error registering existing superimposing resources on service startup.", ex);
}
}
});
}
}
Aggregations