Use Aspire Shell
Groovy in Aspire Shell
One of the most powerful features in Aspire Shell is the ability to parse and evaluate Groovy Expressions on the fly, just as GroovyShell does. But not only normal Groovy Expressions but also Groovy Pipelines expressions.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> 5 + 6
11
Aspire> println "hello world, this is Aspire Shell"
hello world, this is Aspire Shell |
Load components
You can load any component by just typing its configuration:
Example:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> <component name="FetchUrl" subType="default" factoryName="aspire-fetch-url" />
Aspire> <component name="ExtractText" subType="default" factoryName="aspire-extract-text" />
Aspire> |
You can also load components with multiple line configurations:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire: <postUrl>http://localhost:8983/solr/update</postUrl>
Aspire: <postXsl>config/xsl/aspireToSolr.xsl</postXsl>
Aspire: <okayResponse><![CDATA[<int name="status">0</int>]]></okayResponse>
Aspire: </component>
Aspire> |
Each component loaded can be accessed by its name:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> FetchUrl
<component name="FetchUrl" subType="default" factoryName="aspire-fetch-url"/>
Aspire> ExtractText
<component name="ExtractText" subType="default" factoryName="aspire-extract-text"/>
Aspire> PostHTTP
<component name="PostHTTP" subType="default" factoryName="aspire-post-http">
<postUrl>http://localhost:8983/solr/update</postUrl>
<postXsl>config/xsl/aspireToSolr.xsl</postXsl>
<okayResponse><int name="status">0</int></okayResponse>
</component>
Aspire> |
Create jobs in Aspire Shell
From Aspire Shell you can create your own jobs in order to process them through your own Groovy Pipelines.
Example:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> myJob = <doc>
Aspire: <fetchUrl>http://www.searchtechnologies.com</fetchUrl>
Aspire: </doc>
** localhost:50505/2013-06-04T15:42:28Z/0 **
<doc>
<fetchUrl>http://www.searchtechnologies.com</fetchUrl>
</doc>
Aspire> |
Use Groovy Pipelines
If you have already loaded some components and created a job to process, you can use groovy pipelines to process it. (For more details on groovy pipelines go to Groovy Pipelines
Example:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> myJob | FetchUrl | ExtractText
** localhost:50505/2013-06-04T19:03:29Z/0 **
<doc>
<content>
...
//CONTENT EXTRACTED
...
</content>
<extension source="FetchURLStage">
<field name="status">HTTP/1.1 200 OK</field>
<field name="Cache-Control">private</field>
<field name="Content-Length">24233</field>
<field name="Content-Type">text/html; charset=utf-8</field>
<field name="Server">Microsoft-IIS/7.5</field>
<field name="X-AspNet-Version">2.0.50727</field>
<field name="Set-Cookie">ASP.NET_SessionId=rs31fw3r23u3j42unooa5tj1; path=/; HttpOnly</field>
<field name="X-Powered-By">ASP.NET</field>
<field name="Date">Tue, 04 Jun 2013 19:21:19 GMT</field>
</extension>
<extension source="ExtractTextStage">
<field name="Content-Location">http://www.searchtechnologies.com</field>
<field name="Content-Encoding">ISO-8859-1</field>
<field name="resourceName">http://www.searchtechnologies.com</field>
<field name="google-site-verification">jP1bIfjuuyZUYfTkYc_O6ZlTHxCm07voTDcMk72Z8oQ</field>
</extension>
<title source="ExtractTextStage/title">The Enterprise Search Implementation Experts</title>
<protocol source="FetchURLStage/protocol">http</protocol>
<keywords source="ExtractTextStage/keywords">Enterprise Search, Search Engine Experts, Consulting</keywords>
<host source="FetchURLStage/host">www.searchtechnologies.com</host>
<fetchUrl>http://www.searchtechnologies.com</fetchUrl>
<description source="ExtractTextStage/description">Search Technologies is the largest IT services company dedicated to enterprise search implementation, consulting, and managed services. Our expertise covers all leading search products, and all aspects of search applications.</description>
<encoding source="FetchURLStage/encoding">utf-8</encoding>
<contentType source="ExtractTextStage/Content-Type">application/xhtml+xml</contentType>
<httpResponse code="200" source="FetchURLStage">OK</httpResponse>
<mimeType source="FetchURLStage/mimeType">text/html</mimeType>
</doc>
Aspire> |
Aspire Shell commands
Besides groovy expressions you can also use some special commands in Aspire Shell. Those commands are listed in the following table:
Command | Parameters | Description |
---|
components | none | Shows the components loaded inside the current Aspire shell application |
createJob | XML string of an AspireObject | Creates a job based on the XML string of an AspireObject. |
reload | none | Reloads all the components already loaded in the current Aspire shell application, and cleans every non saved groovy expression. |
reset | none | Removes the current Aspire shell application and load it again. Also and cleans every non saved groovy expression. |
load | <application-xml-file> | Loads the specified application into Aspire. Any previous Aspire shell application will be unloaded. Cleans up every non saved groovy expression. |
save | <application-xml-file> | Saves the current Aspire shell application as XML into the specified file. Every groovy expression will be saved as a groovy pipeline, ready to be executed. |
run | <application-xml-file> | Run the groovy expressions saved in the specified application file. Every loaded components and groovy expressions will be replaced by those in the specified application file. |
cd | <directory> | Change the working directory for the 'dir' groovy pipeline function. (For more details click here) |
pwd | none | Shows the working directory for the 'dir' groovy function. (For more details click here) |
help | none or <command-name> | Shows the help for Aspire shell. If no arguments then it shows all the available commands, if specified a command-name as argument, it shows the description for that command. |
clear | none | Clears the command buffer and discard it. Any multiple line command input will be escaped. It can be invoked by the shortcut CTRL-D |
cls | none | Clears the console output |
felix | none | Enter felix mode to execute felix commands. (No AspireShell commands will be available here) |
exit | none | If performed in felix mode, it returns to Aspire Shell mode, else exit AspireShell and then shutdown felix. |
shutdown | none | Exit AspireShell and shutdown felix. |
Command usage
components
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> components
FetchUrl com.searchtechnologies:aspire-fetch-url:2.2.2 / default
ExtractText com.searchtechnologies:aspire-extract-text:2.2.2 / default
PostHTTP com.searchtechnologies:aspire-post-http:2.2.2 / default
Aspire> |
createJob
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> myJob = createJob('<doc><url>http://www.searchtechnologies.com</url></doc>')
** 10.10.21.34:50505/2014-06-23T20:53:32Z/0 **
<doc>
<url>http://www.searchtechnologies.com</url>
</doc>
Aspire> |
You can also skip the createJob command and create a job directly (which will call the createJob method in the background):
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> myJob = <doc><url>http://www.searchtechnologies.com</url></doc>
** 10.10.21.34:50505/2014-06-23T20:53:32Z/0 **
<doc>
<url>http://www.searchtechnologies.com</url>
</doc>
Aspire> |
reload
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> reload
Aspire>
|
reset
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> reset
Aspire> |
save
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> println "hello world, this is AspireShell"
hello world, this is AspireShell
Aspire> save config/savedApp.xml
Aspire> |
Load
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> load config/savedApp.xml
Aspire> |
run
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> run config/savedApp.xml
hello world, this is AspireShell
Aspire> |
cd & pwd
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> cd config
Aspire> pwd
C:\\distributions\my-aspire\target\my-aspire-2.2.2-distribution.dir\config
Aspire> cd ..
Aspire> pwd
C:\\distributions\my-aspire\target\my-aspire-2.2.2-distribution.dir |
clear
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire: clear
Aspire> |
You can also use the clear shortcut CTRL-D
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> <component name="PostHTTP" subType="default" factoryName="aspire-post-http">
Aspire: <CTRL-D>
Aspire> |
cls
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> cls
Aspire> |
felix
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> felix
Felix> find aspire
START LEVEL 1
ID State Level Name
[ 11] [Active ] [ 1] Aspire Application (2.2.2)
Felix> exit
Aspire> |
shutdown
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
Aspire> shutdown
Aspire> Stopping bundle: 11 - file:/C:/Users/aaguilar/.m2/repository/com/searchtechnologies/aspire-application/2.2.2/aspire-application-2.2.2.jar
Stopped component factory: aspire-application (bundle 11)
AspireShell: Shutting down...
$ |
Run Applications
You can use Aspire Shell to run at startup applications you have previously saved in your filesystem:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
$ bin\aspiresh.bat config/savedApp.xml
Removing Felix-Cache and AppBundle-Cache directories
************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location : file:bundles/boot/aspire-bootloader-3.2.jar
*
Maven update policy: always
Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager): {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
hello world, this is AspireShell
Aspire> Stopping bundle: 11 - file:/C:/Users/aaguilar/.m2/repository/com/searchtechnologies/aspire-application/2.2.2/aspire-application-2.2.2.jar
Stopped component factory: aspire-application (bundle 11)
AspireShell: Shutting down...
$ |
You can add the --no-exit option to avoid AspireShell from shutting down after running the application.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
$ bin\aspiresh.bat config/savedApp.xml --no-exit
Removing Felix-Cache and AppBundle-Cache directories
************************************************************************
*
* ASPIRE BOOTLOADER
*
* Bundle id : 10
*
* Location : file:bundles/boot/aspire-bootloader-3.2.jar
*
Maven update policy: always
Settings (org.apache.felix.webconsole.internal.servlet.OsgiManager): {password=admin, manager.root=/osgi, username=admin}
Maven update policy: always
Aspire Console Mode
hello world, this is AspireShell
Aspire> |
Start Content Sources
Aspire Shell does not load the autostart section of the settings.xml file, neither load any content sources configured inside config/content-sources. To enable the autostart and content sources loading you will need to add the --load-content-sources option when starting aspiresh.bat or aspiresh.sh.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
$ bin\aspiresh.bat --load-content-sources |
Enable Aspire HTTP web server
Aspire Shell doesn't start the HTTP web server by default. To enable it you need to edit the config/felix.properties.aspiresh file, find org.osgi.service.http.port=-1 and add the port that you want (for example org.osgi.service.http.port=50505)