@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); }
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); }
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); } } }
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); } } }