public Weblet getWeblet(String webletName) { Weblet weblet = (Weblet) _weblets.get(webletName); if (weblet == null) { try { WebletConfigImpl config = (WebletConfigImpl) _webletConfigs.get(webletName); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class webletClass = loader.loadClass(config.getWebletClass()); weblet = (Weblet) webletClass.newInstance(); weblet.init(config); _weblets.put(webletName, weblet); } catch (ClassNotFoundException e) { throw new WebletException(e); } catch (InstantiationException e) { throw new WebletException(e); } catch (IllegalAccessException e) { throw new WebletException(e); } } return weblet; }
public Weblet getWeblet(String webletName) { Weblet weblet = (Weblet) _weblets.get(webletName); if (weblet == null) { try { WebletConfigImpl config = (WebletConfigImpl) _webletConfigs.get(webletName); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class webletClass = loader.loadClass(config.getWebletClass()); weblet = (Weblet) webletClass.newInstance(); weblet.init(config); _weblets.put(webletName, weblet); } catch (ClassNotFoundException e) { throw new WebletException(e); } catch (InstantiationException e) { throw new WebletException(e); } catch (IllegalAccessException e) { throw new WebletException(e); } } return weblet; }
public void init(WebletConfig config) { super.init(config); String httpAddress = config.getInitParameter("rootaddress"); if (httpAddress == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } _resourceRoot = httpAddress; }
/** * init method which is called by default to process the parameters * * @param config the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); // fetch the weblets init param _packageName = config.getInitParameter("package"); // fetch the resource root param /*auto fix path according to the specs the root must begin with a leading /*/ _resourceRoot = config.getInitParameter("resourceRoot"); if (StringUtils.isBlank(_resourceRoot)) _resourceRoot = "/"; _resourceRoot = _resourceRoot.trim(); if (!_resourceRoot.startsWith("/") && !_resourceRoot.startsWith("\\")) _resourceRoot = "/" + _resourceRoot; // init param missing, lets throw an error if (_packageName == null && _resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } // the init was successful we now have all we need _resourceRoot = (_packageName != null) ? _packageName.replace('.', '/') : _resourceRoot; }
/** * init method which is called by default to process the parameters * * @param config * the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); _resourceRoot = config.getInitParameter("resourceRoot"); // init param missing, lets throw an error if (_resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } }
/** * init method which is called by default to process the parameters * * @param config the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); // fetch the weblets init param String packageName = config.getInitParameter("package"); // fetch the resource root param String resourceRoot = config.getInitParameter("resourceRoot"); // String cacheTimeout = config.getInitParameter("cachecontrol-timeout"); // init param missing, lets throw an error if (packageName == null && resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } // the init was successful we now have all we need _resourceRoot = (packageName != null) ? packageName.replace('.', '/') : resourceRoot; // optional init param }