From: Robert L. <rle...@us...> - 2007-02-16 12:33:49
|
Update of /cvsroot/ccmtools/ccmtools/src/ccmtools/generator/java/templates In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3511/src/ccmtools/generator/java/templates Modified Files: ComponentDefAssemblyClassTemplate.java Added Files: ProvidesDefGetMethodAssemblyImplementationTemplate.java ProvidesDefAssemblyClassTemplate.java OperationDefAssemblyImplementationTemplate.java Log Message: Java assemblies Index: ComponentDefAssemblyClassTemplate.java =================================================================== RCS file: /cvsroot/ccmtools/ccmtools/src/ccmtools/generator/java/templates/ComponentDefAssemblyClassTemplate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ComponentDefAssemblyClassTemplate.java 15 Feb 2007 16:46:41 -0000 1.2 --- ComponentDefAssemblyClassTemplate.java 16 Feb 2007 12:33:44 -0000 1.3 *************** *** 40,45 **** protected final String TEXT_23 = NL; protected final String TEXT_24 = " " + NL + "" + NL + " /** Component callback methods */" + NL + " " + NL + " public void set_session_context(SessionContext ctx) " + NL + " throws CCMException" + NL + " {" + NL + " this.ctx = ("; ! protected final String TEXT_25 = "_Context)ctx; " + NL + " }" + NL + "" + NL + " public void ccm_activate() " + NL + " throws CCMException" + NL + " {" + NL + " // OPTIONAL: IMPLEMENT ME HERE !" + NL + " }" + NL + "" + NL + " public void ccm_passivate() " + NL + " throws CCMException" + NL + " {" + NL + " // OPTIONAL: IMPLEMENT ME HERE !" + NL + " }" + NL + "" + NL + " public void ccm_remove() " + NL + " throws CCMException" + NL + " {" + NL + " // OPTIONAL: IMPLEMENT ME HERE !" + NL + " }" + NL + "}"; protected final String TEXT_26 = NL; public String generate(Object argument) --- 40,52 ---- protected final String TEXT_23 = NL; protected final String TEXT_24 = " " + NL + "" + NL + " /** Component callback methods */" + NL + " " + NL + " public void set_session_context(SessionContext ctx) " + NL + " throws CCMException" + NL + " {" + NL + " this.ctx = ("; ! protected final String TEXT_25 = "_Context)ctx; " + NL + " }" + NL + "" + NL + " public void ccm_activate() " + NL + " throws CCMException" + NL + " {" + NL + " \ttry {"; protected final String TEXT_26 = NL; + protected final String TEXT_27 = " " + NL; + protected final String TEXT_28 = NL; + protected final String TEXT_29 = " " + NL + "" + NL + "\t\t\t// finish configuration \t"; + protected final String TEXT_30 = NL + "\t\t\t"; + protected final String TEXT_31 = "_.configuration_complete();"; + protected final String TEXT_32 = " " + NL + " \t} catch(Exception e) {" + NL + " \t\tthrow new CCMException(e.getMessage(), CCMExceptionReason.CREATE_ERROR);" + NL + " \t}" + NL + " }" + NL + "" + NL + " public void ccm_passivate() " + NL + " throws CCMException" + NL + " {" + NL + " // OPTIONAL: IMPLEMENT ME HERE !" + NL + " }" + NL + "" + NL + " public void ccm_remove() " + NL + " throws CCMException" + NL + " {" + NL + " // OPTIONAL: IMPLEMENT ME HERE !" + NL + " }" + NL + "}"; + protected final String TEXT_33 = NL; public String generate(Object argument) *************** *** 148,152 **** stringBuffer.append(TEXT_23); ! stringBuffer.append(provides.generateGetMethodImplementation()); } --- 155,159 ---- stringBuffer.append(TEXT_23); ! stringBuffer.append(provides.generateGetMethodAssemblyImplementation(component.getInnerFacet(provides))); } *************** *** 155,159 **** --- 162,197 ---- stringBuffer.append(component.generateCcmIdentifier()); stringBuffer.append(TEXT_25); + + for(Iterator i=component.getAssemblyAttributeInitialisation(); i.hasNext();) + { + stringBuffer.append(TEXT_26); + stringBuffer.append(i.next().toString()); + + } + + stringBuffer.append(TEXT_27); + + for(Iterator i=component.getAssemblyAttributeSetup(); i.hasNext();) + { + + stringBuffer.append(TEXT_28); + stringBuffer.append(i.next().toString()); + + } + + stringBuffer.append(TEXT_29); + + for (String key : component.getAssemblyLocalComponents().keySet()) + { + + stringBuffer.append(TEXT_30); + stringBuffer.append(key); + stringBuffer.append(TEXT_31); + + } + + stringBuffer.append(TEXT_32); + stringBuffer.append(TEXT_33); return stringBuffer.toString(); } --- NEW FILE: OperationDefAssemblyImplementationTemplate.java --- package ccmtools.generator.java.templates; import ccmtools.generator.java.metamodel.*; public class OperationDefAssemblyImplementationTemplate { protected static String nl; public static synchronized OperationDefAssemblyImplementationTemplate create(String lineSeparator) { nl = lineSeparator; OperationDefAssemblyImplementationTemplate result = new OperationDefAssemblyImplementationTemplate(); nl = null; return result; } protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; protected final String TEXT_1 = " public "; protected final String TEXT_2 = " "; protected final String TEXT_3 = "("; protected final String TEXT_4 = ")"; protected final String TEXT_5 = NL + " "; protected final String TEXT_6 = NL + " {" + NL + " \t"; protected final String TEXT_7 = NL + " } "; protected final String TEXT_8 = NL; public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); OperationDef op = (OperationDef) argument; stringBuffer.append(TEXT_1); stringBuffer.append(op.generateReturnType()); stringBuffer.append(TEXT_2); stringBuffer.append(op.getIdentifier()); stringBuffer.append(TEXT_3); stringBuffer.append(op.generateParameterDeclarationList()); stringBuffer.append(TEXT_4); stringBuffer.append(TEXT_5); stringBuffer.append(op.generateThrowsStatementLocal()); stringBuffer.append(TEXT_6); stringBuffer.append(op.generateAssemblyReturnStatement()); stringBuffer.append(TEXT_7); stringBuffer.append(TEXT_8); return stringBuffer.toString(); } } --- NEW FILE: ProvidesDefAssemblyClassTemplate.java --- package ccmtools.generator.java.templates; import java.util.Iterator; import ccmtools.generator.java.metamodel.*; public class ProvidesDefAssemblyClassTemplate { protected static String nl; public static synchronized ProvidesDefAssemblyClassTemplate create(String lineSeparator) { nl = lineSeparator; ProvidesDefAssemblyClassTemplate result = new ProvidesDefAssemblyClassTemplate(); nl = null; return result; } protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; protected final String TEXT_1 = "/**" + NL + " * This file was automatically generated by "; protected final String TEXT_2 = NL + " * <http://ccmtools.sourceforge.net>" + NL + " * " + NL + " * "; protected final String TEXT_3 = "Impl facet implementation." + NL + " *" + NL + " */" + NL + "" + NL + "package "; protected final String TEXT_4 = "; " + NL; protected final String TEXT_5 = NL; protected final String TEXT_6 = " " + NL + "" + NL + "/** " + NL + " * This class implements a component facet's methods." + NL + " *" + NL + " */" + NL + "public class "; protected final String TEXT_7 = "Impl " + NL + " implements "; protected final String TEXT_8 = NL + "{" + NL + " /** Reference to the facet's component implementation */" + NL + " private "; protected final String TEXT_9 = "Impl component;" + NL + " " + NL + " /** the facet of the inner component we delegate to */" + NL + " private "; protected final String TEXT_10 = " target;" + NL + "" + NL + " public "; protected final String TEXT_11 = "Impl(" + NL + " \t"; protected final String TEXT_12 = "Impl component," + NL + " \t"; protected final String TEXT_13 = " target)" + NL + " {" + NL + " this.component = component;" + NL + " this.target = target;" + NL + " }" + NL; protected final String TEXT_14 = " " + NL + "// TODO: assembly implementation"; protected final String TEXT_15 = NL; protected final String TEXT_16 = NL + "// TODO: assembly implementation"; protected final String TEXT_17 = NL; protected final String TEXT_18 = " " + NL + "" + NL + "" + NL + " /** Business logic implementations */" + NL; protected final String TEXT_19 = " " + NL + "// TODO: assembly implementation"; protected final String TEXT_20 = NL; protected final String TEXT_21 = NL + " "; protected final String TEXT_22 = NL + "// TODO: assembly implementation"; protected final String TEXT_23 = NL; protected final String TEXT_24 = " " + NL + " " + NL + " "; protected final String TEXT_25 = " "; protected final String TEXT_26 = NL; protected final String TEXT_27 = " " + NL; protected final String TEXT_28 = NL; protected final String TEXT_29 = NL + "}"; protected final String TEXT_30 = NL; public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); ProvidesDef provides = (ProvidesDef) argument; InterfaceDef iface = provides.getInterface(); stringBuffer.append(TEXT_1); stringBuffer.append(iface.generateCcmtoolsVersion()); stringBuffer.append(TEXT_2); stringBuffer.append(iface.generateCcmIdentifier()); stringBuffer.append(TEXT_3); stringBuffer.append(provides.generateJavaNamespace()); stringBuffer.append(TEXT_4); stringBuffer.append(TEXT_5); stringBuffer.append(provides.generateJavaImportStatements(provides.generateJavaNamespace())); stringBuffer.append(TEXT_6); stringBuffer.append(provides.getComponent().getIdentifier()); stringBuffer.append(provides.getIdentifier()); stringBuffer.append(TEXT_7); stringBuffer.append(iface.generateCcmIdentifier()); stringBuffer.append(TEXT_8); stringBuffer.append(provides.getComponent().getIdentifier()); stringBuffer.append(TEXT_9); stringBuffer.append(iface.generateAbsoluteJavaName()); stringBuffer.append(TEXT_10); stringBuffer.append(provides.getComponent().getIdentifier()); stringBuffer.append(provides.getIdentifier()); stringBuffer.append(TEXT_11); stringBuffer.append(provides.getComponent().getIdentifier()); stringBuffer.append(TEXT_12); stringBuffer.append(iface.generateAbsoluteJavaName()); stringBuffer.append(TEXT_13); for(Iterator i=iface.getBaseInterfaces().iterator(); i.hasNext();) { InterfaceDef baseIface = (InterfaceDef)i.next(); for(Iterator j=baseIface.getAttributes().iterator(); j.hasNext(); ) { AttributeDef attr = (AttributeDef)j.next(); stringBuffer.append(TEXT_14); stringBuffer.append(TEXT_15); stringBuffer.append(attr.generateApplicationDeclaration()); } } for(Iterator i=iface.getAttributes().iterator(); i.hasNext();) { AttributeDef attr = (AttributeDef)i.next(); stringBuffer.append(TEXT_16); stringBuffer.append(TEXT_17); stringBuffer.append(attr.generateApplicationDeclaration()); } stringBuffer.append(TEXT_18); for(Iterator i=iface.getBaseInterfaces().iterator(); i.hasNext();) { InterfaceDef baseIface = (InterfaceDef)i.next(); for(Iterator j=baseIface.getAttributes().iterator(); j.hasNext(); ) { AttributeDef attr = (AttributeDef)j.next(); stringBuffer.append(TEXT_19); stringBuffer.append(TEXT_20); stringBuffer.append(attr.generateApplicationImplementation()); } } stringBuffer.append(TEXT_21); for(Iterator i=iface.getAttributes().iterator(); i.hasNext();) { AttributeDef attr = (AttributeDef)i.next(); stringBuffer.append(TEXT_22); stringBuffer.append(TEXT_23); stringBuffer.append(attr.generateApplicationImplementation()); } stringBuffer.append(TEXT_24); for(Iterator i=iface.getBaseInterfaces().iterator(); i.hasNext();) { InterfaceDef baseIface = (InterfaceDef)i.next(); for(Iterator j=baseIface.getOperations().iterator(); j.hasNext(); ) { OperationDef op = (OperationDef)j.next(); stringBuffer.append(TEXT_25); stringBuffer.append(TEXT_26); stringBuffer.append(op.generateAssemblyImplementation()); } } stringBuffer.append(TEXT_27); for(Iterator i=iface.getOperations().iterator(); i.hasNext();) { OperationDef op = (OperationDef)i.next(); stringBuffer.append(TEXT_28); stringBuffer.append(op.generateAssemblyImplementation()); } stringBuffer.append(TEXT_29); stringBuffer.append(TEXT_30); return stringBuffer.toString(); } } --- NEW FILE: ProvidesDefGetMethodAssemblyImplementationTemplate.java --- package ccmtools.generator.java.templates; import ccmtools.generator.java.metamodel.*; public class ProvidesDefGetMethodAssemblyImplementationTemplate { protected static String nl; public static synchronized ProvidesDefGetMethodAssemblyImplementationTemplate create(String lineSeparator) { nl = lineSeparator; ProvidesDefGetMethodAssemblyImplementationTemplate result = new ProvidesDefGetMethodAssemblyImplementationTemplate(); nl = null; return result; } protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; protected final String TEXT_1 = NL + " public "; protected final String TEXT_2 = " get_"; protected final String TEXT_3 = "()" + NL + " {" + NL + " return new "; protected final String TEXT_4 = "."; protected final String TEXT_5 = "Impl(this, "; protected final String TEXT_6 = ");" + NL + " }"; protected final String TEXT_7 = NL; public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); ProvidesDef provides = (ProvidesDef) argument; stringBuffer.append(TEXT_1); stringBuffer.append(provides.getInterface().generateAbsoluteJavaCcmName()); stringBuffer.append(TEXT_2); stringBuffer.append(provides.getIdentifier()); stringBuffer.append(TEXT_3); stringBuffer.append(provides.generateJavaNamespace()); stringBuffer.append(TEXT_4); stringBuffer.append(provides.getComponent().getIdentifier()); stringBuffer.append(provides.getIdentifier()); stringBuffer.append(TEXT_5); stringBuffer.append(provides.getAssemblyFacet()); stringBuffer.append(TEXT_6); stringBuffer.append(TEXT_7); return stringBuffer.toString(); } } |