private ConfigurationAdmin getConfigurationAdmin() { try { if (isInOSGi() && (configurationAdmin == null)) { BundleContext bundleContext = FrameworkUtil.getBundle(ManagedApi.class) .getBundleContext(); if (bundleContext != null) { ServiceReference serviceReference = bundleContext .getServiceReference(ConfigurationAdmin.class.getName()); if (serviceReference != null) { configurationAdmin = (ConfigurationAdmin)bundleContext.getService(serviceReference); } } } } catch (Exception e) { LOG.log(Level.WARNING, "getConfigurationAdmin failed.", e); } return configurationAdmin; }
private ConfigurationAdmin getConfigurationAdmin() { try { if (isInOSGi() && (configurationAdmin == null)) { BundleContext bundleContext = FrameworkUtil.getBundle(ManagedApi.class) .getBundleContext(); if (bundleContext != null) { ServiceReference serviceReference = bundleContext .getServiceReference(ConfigurationAdmin.class.getName()); if (serviceReference != null) { configurationAdmin = (ConfigurationAdmin)bundleContext.getService(serviceReference); } } } } catch (Exception e) { LOG.log(Level.WARNING, "getConfigurationAdmin failed.", e); } return configurationAdmin; }
@ManagedAttribute(description = "The cxf servlet context", currencyTimeLimit = 60) public String getServletContext() { if (!isInOSGi()) { LOG.log(Level.FINE, "Not In OSGi."); return null; //not in OSGi container } String ret = "/cxf"; //if can't get it from configAdmin use the default value if (getConfigurationAdmin() != null) { try { Configuration configuration = getConfigurationAdmin().getConfiguration("org.apache.cxf.osgi", null); if (configuration != null) { Dictionary properties = configuration.getProperties(); if (properties != null) { String servletContext = (String)configuration.getProperties(). get("org.apache.cxf.servlet.context"); if (servletContext != null) { ret = servletContext; } } } } catch (IOException e) { LOG.log(Level.WARNING, "getServletContext failed.", e); } } return ret; }
@ManagedAttribute(description = "The cxf servlet context", currencyTimeLimit = 60) public String getServletContext() { if (!isInOSGi()) { LOG.log(Level.FINE, "Not In OSGi."); return getSingletonCxfServletContext(); } String ret = "/cxf"; //if can't get it from configAdmin use the default value if (getConfigurationAdmin() != null) { try { Configuration configuration = getConfigurationAdmin().getConfiguration("org.apache.cxf.osgi"); if (configuration != null) { Dictionary properties = configuration.getProperties(); if (properties != null) { String servletContext = (String)configuration.getProperties(). get("org.apache.cxf.servlet.context"); if (servletContext != null) { ret = servletContext; } } } } catch (IOException e) { LOG.log(Level.WARNING, "getServletContext failed.", e); } } return ret; }