Browse Source

refactor AbstractSExecModelGenerator and GenericXpandCodeGenerator

holger.willebrandt@gmail.com 13 years ago
parent
commit
4f38e3ac30

+ 1 - 1
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/features/IXpandFeatureConstants.java

@@ -4,7 +4,7 @@ package org.yakindu.sct.generator.core.features;
  * 
  * @author holger willebrandt - Initial contribution and API
  */
-public interface IXpandFeatureConstants extends ICoreFeatureConstants {
+public interface IXpandFeatureConstants {
 
 	public static final String LIBRARY_NAME = "Xpand";
 	public static final String TEMPLATE_FEATURE = "Template";

+ 7 - 6
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/features/impl/XpandLibraryDefaultFeatureValueProvider.java

@@ -1,5 +1,3 @@
-package org.yakindu.sct.generator.core.features.impl;
-
 /**
  * Copyright (c) 2011 committers of YAKINDU and others.
  * All rights reserved. This program and the accompanying materials
@@ -10,6 +8,8 @@ package org.yakindu.sct.generator.core.features.impl;
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
+package org.yakindu.sct.generator.core.features.impl;
+
 import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.LIBRARY_NAME;
 import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.TEMPLATE_FEATURE_TEMPLATE_PATH;
 import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.TEMPLATE_FEATURE_TEMPLATE_PROJECT;
@@ -22,13 +22,13 @@ import org.yakindu.sct.model.sgen.FeatureTypeLibrary;
 import org.yakindu.sct.model.sgraph.Statechart;
 
 /**
- * 
  * 
  * @author holger willebrandt - Initial contribution and API
  */
 public class XpandLibraryDefaultFeatureValueProvider extends
 		AbstractDefaultFeatureValueProvider {
 
+	// (ID::)+ID
 	private static final String XPAND_TEMPLATE_PATH_REGEX = "([a-zA-Z$_][a-zA-Z0-9$_.]*::)+[a-zA-Z$_][a-zA-Z0-9$_.]*";
 
 	public boolean isProviderFor(final FeatureTypeLibrary library) {
@@ -41,7 +41,7 @@ public class XpandLibraryDefaultFeatureValueProvider extends
 		String parameterName = parameterValue.getParameter().getName();
 		if (TEMPLATE_FEATURE_TEMPLATE_PATH.equals(parameterName)) {
 			parameterValue
-					.setValue("org::yakindu::sct::example::templates::Main::main");
+					.setValue("org::yakindu::sct::generator::xpand::Main::main");
 		}
 	}
 
@@ -50,13 +50,14 @@ public class XpandLibraryDefaultFeatureValueProvider extends
 		String value = parameterValue.getValue();
 		if (TEMPLATE_FEATURE_TEMPLATE_PATH.equals(parameterName)
 				&& !parameterValue.getValue()
-						.matches(XPAND_TEMPLATE_PATH_REGEX))
+						.matches(XPAND_TEMPLATE_PATH_REGEX)) {
 			return error("Xpand Template Path Syntax Error");
+		}
 		if (TEMPLATE_FEATURE_TEMPLATE_PROJECT.equals(parameterName)
 				&& !projectExists(value)) {
 			return error(String.format("The Project %s does not exist", value));
 		}
 		return Status.OK_STATUS;
 	}
-	
+
 }

+ 148 - 32
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java

@@ -10,26 +10,40 @@
  */
 package org.yakindu.sct.generator.core.impl;
 
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.DEBUG_FEATURE;
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.DEBUG_FEATURE_DUMP_SEXEC;
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE;
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT;
+
+import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.Collections;
 
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;
 import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
-import org.yakindu.sct.generator.core.GeneratorActivator;
+import org.eclipse.xpand2.output.Output;
 import org.yakindu.sct.generator.core.ISCTGenerator;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sexec.transformation.ModelSequencer;
 import org.yakindu.sct.model.sexec.transformation.SequencerModule;
+import org.yakindu.sct.model.sgen.FeatureConfiguration;
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
@@ -45,12 +59,37 @@ import com.google.inject.Injector;
  */
 public abstract class AbstractSExecModelGenerator implements ISCTGenerator {
 
+	private static final String SEXEC_FILE_EXTENSION = "sexec";
 	private static final String SCT_GENERATOR_CONSOLE = "SCT Generator Console";
 
 	protected abstract void generate(ExecutionFlow flow, GeneratorEntry entry);
 
 	public final void generate(GeneratorEntry entry) {
-		generate(createExecutionFlow(entry.getStatechart()), entry);
+		writeToConsole(String.format("Generating Statechart %s ...", entry
+				.getStatechart().getName()));
+		try {
+			prepareGenerator(entry);
+			generate(createExecutionFlow(entry.getStatechart()), entry);
+			writeToConsole("Done.");
+		} catch (Exception e) {
+			writeToConsole(e);
+		} finally {
+			finishGenerator(entry);
+		}
+	}
+
+	/**
+	 * override this method to do any setup needed before generation
+	 */
+	protected void prepareGenerator(GeneratorEntry entry) {
+		// override if needed
+	}
+
+	/**
+	 * override this method to do any cleanup needed after generation
+	 */
+	protected void finishGenerator(GeneratorEntry entry) {
+		// override if needed
 	}
 
 	/**
@@ -64,44 +103,121 @@ public abstract class AbstractSExecModelGenerator implements ISCTGenerator {
 		return flow;
 	}
 
-	protected void showErrorDialog(Throwable t) {
-		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-				.getShell();
-		ErrorDialog.openError(shell, "Generator Error",
-				"Error executing generator", new Status(IStatus.ERROR,
-						GeneratorActivator.PLUGIN_ID, t.getMessage()));
-	}
-
-	private MessageConsole findConsole(String name) {
+	private MessageConsole getConsole() {
 		ConsolePlugin plugin = ConsolePlugin.getDefault();
 		IConsoleManager conMan = plugin.getConsoleManager();
 		IConsole[] existing = conMan.getConsoles();
-		for (int i = 0; i < existing.length; i++)
-			if (name.equals(existing[i].getName()))
+		for (int i = 0; i < existing.length; i++) {
+			if (SCT_GENERATOR_CONSOLE.equals(existing[i].getName())) {
 				return (MessageConsole) existing[i];
-		// no console found, so create a new one
-		MessageConsole myConsole = new MessageConsole(name, null);
+			}
+		}
+		MessageConsole myConsole = new MessageConsole(SCT_GENERATOR_CONSOLE,
+				null);
 		conMan.addConsoles(new IConsole[] { myConsole });
 		return myConsole;
 	}
 
-	private MessageConsoleStream createConsoleStream() {
-		MessageConsole console = findConsole(SCT_GENERATOR_CONSOLE);
-		MessageConsoleStream out = console.newMessageStream();
-		return out;
-	}
-
-	protected void writeToConsole(Throwable t) {
-		MessageConsoleStream createConsoleStream = createConsoleStream();
-		createConsoleStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
-		PrintWriter printWriter = new PrintWriter(createConsoleStream);
+	protected final void writeToConsole(Throwable t) {
+		MessageConsoleStream out = getConsole().newMessageStream();
+		out.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
+		PrintWriter printWriter = new PrintWriter(out);
 		t.printStackTrace(printWriter);
 		printWriter.flush();
 		printWriter.close();
 	}
 
-	protected void writeToConsole(String line) {
-		createConsoleStream().println(line);
+	protected final void writeToConsole(String line) {
+		getConsole().newMessageStream().println(line);
+	}
+
+	protected final void refreshTargetProject(GeneratorEntry entry) {
+		try {
+			IProject project = getTargetProject(entry);
+			project.refreshLocal(IResource.DEPTH_INFINITE,
+					new NullProgressMonitor());
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
 	};
 
+	protected final IProject getTargetProject(GeneratorEntry entry) {
+		FeatureConfiguration outletConfig = getOutletFeatureConfiguration(entry);
+		String projectName = outletConfig.getParameterValue(
+				OUTLET_FEATURE_TARGET_PROJECT).getValue();
+		IProject project = ResourcesPlugin.getWorkspace().getRoot()
+				.getProject(projectName);
+		if (!project.exists()) {
+			createProject(project, entry);
+		}
+		return project;
+	}
+
+	/**
+	 * The default implementation only creates a new default project. Clients
+	 * may override if they want to contribute generatorspecific project setup
+	 */
+	protected void createProject(IProject project, GeneratorEntry entry) {
+		try {
+			NullProgressMonitor monitor = new NullProgressMonitor();
+			project.create(monitor);
+			project.open(monitor);
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+	}
+
+	protected FeatureConfiguration getOutletFeatureConfiguration(
+			GeneratorEntry entry) {
+		FeatureConfiguration outletConfig = entry
+				.getFeatureConfiguration(OUTLET_FEATURE);
+		return outletConfig;
+	}
+
+	protected boolean isDumpSexec(GeneratorEntry entry) {
+
+		FeatureParameterValue dumpSexec = getFeatureParameter(entry,
+				DEBUG_FEATURE, DEBUG_FEATURE_DUMP_SEXEC);
+
+		return dumpSexec != null && (dumpSexec.getValue().trim().length() > 0)
+				&& dumpSexec.getValue().trim().toLowerCase().equals("true");
+	}
+
+	protected FeatureParameterValue getFeatureParameter(GeneratorEntry entry,
+			String featureName, String paramName) {
+		FeatureConfiguration feature = entry
+				.getFeatureConfiguration(featureName);
+
+		if (feature != null) {
+			return feature.getParameterValue(paramName);
+		}
+
+		return null;
+	}
+
+	protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow,
+			Output output) {
+
+		ResourceSet resourceSet = new ResourceSetImpl();
+
+		resourceSet
+				.getResourceFactoryRegistry()
+				.getExtensionToFactoryMap()
+				.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
+						new XMIResourceFactoryImpl());
+
+		URI fileURI = entry.getStatechart().eResource().getURI()
+				.trimFileExtension().appendFileExtension(SEXEC_FILE_EXTENSION);
+		// URI fileURI = URI.createFileURI(new
+		// File("mylibrary.xmi").getAbsolutePath());
+
+		Resource resource = resourceSet.createResource(fileURI);
+		resource.getContents().add(flow);
+
+		try {
+			resource.save(Collections.EMPTY_MAP);
+		} catch (IOException e) {
+		}
+	}
+
 }

+ 11 - 123
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractXpandBasedCodeGenerator.java

@@ -10,24 +10,13 @@
  */
 package org.yakindu.sct.generator.core.impl;
 
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.*;
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Collections;
 
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
 import org.eclipse.xpand2.XpandExecutionContext;
 import org.eclipse.xpand2.XpandExecutionContextImpl;
 import org.eclipse.xpand2.XpandFacade;
@@ -62,68 +51,20 @@ public abstract class AbstractXpandBasedCodeGenerator extends
 	 */
 	@Override
 	protected final void generate(ExecutionFlow flow, GeneratorEntry entry) {
-		writeToConsole("Generating "+entry.getStatechart().getName()+"...");
-		try {
-			prepareGenerator(entry);
-			Output output = createOutput(entry);
+		Output output = createOutput(entry);
 
-			if (isDumpSexec(entry))
-				dumpSexec(entry, flow, output);
-
-			XpandExecutionContext context = createXpandContext(output);
-			XpandFacade facade = XpandFacade.create(context);
-			facade.evaluate(getTemplatePath(), flow, entry);
-
-			// refresh the project to get external updates:
-			IProject project = getTargetProject(entry);
-			project.refreshLocal(IResource.DEPTH_INFINITE,
-					new NullProgressMonitor());
-			writeToConsole("Done.");
-		} catch (Exception e) {
-			writeToConsole(e);
-		} finally {
-			finishGenerator(entry);
+		if (isDumpSexec(entry)) {
+			dumpSexec(entry, flow, output);
 		}
-	}
-
-	/**
-	 * override this method to do any setup needed before generation
-	 */
-	protected void prepareGenerator(GeneratorEntry entry) {
-		// override if needed
-	}
-
-	/**
-	 * override this method to do any cleanup needed after generation
-	 */
-	protected void finishGenerator(GeneratorEntry entry) {
-		// override if needed
-	}
+		String templatePath = getTemplatePath();
 
-	private IProject getTargetProject(GeneratorEntry entry) {
-		FeatureConfiguration outletConfig = getOutletFeatureConfiguration(entry);
-		String projectName = outletConfig.getParameterValue(
-				OUTLET_FEATURE_TARGET_PROJECT).getValue();
-		IProject project = ResourcesPlugin.getWorkspace().getRoot()
-				.getProject(projectName);
-		if (!project.exists()) {
-			createProject(project, entry);
-		}
-		return project;
-	}
+		writeToConsole("Executing Template " + templatePath);
+		XpandExecutionContext context = createXpandContext(output);
+		XpandFacade facade = XpandFacade.create(context);
+		facade.evaluate(templatePath, flow, entry);
 
-	/**
-	 * The default implementation only creates a new default project. Clients
-	 * may override if they want to contribute generatorspecific project setup
-	 */
-	protected void createProject(IProject project, GeneratorEntry entry) {
-		try {
-			NullProgressMonitor monitor = new NullProgressMonitor();
-			project.create(monitor);
-			project.open(monitor);
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
+		// refresh the project to get external updates:
+		refreshTargetProject(entry);
 	}
 
 	protected XpandExecutionContext createXpandContext(Output output) {
@@ -156,57 +97,4 @@ public abstract class AbstractXpandBasedCodeGenerator extends
 		return output;
 	}
 
-	protected FeatureConfiguration getOutletFeatureConfiguration(
-			GeneratorEntry entry) {
-		FeatureConfiguration outletConfig = entry
-				.getFeatureConfiguration(OUTLET_FEATURE);
-		return outletConfig;
-	}
-
-	protected boolean isDumpSexec(GeneratorEntry entry) {
-
-		FeatureParameterValue dumpSexec = getFeatureParameter(entry,
-				DEBUG_FEATURE, DEBUG_FEATURE_DUMP_SEXEC);
-
-		return dumpSexec != null && (dumpSexec.getValue().trim().length() > 0)
-				&& dumpSexec.getValue().trim().toLowerCase().equals("true");
-	}
-
-	protected FeatureParameterValue getFeatureParameter(GeneratorEntry entry,
-			String featureName, String paramName) {
-		FeatureConfiguration feature = entry
-				.getFeatureConfiguration(featureName);
-
-		if (feature != null) {
-			return feature.getParameterValue(paramName);
-		}
-
-		return null;
-	}
-
-	protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow,
-			Output output) {
-
-		ResourceSet resourceSet = new ResourceSetImpl();
-
-		resourceSet
-				.getResourceFactoryRegistry()
-				.getExtensionToFactoryMap()
-				.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
-						new XMIResourceFactoryImpl());
-
-		URI fileURI = entry.getStatechart().eResource().getURI()
-				.trimFileExtension().appendFileExtension("sexec");
-		// URI fileURI = URI.createFileURI(new
-		// File("mylibrary.xmi").getAbsolutePath());
-
-		Resource resource = resourceSet.createResource(fileURI);
-		resource.getContents().add(flow);
-
-		try {
-			resource.save(Collections.EMPTY_MAP);
-		} catch (IOException e) {
-		}
-	}
-
 }

+ 16 - 3
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericXPandCodeGenerator.java

@@ -1,7 +1,18 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.core.impl;
 
 import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.TEMPLATE_FEATURE;
 import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.TEMPLATE_FEATURE_TEMPLATE_PATH;
+import static org.yakindu.sct.generator.core.features.IXpandFeatureConstants.TEMPLATE_FEATURE_TEMPLATE_PROJECT;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -10,11 +21,13 @@ import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.mwe.core.resources.ResourceLoader;
 import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory;
 import org.eclipse.emf.mwe.core.resources.ResourceLoaderImpl;
-import org.yakindu.sct.generator.core.features.IXpandFeatureConstants;
 import org.yakindu.sct.model.sgen.FeatureConfiguration;
 import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 
+/**
+ * @author holger willebrandt - Initial contribution and API
+ */
 public class GenericXPandCodeGenerator extends AbstractXpandBasedCodeGenerator {
 
 	private String templatePath;
@@ -49,9 +62,9 @@ public class GenericXPandCodeGenerator extends AbstractXpandBasedCodeGenerator {
 	protected IProject getLookupRoot(GeneratorEntry entry) {
 		IProject project = null;
 		FeatureConfiguration templateConfig = entry
-				.getFeatureConfiguration(IXpandFeatureConstants.TEMPLATE_FEATURE);
+				.getFeatureConfiguration(TEMPLATE_FEATURE);
 		FeatureParameterValue projectName = templateConfig
-				.getParameterValue(IXpandFeatureConstants.TEMPLATE_FEATURE_TEMPLATE_PROJECT);
+				.getParameterValue(TEMPLATE_FEATURE_TEMPLATE_PROJECT);
 		if (projectName != null) {
 			project = ResourcesPlugin.getWorkspace().getRoot()
 					.getProject(projectName.getValue());

+ 14 - 13
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/WorkspaceClassLoaderFactory.java

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.core.impl;
 
 import java.io.File;
@@ -13,7 +23,6 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jdt.launching.JavaRuntime;
 
 import com.google.common.collect.Lists;
@@ -48,7 +57,6 @@ public class WorkspaceClassLoaderFactory {
 			try {
 				urls.add(getFileSystemFile(project).toURI().toURL());
 			} catch (MalformedURLException e1) {
-				// TODO Auto-generated catch block
 				e1.printStackTrace();
 			}
 			addReferencedProjectsClasspaths(project, urls);
@@ -63,7 +71,6 @@ public class WorkspaceClassLoaderFactory {
 				addClasspathEntries(iProject, urls);
 			}
 		} catch (CoreException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 	}
@@ -76,16 +83,11 @@ public class WorkspaceClassLoaderFactory {
 	}
 
 	protected IJavaProject toJavaProject(IProject project) {
-		IJavaProject javaProject = null;
-		try {
-			javaProject = JavaCore.create(project);
-//			javaProject.e
-			// access children to decide whether we have a java project or not
-			javaProject.getChildren();
-		} catch (JavaModelException jme) {
-			return null;
+		IJavaProject javaProject = JavaCore.create(project);
+		if (javaProject.exists()) {
+			return javaProject;
 		}
-		return javaProject;
+		return null;
 	}
 
 	protected void addJavaClasspathEntries(IJavaProject project, List<URL> urls) {
@@ -93,7 +95,6 @@ public class WorkspaceClassLoaderFactory {
 			urls.addAll(Lists.newArrayList(convertClassPath(JavaRuntime
 					.computeDefaultRuntimeClassPath(project))));
 		} catch (CoreException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 	}