Java Code Examples for org.apache.axis2.engine.AxisConfiguration#addObservers()

The following examples show how to use org.apache.axis2.engine.AxisConfiguration#addObservers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemStatisticsDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
@Activate
protected void activate(ComponentContext ctxt) {

    BundleContext bundleCtx = ctxt.getBundleContext();
    // Publish the OSGi service
    Dictionary props = new Hashtable();
    props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
    bundleCtx.registerService(AxisObserver.class.getName(), this, props);
    PreAxisConfigurationPopulationObserver preAxisConfigObserver = new PreAxisConfigurationPopulationObserver() {

        public void createdAxisConfiguration(AxisConfiguration axisConfiguration) {

            axisConfiguration.addObservers(new SystemStatisticsDeploymentInterceptor());
        }
    };
    bundleCtx.registerService(PreAxisConfigurationPopulationObserver.class.getName(), preAxisConfigObserver, null);
}
 
Example 2
Source File: UrlMappingDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
@Activate
protected void activate(ComponentContext ctxt) {

    BundleContext bundleCtx = ctxt.getBundleContext();
    // Publish the OSGi service
    Dictionary props = new Hashtable();
    props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
    bundleCtx.registerService(AxisObserver.class.getName(), this, props);
    PreAxisConfigurationPopulationObserver preAxisConfigObserver = new PreAxisConfigurationPopulationObserver() {

        public void createdAxisConfiguration(AxisConfiguration axisConfiguration) {

            init(axisConfiguration);
            axisConfiguration.addObservers(UrlMappingDeploymentInterceptor.this);
        }
    };
    bundleCtx.registerService(PreAxisConfigurationPopulationObserver.class.getName(), preAxisConfigObserver, null);
    // Publish an OSGi service to listen tenant configuration context creation events
    Dictionary properties = new Hashtable();
    properties.put(CarbonConstants.AXIS2_CONFIG_SERVICE, Axis2ConfigurationContextObserver.class.getName());
    bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(), new UrlMappingServiceListener(),
            properties);
}
 
Example 3
Source File: SecurityDeploymentListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public void createdConfigurationContext(ConfigurationContext configCtx) {
    AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    //Register SecurityDeploymentInterceptor as an AxisObserver in tenant's AxisConfig.

    SecurityDeploymentInterceptor secDeployInterceptor = new SecurityDeploymentInterceptor();
    secDeployInterceptor.init(axisConfig);
    axisConfig.addObservers(secDeployInterceptor);

    //Store the policy resources in newly created tenant's config. registry
    Map<String, Resource> policyResourceMap = SecurityServiceHolder.getPolicyResourceMap();
    try {
        Registry registry = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(
                tenantId);
        boolean transactionStarted = Transaction.isStarted();
        if (!transactionStarted) {
            registry.beginTransaction();
        }
        for (String resourceLoc : policyResourceMap.keySet()) {
            if (!registry.resourceExists(resourceLoc)) {
                registry.put(resourceLoc, policyResourceMap.get(resourceLoc));
            }
        }
        if (!transactionStarted) {
            registry.commitTransaction();
        }
    } catch (Exception e) {
        String errorMsg = "Error when storing the policy resource in registry for tenant : " +
                tenantId;
        log.error(errorMsg, e);
    }
}
 
Example 4
Source File: UrlMappingServiceListener.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void creatingConfigurationContext(org.apache.axis2.context.ConfigurationContext configCtx) {
    AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
    //Register UrlMappingDeploymentInterceptor as an AxisObserver in tenant's AxisConfig.
    UrlMappingDeploymentInterceptor secDeployInterceptor = new UrlMappingDeploymentInterceptor();
    secDeployInterceptor.init(axisConfig);
    axisConfig.addObservers(secDeployInterceptor);
}
 
Example 5
Source File: Util.java    From carbon-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Engage the TargetServiceObserver on the given AxisConfiguration. This will enable
 * service discovery.
 *
 * @param axisConf AxisConfiguration instance
 */
public static void registerServiceObserver(AxisConfiguration axisConf) {
    TargetServiceObserver targetServiceObserver = new TargetServiceObserver();
    targetServiceObserver.init(axisConf);
    axisConf.addObservers(targetServiceObserver);
}