Author: tfennelly
Date: 2011-05-05 14:56:04 -0400 (Thu, 05 May 2011)
New Revision: 31111
Added:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/JavaGraphBuilder.java
Modified:
branches/jbosstools-3.2.x/smooks/
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean12/PropertiesAndSetterMethodSearchFieldEditorCreator.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchConfigurationDelegate.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchShortcut.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java
Log:
https://issues.jboss.org/browse/JBIDE-7509
Launch Configuration doesn't work for Java Sources
Property changes on: branches/jbosstools-3.2.x/smooks
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/smooks:29129-29130,29167-29168
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -50,7 +50,7 @@
* @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
public class RuntimeMetadata {
-
+ private String inputClassName = null;
private Smooks metadataExtractor;
private boolean isSmooksConfig;
private boolean isValidSmooksConfig;
@@ -70,7 +70,21 @@
// Build dependency map...
RuntimeDependency.addDependencyChecklist(metadataExtractor);
}
+
+
+ public String getInputClassName() {
+ return inputClassName;
+ }
+
+
+
+ public void setInputClassName(String inputClassName) {
+ this.inputClassName = inputClassName;
+ }
+
+
+
public boolean isSmooksConfig() {
return isSmooksConfig;
}
@@ -188,19 +202,24 @@
if (inputType != null) {
String inputPath = inputParams.getProperty(inputType);
if (inputPath != null) {
- String resolvedFilePath;
+ String resolvedFilePath = null;
try {
resolvedFilePath = SmooksUIUtils.parseFilePath(inputPath.trim());
} catch (Exception e) {
// It's not a valid config...
inputFile = new File(inputPath.trim());
- return;
+// return;
}
-
- inputFile = new File(resolvedFilePath);
- if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(inputType) || (inputFile.exists()
&& inputFile.isFile())) {
+ if(resolvedFilePath != null){
+ inputFile = new File(resolvedFilePath);
+ }
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(inputType)){
isValidSmooksConfig = true;
+ setInputClassName(inputPath);
}
+ if ((inputFile.exists() && inputFile.isFile())) {
+ isValidSmooksConfig = true;
+ }
}
}
} catch (Exception e) {
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -11,22 +11,10 @@
package org.jboss.tools.smooks.configuration.editors;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
@@ -35,8 +23,6 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.Document;
-
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -70,8 +56,6 @@
import org.jboss.tools.smooks.configuration.editors.edireader12.EDIDataParser;
import org.jboss.tools.smooks.configuration.editors.input.InputParameter;
import org.jboss.tools.smooks.configuration.editors.input.InputType;
-import org.jboss.tools.smooks.configuration.editors.javabean12.JavaBeanModel;
-import org.jboss.tools.smooks.configuration.editors.javabean12.JavaBeanModelFactory;
import org.jboss.tools.smooks.configuration.editors.uitls.JsonInputDataParser;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import
org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
@@ -80,10 +64,12 @@
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
import org.jboss.tools.smooks.configuration.editors.xml.XSDObjectAnalyzer;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.launch.JavaGraphBuilder;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
import org.milyn.Smooks;
import org.milyn.payload.JavaSource;
+import org.w3c.dom.Document;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -539,109 +525,6 @@
return super.close();
}
- public static class JavaGraphBuilder {
-
- public <T> T buildGraph(Class<T> messageType) {
- try {
- return buildObject(messageType);
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalArgumentException("Unable to construct an instance of
'" + messageType.getName() + "'", e);
- }
- }
-
- @SuppressWarnings("unchecked")
- private <T> T buildObject(Class<T> objectType) throws
IllegalAccessException, InstantiationException, InvocationTargetException,
NoSuchMethodException {
-
- if(String.class.isAssignableFrom(objectType)) {
- return objectType.cast("x");
- } else if(Number.class.isAssignableFrom(objectType)) {
- return objectType.getConstructor(String.class).newInstance("1");
- } else if(objectType.isPrimitive()) {
- return (T) primitiveToObjectMap.get(objectType);
- } else if(objectType == Object.class) {
- // don't construct raw Object types... leave them and just return
null...
- return null;
- } else if(objectType.isEnum()) {
- return (T) EnumSet.allOf((Class<Enum>)objectType).iterator().next();
- }
-
- T messageInstance = objectType.newInstance();
-
- // populate all the fields...
- Method[] methods = objectType.getMethods();
- for(Method method : methods) {
- if(method.getName().startsWith("set") &&
method.getParameterTypes().length == 1) {
- Class<?> propertyType = method.getParameterTypes()[0];
- Object propertyInstance = null;
-
- if(Collection.class.isAssignableFrom(propertyType)) {
- propertyInstance = buildCollection(method, propertyType);
- } else if(propertyType.isArray()) {
- propertyInstance = buildArray(method, propertyType);
- } else {
- propertyInstance = buildObject(propertyType);
- }
-
- if(propertyInstance != null) {
- method.invoke(messageInstance, propertyInstance);
- }
- }
- }
-
- return messageInstance;
- }
-
- private Object buildArray(Method method, Class<?> propertyType) throws
ArrayIndexOutOfBoundsException, IllegalArgumentException, IllegalAccessException,
InstantiationException, InvocationTargetException, NoSuchMethodException {
- Class<?> arrayType = propertyType.getComponentType();
- Object[] arrayObj = (Object[]) Array.newInstance(arrayType, 1);
-
- Array.set(arrayObj, 0, buildObject(arrayType));
-
- return arrayObj;
- }
-
- private Object buildCollection(Method method, Class<?> propertyType) throws
IllegalAccessException, InstantiationException, InvocationTargetException,
NoSuchMethodException {
- Type genericType = method.getGenericParameterTypes()[0];
-
- if(genericType instanceof ParameterizedType) {
- ParameterizedType genericTypeClass = (ParameterizedType) genericType;
- Collection collection = null;
-
- if(!propertyType.isInterface()) {
- // It's a concrete Collection type... just create an instance...
- collection = (Collection) propertyType.newInstance();
- }else if(List.class.isAssignableFrom(propertyType)) {
- collection = new ArrayList();
- } else if(Set.class.isAssignableFrom(propertyType)) {
- collection = new LinkedHashSet();
- }
-
- if(collection != null) {
- collection.add(buildObject((Class<Object>)
genericTypeClass.getActualTypeArguments()[0]));
- return collection;
- }
- }
-
- return null;
- }
-
- private static final Map<Class, Object> primitiveToObjectMap;
-
- static {
- primitiveToObjectMap = new HashMap<Class, Object>();
- primitiveToObjectMap.put(int.class, 1);
- primitiveToObjectMap.put(long.class, 1L);
- primitiveToObjectMap.put(boolean.class, true);
- primitiveToObjectMap.put(float.class, 1f);
- primitiveToObjectMap.put(double.class, 1d);
- primitiveToObjectMap.put(char.class, '1');
- primitiveToObjectMap.put(byte.class, Byte.parseByte("1"));
- primitiveToObjectMap.put(short.class, 1);
- }
-
- }
-
public static Document getModel(Class<?> theModelClass) throws Exception {
try {
Object objectGraph = graphBuilder.buildGraph(theModelClass);
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean12/PropertiesAndSetterMethodSearchFieldEditorCreator.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean12/PropertiesAndSetterMethodSearchFieldEditorCreator.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean12/PropertiesAndSetterMethodSearchFieldEditorCreator.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -73,10 +73,10 @@
for (int i = 0; i < children.length; i++) {
Control child = children[i];
if(child instanceof Button){
- child.setEnabled(false);
+// child.setEnabled(false);
}
}
- editPart.getContentControl().setEnabled(false);
+// editPart.getContentControl().setEnabled(false);
return editPart;
}
}
Copied:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/JavaGraphBuilder.java
(from rev 29168,
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/JavaGraphBuilder.java)
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/JavaGraphBuilder.java
(rev 0)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/JavaGraphBuilder.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -0,0 +1,131 @@
+package org.jboss.tools.smooks.launch;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.milyn.Smooks;
+import org.milyn.payload.JavaSource;
+import org.w3c.dom.Document;
+
+public class JavaGraphBuilder {
+
+ public <T> T buildGraph(Class<T> messageType) {
+ try {
+ return buildObject(messageType);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Unable to construct an instance of
'" + messageType.getName() + "'", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T buildObject(Class<T> objectType) throws
IllegalAccessException, InstantiationException, InvocationTargetException,
NoSuchMethodException {
+
+ if(String.class.isAssignableFrom(objectType)) {
+ return objectType.cast("x");
+ } else if(Number.class.isAssignableFrom(objectType)) {
+ return objectType.getConstructor(String.class).newInstance("1");
+ } else if(objectType.isPrimitive()) {
+ return (T) primitiveToObjectMap.get(objectType);
+ } else if(objectType == Object.class) {
+ // don't construct raw Object types... leave them and just return
null...
+ return null;
+ } else if(objectType.isEnum()) {
+ return (T) EnumSet.allOf((Class<Enum>)objectType).iterator().next();
+ }
+
+ T messageInstance = objectType.newInstance();
+
+ // populate all the fields...
+ Method[] methods = objectType.getMethods();
+ for(Method method : methods) {
+ if(method.getName().startsWith("set") &&
method.getParameterTypes().length == 1) {
+ Class<?> propertyType = method.getParameterTypes()[0];
+ Object propertyInstance = null;
+
+ if(Collection.class.isAssignableFrom(propertyType)) {
+ propertyInstance = buildCollection(method, propertyType);
+ } else if(propertyType.isArray()) {
+ propertyInstance = buildArray(method, propertyType);
+ } else {
+ propertyInstance = buildObject(propertyType);
+ }
+
+ if(propertyInstance != null) {
+ method.invoke(messageInstance, propertyInstance);
+ }
+ }
+ }
+
+ return messageInstance;
+ }
+
+ private Object buildArray(Method method, Class<?> propertyType) throws
ArrayIndexOutOfBoundsException, IllegalArgumentException, IllegalAccessException,
InstantiationException, InvocationTargetException, NoSuchMethodException {
+ Class<?> arrayType = propertyType.getComponentType();
+ Object[] arrayObj = (Object[]) Array.newInstance(arrayType, 1);
+
+ Array.set(arrayObj, 0, buildObject(arrayType));
+
+ return arrayObj;
+ }
+
+ private Object buildCollection(Method method, Class<?> propertyType) throws
IllegalAccessException, InstantiationException, InvocationTargetException,
NoSuchMethodException {
+ Type genericType = method.getGenericParameterTypes()[0];
+
+ if(genericType instanceof ParameterizedType) {
+ ParameterizedType genericTypeClass = (ParameterizedType) genericType;
+ Collection collection = null;
+
+ if(!propertyType.isInterface()) {
+ // It's a concrete Collection type... just create an instance...
+ collection = (Collection) propertyType.newInstance();
+ }else if(List.class.isAssignableFrom(propertyType)) {
+ collection = new ArrayList();
+ } else if(Set.class.isAssignableFrom(propertyType)) {
+ collection = new LinkedHashSet();
+ }
+
+ if(collection != null) {
+ collection.add(buildObject((Class<Object>)
genericTypeClass.getActualTypeArguments()[0]));
+ return collection;
+ }
+ }
+
+ return null;
+ }
+
+ private static final Map<Class, Object> primitiveToObjectMap;
+
+ static {
+ primitiveToObjectMap = new HashMap<Class, Object>();
+ primitiveToObjectMap.put(int.class, 1);
+ primitiveToObjectMap.put(long.class, 1L);
+ primitiveToObjectMap.put(boolean.class, true);
+ primitiveToObjectMap.put(float.class, 1f);
+ primitiveToObjectMap.put(double.class, 1d);
+ primitiveToObjectMap.put(char.class, '1');
+ primitiveToObjectMap.put(byte.class, Byte.parseByte("1"));
+ primitiveToObjectMap.put(short.class, 1);
+ }
+
+}
+
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchConfigurationDelegate.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchConfigurationDelegate.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchConfigurationDelegate.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -80,8 +80,8 @@
launchMetadata.setSmooksConfig(project.findMember(smooksConfigName));
if(SmooksInputType.INPUT_TYPE_JAVA.equals(launchMetadata.getInputType())) {
- displayError(smooksConfigName,
Messages.SmooksLaunchConfigurationDelegate_Error_Java_Unsupported);
- return;
+// displayError(smooksConfigName,
Messages.SmooksLaunchConfigurationDelegate_Error_Java_Unsupported);
+// return;
} else if(!launchMetadata.isValidSmooksConfig()) {
displayError(smooksConfigName, launchMetadata.getErrorMessage());
return;
@@ -107,6 +107,9 @@
String inputType = launchMetadata.getInputType();
String inputPath = launchMetadata.getInputFile().getAbsolutePath();
+ if(SmooksInputType.INPUT_TYPE_JAVA.equals(launchMetadata.getInputType())) {
+ inputPath = launchMetadata.getInputClassName();
+ }
String nodeTypes = launchMetadata.getNodeTypesString();
runConfig.setProgramArguments(new String[]
{launchMetadata.getConfigFile().getAbsolutePath(), inputType, inputPath, nodeTypes});
@@ -155,6 +158,7 @@
File wsRootDir = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toFile();
File wsTempClasses = new File(wsRootDir, "temp/launcher/classes");
//$NON-NLS-1$
+ writeClassToFilesys(JavaGraphBuilder.class, wsTempClasses);
writeClassToFilesys(SmooksLauncher.class, wsTempClasses);
writeClassToFilesys(SmooksInputType.class, wsTempClasses);
writeClassToFilesys(ProcessNodeType.class, wsTempClasses);
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchShortcut.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchShortcut.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLaunchShortcut.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -106,8 +106,8 @@
RuntimeMetadata metadata = new RuntimeMetadata();
metadata.setSmooksConfig(elementToLaunch);
if(SmooksInputType.INPUT_TYPE_JAVA.equals(metadata.getInputType())) {
- MessageDialog.openError(getShell(),
Messages.SmooksLaunchShortcut_Title_Launch_Failed,
Messages.SmooksLaunchConfigurationDelegate_Error_Java_Unsupported);
- return;
+// MessageDialog.openError(getShell(),
Messages.SmooksLaunchShortcut_Title_Launch_Failed,
Messages.SmooksLaunchConfigurationDelegate_Error_Java_Unsupported);
+// return;
} else if (!metadata.isValidSmooksConfig()) {
MessageDialog.openError(getShell(),
Messages.SmooksLaunchShortcut_Title_Launch_Failed, metadata.getErrorMessage());
return;
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-05
17:10:17 UTC (rev 31110)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-05
18:56:04 UTC (rev 31111)
@@ -30,6 +30,7 @@
import java.util.Properties;
import java.util.Set;
+import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.jboss.tools.smooks.configuration.ProcessNodeType;
@@ -37,6 +38,7 @@
import org.jboss.tools.smooks.launch.serialize.ObjectSerializer;
import org.milyn.Smooks;
import org.milyn.payload.JavaResult;
+import org.milyn.payload.JavaSource;
import org.milyn.payload.StringResult;
import org.xml.sax.SAXException;
@@ -59,54 +61,64 @@
if(args.length != 4) {
throw new
RuntimeException(localizedMessages.getProperty("SmooksLauncher_Error_Expected_Four_Args"));
//$NON-NLS-1$
}
-
+ Source inputSource = null;
if(args[1].equals(SmooksInputType.INPUT_TYPE_JAVA)) {
- System.out.println(localizedMessages.getProperty("SmooksLauncher_Error_Do_Not_Support_Java_Inputs"));
//$NON-NLS-1$
+ Class<?> clazz;
+ try {
+ clazz = Class.forName(args[2]);
+ System.out.println(clazz);
+ JavaGraphBuilder graphBuilder = new JavaGraphBuilder();
+
+ Object objectGraph = graphBuilder.buildGraph(clazz);
+ inputSource = new JavaSource(objectGraph);
+ } catch (ClassNotFoundException e) {
+ System.out.println("Class not found \n" + e.getLocalizedMessage());
+ }
} else {
- File smooksConfig = new File(args[0]);
File input = new File(args[2]);
-
- assertFile(smooksConfig, "Smooks"); //$NON-NLS-1$
assertFile(input, "Input"); //$NON-NLS-1$
+ inputSource = new StreamSource(new FileInputStream(input));
+ }
+
+ File smooksConfig = new File(args[0]);
+ assertFile(smooksConfig, "Smooks"); //$NON-NLS-1$
+ Smooks smooks = new Smooks(smooksConfig.toURI().getPath());
+ try {
+ Set<ProcessNodeType> processNodeTypes =
SmooksLauncher.fromNodeTypeString(args[3]);
+ JavaResult javaResult = new JavaResult();
+ boolean nothingDisplayed = true;
- Smooks smooks = new Smooks(smooksConfig.toURI().getPath());
- try {
- Set<ProcessNodeType> processNodeTypes =
SmooksLauncher.fromNodeTypeString(args[3]);
- JavaResult javaResult = new JavaResult();
- boolean nothingDisplayed = true;
+ if(processNodeTypes.contains(ProcessNodeType.TEMPLATING)) {
+ StringResult stringResult = new StringResult();
- if(processNodeTypes.contains(ProcessNodeType.TEMPLATING)) {
- StringResult stringResult = new StringResult();
-
- smooks.filterSource(new StreamSource(new FileInputStream(input)), stringResult,
javaResult);
- System.out.println("[" +
localizedMessages.getProperty("SmooksLauncher_Templating_To_StreamResult") +
" ...]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ smooks.filterSource(inputSource, stringResult, javaResult);
+ System.out.println("[" +
localizedMessages.getProperty("SmooksLauncher_Templating_To_StreamResult") +
" ...]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.out.println(" |--"); //$NON-NLS-1$
+ System.out.println(indent(stringResult.toString()));
+ System.out.println(" |--\n"); //$NON-NLS-1$
+ nothingDisplayed = false;
+ } else {
+ smooks.filterSource(inputSource, javaResult);
+ }
+ System.out.println("successfully");
+ Collection<ObjectSerializer> serializedJavaResults =
ObjectSerializer.serialize(javaResult);
+ if(!serializedJavaResults.isEmpty()) {
+ System.out.println("[" +
localizedMessages.getProperty("SmooksLauncher_Java_Mapping_Results") +
"...]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ for(ObjectSerializer serializedJavaResult : serializedJavaResults) {
System.out.println(" |--"); //$NON-NLS-1$
- System.out.println(indent(stringResult.toString()));
- System.out.println(" |--\n"); //$NON-NLS-1$
- nothingDisplayed = false;
- } else {
- smooks.filterSource(new StreamSource(new FileInputStream(input)), javaResult);
+ System.out.println(indent(serializedJavaResult.getSerializedForm()));
+ System.out.println(" |--"); //$NON-NLS-1$
}
-
- Collection<ObjectSerializer> serializedJavaResults =
ObjectSerializer.serialize(javaResult);
- if(!serializedJavaResults.isEmpty()) {
- System.out.println("[" +
localizedMessages.getProperty("SmooksLauncher_Java_Mapping_Results") +
"...]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- for(ObjectSerializer serializedJavaResult : serializedJavaResults) {
- System.out.println(" |--"); //$NON-NLS-1$
- System.out.println(indent(serializedJavaResult.getSerializedForm()));
- System.out.println(" |--"); //$NON-NLS-1$
- }
- nothingDisplayed = false;
- }
-
- if(nothingDisplayed) {
- System.out.println(localizedMessages.getProperty("SmooksLauncher_Nothing_To_Display"));
//$NON-NLS-1$
- }
- } finally {
- smooks.close();
+ nothingDisplayed = false;
}
- }
+
+ if(nothingDisplayed) {
+ System.out.println(localizedMessages.getProperty("SmooksLauncher_Nothing_To_Display"));
//$NON-NLS-1$
+ }
+ } finally {
+ smooks.close();
+ }
}
private static Properties loadLocalizedMessages() {