There is no clear cut definition and always debatable. The way I see it..
Q. So what is the difference between a component and a service?
A component is an application level software unit like JSF component, EJB, Applet etc. All the J2EE components depend on the container for the system level support like transactions, security, pooling, life cycle management, threading etc. A service is a component that can be used remotely through a remote interface either synchronously or asynchronously (e.g. Web service, messaging system, sockets, RPC etc). A service is a step up from �distributed objects�. A service is a function that has a clearly defined service contract (e.g. interface, XML contract) to their consumers or clients, self contained and does not depend on the context or state of other services.
Essentially, a component could be defined as a replaceable unit that provides adhoc connections by well defined interfaces. But, besides that, a component has a special talent to be reusable by any context, instead that environemnt that it was originally created.
For example, a class could have interfaces and by those interfaces, could be replaceable, since changing its implemention would not create any impact in the consumer artifact, since the interfaces are immutable. But are this class really reusable? The experience says that: No, classes are created to solve any particular problem.
A component, instead, is a kind of classes that could live and be executed at at execution environment that supports the 3'C concept:
- Container - Conector - Component
A shorter example of a truly component could be the CORBA objects. Since they have formal interfaces and are executed in a common environment (the container) it is really reusable. I can create a CORBA object in C++ and use that object at a Delphi program running the CORBA execution environment.
Another example of an component is the EJB's. They are essentially classes, that are used by formal interfaces. The diference is the container and the conectors that provide the capatibility of be executed at any particular EJB container that are aligned with the EJB specification. Servlets are, by this point of view, another example of truly components.
Based on that concept, Sun sees J2EE artifatcs as components, because the 3'C architecture provide that capatibility.