1 / 21

Java in the Box: Implementing the BoxScript Component Language

This article explores the implementation of the BoxScript component language in Java, highlighting key concepts such as abstract, concrete, and compound boxes. It also discusses box variants and conformity.

jmunn
Download Presentation

Java in the Box: Implementing the BoxScript Component Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java in the Box: Implementing the BoxScript Component Language Yi Liu Electrical Engineering and Computer Science South Dakota State University H. Conrad Cunningham Computer and Information ScienceUniversity of Mississippi

  2. Software Components

  3. provided required required provided interface inner component Component1 Component2 Components – A Closer Look

  4. Storage Storage Pricing Discounting Discounting2 CalPrice Pricing Discounting2 Discounting A Simple Example Compositionality Flexibility

  5. Key Concepts Interface • Interface (type) • Java interface gives operation signatures • Provided interface • describes operations the component implements that other components may use • Required interface • describes operations the component uses that must be implemented by another component Price.java public interface Price { double getPrice(int client, int item, int quantity); }

  6. 1…n P1 Pn … Box … R1 Rn 0…m Key Concepts Box • A box is a component • whose description includes provided and required interfaces • has 1..n provided interfaces • has 0..m required interfaces • Boxes may be • abstract • concrete • atomic • compound

  7. Price Pr PricingAbs Dc PrRt PriceRetrieve Discount Key Concepts Abstract Box • Abstract box • does not implement provided interfaces • implemented by concrete boxes PricingAbs.box abstract box PricingAbs { provided interface Price Pr; required interface Discount Dc, PriceRetrieve PrRt; } Interface type Interface Handle

  8. Price Pr Pricing Dc PrRt PriceRetrieve Discount Key Concepts Concrete Box • Atomic box • does not contain any other boxes • implements the provided interfaces Pricing.box box Pricing implements PricingAbs { provided interface Price Pr; required interface Discount Dc; } Interface type Interface handle

  9. Price Pr Pricing Dc PrRt PriceRetrieve Discount Key Concepts Interface Implementation for Atomic Box PrImp.java public class PrImp implements Price { private BoxTop _box; Discount dc; // required interface PriceRetrieve prRt; //required interface public PrImp(BoxTop myBox) { _box = myBox; InterfaceName name = new InterfaceName("Dc"); dc = (Discount)_box.getRequiredItf(name); name = new InterfaceName(“PrRt"); prRt = (PriceRetrieve)_box.getRequiredItf(name); } public double getPrice(int client,int item,int quantity) { double price = prRt.itemPrice(item); double disc = dc.getDiscount(client, item, quantity); return price * (1 – disc * 0.01) * quantity; } }

  10. Key Concepts Compound Box • Compound box • Composed from atomic boxes or other compound boxes • Follows composition rules • hide provided interfaces unless explicitly exposed • must expose required interface of constituent unless connected to provided interface of another constituent

  11. box handle Price Pr PricingAbs boxP Price tPrice Discount Dis Dc PriceRetrieve Discount PrRt DiscountingAbs boxD PriceRetrieve PrRt StorageAbs boxS CalPrice Key ConceptsCompound Box Example box CalPrice implements CalPriceAbs { composed from PricingAbs boxP, DiscountingAbs boxD, StorageAbsboxS; provided interface Price tPricefromboxP.Pr; connectboxP.DctoboxD.Dis, boxP.PrRt to boxS.PrRt; }

  12. Key ConceptsBox Variant • Box variants • Enable flexibility • Implement same (parent) abstract box • Can be substituted for each other • Conform to their (parent) abstract box • provide at least the provided interfaces of parent • require at most the required interfaces of parent

  13. Key ConceptsBox Conformity Suppose • IP2’ extends IP2 • IR1’ extends IR1 IP1 IP2’ IP3 IP1 IP2 Provided interfaces P1 P3 P2 P1 P2 B BAbs Required interfaces R1 R2 R1 R2 R3 IR1 IR2 IR1’ IR2 IR3 B conforms to BAbs

  14. Box code BoxCompiler Java code Java Compiler BoxScript ImplementationBox Source Code and Compilation • For all boxes • interfaces (.java) by user • box description (.box) by user • For atomic boxes only • interface implementation (.java) by user • For concrete boxes only • configuration information (.conf) by user • box manager code (.java) by compiler

  15. BoxScript Implementation Box Manager Implementation • package declaration • define filesystem usage • import • interfacedeclarations • data type declarations • variable declarations • instance variables for class • class definition Box manager B.java Concrete Box B

  16. <<interface >> Price references implements instantiates <<Java class >> Pricing <<Java class >> PrImp instantiates Pricing constructor Pricing <<interface >> Discount <<Java class >> CalPrice instantiates Discounting implements constructor CalPrice instantiates <<Java class >> Discounting <<Java class >> DisImp constructor Discounting references BoxScript ImplementationBox Runtime Structure Lazy instantiation

  17. BoxScript ImplementationBox Manager Code • Generated by compiler • to instantiate box instances • to assign references to interface handles

  18. BoxTop BoxTop() void setProvInterfacceDsc(InterfaceDsc pItfDsc) void setRequInterfaceDsc(InterfaceDsc rItfDsc) Object getProvidedItf(InterfaceName name) Object getRequiredItf(InterfaceName name) void setRequiredItf(InterfaceName iname, Object objRef) BoxScript Implementation Box Manager Implementation • Supports lazy instantiation • BoxTop

  19. BoxScript Implementation Box Manager Implementation • Code generation generateCode (B’dscFile, mngFile) //mngFile : filename for box manager read in dscFile genPackage(); genImports(); genVars(); genConstructor(); genGetProvidedItf(); // generate overriding method getProvidedItf if B is compound genSetRequiredItf(); // generate overriding method setRequiredItf writeIntoFile(mngFile);

  20. Conclusion • Component-oriented programming language BoxScript • Builds upon Java • Provides novel concepts of • box type structure • box variants • box conformity • interface satisfaction to support composition and flexibility

  21. Questions

More Related