Chapter 27. Gadget Importer Tool
The gadget importer allows you to add gadgets to the application registry. The tool uses a WebApp folder which contains the gadgets configuration. WebApp has a standard structure that is processed by the Gadget importer.
The WebApp folder consist of
web.xml and gadget.xml configuration files.
Local gadget resources
For local gadgets the source and resources must be located in the same folder. The Gadget importer tool searches for the folder containing the gadget source followed by searching the resources in the folder. The Gadget importer tool stores the gadget resources in JCR. So, placing the gadget resources in a different folder other than the gadget source can cause many unwanted files to be stored as the resource files of the gadget.
27.1. Importing Gadgets
27.1.1. Importing Gadgets
This section explains the structure and configuration of a WebApp. WebApp is processed by the Gadget importer tool.
For more information on using user interface to import gadgets, see User guide.
27.1.2. Creating a Standard WebApp Folder to Import Gadgets
Red Hat JBoss Portal allows you to create a WebApp folder to contain the configuration of the list of gadgets which are automatically added to the Application Registry.
This section explains the structure and configuration of a WebApp. WebApp is processed by the Gadget importer.
27.1.3. Configuring the WebApp Files
The WebApp structure consists of
web.xml and gadget.xml files.
To register WebApp to RedHat JBoss Portal, add the parameter
org.gatein.wci.api.GateInServlet in web.xml file.
<web-app>
<display-name>eXoGadgets</display-name>
<servlet>
<servlet-name>GateInServlet</servlet-name>
<servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>
The
gadget.xml file locates the configuration of gadgets that are added to the Application Registry.
<gadgets
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gadgets_1_0"
xmlns="http://www.gatein.org/xml/ns/gadgets_1_0">
<gadget name="To-do">
<path>/gadgets/Todo/Todo.xml</path>
</gadget>
<gadget name="Calendar">
<path>/gadgets/Calendar/Calendar.xml</path>
</gadget>
<gadget name="Calculator">
<path>/gadgets/Calculator/Calculator.xml</path>
</gadget>
<gadget name="rssAggregator">
<path>/gadgets/rssAggregator/rssAggregator.xml</path>
</gadget>
<gadget name="Currency">
<url>http://www.donalobrien.net/apps/google/currency.xml</url>
</gadget>
<gadget name="ServicesManagement">
<path>/gadgets/ServicesManagement/ServicesManagement.xml</path>
</gadget>
</gadgets>
The
gadget.xml has three important tags, gadget,path, and url.
<gadget>: A gadget is configured in the<gadget>tag. Thenameattribute is the gadget name. The gadget name is managed by the Application Registry.<path>: This tag is the child of the<gadget>tag. It contains the path to the gadget and helps the Gadget service to find the location of the gadget source and resources. It is known as the local path of the server.<url>: This tag is configured to indicate the URL of the gadget incase the source of gadget resides on an external server.
Note
The Gadget importer searches for a folder that contains the gadget source, then finds resources in the folder and store them into JCR as the resources of the gadget. Therefore, putting the gadget resources in the folder different from the gadget source can cause unnecessary files to be stored as the resource files of the gadget.
27.2. Virtual Servers for Gadgets
27.2.1. Setting up Virtual Servers for Gadget Rendering
Red Hat JBoss Portal recommends using two virtual hosts for security. If the gadget is running on a different domain than the container (the website that contains the application), it is unable to interfere with the portal by modifying code or cookies.
An example, where the portal is hosted on
http://www.sample.com and the gadgets on http://www.samplemodules.com .
To configure virtual server for gadgets, set the
gadgets.hostName parameter value to path/to/gadgetServer in GadgetRegisteryService.
Example 27.1. Setting the value variable for the gadget hostname
<component>
<key>org.exoplatform.application.gadget.GadgetRegistryService</key>
<type>org.exoplatform.application.gadget.jcr.GadgetRegistryServiceImpl</type>
<init-params>
<value-param>
<name>gadgets.hostName</name>
<description>Gadget server url</description>
<value>http://localhost:8080/GateInGadgetServer/gadgets/</value>
</value-param>
</init-params>
</component>
Portal supports multiple rendering servers to balance the load across multiple servers.
Note
When deploying on the same server, the gadget must be initiated before handling any calls requests. For example, if the webapp
GateInGadgets uses org.exoplatform.application.gadget.GadgetRegister so the webapp must be initiated before it is called .
27.2.2. Configuring Gadget Server
The gadget container uses three security files for authenticating and authorizing gadgets.
key.txtoauthkey.pemoauthkey_pub.pem
The location of the security keys for different servers are listed below.
- JBoss:
$JBOSS_HOME/standalone/configuration/gatein/gadgets. This folder is configured by system variables in$JBOSS_HOME/standalone/configuration/gatein/configuration.properties. -
Example 27.2. Configuring Security key paths
gatein.gadgets.securitytokenkeyfile=$\{gatein.conf.dir\}/gadgets/key.txt gatein.gadgets.signingkeyfile=$\{gatein.conf.dir\}/gadgets/oauthkey.pemIf you have other files update the path variables to point to your files.
The
key.txt file consist of a secret key, which is used to encrypt the security token for user authentication. At portal startup, this file is read through the gatein.gadgets.securitytokenkeyfile path.
If the
key.txt file is not found, JBoss Portal generates a new key.txtand stores it in the gatein.gadgets.securitytokenkeyfile path.
The
oauthkey.pem and oauthkey_pub.pem are a key pair of RSA cryptography standard. oauthkey.pem is the private key and oauthkey_pub.pem is the public key. These keys are the default keys of the gadget container which is used by OAuth gadget to authorize with external service providers.
27.2.3. Configuring Gadget Proxy and Concat
The proxy and concat server must be on the same domain as the gadget server. You can configure the container in using
eXoGadgetServer:/WEB-INF/classes/containers/default/container.js .
Example 27.3. Setting proxy and concat server url
"gadgets.content-rewrite" : {
"include-urls": ".*",
"exclude-urls": "",
"include-tags": ["link", "script", "embed", "img", "style"],
"expires": "86400",
"proxy-url": "http://localhost:8080/eXoGadgetServer/gadgets/proxy?url=",
"concat-url": "http://localhost:8080/eXoGadgetServer/gadgets/concat?"
},
Add the following code to the beginning of the JVM to allow external gadgets to obtain a connection to a server behind a firewall.
-Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword
27.3. Shindig Server
27.3.1. Configuring Shindig Container
Red Hat JBoss Portal uses a custom Shindig OpenSocial container for handling gadgets. The Shindig configuration file is located at:
$JBOSS_HOME/JPP_HOME/standalone/configuration/gatein/gadgets/shindig.properties
Note
For Shindig configuration options, see the Apache Shindig documentation.
27.3.2. Configuring Shindig Container for Offline access
The default features available in the current version of shindig require online access. If the server starts without internet access, there is a minor delay of usually 1 sec at startup when the server tries to access third party services.
Due to specific server settings, the delay at startup can be longer. If you are using Red Hat JBoss Portal offline and the gadget server has long time outs during startup, you can configure the shindig server to exclude online features.
To configure shindig server in offline mode you need to modify the shindig configuration file located at,
$JBOSS_HOME/standalone/configuration/gatein/gadgets/shindig.properties
The location of feature manifest is changed from online to offline by excluding the
online-features.txt file reference.
Example 27.4. Online Mode setting
# Location of feature manifests (comma separated) shindig.features.default=res://features/default-features.txt,res://features/online-features.txt
Example 27.5. Offline Mode setting
# Location of feature manifests (comma separated) shindig.features.default=res://features/default-features.txt
Important
In offline mode the analytics is not available for the gadgets.