Java Beans Profile Domingos Neto drmnetogmail com Marcos
Java. Beans Profile Domingos Neto drmneto@gmail. com Marcos Aurélio maurelio 1234@gmail. com
Outline • • Introduction Java profile Java. Beans profile References
Introduction <<profile>> Java. Beans <<apply>> Application PSM
Introduction UML 2 <<import>> <<profile> > Java <<import>> <<profile>> Java. Beans
Java UML 2 Profile • Extending UML metaclasses with Java Concepts • We represented only the concepts that are important to Java. Beans Profile • Java Concepts: – Classes • Attributes • Methods – Parameters • Constructors – Interfaces – Exceptions
• Java does not allow multiple class inheritance, classes can’t be active neither own ports. context Java. Class inv: super. Class->size() <= 1 and owned. Port->is. Empty() and is. Active = false • Every class has an constructor context Java. Class inv: self. owned. Operation->exists(ocl. Is. Kind. Of(Constructor)) and owned. Parameter->is. Empty() • Every class operation is a constructor or a method context Java. Class inv: self. owned. Operation->exists(ocl. Is. Kind. Of(Constructor) xor ocl. Is. Kind. Of(Method))
• Java interfaces cannot contain another interfaces or classes. context java: : Interface inv: self. nested. Classifier->is. Empty() • Java methods cannot have multivalorated return values. context java: : Method inv: ((self. lower = 1) and (self. upper = 1)) or ((self. lower = 0) and (self. upper = 0)) • Java methods accept only input parameters. context java: : Parameter inv: self. direction = Parameter. Direction. Kind: : in
Attributes • Represents Java attributes. Java has no support for: – associations between classes, – attribute overriding; – attribute redefinition; – “set” attributes – Read-only attributes
Attribute – OCL Constraints context java: : Attribute inv: ((self. is. Derived = false) and (self. is. Read. Only = false) and (self. is. Derived. Union = false) and (self. is. Composite = false) and (self. association->is. Empty()) and (self. upper = 1) and (self. lower = 1) and (self. redefined. Property->is. Empty()) and (self. subsetted. Property->is. Empty()))
Java Profile usage Example
Java. Beans Profile • Specializes Java profile for modeling Java. Bean components. • Modeled Java. Beans concepts – Bean – Property – Event Listener – Event Triggering
Java. Beans Profile
Java. Beans Profile
Java. Beans Profile
Java. Beans – OCL context java. Beans: : Bean inv: let constructor: Constructor in (constructor. name = self. name) and (constructor. owned. Parameter->size() = 0) and (self. interface. Realization->includes(i : Java: : Interface | i. contract. name = "Serializable“ and i. package. name = "java. io")) and self. owned. Operation->includes(constructor)
Java. Beans - OCL context java. Beans: : Simple. Property inv: ( let getter. Method : Method in let get. Tag: String = "get“ in ( (getter. Method. owned. Parameter->size() = 0) and (getter. Method. name = (get. Tag. concat(simple. Property. name))) and (getter. Method. type = simple. Property. datatype) and self. class. owned. Operation->includes(getter. Method) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) or let setter. Method : Method in let set. Tag: String = “set“ in ( (setter. Method. owned. Parameter->size() = 1) and (setter. Method. name = (set. Tag. concat(simple. Property. name))) and (setter. Method. type->is. Empty()) and self. class. owned. Operation->includes(setter. Method) and (setter. Method. owned. Parameter->first(). type = simple. Property. datatype) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) )
Java. Beans - OCL context java. Beans: : Indexed. Property inv: ( let getter. Method : Method in let get. Tag: String = "get“ in ( (getter. Method. owned. Parameter->size() = 1) and (getter. Method. name = (get. Tag. concat(indexed. Property. name))) and (getter. Method. type = indexed. Property. datatype) and self. class. owned. Operation->includes(getter. Method) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) or let setter. Method : Method in let set. Tag: String = “set“ in ( (setter. Method. owned. Parameter->size() = 2) and (setter. Method. name = (set. Tag. concat(indexed. Property. name))) and (setter. Method. type->is. Empty()) and self. class. owned. Operation->includes(setter. Method) and (setter. Method. owned. Parameter->first(). type = Integer) and (setter. Method. owned. Parameter->last(). type = indexed. Property. datatype) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) )
Java. Beans - OCL context java. Beans: : Bound. Property inv: ( let getter. Method : Method in let get. Tag: String = "get“ in ( (getter. Method. owned. Parameter->size() = 0) and (getter. Method. name = (get. Tag. concat(bound. Property. name))) and (getter. Method. type = bound. Property. datatype) and self. class. owned. Operation->includes(getter. Method) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) or let setter. Method : Method in let set. Tag: String = “set“ in ((setter. Method. owned. Parameter->size() = 1) and (setter. Method. name = (set. Tag. concat(bound. Property. name))) and (setter. Method. type->is. Empty()) and self. class. owned. Operation->includes(setter. Method) and (setter. Method. owned. Parameter->first(). type = bound. Property. datatype) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) )
Java. Beans - OCL context java. Beans: : Constrained. Property inv: ( let getter. Method : Method in let get. Tag: String = "get“ in ( (getter. Method. owned. Parameter->size() = 0) and (getter. Method. name = (get. Tag. concat(constrained. Property. name))) and (getter. Method. type = constrained. Property. datatype) and self. class. owned. Operation->includes(getter. Method) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) or let setter. Method : Method in let set. Tag: String = “set“ in ( (setter. Method. owned. Parameter->size() = 1) and (setter. Method. name = (set. Tag. concat(constrained. Property. name))) and (setter. Method. type->is. Empty()) and self. class. owned. Operation->includes(setter. Method) and (setter. Method. owned. Parameter->first(). type = constrained. Property. datatype) and (setter. Method. raised. Exception->includes(Java: : Beans: : Property. Veto. Exception)) and self. class. ocl. Is. Kind. Of(Java. Beans: : Bean)) )
Java. Beans - OCL context java. Beans: : Triggers inv: ( let event: Property. Change. Event in let bean: Bean in let add. Listener. Method: Method in let remove. Listener. Method: Method in (add. Listener. Method. name = "add. Property. Change. Listener") and (remove. Listener. Method. name = "remove. Property. Change. Listener") and (add. Listener. Method. owned. Parameter->size() = 1) and (add. Listener. Method. owned. Parameter->first(). ocl. Is. Kind. Of(Java. Beans: : Property. Change. Listener) and (remove. Listener. Method. owned. Parameter->first(). ocl. Is. Kind. Of(Java. Beans: : Property. Change. Listener) and bean. owned. Operation->includes(add. Listener. Method) and bean. owned. Operation->includes(remove. Listener. Method) and self. client = bean and self. supplier = event) or let event: Vetoable. Change. Event in let bean: Bean in let add. Listener. Method: Method in let remove. Listener. Method: Method in (add. Listener. Method. name = "add. Vetoable. Change. Listener") and (remove. Listener. Method. name = "remove. Vetoable. Change. Listener") and (add. Listener. Method. owned. Parameter->size() = 1) and (add. Listener. Method. owned. Parameter->first(). ocl. Is. Kind. Of(Java. Beans: : Vetoable. Change. Listener) and (remove. Listener. Method. owned. Parameter->first(). ocl. Is. Kind. Of(Java. Beans: : Vetoable. Change. Listener) and bean. owned. Operation->includes(add. Listener. Method) and bean. owned. Operation->includes(remove. Listener. Method)) and self. client = bean and self. supplier = event )
Java. Beans API • <<Exception>>java: : beans: : Veto. Exception • <<Interface>>java: : io: : Serializable
Java. Beans Profile usage example
- Slides: 23