Author: vyemialyanchyk
Date: 2010-12-02 09:59:30 -0500 (Thu, 02 Dec 2010)
New Revision: 27100
Added:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ant-tasks-description.xml
Removed:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/ant-tasks-description.xml
Modified:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/build.properties
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExportersXMLAttributeDescription.java
Log:
https://jira.jboss.org/browse/JBIDE-7746 - fix, for beta2
Deleted:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/ant-tasks-description.xml
===================================================================
---
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/ant-tasks-description.xml 2010-12-02
14:37:26 UTC (rev 27099)
+++
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/ant-tasks-description.xml 2010-12-02
14:59:30 UTC (rev 27100)
@@ -1,62 +0,0 @@
-<ant-tasks>
- <task name="hbm2doc" id="org.hibernate.tools.hbm2doc">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- </task>
- <task name="hbm2cfgxml" id="org.hibernate.tools.hbm2cfgxml">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <attribute name="ejb3" gui-name="ejb3"
default="false"/>
- </task>
- <task name="hbm2hbmxml" id="org.hibernate.tools.hbm2hbmxml">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- </task>
- <task name="hbmtemplate"
id="org.hibernate.tools.hbmtemplate">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <attribute name="filepattern" gui-name="file_pattern"
default=""/>
- <attribute name="foreach" gui-name="for_each"
default=""/>
- <attribute name="template" gui-name="template_name"
default=""/>
- <attribute name="exporterclass" gui-name="exporterclass"
default=""/>
- </task>
- <task name="hbm2java" id="org.hibernate.tools.hbm2java">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <attribute name="jdk5" gui-name="jdk5"
default="false"/>
- <attribute name="ejb3" gui-name="ejb3"
default="false"/>
- </task>
- <task name="hbm2ddl" id="org.hibernate.tools.hbm2ddl">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <attribute name="export" gui-name="exportToDatabase"
default="true"/>
- <attribute name="update" gui-name="schemaUpdate"
default="false"/>
- <attribute name="drop" gui-name="drop"
default="false"/>
- <attribute name="create" gui-name="create"
default="true"/>
- <attribute name="outputfilename" gui-name="outputFileName"
default=""/>
- <attribute name="delimiter" gui-name="delimiter"
default=";"/>
- <attribute name="format" gui-name="format"
default="false"/>
- <attribute name="haltonerror" gui-name="haltonerror"
default="false"/>
- <attribute name="console" gui-name="scriptToConsole"
default="true"/>
- </task>
- <task name="hbm2dao" id="org.hibernate.tools.hbm2dao">
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <attribute name="jdk5" gui-name="jdk5"
default="false"/>
- <attribute name="ejb3" gui-name="ejb3"
default="false"/>
- </task>
- <task name="query" id="org.hibernate.tools.query">
- <attribute name="destfile" gui-name="outputFileName"
default=""/>
- <attribute name="destdir" gui-name="outputdir"
default=""/>
- <attribute name="templatepath" gui-name="template_path"
default=""/>
- <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
- <subtag name="hql" gui-name="query_string"
default=""/>
- </task>
-</ant-tasks>
Modified:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/build.properties
===================================================================
---
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/build.properties 2010-12-02
14:37:26 UTC (rev 27099)
+++
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/build.properties 2010-12-02
14:59:30 UTC (rev 27100)
@@ -6,9 +6,7 @@
doc/,\
META-INF/,\
about.html,\
- ant-tasks-description.xml,\
plugin.properties
src.includes = src/,\
icons/,\
- doc/,\
- ant-tasks-description.xml
+ doc/
Modified:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExportersXMLAttributeDescription.java
===================================================================
---
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExportersXMLAttributeDescription.java 2010-12-02
14:37:26 UTC (rev 27099)
+++
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExportersXMLAttributeDescription.java 2010-12-02
14:59:30 UTC (rev 27100)
@@ -11,10 +11,11 @@
package org.hibernate.eclipse.launch;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
-import java.net.URL;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -25,9 +26,6 @@
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
/**
@@ -40,7 +38,7 @@
/**
* path to file to store description
*/
- public static final String ANT_TASKS_DESCRIPTION_PATH =
"ant-tasks-description.xml"; //$NON-NLS-1$
+ public static final String ANT_TASKS_DESCRIPTION_PATH =
"org/hibernate/eclipse/launch/ant-tasks-description.xml"; //$NON-NLS-1$
public static class AttributeDescription {
public String name;
@@ -116,27 +114,44 @@
}
private static Document getDocument() {
- File resourceFile = null;
- try {
- resourceFile = getResourceItem(ANT_TASKS_DESCRIPTION_PATH);
- } catch (IOException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("getResource: ", e);
//$NON-NLS-1$
- }
- if (resourceFile == null || !resourceFile.exists()) {
- HibernateConsolePlugin.getDefault().logErrorMessage("Can't read file: "
+ ANT_TASKS_DESCRIPTION_PATH, (Throwable)null); //$NON-NLS-1$
+ InputStream input = getResInputStream(ANT_TASKS_DESCRIPTION_PATH,
ExportersXMLAttributeDescription.class);
+ if (input == null) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("Can't read resource:
" + ANT_TASKS_DESCRIPTION_PATH, (Throwable)null); //$NON-NLS-1$
return null;
}
- StringBuffer cbuf = new StringBuffer((int) resourceFile.length());
+ StringBuffer cbuf = new StringBuffer();
+ InputStreamReader isReader = null;
+ BufferedReader in = null;
try {
String ls = System.getProperties().getProperty("line.separator",
"\n"); //$NON-NLS-1$//$NON-NLS-2$
- BufferedReader in = new BufferedReader(new FileReader(resourceFile));
+ isReader = new InputStreamReader(input);
+ in = new BufferedReader(isReader);
String str;
while ((str = in.readLine()) != null) {
cbuf.append(str + ls);
}
- in.close();
} catch (IOException e) {
HibernateConsolePlugin.getDefault().logErrorMessage("IOException: ", e);
//$NON-NLS-1$
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ if (isReader != null) {
+ try {
+ isReader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ try {
+ input.close();
+ } catch (IOException e) {
+ // ignore
+ }
}
Document res = null;
try {
@@ -146,17 +161,30 @@
}
return res;
}
-
- private static File getResourceItem(String strResPath) throws IOException {
- IPath resourcePath = new Path(strResPath);
- File resourceFile = resourcePath.toFile();
- URL entry = HibernateConsolePlugin.getDefault().getBundle().getEntry(
- strResPath);
- if (entry != null) {
- URL resProject = FileLocator.resolve(entry);
- strResPath = FileLocator.resolve(resProject).getFile();
+
+ /**
+ * @param resName fully qualified path of the resource
+ * @param clazz the class where the resource will exist
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static InputStream getResInputStream(final String resName, final Class clazz) {
+ InputStream input = null;
+ if (System.getSecurityManager() == null) {
+ input = getResInputStreamInternal(resName, clazz);
+ } else {
+ input = AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return getResInputStreamInternal(resName, clazz);
+ }
+ });
}
- resourceFile = new File(strResPath);
- return resourceFile;
+ return input;
}
+
+ @SuppressWarnings("rawtypes")
+ static InputStream getResInputStreamInternal(final String resName, Class clazz) {
+ ClassLoader loader = clazz.getClassLoader();
+ final InputStream input = loader == null ?
ClassLoader.getSystemResourceAsStream(resName) : loader.getResourceAsStream(resName);
+ return input;
+ }
}
Copied:
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ant-tasks-description.xml
(from rev 27001,
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/ant-tasks-description.xml)
===================================================================
---
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ant-tasks-description.xml
(rev 0)
+++
branches/jbosstools-3.2.0.Beta2/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ant-tasks-description.xml 2010-12-02
14:59:30 UTC (rev 27100)
@@ -0,0 +1,62 @@
+<ant-tasks>
+ <task name="hbm2doc" id="org.hibernate.tools.hbm2doc">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ </task>
+ <task name="hbm2cfgxml" id="org.hibernate.tools.hbm2cfgxml">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <attribute name="ejb3" gui-name="ejb3"
default="false"/>
+ </task>
+ <task name="hbm2hbmxml" id="org.hibernate.tools.hbm2hbmxml">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ </task>
+ <task name="hbmtemplate"
id="org.hibernate.tools.hbmtemplate">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <attribute name="filepattern" gui-name="file_pattern"
default=""/>
+ <attribute name="foreach" gui-name="for_each"
default=""/>
+ <attribute name="template" gui-name="template_name"
default=""/>
+ <attribute name="exporterclass" gui-name="exporterclass"
default=""/>
+ </task>
+ <task name="hbm2java" id="org.hibernate.tools.hbm2java">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <attribute name="jdk5" gui-name="jdk5"
default="false"/>
+ <attribute name="ejb3" gui-name="ejb3"
default="false"/>
+ </task>
+ <task name="hbm2ddl" id="org.hibernate.tools.hbm2ddl">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <attribute name="export" gui-name="exportToDatabase"
default="true"/>
+ <attribute name="update" gui-name="schemaUpdate"
default="false"/>
+ <attribute name="drop" gui-name="drop"
default="false"/>
+ <attribute name="create" gui-name="create"
default="true"/>
+ <attribute name="outputfilename" gui-name="outputFileName"
default=""/>
+ <attribute name="delimiter" gui-name="delimiter"
default=";"/>
+ <attribute name="format" gui-name="format"
default="false"/>
+ <attribute name="haltonerror" gui-name="haltonerror"
default="false"/>
+ <attribute name="console" gui-name="scriptToConsole"
default="true"/>
+ </task>
+ <task name="hbm2dao" id="org.hibernate.tools.hbm2dao">
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <attribute name="jdk5" gui-name="jdk5"
default="false"/>
+ <attribute name="ejb3" gui-name="ejb3"
default="false"/>
+ </task>
+ <task name="query" id="org.hibernate.tools.query">
+ <attribute name="destfile" gui-name="outputFileName"
default=""/>
+ <attribute name="destdir" gui-name="outputdir"
default=""/>
+ <attribute name="templatepath" gui-name="template_path"
default=""/>
+ <attribute name="templateprefix" gui-name="templateprefix"
default=""/>
+ <subtag name="hql" gui-name="query_string"
default=""/>
+ </task>
+</ant-tasks>