Implementation Strategies for APPCs - PowerPoint PPT Presentation

About This Presentation
Title:

Implementation Strategies for APPCs

Description:

package ShowAccessAPPC; // compile once. public abstract class DataToAccess ... Instead of having APPC object, insert its compiled code into the host class. ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 13
Provided by: Gues229
Category:

less

Transcript and Presenter's Notes

Title: Implementation Strategies for APPCs


1
Implementation Strategies for APPCs
  • Subclassing APPC classes (Inner Classes)
  • BCA w/ publish and subscribe
  • BCA w/ code insertion

2
A recurring example
appc ShowAccessAPPC public class DataToAccess
replace Object readOp()
System.out.println("Read access) return
expected_readOp()
package Host // host is static. compile it
once public class Point private int x0,y0
Host(int x, int y) this.xx this.yy int
getX() return x int getY() return y
package Connector connect ShowAccessAPPC
DataToAccess is Point with readOp getX
3
Issues
  • We need to connect the host (Point) and the APPC
    (DataToAccess) so that the APPC can access
    methods on the host (readOp) and the host will
    use the behavior added by the APPC.

4
Subclassing the APPC classes
  • To connect the APPC to the host, make the APPC be
    an abstract class. Use information from the
    connector to create a subclass of the abstract
    class that provides the necessary behavior.
  • Make the host use the APPC behavior by creating
    subclasses of host classes that have methods that
    access the APPC behavior.

5
Inner Classes
package ShowAccessAPPC // compile once public
abstract class DataToAccess public abstract
Object expected_readOp() public Object
readOp() System.out.println("Read
access") return expected_readOp()
package Connector public class MyPoint
extends Host.Point ShowAccessAPPC.DataToAcces
dta_getX new ShowAccessAPPC.DataToAccess()
public Object expected_readOp() return
expected_getX() public Object get_host()
return MyPoint.this // rename the old
method public Integer expected_getX() return
super.getX() // override the replaced
method public Integer get_getX() return
(Integer) dta_getY.readOp()
6
Problems
  • Need to translate arguments from host to appc
    packages, and results back again
  • Need to rework application to create MyPoint
    objects instead of Point (use abstract factory
    pattern)
  • Trouble with inheritance in the APPC cg

7
Binary Component Adaptation
  • BCA allows classes to be modified after
    compilation, just before they are loaded by the
    JVM.
  • Use BCA to modify the host class to call the APPC
    at appropriate times. This avoids the use of the
    Factory Pattern.
  • Still has trouble with inheritance in APPC and
    still needs to be translated.

8
Point class is modified in situ
package Host public class Point private int
x0,y0 // add instance variables
ShowAccessAPPC.DataToAcces dta_getX new
ShowAccessAPPC.DataToAccess() public Object
expected_readOp() return expected_getX()
public Object get_host() return MyPoint.this
// rename the old methods public
Integer expected_getX() return x //
override the replaced methods. public Integer
getX() return (Integer) dta_getY.readOp()
public Integer getY() return y
9
Inserting code using BCA
  • Instead of having APPC object, insert its
    compiled code into the host class.
  • preprocess the APPC to make it ammenable to this

10
APPC code that is compiled
package ShowAccessAPPC // compile once public
interface DataToAccess Object
expected_readOp() Object readOp() public
class DataToAccess_Hidden implements DataToAccess
public Object expected_readOp() return
null public Object readOp()
System.out.println("Read access") return
expected_readOp()
11
Point Code generated by BCA
package Host public class Point implements
DataToAccess private int x0, y0 //
rename the old methods public Integer
expected_getX() return x // SNIPPED from
class file of // DataTOAccess_Hidden (not
recompiled) public Object readOp()
System.out.println("Read access") return
expected_getX() // override the
replaced methods. public Integer get_getX()
return (Integer) readOp() public Integer
get_getY() return y
12
Properties
  • No need to translate objects
  • Able to use instantion in the APPC code
  • Inheritance in APPCs works
  • Larger class files, with object code duplication
Write a Comment
User Comments (0)
About PowerShow.com