Creating an Abstract Class
You can create an abstract class in the Project Explorer view.
Procedure
- In the Project Explorer view, copy the component implementation class and add the prefix Abstract to the class name of the copy. For example, if the component class is named ClassName, then rename the copy to AbstractClassName.
-
Edit the abstract component implementation class
AbstractClassName.
-
Edit the component implementation class
ClassName.
- ClassName implements one or more port types. Replace all the implements declarations with extends AbstractClassName.
- Remove all reference and property declarations and all accessor methods from the component implementation class.
- Edit method implementations to use accessor methods for property and reference objects.
-
If any of the
import statements displays a warning icon
, left-click the icon and click
Organize imports: in the pop-up that
displays.
- Save the concrete class.
Example
Before Concrete Class
public class Foo implements Calculator, AreaService {
public CalculatorOutputDocument add(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument divide(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument multiply(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument substract(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
@Reference
Phonebook Reference1;
public Phonebook getReference1()
{
return Reference1;
}
public void setReference1(Phonebook Reference1)
{
this.Reference1 = Reference1;
}
@Reference
AreaService Reference2;
public AreaService getReference2()
{
return Reference2;
}
public void setReference2(AreaService Reference2)
{
this.Reference2 = Reference2;
}
public AreaDocument calculateRectArea(ParametersDocument parameters)
{
return AreaDocument.Factory.newInstance();
}
@Property
String MyProperty1;
public String getMyProperty1()
{
return MyProperty1;
}
public void setMyProperty1(String MyProperty1)
{
this.MyProperty1 = MyProperty1;
}
@Property
String MyProperty2;
public String getMyProperty2()
{
return MyProperty2;
}
public void setMyProperty2(String MyProperty2)
{
this.MyProperty2 = MyProperty2;
}
}
After Abstract Class
/**
* @Generated TEMPL003
*/
public abstract class AbstractFoo implements Calculator, AreaService
{
@Reference
private Phonebook Reference1;
public Phonebook getReference1()
{
return Reference1;
}
public void setReference1(Phonebook Reference1)
{
this.Reference1 = Reference1;
}
@Reference
private AreaService Reference2;
public AreaService getReference2()
{
return Reference2;
}
public void setReference2(AreaService Reference2)
{
this.Reference2 = Reference2;
}
@Property
private String MyProperty1;
public String getMyProperty1()
{
return MyProperty1;
}
public void setMyProperty1(String MyProperty1)
{
this.MyProperty1 = MyProperty1;
}
@Property
private String MyProperty2;
public String getMyProperty2()
{
return MyProperty2;
}
public void setMyProperty2(String MyProperty2)
{
this.MyProperty2 = MyProperty2;
}
public abstract CalculatorOutputDocument add(CalculatorInputDocument input);
public abstract CalculatorOutputDocument divide(CalculatorInputDocument input);
public abstract CalculatorOutputDocument multiply(CalculatorInputDocument input);
public abstract CalculatorOutputDocument substract(CalculatorInputDocument input);
public abstract AreaDocument calculateRectArea(ParametersDocument parameters);
}
After Concrete Class
public class Foo extends AbstractFoo
{
public CalculatorOutputDocument add(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument divide(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument multiply(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public CalculatorOutputDocument substract(CalculatorInputDocument input)
{
return CalculatorOutputDocument.Factory.newInstance();
}
public AreaDocument calculateRectArea(ParametersDocument parameters)
{
return AreaDocument.Factory.newInstance();
}
}
Copyright © Cloud Software Group, Inc. All rights reserved.