Author: dazarov
Date: 2010-03-19 13:29:20 -0400 (Fri, 19 Mar 2010)
New Revision: 20942
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5977
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2010-03-19 16:59:44 UTC (rev
20941)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2010-03-19 17:29:20 UTC (rev
20942)
@@ -32,43 +32,43 @@
<extension
point="org.jboss.tools.jst.web.kb.tagLib">
<tag-lib
- location="taglibs/Ajax4jsf.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/Ajax4jsf.xml"
name="JBoss Ajax4jsf"
uri="http://richfaces.org/a4j"/>
<tag-lib
- location="taglibs/Richfaces.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/Richfaces.xml"
name="JBoss RichFaces"
uri="http://richfaces.org/rich"/>
<tag-lib
- location="taglibs/JsfCore.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/JsfCore.xml"
name="JSF Core"
uri="http://java.sun.com/jsf/core"/>
<tag-lib
- location="taglibs/JsfHtmlBasic.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/JsfHtmlBasic.xml"
name="JSF HTML Basic"
uri="http://java.sun.com/jsf/html"/>
<tag-lib
- location="taglibs/Facelets.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/Facelets.xml"
name="Facelets UI"
uri="http://java.sun.com/jsf/facelets"/>
<tag-lib
- location="taglibs/FaceletsHtml.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/FaceletsHtml.xml"
name="Facelets Html"
uri="http://www.w3.org/1999/xhtml/facelets"/>
<tag-lib
- location="taglibs/JBossSeam.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/JBossSeam.xml"
name="JBoss Seam"
uri="http://jboss.com/products/seam/taglib"/>
<tag-lib
- location="taglibs/Jsp.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/Jsp.xml"
name="JSP"
uri="http://java.sun.com/JSP/Page"/>
<tag-lib
name="Struts HTML"
- location="taglibs/StrutsHtml.xml"
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/StrutsHtml.xml"
uri="http://struts.apache.org/tags-html"/>
<component-extension
- location="taglibs/componentExtension.xml"/>
+
location="platform:/plugin/org.jboss.tools.jst.web.kb/taglibs/componentExtension.xml"/>
</extension>
<extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2010-03-19
16:59:44 UTC (rev 20941)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2010-03-19
17:29:20 UTC (rev 20942)
@@ -11,8 +11,8 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -62,14 +62,14 @@
protected String name;
protected String defaultPrefix;
- public CustomTagLibrary(File file, String uri, String version, String name) {
+ public CustomTagLibrary(InputStream inputStream, String uri, String version, String
name) {
setURI(uri);
setVersion(version);
this.name = name;
Document document = null;
try {
DocumentBuilder builder = createDocumentBuilder(false);
- document = builder.parse(file);
+ document = builder.parse(inputStream);
} catch (SAXException e) {
WebKbPlugin.getDefault().logError(e);
} catch (IOException e) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java 2010-03-19
16:59:44 UTC (rev 20941)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java 2010-03-19
17:29:20 UTC (rev 20942)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib;
-import java.io.File;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -28,8 +28,8 @@
*/
public class HTMLTagLibrary extends CustomTagLibrary {
- public HTMLTagLibrary(File file, String uri, String version, String name) {
- super(file, uri, version, name);
+ public HTMLTagLibrary(InputStream inputStream, String uri, String version, String name)
{
+ super(inputStream, uri, version, name);
}
/*
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java 2010-03-19
16:59:44 UTC (rev 20941)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java 2010-03-19
17:29:20 UTC (rev 20942)
@@ -10,8 +10,9 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.taglib;
-import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
import java.util.HashSet;
import java.util.Set;
@@ -28,7 +29,6 @@
import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibAttribute;
import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibrary;
import org.jboss.tools.jst.web.kb.internal.taglib.HTMLTagLibrary;
-import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@@ -78,6 +78,17 @@
}
return extensions;
}
+
+ private InputStream getInputStream(IConfigurationElement element){
+ String location = element.getAttribute("location"); //$NON-NLS-1$
+ try{
+ URL url = FileLocator.resolve(new URL(location));
+ return url.openConnection().getInputStream();
+ }catch(IOException ex){
+ WebKbPlugin.getDefault().logError(ex);
+ return null;
+ }
+ }
private void init() {
Set<ICustomTagLibrary> libSet = new HashSet<ICustomTagLibrary>();
@@ -93,62 +104,28 @@
String elementName = elements[j].getName();
if(CustomTagLibrary.TAG_LIB.equals(elementName)) {
String uri = elements[j].getAttribute("uri"); //$NON-NLS-1$
- String location = elements[j].getAttribute("location"); //$NON-NLS-1$
String version = elements[j].getAttribute("version"); //$NON-NLS-1$
String name = elements[j].getAttribute("name"); //$NON-NLS-1$
- Bundle sourcePlugin = Platform.getBundle(elements[j].getNamespaceIdentifier());
- File schemaLocation = null;
- try {
- String pluginPath =
FileLocator.resolve(sourcePlugin.getEntry("/")).getPath(); //$NON-NLS-1$
- if(uri==null || uri.length()==0 || location==null || location.length()==0) {
- WebKbPlugin.getDefault().logWarning("Incorrect
org.jboss.tools.jst.web.kb.KbTagLib extension in " + pluginPath + " plugin. URI
or location can't be empty."); //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- }
- schemaLocation = new File(pluginPath, location);
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- continue;
- }
- if(schemaLocation.isFile()) {
- CustomTagLibrary lib = FACELETS_HTML_TAG_LIB_URI.equals(uri)?new
HTMLTagLibrary(schemaLocation, uri, version, name):new CustomTagLibrary(schemaLocation,
uri, version, name);
- libSet.add(lib);
- } else {
- WebKbPlugin.getDefault().logWarning("Can't load KB schema: " +
schemaLocation); //$NON-NLS-1$
- }
+ InputStream schemaStream = getInputStream(elements[j]);
+ CustomTagLibrary lib = FACELETS_HTML_TAG_LIB_URI.equals(uri)?new
HTMLTagLibrary(schemaStream, uri, version, name):new CustomTagLibrary(schemaStream, uri,
version, name);
+ libSet.add(lib);
} else if(CustomTagLibrary.COMPONET_EXTENSION.equals(elementName)) {
- String location = elements[j].getAttribute("location"); //$NON-NLS-1$
- Bundle sourcePlugin = Platform.getBundle(elements[j].getNamespaceIdentifier());
- File schemaLocation = null;
+ InputStream schemaStream = getInputStream(elements[j]);
+ Document document = null;
try {
- String pluginPath =
FileLocator.resolve(sourcePlugin.getEntry("/")).getPath(); //$NON-NLS-1$
- if(location==null || location.length()==0) {
- WebKbPlugin.getDefault().logWarning("Incorrect
org.jboss.tools.jst.web.kb.KbTagLib extension in " + pluginPath + " plugin.
Location can't be empty."); //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- }
- schemaLocation = new File(pluginPath, location);
+ DocumentBuilder builder = CustomTagLibrary.createDocumentBuilder(false);
+ document = builder.parse(schemaStream);
+ } catch (SAXException e) {
+ WebKbPlugin.getDefault().logError(e);
} catch (IOException e) {
WebKbPlugin.getDefault().logError(e);
- continue;
+ } catch (ParserConfigurationException e) {
+ WebKbPlugin.getDefault().logError(e);
}
- if(schemaLocation.isFile()) {
- Document document = null;
- try {
- DocumentBuilder builder = CustomTagLibrary.createDocumentBuilder(false);
- document = builder.parse(schemaLocation);
- } catch (SAXException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (ParserConfigurationException e) {
- WebKbPlugin.getDefault().logError(e);
- }
- Element root = document.getDocumentElement();
- CustomTagLibAttribute[] attributes = CustomTagLibrary.getAttributes(root);
- for (int k = 0; k < attributes.length; k++) {
- extensionSet.add(attributes[k]);
- }
- } else {
- WebKbPlugin.getDefault().logWarning("Can't load KB schema: " +
schemaLocation); //$NON-NLS-1$
+ Element root = document.getDocumentElement();
+ CustomTagLibAttribute[] attributes = CustomTagLibrary.getAttributes(root);
+ for (int k = 0; k < attributes.length; k++) {
+ extensionSet.add(attributes[k]);
}
}
}