Java源码示例:org.wso2.carbon.core.ServerStartupObserver

示例1
@Activate
protected void activate(ComponentContext ctxt) {
    try {
        APIKeyMgtDataHolder.initData();
        log.debug("Key Manager User Operation Listener is enabled.");
        // Register subscription datastore related service
        serviceRegistration = ctxt.getBundleContext().registerService(
                Axis2ConfigurationContextObserver.class.getName(), new ServerStartupListener(), null);
        serviceRegistration = ctxt.getBundleContext().registerService(
                ServerStartupObserver.class.getName(), new ServerStartupListener(), null);

        // Register KeyManagerDataService
        serviceRegistration = ctxt.getBundleContext().registerService(KeyManagerDataService.class.getName(),
                new KeyManagerDataServiceImpl(), null);

        if (log.isDebugEnabled()) {
            log.debug("Identity API Key Mgt Bundle is started.");
        }
    } catch (Exception e) {
        log.error("Failed to initialize key management service.", e);
    }
}
 
示例2
@Activate
protected void activate(ComponentContext context) {

    log.debug("Activating component...");
    APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIMConfiguration();
    if (configuration != null) {
        if (!configuration.getThrottleProperties().getJmsConnectionProperties().isEnabled()) {
            return;
        }
    } else {
        log.warn("API Manager Configuration not properly set.");
    }
    JMSListenerStartupShutdownListener jmsListenerStartupShutdownListener =
            new JMSListenerStartupShutdownListener();
    registration = context.getBundleContext()
            .registerService(ServerStartupObserver.class, jmsListenerStartupShutdownListener, null);
    registration = context.getBundleContext()
            .registerService(ServerShutdownHandler.class, jmsListenerStartupShutdownListener, null);
}
 
示例3
protected void activate(ComponentContext ctx) {
    if (log.isDebugEnabled()) {
        log.debug("Activating Url printer Service Component");
    }
    try {
        BundleContext bundleContext = ctx.getBundleContext();
        bundleContext.registerService(ServerStartupObserver.class.getName(), new URLPrinterStartupHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("Url printer Service Component has been successfully activated");
        }
    } catch (Throwable e) {
        log.error("Error occurred while activating Url printer Service Component", e);
    }
}
 
示例4
private void registerServices(ComponentContext componentContext) {
    if (log.isDebugEnabled()) {
        log.debug("Registering OSGi service DeviceManagementProviderServiceImpl");
    }
    /* Registering Device Management Service */
    BundleContext bundleContext = componentContext.getBundleContext();

    APIPublisherService publisher = new APIPublisherServiceImpl();
    APIPublisherDataHolder.getInstance().setApiPublisherService(publisher);
    bundleContext.registerService(APIPublisherService.class, publisher, null);
    bundleContext.registerService(ServerStartupObserver.class, new APIPublisherStartupHandler(), null);
}
 
示例5
@Activate
protected void activate(ComponentContext ctx) {
    if (log.isDebugEnabled()) {
        log.debug("Activating tenant initialization component.");
    }
    BundleContext bundleContext = ctx.getBundleContext();
    bundleContext.registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null);
}
 
示例6
@Activate
protected void activate(ComponentContext componentContext) {
    try {
        log.debug("Startup Service Component activated");
        BundleContext bundleContext = componentContext.getBundleContext();
        registration = bundleContext
                .registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null);
    } catch (Exception e) {
        log.error("Error occurred in startup service component activation", e);
    }
}
 
示例7
@Activate
protected void activate(ComponentContext context) {

    BundleContext bundleContext = context.getBundleContext();
    if (log.isDebugEnabled()) {
        log.debug("API handlers component activated");
    }
    try {
        ConfigurationContext ctx =
                ConfigurationContextFactory.createConfigurationContextFromFileSystem(getClientRepoLocation(),
                        getAxis2ClientXmlLocation());
        ServiceReferenceHolder.getInstance().setAxis2ConfigurationContext(ctx);
        if (APIConstants.API_KEY_VALIDATOR_WS_CLIENT.equals(APISecurityUtils.getKeyValidatorClientType())) {
            clientPool = APIKeyValidatorClientPool.getInstance();
        }
        APIManagerConfiguration apiManagerConfiguration =
                ServiceReferenceHolder.getInstance().getAPIManagerConfiguration();
        String gatewayType = apiManagerConfiguration.getFirstProperty(APIConstants.API_GATEWAY_TYPE);
        GatewayStartupListener gatewayStartupListener = new GatewayStartupListener();
        bundleContext.registerService(ServerStartupObserver.class.getName(), gatewayStartupListener, null);
        bundleContext.registerService(ServerShutdownHandler.class, gatewayStartupListener, null);

        if ("Synapse".equalsIgnoreCase(gatewayType)) {
            // Register Tenant service creator to deploy tenant specific common synapse configurations
            TenantServiceCreator listener = new TenantServiceCreator();
            bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(), listener, null);
            if (apiManagerConfiguration.getThrottleProperties().isEnabled()) {
                ServiceReferenceHolder.getInstance().setThrottleDataPublisher(new ThrottleDataPublisher());
                ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder();
                APIThrottleDataServiceImpl throttleDataServiceImpl =
                        new APIThrottleDataServiceImpl(throttleDataHolder);
                CacheInvalidationService cacheInvalidationService = new CacheInvalidationServiceImpl();
                // Register APIThrottleDataService so that ThrottleData maps are available to other components.
                ServiceReferenceHolder.getInstance().setCacheInvalidationService(cacheInvalidationService);
                ServiceReferenceHolder.getInstance().setAPIThrottleDataService(throttleDataServiceImpl);
                ServiceReferenceHolder.getInstance().setThrottleDataHolder(throttleDataHolder);
                ServiceReferenceHolder.getInstance().setRevokedTokenService(new RevokedTokenDataImpl());
                log.debug("APIThrottleDataService Registered...");
                // start web service throttle data retriever as separate thread and start it.
                if (apiManagerConfiguration.getThrottleProperties().getBlockCondition().isEnabled()) {
                    BlockingConditionRetriever webServiceThrottleDataRetriever = new BlockingConditionRetriever();
                    webServiceThrottleDataRetriever.startWebServiceThrottleDataRetriever();
                    KeyTemplateRetriever webServiceBlockConditionsRetriever = new KeyTemplateRetriever();
                    webServiceBlockConditionsRetriever.startKeyTemplateDataRetriever();

                    // Start web service based revoked JWT tokens retriever.
                    // Advanced throttle properties & blocking conditions have to be enabled for JWT token
                    // retrieval due to the throttle config dependency for this feature.
                    RevokedJWTTokensRetriever webServiceRevokedJWTTokensRetriever = new RevokedJWTTokensRetriever();
                    webServiceRevokedJWTTokensRetriever.startRevokedJWTTokensRetriever();
                }
            }

            // Set APIM Gateway JWT Generator

            registration =
                    context.getBundleContext().registerService(AbstractAPIMgtGatewayJWTGenerator.class.getName(),
                            new APIMgtGatewayJWTGeneratorImpl(), null);
            registration =
                    context.getBundleContext().registerService(AbstractAPIMgtGatewayJWTGenerator.class.getName(),
                            new APIMgtGatewayUrlSafeJWTGeneratorImpl(), null);
            // Start JWT revoked map cleaner.
            RevokedJWTMapCleaner revokedJWTMapCleaner = new RevokedJWTMapCleaner();
            revokedJWTMapCleaner.startJWTRevokedMapCleaner();
            ServiceReferenceHolder.getInstance().setTracer(ServiceReferenceHolder.getInstance().getTracingService()
                    .buildTracer(APIMgtGatewayConstants.SERVICE_NAME));
        }
    } catch (IOException e) {
        log.error("Error while initializing the API Gateway (APIHandlerServiceComponent) component", e);
    }
    // Create caches for the super tenant
    ServerConfiguration.getInstance().overrideConfigurationProperty("Cache.ForceLocalCache", "true");
    CacheProvider.createGatewayKeyCache();
    CacheProvider.createResourceCache();
    CacheProvider.createGatewayTokenCache();
    CacheProvider.createInvalidTokenCache();
    CacheProvider.createGatewayBasicAuthResourceCache();
    CacheProvider.createGatewayUsernameCache();
    CacheProvider.createInvalidUsernameCache();
    CacheProvider.createGatewayApiKeyCache();
    CacheProvider.createGatewayApiKeyDataCache();
    CacheProvider.getInvalidGatewayApiKeyCache();
    CacheProvider.getJWKSCache();
}