Esempio n. 1
0
  @Override
  public synchronized void start(BundleContext bundleContext) throws Exception {

    // This is how we replace the default FactoryFinder strategy
    // with one that is more compatible in an OSGi env.
    FactoryFinder.setObjectFactory(this);

    debug("activating");
    this.bundleContext = bundleContext;

    cachePackageCapabilities(
        Service.class, Transport.class, DiscoveryAgent.class, PersistenceAdapter.class);

    debug("checking existing bundles");
    bundleContext.addBundleListener(this);
    for (Bundle bundle : bundleContext.getBundles()) {
      if (bundle.getState() == Bundle.RESOLVED
          || bundle.getState() == Bundle.STARTING
          || bundle.getState() == Bundle.ACTIVE
          || bundle.getState() == Bundle.STOPPING) {
        register(bundle);
      }
    }
    debug("activated");
  }
Esempio n. 2
0
 protected MessageRenderer getMessageRenderer(HttpServletRequest request)
     throws IOException, ServletException {
   String style = request.getParameter("view");
   if (style == null) {
     style = "simple";
   }
   try {
     return (MessageRenderer) factoryFinder.newInstance(style);
   } catch (IllegalAccessException e) {
     throw new NoSuchViewStyleException(style, e);
   } catch (InstantiationException e) {
     throw new NoSuchViewStyleException(style, e);
   } catch (ClassNotFoundException e) {
     throw new NoSuchViewStyleException(style, e);
   }
 }