Ejemplo n.º 1
0
  @Override
  public void start(BundleContext bundleContext) throws Exception {
    context = bundleContext;

    // URL x = context.getBundle().getEntry("config.xml");
    // InputStream is = x.openStream();

    ServiceReference reference = context.getServiceReference(IAqua.class.getName());
    aqua = (IAqua) context.getService(reference);

    FileInputStream is = new FileInputStream(new File(getBaseDir(), "config.xml"));
    config = new XmlConfig(MXml.loadXml(is).getDocumentElement());
    config.setString("_path", getBaseDir().getAbsolutePath());
    is.close();

    // init directories to publish
    IConfig cp = aqua.getConfig().getConfig("deploy");
    contentDir = cp.getExtracted("content") + "/" + getId();
    templateDir = cp.getExtracted("templates") + "/" + getId();

    getConfiguration().setProperty("_contentdir", contentDir);
    getConfiguration().setProperty("_templatedir", templateDir);

    // publish
    publish();

    // load resources
    loadResources();

    jmx = new JmxAquaModule(this);
    Activator.getAqua().getJmxManager().register(jmx);
  }
Ejemplo n.º 2
0
  private void publish(IConfig config, File dir) throws Exception {
    String clazz = config.getString("class", null);
    Publisher publisher = null;
    if (clazz == null) publisher = new PathPublisher();
    else publisher = getAqua().createPublisher(clazz);

    publisher.publish(config, dir);
  }
Ejemplo n.º 3
0
  public void publish() throws Exception {

    getContentFile(null).mkdirs();
    getTemplateFile(null).mkdirs();

    // publish
    IConfig cdeploy = getConfiguration().getConfig("deploy");
    if (cdeploy != null) {
      for (IConfig cpublish : cdeploy.getConfigBundle("content")) {
        publish(cpublish, getContentFile(null));
      }
      for (IConfig cpublish : cdeploy.getConfigBundle("templates")) {
        publish(cpublish, getTemplateFile(null));
      }
      for (IConfig cpublish : cdeploy.getConfigBundle("other")) {
        publish(cpublish, null);
      }
    }
  }
Ejemplo n.º 4
0
 public void loadResources() throws Exception {
   ResApplication resApp =
       (ResApplication) getAqua().getAquaApplication(ResApplication.class.getCanonicalName());
   IConfig config = getConfiguration();
   IConfig resources = config.getConfig("resources");
   if (resources != null) {
     for (IConfig resource : resources.getConfigBundle("resource")) {
       AquaRes res = getAqua().createAquaRes(resource.getProperty("type"));
       res.setConfig(resource);
       resApp.register(res);
       this.resources.put(resource.getProperty("name"), res);
     }
   }
 }