If we don't define service in java implementation class or the componentType
file, the default service is the same as implementation class.
for example, the java class is like:
public class DServiceImpl {
public String sayHello() {
return "Hello" ;
}
}
The componentType is :
<componentType>
<implementation.java class="com.ibm.was.sca.DServiceImpl"/>
</componentType>
The composite file is :
<composite>
<component name="Component">
<implementation.java class="com.ibm.was.sca.DServiceImpl"/>
</component>
</composite>
You can pass the test with: DService service =
ServiceFinder.getService(DService.class, "Component/DServiceImpl");
If you add a <service> in the composite file:
<composite>
<component name="Component">
<implementation.java
class="com.ibm.was.sca.DServiceImpl"/>
<service name="DService1">
<interface.java interface="com.ibm.was.sca.DService"/>
</service>
</component>
</composite>
You can still get the service with the name "Component/DServiceImpl", but it
will report a warning:
WARNING: Skipping component service not defined in the component type:
Component#DService1
Then if you specify another name in the componentType:
<componentType>
<implementation.java class="com.ibm.was.sca.DServiceImpl"/>
<service name="DService1">
<interface.java interface="com.ibm.was.sca.DService"/>
</service>
</componentType>
Now the service name will be changed to DService1, so you will not get the
service by "Component/DServiceImpl". You have to use DService1 instead.
If you change the name in composite file from DService1 to DService2, you
can still get the service with name "Component/DService1" but with a
warning:
WARNING: Skipping component service not defined in the component type:
Component#DService2
Now change the DService2 to DServiceImpl in composite file, there will be no
warning, all can pass.
So DServiceImpl is a specical name, a default name.