The Kosmos server component is a loosely coupled network of collaborating POJOs, wired together via the powerful Spring IoC container.
Obviously, the most important POJOs are the services themselves.
As the monitored resources and their interfaces vary a lot,
there is no uniform way for the concrete services to access them.
Services use various techniques to get the information requested,
ranging from simple web crawling to using remote APIs. The actual
techniques are documented in the javadocs of the appropriate
XxxServiceImpl
implementation classes.
The common features of the services are factored out to
the AbstractKosmosService
class. This where
the initialization and static content storage gets done. You should start
learning the server component code by studying the javadocs of this
class. Also, to understand the static store mechanism, please
take a look at the StaticContentStore
interface,
and WebdavStaticContentStore
as a sample
implementation.
The service methods themselves are intercepted by a fairly simple AOP interceptor that stores service method results in an EHCache-based cache, keyed by the service method invocation arguments. If the same service method is invoked again with the same arguments, the interceptor tries to look up the return value in the cache first. It delegates to the service POJO only in case of cache miss. All this is completely transparent for the service POJOs.
There is another useful, infrastructure layer mechanism to achieve
performance improvement: scheduled updates. Configuring the update trigger
in kosmos-services-servlet.xml
, you can schedule
automatic service reloads at given periods or times. For example,
you can schedule a very expensive Subversion repository traversal
at 2 o'clock in the morning every day, so the portal will reflect
up-to-date results by the time you get to your browser.
Scheduling is done using the powerful Quartz library and gives you extreme
flexibility.
From the server to the portlets, the data is transferred simply
by instantiating the POJO classes in the
hu.midori.kosmos.model
package and sending them over
the wire using Hessian.
Again, all this is very simple and lightweight.