sabob
|
Posted: December 02, 2009 09:51 by sabob
|
|
Hi all, Currently NB-Click determines if the project is a Click project based on whether the ClickServlet is registered in web.xml. However if using a subclass of ClickServlet this check won't work. So how about checking for the existence of 'click.xml' instead? public class ClickConfigUtilities { ... public static boolean isClickProject(WebModule wm) { Project project = getProject(wm); return getClickConfigFile(project, ClickConstants.DEFAULT_CLICK_APP_CONFIG_FILE) != null; } public static Project getProject(WebModule webModule) { FileObject docBase = webModule.getDocumentBase(); return FileOwnerQuery.getOwner(docBase); } kind regards bob |
Logic for determining a Click project
Replies: 1 - Last Post: December 04, 2009 12:29
by: hantsy
by: hantsy
showing 1 - 2 of 2
hantsy
|
Posted: December 04, 2009 12:29 by hantsy
|
|
NBClick(http://nbclick.dev.java.net) is just initialized...I can not found the code you post. My plugin(this project) will check ClickServlet and Spring specific ClickServlet which are provided by Apache Clcik officially... but not check the existence of click.xml file. You can explorer the source code about this issue. NetBeans calls the isInWebModule method of WebFrameworkProvider to determine weather a WebFramework is added. public class ClickFrameworkProvider extends WebFrameworkProvider { @Override public boolean isInWebModule(WebModule wm) { return ClickConfigUtilities.isClickProject(wm); } ...... } The following code fragment is In the ClickConfigUtilities. public static boolean isClickProject(WebModule wm) { if (wm == null) { return false; } try { WebApp wa = DDProvider.getDefault().getDDRoot(wm.getDeploymentDescriptor()); if (wa != null) { return (ClickConfigUtilities.findServlet(wa, ClickConstants.CLICK_SERVELT_CLASS) != null) || (ClickConfigUtilities.findServlet(wa, ClickConstants.SPRING_CLICK_SERVELT_CLASS) != null); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } return false; } Theoretically it needs check the ClickServlet (or subclass of ClickServlet ) in web.xml and check if the Class exists in the Project classpath and if click.xml exists in the Project at the same time. But a uncertain subclass of ClickServlet check will scan the complete classpath of the Project. There is a small performance issue. But if click.xml exists in the Project, but ClickServlet (or its subclass) are not registered in web.xml, I think the Project can not be considered as a Click Project. If the ClickServlet registered in web.xml does not exists in the Project , it means tthe Click. related jar files is missing...when run this project, it will cause exception. if click.xml does not exists , it also cause problem at runtime. The later two means Click is registered but some configuration is problematic. This is not a big problem. I would like listen the voice about this issue from all Click users. |
Replies: 1 - Last Post: December 04, 2009 12:29
by: hantsy
by: hantsy







