private StringBuilder generateSource() throws Exception {
		if (control != null) {
			if (control.indexOf('.') == -1) {
				throw new IllegalArgumentException(
						"Not a valid control reference (object.field): '"
								+ control + "'");
			}
		}

		StringBuilder b = new StringBuilder();
		b.append("import java.util.*;\n");
		b.append("import oms3.*;\n");
		b.append("import oms3.annotations.*;\n");
		b.append("public class " + "$$$" + " extends " + controlClass + " {\n");
		b.append("\n");

		// Fields
		for (Param param : getParam()) {
			String p = param.getName();
			if (p.indexOf('.') == -1) {
				throw new IllegalArgumentException(
						"Not a valid parameter reference (object.field): '" + p
								+ "'");
			}
			String[] name = p.split("\\.");
			String type = getClassForParameter(name[0], name[1], true);
			String role = getClassForParameter(name[0], name[1], false);
			b.append(" // " + p + "\n");
			b.append(" @Role(\"" + role + "\")\n");
			b.append(" @In public " + type + " " + name[0] + "_" + name[1]
					+ ";\n");
			b.append("\n");
		}

		// Components
		for (KVP def : comps.entries) {
			String compClass = def.getValue().toString();
			compClass = getComponentClassName(compClass); // name -> class
			b.append(" public " + compClass + " " + def.getKey() + " = new "
					+ compClass + "();\n");
		}
		b.append("\n\n");

		// init version.
		b.append(" @Initialize\n");
		b.append(" public void init() {\n");
		if (control != null) {
			String[] it = control.split("\\.");
			b.append("  conditional(" + it[0] + ", \"" + it[1] + "\");\n");
		}

		// in2in
		for (Param param : getParam()) {
			String[] name = param.getName().split("\\.");
			b.append("  in2in(\"" + name[0] + '_' + name[1] + "\", " + name[0]
					+ ", \"" + name[1] + "\");\n");
		}

		// out2in
		kvpExpand(b, out2in.entries, "out2in");

		// feedback
		kvpExpand(b, feedback.entries, "feedback");

		b.append("  initializeComponents();\n");
		b.append(" }\n");
		b.append("}\n");
		return b;
	}