//Artefact:SoftwareComponent/com/sphenon/engines/ObjectAssembler

Usage - Tutorial

OCP
Introduction
OCPs: Object Aggregation Language
  • ‣ Java classes descibre single objects
  • ‣ OCPs describe multiple connected objects
Context of OCPs
  • ‣ OCPs are related to several technologies
OCP Usage
  • ‣ 1996: loading of test data
  • ‣ today: 15% OCPs compared to Java files
  • ‣ grown project (evolution...)
Getting Started
OCP Example: Test Data
<Product> <ArticleNumber>12345</Artikelnummer> <Name>Digital Receiver</Name> <ShortDescription>...</ShortDescription> <Description>...</Description> <Image><Name>pic1.jpg</Name></Image> <Preview><Name>pic2.jpg</Name></Preview> <Certificates/> <AdditionalImage>pic3a.jpg</AdditionalImage> <AdditionalImage>pic3b.jpg</AdditionalImage> <EnabledFrom NULL="true"/> <EnabledTil NULL="true"/> <Variant> <ArticleNumber>23456</ArticleNumber> <Feature><de>nein</de><en>no</en></Feature> </Variant> </ArticleNumber> </Product>
  • ‣ The example show a test objects to be loaded into a product database
OCP Example: Tests
<test CLASS="Aggregate::.../BuildAndTestFiling"> <TextLocator>oorl://Filing/...model03</TextLocator> <DoBuild>true</DoBuild> <DoTest>false</DoTest> </test>
A Simple Object Construction Plan
The following example shows a simple Object Construction Plan (OCP).
example.ocp
<Planet> <Name>world</Name> </Planet>
The respective Java Class
The Object Construction Plan loads an instance of class "Planet", which is defined as follows:
Planet.java
package org.xocp.test; public class Planet { protected String name; public String getName () { return this.name; } public void setName (String name) { this.name = name; } }
A Little Help
To run the example without any further preparation, we temporarily add an exact class specification.
example.ocp
<Planet CLASS="org.xocp.test.Planet"> <Name>world</Name> </Planet>
Some Test Code
Here's a test class which executes the OCP and prints out the result.
Test.java
package org.xocp.test; import org.xocp.factories.Factory_Aggregate; public class Test { public static void main(String[] args) { Planet p = (Planet) Factory_Aggregate.construct("example1.ocp"); System.out.println("Hello " + p.getName() + "!\n"); } }
Test Execution
To execute the test, the following command can be used. It is assumed, that the jar- and ocp-file are located in the current directory.
Testaufruf
java -classpath objectassembler.jar org.xocp.test.Test
OCP Example: Application-Aggregation
<Space Id="XYZ Gruppe"> <Equipments>...</Equipments> <Content>...</Content> <SubSpace Id="AdressStammdaten">... <SubSpace Id="Abrechnung">... <SubSpace Id="TourStammdaten...">... </Space>
OCP Example: User Interface Widgets
<object CLASS="Placeholder" KeepCreatedValue="true" PerSession="true"> <Equipments/> <Instantiator> <TargetClass>.../loginpanel</TargetClass> <Layout Resource.Style="ADOA-loginpanel"/> </Instantiator> </object>
OCP Example: Process Description
<Undertaking> <Work> <At> <Dates> ... <Date>1/5/2009</Date> <Date>1/6/2009</Date> <Date>1/7/2009</Date> ... </Dates> </At> <Aggregate>.../MonthlyWork</Aggregate> </Work> <Allocation> <Work OIDREF="work"/> <Responsibility/> <Agent Id="localhost"/> </Allocation> </Undertaking>
How it works
Factorysite, Scaffolds - No Database
Normally, each execution of an OCP yields a new instance of the corresponding object aggregate. OCPs describe a factory network and behave therefore like any factory, not like a database.
Test.java
... Planet p1 = (Planet) Factory_Aggregate.construct("file:example1.ocp"); Planet p2 = (Planet) Factory_Aggregate.construct("file:example1.ocp"); // two aggragates assert(p1 != p2); ...
Matching Factory Search
example3.ocp
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>world</Name> </Planet>
Singleton
As with any good factory, you can modify this behaviour to get a singleton.
example.ocp
<Planet SINGLETON="true" CLASS="org.xocp.test.Planet"> <Name>world</Name> </Planet>
Test.java
... Planet p1 = (Planet) Factory_Aggregate.construct("file:example1.ocp"); Planet p2 = (Planet) Factory_Aggregate.construct("file:example1.ocp"); // singleton assert(p1 == p2); ...
Explicit Class, Factory, Retriever
<Planet xmlns="http://xmlns.xocp.org/test" CLASS="PlanetWithRing"> <Name>Saturn</Name> ... <RingDiameter>...</RingDiameter> </Planet>
<Planet xmlns="http://xmlns.xocp.org/test" FACTORY="Factory_PlanetWithRing"> <Name>Saturn</Name> ... <RingDiameter>...</RingDiameter> </Planet>
<Planet xmlns="http://xmlns.xocp.org/test" RETRIEVER="Retriever_PlanetWithRing"> <Query>rötlich, mit Ringen</Query> </Planet>
Factory & Retriever Interfaces
public class Factory_PlanetWithRings { public void setName... public void setRingDiameter... ... public Planet create () ... // optional: public Planet precreate () ... }
public class Retriever_PlanetWithRings { public void setQuery... public Planet retrieve () ... }
Basic Elements
Simple Data Types
public class Planet { public void setDiameter (int diameter) { ... } public void setHasLifeForms (boolean has_life_forms) { ... } }
<Planet xmlns="http://xmlns.xocp.org/test"> <Diameter>12000</Diameter> <HasLifeForms>true</HasLifeForms> </Planet>
Enumerations
<Planet xmlns="http://xmlns.xocp.org/test"> <Farbe>ROT</Farbe> </Planet>
public enum Farben { ROT, GELB, GRUEN, BLAU }
Default Value
Planet.java
package org.xocp.test; public class Planet { ... public String defaultName () { return "world"; } }
<Planet xmlns="http://xmlns.xocp.org/test"/>
Embedded XML (Text)
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Saturn</Name> ... <Description CONTENT="XML/Text"> <section> <title>Saturn</title> <para> Saturn is a great planet. It has rings! </para> </section> </Description> </Planet>
Embedded XML (DOM)
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Saturn</Name> ... <Description CONTENT="XML/DOM"> <section> <title>Saturn</title> <para> Saturn is a great planet. It has rings! </para> </section> </Description> </Planet>
Indented Text
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Saturn</Name> ... <Description CONTENT="Text/Indented"> Dieser Text ist hier hübsch eingerückt, in der Ausgabe jedoch *nicht*! </item27a> </Description> </Planet>
Configuration
Searchpath for Classes
In the OCP example, it was necessary to give the complete specification of the class name. Typically, that's tedious work.
Therefore, similar to the Java import directive you can specify a list of packages which are searches for classes.
The most simple way to this is to create the following property entry:
.properties
com.sphenon.basics.metadata.TypeManager.SearchPathes.DEFAULT\ =org.xocp.test:java.util:java.lang
To improve management of the OCP files and at the same time keep them concise, the search path can be associated to the XML namespace of the OCP.
Since namespaces may be associated with further information and since such a search path may be use in other contexts (e.g. project wide), the association is via another indirection, the socalled "type context" .
Alltogether the configuration looks like this:
.properties
org.xocp.TypeContext4XMLNS.http\://xmlns.xocp.org/test\ =org.xocp.testtc com.sphenon.basics.metadata.TypeManager.SearchPathes.\ org.xocp.testtc\ =org.xocp.test:java.util:java.lang
The first entry specifies the type context which is to be used within the given XML namespace.
The second entry contains the search path, which belongs to that type context.
The OCP now looks as follows. The example may not look that impressive (actually, it's longer than before), but in typically there's not just one class in it.
example.ocp
<Planet CLASS="Planet" xmlns="http://xmlns.xocp.org/test"> <Name>world</Name> </Planet>
Root Class
org.xocp.RootClass4XMLNS.http\://xmlns.xocp.org/test\ =org.xocp.test.Planet
example3.ocp
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>world</Name> </Planet>
Specific File Extensions
Class Extension Property
org.xocp.ExtensionForClass.Planet=planet
example3.ocp
<Planet> <Name>world</Name> </Planet>
Linking Objects
Object References (Java)
public class Planet { ... public void setNeighbour (Planet neighbour) { ... } }
Nested Embedding
<Planet xmlns="http://xmlns.xocp.org/test"> ... <Neighbour> <Name>Mars</Name> ... </Neighbour> </Planet>
Null Value
<Planet xmlns="http://xmlns.xocp.org/test"> ... <Neighbour> <Name>Neptun</Name> <Neighbour NULL="true"/> <!-- Pluto is no planet any more --> </Neighbour> </Planet>
References
public class Sun { ... } public class Planet { ... public void setSun (Sun sun) { ... } }
<Planet xmlns="http://xmlns.xocp.org/test"> ... <Sun OID="sun"/> <Neighbour> <Name>Mars</Name> ... <Sun OIDREF="sun"/> <!-- same sun --> </Neighbour> </Planet>
Cycles
... <Erni OID="erni"> <Friend OIDREF="bert"/> </Erni> <Bert OID="bert"> <Friend OIDREF="erni"/> </Bert> ...
Locators
... <Object LOCATOR="person/Friend/Name"/> ...
person.getFriend().getName()
Locator Examples (oorl.org)
person/Friend/Name oorl://Property/Friend/Name (base: person) oorl://File//home/leue/example.txt oorl://JarResource//META-INF/MANIFEST oorl://SoftwareUnit/components/engines/factorysite oorl://Model/org/xocp/test/Person/Attribute/2/Type oorl://OCP/Aggregate::...%2FBuildAndTestFiling/ TextLocator=oorl:%2F%2FFiling%2F...model03/ DoBuild=true/DoTest=false
Modularisation
OCP Parameter
<Moon CLASS="Moon" xmlns="http://xmlns.xocp.org/test"> <Name PARAMETER="Name"/> </Moon>
Include external OCP via Factory
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Earth</Name> ... <Moon FACTORY="Factory_Aggregate"> <AggregateClass>...Moon</AggregateClass> <TargetParameters> <Name>Moon</Name> ... </TargetParameters> </Moon> </Planet>
Include external OCP via Aggregate-Syntax
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Earth</Name> ... <Moon CLASS="Aggregate::.../Moon"> <Name>Moon</Name> </Moon> </Planet>
Optional, Output and Predefined Parameters
<Moon CLASS="Moon" xmlns="http://xmlns.xocp.org/test"> <Name OPTIONALPARAMETER="Name">Moon</Name> </Moon>
<Moon CLASS="Moon" xmlns="http://xmlns.xocp.org/test"> <Name OPTIONALPARAMETER="Name">Moon</Name> <Bases> <Base1 Name="B1" ASSIGNTO="DefaultBase"/> <Base2 Name="B2"/> <Base3 Name="B3"/> </Bases> </Moon>
<my_id PARAMETER="__OCP_ID__"/> <my_location PARAMETER="__OCP_LOCATION__"/>
Packages
OCP Searchpath
... <Moon CLASS="Aggregate::org/xocp/test/Moon"> ...
OCP-Path Property
org.xocp.SearchPath=\ <folder1>,<folder2>,<folder3>,...
Special CLASSPATH OCP-Path Entry
org.xocp.SearchPath=\ ...,ctn://JavaResource//my/java/package/...
Browsing OCPs
OCP File Tree
org xocp test solarsystem Earth.planet Mars.planet Jupiter.planet
public interface PlanetPackage extends Planet { public Vector getPlanets(CallContext context); }
PlanetPackage p = (PlanetPackage) Factory_Aggregate.construct("org/xocp/test/solarsystem");
Tree Nodes (Configuration)
<treenode CLASS="PlanetPackage" xmlns="..."> <Id PARAMETER="AGGREGATEPREFIX"/> <Planets CLASS="Vector" DYNAMICPARAMETERS="true"> <parameters CLASS="Vector_ScaffoldParameter_long_" FACTORY="Factory_ScaffoldParameters_FolderBased"> <Folders PARAMETER="FOLDERS"/> <Extension PARAMETER="EXTENSION"/> <AggregatePrefix PARAMETER="AGGREGATEPREFIX"/> <ComponentClass PARAMETER="COMPONENTCLASS"/> </parameters> </Planets> </treenode>
Property: Node in Planet Tree
org.xocp.FolderAggregateClassForClass.Planet=.../planetpackage
Creating Jar Index
makejaridx.pl <classpath> <indexfolder> <includeregexp> <excluderegexp>
Metadata
<SolarSystem xmlns="http://xmlns.xocp.org/test" meta:Author="Andreas" meta:Created="17.6.2009" Planet-1.Name="Earth" Planet-2.Name="Mars" Planet-3 Name="Jupiter" Planet-4.Name="Saturn" Planet-4.RingDiameter="123"> <meta:Description CLASS="String"> Das Sonnensytem ist sehr groß. Darinnen gibt es ein paar Planeten. </meta:Description> </SolarSystem>
Object Orientation
Derived Java Classes
public class PlanetWithRings extends Planet { ... public void setRingDiameter (int ring_diameter) { ... } }
<Planet xmlns="http://xmlns.xocp.org/test"> <Name>Jupiter</Name> ... <Neighbour> <Name>Saturn</Name> ... <RingDiameter>...</RingDiameter> </Neighbour> </Planet>
Derived OCPs
mars.ocp
<Planet xmlns="http://xmlns.xocp.org/test"> <Name OID="neighbour_name">Mars</Name> <Moons OID="moons">...Phobos, Deimos...</Moons> </Planet>
<!-- parallel universe --> <Planet BASE="earth" xmlns="http://xmlns.xocp.org/test"> <neighbour_name>Lars</neighbour_name> <moons OVERRIDE="merge">...additional moons...</moons> </Planet>
Polymorphic OCPs
<Futter SIGNATURE="Tier tier" POLYMORPHIC="Class"> ... </Futter
<Moehre SIGNATURE="Hase hase" BASE="Futter"> ... </Moehre>
Futter f = (Futter) Factory_Aggregate.construct("Futter", new Hase());
OCP Example: Parser Configuration (oogenerator.org)
<parser CLASS="TemplateParser" xmlns="..."> <SourceHandler CLASS="TCHCompactUnicodeSyntax2ASCII"> <ASCIISourceHandler CLASS="TCHLanguageDispatcher"> <TextHandler CLASS="TCHText"/> <JavaCodeHandlerCLASS="TCHJavaCode"/> <JavaExpressionHandler CLASS="TCHJavaExpression"/> <TemplateCommentHandler CLASS="TCHTemplateComment"/> <TemplateCodeHandler CLASS="TCHTemplateCode"/> <TagHandler CLASS="TCHTag"/> <PPTagHandler CLASS="TCHPPTag"/> </ASCIISourceHandler> </SourceHandler> <IncludeModules OID="moduler"> <Module>com.sphenon.engines.generator.modules.JavaPP</Module> </IncludeModules> </parser>
<myparser BASE="TemplateParser" xmlns="..."> <modules OVERRIDE="merge"> <Module>com.sphenon.engines.generator.mymodules.MyPP</Module> </modules> </myparser>
Collections
Collections (Java)
public class SolarSystem { public void setPlanets (Vector<Planets> planets) { ... } }
Factory for Collections (Java)
public class Factory_Vector_Planets_long_ { public java.util.Vector create (CallContext context) { ... } public void set_ParametersAtOnce(CallContext call_context, String[] names, Object[] values) { ... } }
Collections (OCP)
Collections
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planets> <Planet><Name>Earth</Name></Planet> <Planet><Name>Mars</Name></Planet> <Planet><Name>Jupiter</Name></Planet> </Planets> </SolarSystem>
Component Type, Arrays, Generic Instances
Component Type
<item11a CLASS="Vector" COMPONENTTYPE="String"> <a>Hallo A</a> <b>Hallo B</b> </item11a>
Component Type
<item11b CLASS="String[]"> <a>Hallo A</a> <b>Hallo B</b> </item11b>
Component Type
<item11b CLASS="Vector&lt;String&gt;"> <a>Hallo A</a> <b>Hallo B</b> </item11b>
Generic Types
Component Type
<item11c CLASS="Vector&lt;Vector&lt;String&gt;&gt;"> <v1> <a>Hallo A</a> <b>Hallo B</b> </v1> <v2> <a>Hallo A</a> <b>Hallo B</b> </v2> </item11c>
Generic Types
Component Type
<item11d CLASS="GenericsTest"> <VS> <a>Hallo A</a> <b>Hallo B</b> </V> </item11d>
Component Type
public class GenericsTest { protected Vector<String> vs; public Vector<String> getVS () { return this.vs; } public void setVS (Vector<String> vs) { this.vs = vs; } }
Syntactic Sugar
XML Attributes
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planets> <Planet Name="Earth"/> <Planet Name="Mars"/> <Planet Name="Jupiter"/> <Planet CLASS="PlanetWithRings" Name="Saturn"/> </Planets> </SolarSystem>
Alias for Frequent Subclasses
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planets> ... <PlanetWithRings Name="Saturn"/> ... </Planets> </SolarSystem>
org.xocp.AliasLibrary.\ org.xocp.test=\ PlanetWithRings@Vector_Planet_long_=|PlanetWithRings|||,.. more aliases
Alias for Saving Container Tags
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet Name="Earth"/> <Planet Name="Mars"/> <Planet Name="Jupiter"/> <PlanetWithRings Name="Saturn"/> </SolarSystem>
org.xocp.AliasLibrary.\ org.xocp.test=\ Planet@SolarSystem=Planets|||||CONTAINER,.. more aliases
OCP Example: UML Model
<Class> <ExternalImport>java.lang.String</ExternalImport> <PrimitiveImport>int</PrimitiveImport> <Name>Person</Name> <Stereotype>CoreClass</Stereotype> <Attribute Name="Vorname" Type="String"/> <Attribute Name="Nachname" Type="String"/> <Attribute Name="Alter" Type="Integer"/> </Class>
Structured XML Attributes
<SolarSystem xmlns="http://xmlns.xocp.org/test" Planet-1.Name="Earth" Planet-2.Name="Mars" Planet-3 Name="Jupiter" Planet-4.Name="Saturn" Planet-4.RingDiameter="123"/>
OCP Example: Shortcuts
<Group Name="Model03 Shortcuts"> <Layout Tool="QuickClick" Variant="islaycolors" Style.Background="#3C3C58" Style.Foreground="#F4FFEF"/> <Edit Name="Edit Shortcuts" File=".../model03.shortcuts"/> <Evaluate Name="compile" Expression="..."/> <Evaluate Name="test" Expression="..."/> <Browse Name="API Documentation" URL=".../javadoc/index.html"/> <Group Name="Java"> <Edit Name="Java" File=".../model03/source/java"/> </Group> </Group>
OCP Example: Project Definition
<JavaPackage> <Id>model03</Id> <Name>Test Application Model03</Name> <MainJavaPackage>net.leue.andreas.sandbox.model03</MainJavaPackage> <HasTemplates>false</HasTemplates> <HasTemplateInstances>true</HasTemplateInstances> <HasModelInstances>true</HasModelInstances> <HasOCPs>true</HasOCPs> <ModelViewOptions StateBackends.sb1="InMemory" StateBackends.sb2="JPA"> <OOModelsRetrieval>true</OOModelsRetrieval> <TestClass>Test</TestClass> <Import>foreign/bundles/emos</Import> <Import>components/ad/interaction</Import> </JavaPackage>
DSL-layering
<Package OID="unit" xmlns="http://xmlns.sphenon.com/com/sphenon/software/production/softwareunit" xmlns:code="code"> <Id PARAMETER="Id" CLASS="String"/> <Name OPTIONALPARAMETER="Name" CLASS="String" IDREF="Id"/> <Model OID="modeltree" IF="$(Boolean HasModelInstances ?) == true" CLASS="com.sphenon.software.umlproduction.Artefact_UMLModelElement"> <Id>model</Id> <Name>OOEM Model</Name> <Dependencys/> <Accessorys/> <Location><Location OID="model_location"><TextLocator>origin/source/models</TextLocator></Location></Location> <UMLModelElement CLASS="com.sphenon.modelling.uml.UMLPackage" OID="model" FACTORY="Factory_Aggregate" TYPECHECK="allow_dynamic"> <AggregateClass RETRIEVER="com.sphenon.basics.locating.retrievers.Retriever_TextLocator"> <Locator LOCATOR="model_location/Locators/0"/> </AggregateClass> <AggregateTargetClass>Tree<UMLModelElement></AggregateTargetClass> <Parameters> <IsRoot CLASS="boolean">true</IsRoot> </Parameters> </UMLModelElement> <StepFactory CLASS="Factory_Step_OOModelsRetrieval" IF="$(Boolean OOModelsRetrieval ?) == true"> <Id>retrieve_model</Id> <Purpose> <Value CLASS="ChangeProduction"> <Sources/> <Targets> <Target Name="ModelTree"><Artefact IDREF="modeltree"/></Target> </Targets> </Value> </Purpose> </StepFactory> </Model> <Model IF="$(Boolean HasModelInstances ?) == true" CLASS="com.sphenon.software.umlproduction.Artefact_UMLModelElement"> <Id>modelview</Id> <Name>OOV Core Model</Name> <Dependencys/> <Accessorys/> <Location><Location IDREF="model_location"/></Location> <UMLModelElement OIDREF="modelview"/> </Model> <PlainJavaLibrary PASS="2" OID="library" code:PreCondition="HasModelInstances == null || HasModelInstances == false || HasTemplateInstances == true"> <Id PARAMETER="Id" CLASS="String"/> <Name>Java</Name> <Sources>origin/source/java</Sources> <TemplateInstances> <Specification OID="tispecification" IF="true" CLASS="com.sphenon.engines.generator.classes.TemplateInstancesSpecification"> <InstancePackage OPTIONALPARAMETER="TemplateInstancePackage" EXPRESSION="true">MainJavaPackage+'.tplinst'</InstancePackage> <TemplatePackagePath OPTIONALPARAMETER="TemplatePackagePath">com.sphenon.basics.context.templates:com.sphenon.basics.smallparts.templates:com.sphenon.basics.many.templates:com.sphenon.basics.reference.templates:com.sphenon.basics.retriever.templates:com.sphenon.ui.vui.templates</TemplatePackagePath> <Traits SWITCH="true"> <t1 IF="$(Boolean HasModelInstances ?) == true" CLASS="com.sphenon.software.umlproduction.JavaTemplateTraits_FromModel"><Model OIDREF="model"/></t1> <t2 IF="true" CLASS="com.sphenon.engines.generator.JavaTemplateTraits_JavaTypes"/> </Traits> <IncludeJavaLibraryTypes OPTIONALPARAMETER="IncludeJavaLibraryTypes">false</IncludeJavaLibraryTypes> <InstanceSpecifications CLASS="VectorUnion_String_long_"> <Vectors> <Vector IF=" $(Boolean HasTemplateInstances ?) == true" FACTORY="Factory_Aggregate" TYPECHECK="allow_dynamic"> <AggregateClass NULL="true"/> <AggregateTreeNode> <Location>origin/source/templateinstances.ocp</Location> </AggregateTreeNode> <Parameters/> </Vector> <Vector IF=" $(Boolean HasModelInstances ?) == true" CLASS="Vector_OnDemandAggregate_String_long_"> <AggregateClass>com/sphenon/ad/adcore/model/coremodel/ADCModelTemplateInstances</AggregateClass> <Arguments> <Model OIDREF="model"/> <PackageFilter OIDREF="filter"/> </Arguments> </Vector> </Vectors> </InstanceSpecifications> </Specification> <Instances>build/generated/source/javati</Instances> <PackageImports>origin/source/packageimports.ocp</PackageImports> </TemplateInstances> <ModelInstances IF="$(Boolean HasModelInstances ?) == true" OID="modelinstancespec"> <Model OID="modelview" CLASS="Aggregate::com/sphenon/software/production/ModelView"> <PackageFilter OID="filter" CLASS="String" EXPRESSION="true">$(String MainJavaPackage)+":org.uml.stereotypes"</PackageFilter> <!-- <ModelPath CLASS="Location">origin/source/models</ModelPath> --> <Model OIDREF="model"/> <Options OPTIONALPARAMETER="ModelViewOptions"/> </Model> <Instances>build/generated/source/javami</Instances> <Templates>build/generated/source/javamt</Templates> <OCPs>build/generated/source/ocp</OCPs> <PackageImports>origin/source/packageimports.ocp</PackageImports> </ModelInstances> <ModelOCPs IF="$(Boolean HasModelInstances ?) == true" CLASS="Aggregate::com/sphenon/software/production/PJLModelOCPs"> <Instances LOCATOR="modelinstancespec/OCPs"/> <Model LOCATOR="modelinstancespec/Model"/> </ModelOCPs> <Classes>build/generated/class</Classes> <Archive CLASS="String" EXPRESSION="true">'build/generated/library/' + Id + '.jar'</Archive> <OCPs IF="$(Boolean HasOCPs ?) == true" IDREF="ocps"/> <Unit OIDREF="unit"/> </PlainJavaLibrary> <Templates IF="$(Boolean HasTemplates ?) == true" OID="templates">origin/source/templates</Templates> <OCPs IF="$(Boolean HasOCPs ?) == true" OID="ocps">origin/source/ocp</OCPs> <ModelTemplates IF="$(Boolean HasModelInstances ?) == true" OID="modeltemplates" CLASS="Aggregate::com/sphenon/software/production/PJLModelTemplates"> <Instances LOCATOR="modelinstancespec/Templates"/> <Model OIDREF="modelview"/> <Library OIDREF="library"/> <TemplateInstanceRegistry LOCATOR="tispecification/TemplateInstanceRegistry"/> </ModelTemplates> <JavaDoc PASS="3"> <Library OIDREF="library"/> <Documents>build/generated/javadoc</Documents> </JavaDoc> <Doclets PASS="3"> <Library OIDREF="library"/> <Documents>build/generated/doclet</Documents> </Doclets> <TestSuite PASS="3" IF="$(String TestClass ?) != null" CLASS="TestSuite_TestClass"> <ClassName CLASS="String" EXPRESSION="true">MainJavaPackage + '.test.' + TestClass</ClassName> <JavaLibrary OIDREF="library"/> </TestSuite> <Exports> <JavaLibrary OIDREF="library"/> <Templates IF="$(Boolean HasTemplates ?) == true" OIDREF="templates"/> <ModelTemplates IF="$(Boolean HasModelInstances ?) == true" OIDREF="modeltemplates"/> </Exports> <Imports OPTIONALPARAMETER="Imports" NULL="true"/> </Package>
Scripting
Listener
<Planet xmlns="http://xmlns.xocp.org/test" LISTENER="org.xocp.test.PlanetCreationObserver"> <Name>Saturn</Name> </Planet>
Value Expressions
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <PlanetWithRings> <Name EXPRESSION="true">'Sat'+'urn'</Name> <Diameter EXPRESSION="value">102+(3*7)</Diameter> </PlanetWithRings> </SolarSystem>
Loops
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet FOREACH="index: [1, 2, 3]"> <Name EXPRESSION="true">'Erde Nummer '+index</Name> </Planet> </SolarSystem>
Conditions
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet IF="year < 2007"> <Name>Pluto</Name> </Planet> </SolarSystem>
Local Variables
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet DEFINE="name: 'Saturn'"> <Name EXPRESSION="true">name</Name> </Planet> </SolarSystem>
Switch/Case
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet SWITCH="true"> <Name> <frueher IF="year < 2007">Pluto</frueher> <heute IF="year >= 2007">Pluto (ehemals)</frueher> </Name> </Planet> </SolarSystem>
Assertions
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet> <code:PreCondition>year < 2007</code:PreCondition> <Name>Pluto</Name> <code:PostCondition>result.getName() = 'Pluto'</code:PostCondition> </Planet> </SolarSystem>
Arbitrary Code
<SolarSystem xmlns="http://xmlns.xocp.org/test"> <Planet> <code:PreBuildScript> java.lang.System.err.println("Jetzt geht's los!"); </code:PreBuildScript> <Name>Pluto</Name> <code:PostBuildScript> java.lang.System.err.println("Fertig!"); </code:PostBuildScript> </Planet> </SolarSystem>
OCP Example: Dynamic Model Transformation (OOV)
<UMLClass SIGNATURE="UMLClass Source" CLASS="UMLClass"> <Name EXPRESSION="true">Source.getName()</Name> <Attributes CLASS="VectorAdapter"> <SourceVector LOCATOR="Source/Attributes"/> <Converter CLASS="...ConverterToAggregate" AggregateClass=".../UMLAttribute"> </Attributes> </UMLClass>
End
Links
  • ‣ www.xocp.org
  • ‣ www.oogenerator.org
  • ‣ www.oomodels.org