protected void activate(ComponentContext ctx) {
    try {
      // Register the valves with Tomcat
      ArrayList<CarbonTomcatValve> valves = new ArrayList<CarbonTomcatValve>();
      valves.add(new TenantLazyLoaderValve());
      if (GhostDeployerUtils.isGhostOn()) {
        valves.add(new GhostWebappDeployerValve());
        // registering WebappUnloader as an OSGi service
        WebappUnloader webappUnloader = new WebappUnloader();
        ctx.getBundleContext()
            .registerService(ArtifactUnloader.class.getName(), webappUnloader, null);
        GhostWebappMetaArtifactsLoader artifactsLoader = new GhostWebappMetaArtifactsLoader();
        ctx.getBundleContext()
            .registerService(GhostMetaArtifactsLoader.class.getName(), artifactsLoader, null);

      } else {
        setServerURLParam(DataHolder.getServerConfigContext());
      }
      // adding TenantLazyLoaderValve first in the TomcatContainer if Url mapping available
      if (DataHolder.getHotUpdateService() != null
      //                && TomcatValveContainer.isValveExists(new UrlMapperValve //TODO: Fix this
      // once URLMapper component becomes available
      ) {
        TomcatValveContainer.addValves(WebappsConstants.VALVE_INDEX, valves);
      } else {
        TomcatValveContainer.addValves(valves);
      }

    } catch (Throwable e) {
      log.error("Error occurred while activating WebappManagementServiceComponent", e);
    }
  }
  @Activate
  protected void activate(ComponentContext componentContext) throws Exception {
    LOG.info("Starting Activation of AMQ Broker ");
    try {
      Dictionary<?, ?> properties = componentContext.getProperties();
      BundleContext bundleContext = componentContext.getBundleContext();
      String brokerUrl = (String) properties.get(ACTIVEMQ_BROKER_URL);

      broker = new BrokerService();

      // generate a full path
      String slingHome = bundleContext.getProperty("sling.home");
      String dataPath = slingHome + "/activemq-data";
      LOG.info("Setting Data Path to  [{}] [{}] ", new Object[] {slingHome, dataPath});
      broker.setDataDirectory(dataPath);

      String federatedBrokerUrl = (String) properties.get(ACTIVEMQ_FEDERATED_BROKER_URL);

      if (federatedBrokerUrl != null && federatedBrokerUrl.length() > 0) {
        LOG.info("Federating ActiveMQ  [" + federatedBrokerUrl + "]");
        NetworkConnector connector = broker.addNetworkConnector(federatedBrokerUrl);
        connector.setDuplex(true);
      }

      // configure the broker
      LOG.info("Adding ActiveMQ connector [" + brokerUrl + "]");
      broker.addConnector(brokerUrl);

      broker.start();
    } catch (Exception e) {
      LOG.info(e.getMessage(), e);
      throw e;
    }
  }
Example #3
0
 protected void activate(ComponentContext ctxt) {
   // You may delete all references to metatype service if
   // your algorithm does not require parameters and return
   // null in the createParameters() method
   MetaTypeService mts = (MetaTypeService) ctxt.locateService("MTS");
   provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle());
 }
Example #4
0
 @Activate
 public void activate(ComponentContext componentContext)
     throws IOException, ParserConfigurationException, SAXException {
   BundleContext bundleContext = componentContext.getBundleContext();
   solrHome = Utils.getSolrHome(bundleContext);
   multiMasterProperties = getMultiMasterProperties(toMap(componentContext.getProperties()));
 }
 /**
  * Activate this component. Open the session and register event listeners.
  *
  * @param context The component context
  */
 protected void activate(final ComponentContext context) {
   reverseReplicate =
       OsgiUtil.toBoolean(
           context.getProperties().get(PROPERTY_REVERSE_REPLICATE), DEFAULT_REVERSE_REPLICATE);
   fieldWhitelist = OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_FIELD_WHITELIST));
   attachmentTypeBlacklist =
       OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_ATTACHMENT_TYPE_BLACKLIST));
 }
 @AfterTest
 public void afterTest() throws Exception {
   ComponentContext context = mock(ComponentContext.class);
   when(context.getProperties()).thenReturn(properties);
   configObjectService.deactivate(context);
   configObjectService = null;
   enhancedConfig = null;
 }
 /**
  * Returns a mocked {@link ComponentContext} instance.
  *
  * @return a {@link ComponentContext} instance
  */
 private ComponentContext getMockedContext() {
   ComponentContext mockedContext = mock(ComponentContext.class);
   BundleContext mockedBundleContext = mock(BundleContext.class);
   Dictionary<String, String> compContextProperties = new Hashtable<String, String>();
   // compContextProperties.put("config.factory-pid", null);
   when(mockedContext.getProperties()).thenReturn(compContextProperties);
   when(mockedContext.getBundleContext()).thenReturn(mockedBundleContext);
   return mockedContext;
 }
 public void activate(ComponentContext context) throws Exception {
   Object rn = context.getProperties().get(REPO_NAME_PROPERTY);
   Object componentName = context.getProperties().get("component.name");
   String repoName = rn instanceof String ? (String) rn : String.valueOf(componentName);
   repository =
       CDOServerUtil.createRepository(
           repoName, createStore(context), getRepositoryProperties(context));
   LifecycleUtil.activate(repository);
 }
 public ComponentContext configureForCookieFast() {
   ComponentContext context = createMock(ComponentContext.class);
   Hashtable<String, Object> dict = new Hashtable<String, Object>();
   dict.put(TrustedTokenServiceImpl.USE_SESSION, false);
   dict.put(TrustedTokenServiceImpl.COOKIE_NAME, "secure-cookie");
   dict.put(TrustedTokenServiceImpl.TTL, 100L);
   dict.put(TrustedTokenServiceImpl.SECURE_COOKIE, false);
   EasyMock.expect(context.getProperties()).andReturn(dict);
   return context;
 }
Example #10
0
  @Activate
  protected void activate(ComponentContext context) {
    this.context = context;

    Dictionary properties = context.getProperties();
    setProperties(properties);

    configuration = getConfiguration(context);

    activate(context.getBundleContext(), null, configuration);

    logger.info("OpenIDM Policy Service component is activated.");
  }
 protected void activate(ComponentContext componentContext) throws AgentServerException {
   if (log.isDebugEnabled()) {
     log.debug("Starting the Bam Event Receiver Server component");
   }
   initialize();
   BAMEventReceiverComponentManager.getInstance().init(registryService);
   ServiceReference serviceReference =
       componentContext.getBundleContext().getServiceReference(AgentServer.class.getName());
   if (serviceReference != null) {
     agentServer = (AgentServer) componentContext.getBundleContext().getService(serviceReference);
   }
   agentServer.subscribe(new BAMAgentCallback());
 }
  @Activate
  @Modified
  protected void activate(ComponentContext componentContext) {
    _freemarkerEngineConfiguration =
        Configurable.createConfigurable(
            FreeMarkerEngineConfiguration.class, componentContext.getProperties());

    BundleContext bundleContext = componentContext.getBundleContext();

    _bundle = bundleContext.getBundle();

    BundleWiring bundleWiring = _bundle.adapt(BundleWiring.class);

    _classLoader = bundleWiring.getClassLoader();
  }
 /**
  * Activates this component.
  *
  * @param componentContext The OSGi <code>ComponentContext</code> of this component.
  */
 protected void activate(ComponentContext componentContext) {
   super.activate(componentContext);
   String groupList = (String) componentContext.getProperties().get(GROUP_AUTHORISED_TOCREATE);
   if (groupList != null) {
     authorizedGroups = StringUtils.split(groupList, ',');
   }
 }
 protected void activate(ComponentContext context) {
   BundleContext bundleContext = context.getBundleContext();
   tracker =
       new ExternalRepositoryProcessorTracker(
           bundleContext, ExternalRepositoryProcessor.class.getName(), null);
   tracker.open();
 }
  @Modified
  public void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();

    int newMessageHandlerThreadPoolSize;

    try {
      String s = get(properties, "messageHandlerThreadPoolSize");

      newMessageHandlerThreadPoolSize =
          isNullOrEmpty(s) ? messageHandlerThreadPoolSize : Integer.parseInt(s.trim());

    } catch (NumberFormatException e) {
      log.warn(e.getMessage());
      newMessageHandlerThreadPoolSize = messageHandlerThreadPoolSize;
    }

    // Any change in the following parameters implies thread pool restart
    if (newMessageHandlerThreadPoolSize != messageHandlerThreadPoolSize) {
      setMessageHandlerThreadPoolSize(newMessageHandlerThreadPoolSize);
      restartMessageHandlerThreadPool();
    }

    log.info(FORMAT, messageHandlerThreadPoolSize);
  }
  protected void activate(ComponentContext componentContext) {
    if (log.isDebugEnabled()) {
      log.debug("RSS Cluster tools Admin bundle is activated.");
    }
    try {
      BundleContext bundleContext = componentContext.getBundleContext();
      PrivilegedCarbonContext.startTenantFlow();
      PrivilegedCarbonContext.getThreadLocalCarbonContext()
          .setTenantId(MultitenantConstants.SUPER_TENANT_ID);

      bundleContext.registerService(
          TransactionManagerDummyService.class.getName(),
          new TransactionManagerDummyService(),
          null);
      UsageManagerDataHolder.getInstance().initTransactionManager();

      // initialize configurations
      StorageMetaDataConfig.getInstance().init();
      StorageDataPublishManager.getInstance().init(taskService, secretCallbackHandlerService);
      UsageManagerDataHolder.getInstance().setRSSManagerService(this.RSSManagerService);
      UsageManagerDataHolder.getInstance().setRealmService(realmService);

    } catch (Exception e) {
      log.error(e);
      if (log.isDebugEnabled()) {
        log.debug("Error while initializing configurations ", e);
      }
    } finally {
      PrivilegedCarbonContext.endTenantFlow();
    }
  }
 protected void activate(ComponentContext context) {
   // Registering OAuth2Service as a OSGIService
   bundleContext = context.getBundleContext();
   bundleContext.registerService(
       ApplicationManagementService.class.getName(), new ApplicationManagementService(), null);
   log.info("Identity ApplicationManagementComponent bundle is activated");
 }
 protected void activate(final ComponentContext cContext) {
   context = cContext.getBundleContext();
   getMetadataDependencyRegistry()
       .registerDependency(PhysicalTypeIdentifier.getMetadataIdentiferType(), getProvidesType());
   setIgnoreTriggerAnnotations(true);
   setDependsOnGovernorBeingAClass(false);
 }
  protected void activate(ComponentContext ctxt) {
    log.info("Initializing the BPMN core component...");
    try {
      BundleContext bundleContext = ctxt.getBundleContext();
      BPMNServerHolder holder = BPMNServerHolder.getInstance();
      ActivitiEngineBuilder activitiEngineBuilder = new ActivitiEngineBuilder();
      holder.setEngine(activitiEngineBuilder.buildEngine());
      holder.setTenantManager(new TenantManager());

      BPMNRestExtensionHolder restHolder = BPMNRestExtensionHolder.getInstance();

      restHolder.setRestInvoker(new RESTInvoker());
      bundleContext.registerService(
          WaitBeforeShutdownObserver.class.getName(), new BPMNEngineShutdown(), null);

      //            DataSourceHandler dataSourceHandler = new DataSourceHandler();
      //            dataSourceHandler.initDataSource(activitiEngineBuilder.getDataSourceJndiName());
      //            dataSourceHandler.closeDataSource();
      //        } catch (BPMNMetaDataTableCreationException e) {
      //            log.error("Could not create BPMN checksum table", e);
      //        } catch (DatabaseConfigurationException e) {
      //            log.error("Could not create BPMN checksum table", e);
    } catch (Throwable e) {
      log.error("Failed to initialize the BPMN core component.", e);
    }
  }
 protected void activate(ComponentContext context) {
   BundleContext bundleContext = context.getBundleContext();
   bundleContext.registerService(AdapterComponent.class, new AdapterComponent(), null);
   if (log.isDebugEnabled()) {
     log.debug("Social Activity service is activated with Adaptor implementation");
   }
 }
 @Activate
 protected void activate(ComponentContext context) {
   this.propOpt =
       PropertiesUtil.toString(
           context.getProperties().get(PROPERTY_OPTIMIZATION), DEFAULT_OPTIMIZATION);
   this.optimization = ClosureOptimizationLevel.fromString(this.propOpt);
 }
 @Override
 public Bundle[] getBundles() {
   if (m_ctx == null) {
     return null;
   }
   return m_ctx.getBundleContext().getBundles();
 }
Example #23
0
  protected void activate(ComponentContext componentContext) {

    synchronized (delayedReferences) {
      osgiComponentContext = componentContext;
      for (ServiceReference ref : delayedReferences) {
        addProcessor(ref);
      }
      delayedReferences.clear();
    }
    synchronized (delayedBatchReferences) {
      osgiComponentContext = componentContext;
      for (ServiceReference ref : delayedBatchReferences) {
        addBatchProcessor(ref);
      }
      delayedBatchReferences.clear();
    }
    synchronized (delayedPropertyReferences) {
      osgiComponentContext = componentContext;
      for (ServiceReference ref : delayedPropertyReferences) {
        addProvider(ref);
      }
      delayedPropertyReferences.clear();
    }

    maximumResults = (Long) componentContext.getProperties().get("maximumResults");
  }
  protected void activate(ComponentContext context) {
    try {
      bundleContext = context.getBundleContext();
      if (CommonUtil.getStratosConfig() == null) {
        StratosConfiguration stratosConfig = CommonUtil.loadStratosConfiguration();
        CommonUtil.setStratosConfig(stratosConfig);
      }

      // Loading the EULA
      if (CommonUtil.getEula() == null) {
        String eula = CommonUtil.loadTermsOfUsage();
        CommonUtil.setEula(eula);
      }

      // packageInfos = new PackageInfoHolder();
      // context.getBundleContext().registerService(
      //		PackageInfoHolder.class.getName(), packageInfos, null);

      // Register manager configuration OSGI service
      try {
        StratosConfiguration stratosConfiguration = CommonUtil.loadStratosConfiguration();
        bundleContext.registerService(
            StratosConfiguration.class.getName(), stratosConfiguration, null);
        if (log.isDebugEnabled()) {
          log.debug("******* Cloud Common Service bundle is activated ******* ");
        }
      } catch (Exception ex) {
        String msg = "An error occurred while initializing Cloud Common Service as an OSGi Service";
        log.error(msg, ex);
      }
    } catch (Throwable e) {
      log.error("Error in activating Cloud Common Service Component" + e.toString());
    }
  }
Example #25
0
  /** @param serviceReference */
  private void addBatchProcessor(ServiceReference serviceReference) {
    SolrSearchBatchResultProcessor processor =
        (SolrSearchBatchResultProcessor)
            osgiComponentContext.locateService(SEARCH_BATCH_RESULT_PROCESSOR, serviceReference);
    Long serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID);

    batchProcessorsById.put(serviceId, processor);
    String[] processorNames =
        getSetting(serviceReference.getProperty(REG_BATCH_PROCESSOR_NAMES), new String[0]);

    if (processorNames != null) {
      for (String processorName : processorNames) {
        batchProcessors.put(processorName, processor);
      }
    }

    // bit of a kludge until I can figure out why felix doesn't wire up the default
    // processor even though it finds a matching service.
    boolean defaultBatchProcessor =
        getSetting(
            serviceReference.getProperty(
                SolrSearchBatchResultProcessor.DEFAULT_BATCH_PROCESSOR_PROP),
            false);
    if (defaultBatchProcessor) {
      defaultSearchBatchProcessor = processor;
    }
  }
 @Activate
 private void activate(ComponentContext componentContext) {
   Dictionary config = componentContext.getProperties();
   requestThreadLocal =
       PropertiesUtil.toBoolean(
           config.get(PARAM_REQUEST_THREAD_LOCAL), PARAM_REQUEST_THREAD_LOCAL_DEFAULT);
 }
Example #27
0
 private void registerAxis2ConfigurationContextObserver(ComponentContext context) {
   context
       .getBundleContext()
       .registerService(
           Axis2ConfigurationContextObserver.class.getName(),
           new Axis2ConfigurationContextObserverImpl(),
           null);
 }
 @SuppressWarnings("unchecked")
 @Activate
 protected void activate(ComponentContext context) {
   Dictionary properties = context.getProperties();
   casServerUrl = (String) properties.get(serverName);
   casServerLoginUrl = (String) properties.get(loginUrl);
   casServerLogoutUrl = (String) properties.get(logoutUrl);
 }
  protected void activate(ComponentContext context) {
    BundleContext bundleContext = context.getBundleContext();
    tracker = new SearchResultProcessorTracker(bundleContext);
    tracker.open();

    siteSearchResultProcessor = new SiteSearchResultProcessor();
    siteSearchResultProcessor.bindSiteService(siteService);
  }
 public DefaultAuthorizablesLoader(
     AuthorizablePostProcessService authorizablePostProcessService,
     ComponentContext componentContext,
     SlingRepository repository) {
   this.authorizablePostProcessService = authorizablePostProcessService;
   this.bundle = componentContext.getBundleContext().getBundle();
   this.repository = repository;
 }