You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/10/19 01:50:05 UTC
svn commit: rev 55037 - incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis
Author: mmerz
Date: Mon Oct 18 16:50:04 2004
New Revision: 55037
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
Log:
Fixed debug error output for apt-compilation.
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java Mon Oct 18 16:50:04 2004
@@ -85,6 +85,7 @@
* @author Doug Davis (dug@us.ibm.com)
* @author Sam Ruby (rubys@us.ibm.com)
*
+ * todo: fix directory structure/classloaders for output files
*/
public class DropInDeploymentHandler extends BasicHandler
{
@@ -94,6 +95,10 @@
private Map<Class, SOAPService> mSoapServiceMap =
new HashMap<Class, SOAPService>();
+ /**
+ * @param mc
+ * @throws AxisFault
+ */
public void invoke(MessageContext mc)
throws AxisFault
{
@@ -115,11 +120,21 @@
}
}
- public void generateWSDL(MessageContext msgContext) throws AxisFault
+ /**
+ * @param mc
+ * throws AxisFault
+ */
+ public void generateWSDL(MessageContext mc)
+ throws AxisFault
{
- invoke(msgContext);
+ invoke(mc);
}
+ /**
+ * @param
+ * @return
+ * @throws Exception
+ */
protected SOAPService createSOAPServiceFromAnnotatedClass(Class clazz)
throws Exception
{
@@ -140,6 +155,12 @@
return rpc;
}
+ /**
+ * @param wsm
+ * @param cls
+ * @return
+ * @throws Exception
+ */
protected SOAPService createSOAPServiceUsingAnnotations(WebServiceTYPEMetadata wsm, Class cls)
throws Exception
{
@@ -196,58 +217,13 @@
}
return rpc;
}
-
- protected void compileWithApt(String defaultClasspath, String outDirPath, File clsFile, String jFile)
- throws Exception
- {
- com.sun.tools.apt.Main apt = new com.sun.tools.apt.Main();
- String[] args = {
- "-classpath", defaultClasspath, // classpath -- todo necessary?
- "-d", outDirPath, // output directory
- jFile // source file
- };
-
- PrintWriter pw = new PrintWriter(new StringWriter());
- int result = apt.compile(args, pw);
-
- if (0 != result) // todo evaluate the return code
- {
- clsFile.delete();
-
- // construct error message
- Document doc = XMLUtils.newDocument();
- Element root = doc.createElementNS("", "Errors");
- StringBuffer message = new StringBuffer("Error compiling ");
- message.append(jFile);
- message.append(":\n");
- message.append(pw.toString());
- message.append("\n");
- root.appendChild(doc.createTextNode(message.toString()));
-
- // generate fault
- AxisFault af = new AxisFault(
- "Server.compileError",
- Messages.getMessage("badCompile00", jFile),
- null,
- new Element[] { root }
- );
-
- // log fault
- log.warn("Error compiling JWS", af);
-
- // FIXME jcolwell@bea.com 2004-Sep-23 --
- // logging error to System.out since I have no idea
- // where log.warn is dumping the error.
- // Additionally, the error only shows up if a method
- // is invoked, otherwise, the error is not displayed.
- // af.printStackTrace();
-
- // throw fault
- throw af;
- }
- }
-
+ /**
+ * Mostly taken from Axis code base.
+ * @param mc
+ * @return
+ * @throws
+ */
protected Class compileDroppedInSource(MessageContext mc)
throws Exception
{
@@ -351,8 +327,11 @@
File javaFile = new File(jFile);
try {
srcFile.renameTo(javaFile);
- compileWithApt(ClasspathUtils.getDefaultClasspath(mc), outDirPath, clsFile, jFile);
- ClassUtils.removeClassLoader( clsName );
+ if (0 != compile(ClasspathUtils.getDefaultClasspath(mc), outDirPath, jFile))
+ {
+ clsFile.delete();
+ }
+ ClassUtils.removeClassLoader(clsName);
mSoapServiceMap.remove(clsName); // clean out the cached service
}
finally {
@@ -364,10 +343,11 @@
ClassLoader cl = ClassUtils.getClassLoader(clsName);
if (null == cl)
{
- //cl = new JWSClassLoader(clsName, mc.getClassLoader(), cFile);
- System.out.println(outDirectory.getCanonicalPath());
- cl = new URLClassLoader(new URL[]{outDirectory.toURL()},
- mc.getClassLoader());
+ // todo: cl = new JWSClassLoader(clsName, mc.getClassLoader(), cFile);
+ cl = new URLClassLoader(
+ new URL[]{outDirectory.toURL()},
+ mc.getClassLoader()
+ );
}
mc.setClassLoader(cl);
@@ -375,5 +355,64 @@
}
}
return null;
+ }
+
+ /**
+ * @param classpath
+ * @param outDirPath
+ * @param jFile
+ * @return
+ * @throws Exception
+ */
+ protected int compile(String classpath, String outDirPath, String jFile)
+ throws Exception
+ {
+ com.sun.tools.apt.Main apt = new com.sun.tools.apt.Main();
+ String[] args = {
+ "-verbose",
+ "-classpath", classpath, // classpath
+ "-d", outDirPath, // output directory
+ jFile // source file
+ };
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int result = apt.compile(args, pw);
+
+ if (0 != result) // todo evaluate the return code
+ {
+ // construct error message
+ Document doc = XMLUtils.newDocument();
+ Element root = doc.createElementNS("", "Errors");
+ StringBuffer message = new StringBuffer("Error compiling ");
+ message.append(jFile);
+ message.append(":\n");
+ message.append(sw.toString()); // print compiler output
+ message.append("\n");
+ root.appendChild(doc.createTextNode(message.toString()));
+
+ // generate fault
+ AxisFault af = new AxisFault(
+ "Server.compileError",
+ Messages.getMessage("badCompile00", jFile),
+ null,
+ new Element[] { root }
+ );
+
+ // log fault
+ log.warn("Error compiling JWS", af);
+
+ // FIXME jcolwell@bea.com 2004-Sep-23 --
+ // logging error to System.out since I have no idea
+ // where log.warn is dumping the error.
+ // Additionally, the error only shows up if a method
+ // is invoked, otherwise, the error is not displayed.
+ // af.printStackTrace();
+
+ // throw fault
+ throw af;
+ }
+
+ return result;
}
}