Now that we’ve told Projector what belongs to our application, we need to create a file called processors.xml that we’ve already referenced in our description file. This file must be created in the config folder as the name and location of the file must match the URI given in the application description.
You still don’t know exactly what a processor is in terms of the Projector framework. This will be described in more detail later as it is part of the fundamental core of Projector. Up to now we only need to know that it is some portion of logic that is doing some fine stuff and can be invoked by mapping it to an URL.We now want to use the newly created file to define such a mapping:
<?xml version="1.0" encoding="UTF-8" ?>
<processors>
<processor uri="hello"
config-uri="templates/helloWorld.tmpl"
class="org.apache.slide.projector.processor.TemplateRenderer" />
</processors>What does this entry mean in detail? The processor with the implementing Java class TemplateRenderer is registered under the URI hello. This class is part of the Projector core, so this is the reason why our application depends on the core application. It is the base class that handles the default templating mechanism that will be described in detail in the following chapter. The TemplateRenderer is configurable, so we have to associate a configuration file with this processor instance. In case of the TemplateRenderer the configuration file means the template that will be used.
So the last step in our first example is to create a new file in the templates folder that is called helloWorld.tmpl. This file contains a very simple HTML-page:
<html>
<body>
<h1>Hello world!</h1>
</body>
</html>If you have a look at the Synchronize view in Eclipse you’ll notice that our changes that have not been uploaded to the Slide server will show up. Upload all files by right-clicking on the root folder and selecting the Upload menu entry.
Now that we have made our first steps in the Projector universe we proudly want to have a look at the result. Open a web browser and enter the URL
http://localhost:8080/projector/hello
This URL assumes that you are running the Slide/Projector bundle on the same machine as your web browser and without changing the default configuration. If you are familiar with the J2EE world you might notice that projector is the name of the Projector web application itself. This can be change if you don’t like to have any hints that you are using Projector in the URL of you site.
If this is the first time that you access Projector it might take some time until the result appears as Projector starts up and launches all applications that have been deployed. Finally you will see the following:
Congratulations! You’ve managed to get your first Projector application running. The result might be slightly disappointing if we take into account that the same result could have achieved by simply dropping the HTML page into the Slide server as shown in the previous parts of this book, but – promised - soon you will see the first benefits of using Projector.