Creating an Abstract Class

You can create an abstract class in the Project Explorer view.

Procedure

  1. 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.
  2. Edit the abstract component implementation class AbstractClassName.
    1. Delete the service method implementations and the life cycle methods (@Init and @Destroy).
      Errors will display.
    2. Add the abstract declaration to AbstractClassName.
    3. Add the abstract declaration to each service method.
    4. Set the access level of properties (@Property) and references (@Reference) to private.
    5. Add the javadoc annotation @Generated TEMPL003 at the class level:
      /**
       * @Generated TEMPL003
       */
      public abstract class AbstractClassName
    6. Move custom user members and methods from AbstractClassName to ClassName.
    7. If any of the import statements displays a warning icon , left-click the icon and click Organize imports: in the pop-up that displays.

    8. Save the abstract class.
  3. Edit the component implementation class ClassName.
    1. ClassName implements one or more port types. Replace all the implements declarations with extends AbstractClassName.
    2. Remove all reference and property declarations and all accessor methods from the component implementation class.
    3. Edit method implementations to use accessor methods for property and reference objects.
    4. If any of the import statements displays a warning icon , left-click the icon and click Organize imports: in the pop-up that displays.

    5. 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();
        }
}