Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following illustrates part of a Java component:

Code Block
languagejava
 public@Component 
public class CalculatorServiceImpl implements CalculatorService {

    @Reference
    protected AddService addService;

    @Property
    protected int maxValue; 
  
    public double add(double n1, double n2) {
        return addService.add(n1, n2);
    }
    
    ......
}

...

Configuring a Component

A component is can be defined and configured in an XML called a composite instead of using the Component annotation. The following outlines how this is done:

...

Components typically offer one or more services that clients invoke. If a component implements a single interface, it provides one service as defined by the interface. It may be necessary to explicitly define the service a component offers, for example, if it implements more than one interface. This is done using the SCA Service annotation:

Code Block
languagejava
@Component
@Service(CalculatorService.class)
public class CalculatorServiceImpl implements CalculatorService {
    ...
}  

...

Scopes are defined using the org.oasisopen.sca.annotation.Scope annotation:

 

Code Block
languagejava
@Component
@Scope("COMPOSITE")
public class CalculatorServiceImpl implements CalculatorService {
    ...
}  

...