<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Caucho Technology</title>
	<atom:link href="http://blog.caucho.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.caucho.com</link>
	<description>Inside info, thoughts, and opinions from Caucho engineers</description>
	<pubDate>Sat, 04 Feb 2012 00:16:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP with CGI and FastCGI</title>
		<link>http://blog.caucho.com/2012/02/03/php-with-cgi-and-fastcgi/</link>
		<comments>http://blog.caucho.com/2012/02/03/php-with-cgi-and-fastcgi/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 00:16:33 +0000</pubDate>
		<dc:creator>Paul Cowan</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1050</guid>
		<description><![CDATA[I&#8217;ve added 2 cookbooks to the Resin 4 Wiki demonstrating Resin&#8217;s capability to execute scripts via CGI and FastCGI.
 wiki: Native PHP With CGIServlet 
 wiki: Native PHP With FastCGIServlet 
The example use PHP as the CGI executable, but they can be easily adapted to any CGI script.  
Of course Resin includes Quercus, a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve added 2 cookbooks to the <a href="http://wiki4.caucho.com">Resin 4 Wiki</a> demonstrating Resin&#8217;s capability to execute scripts via <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> and <a href="http://en.wikipedia.org/wiki/FastCGI">FastCGI</a>.</p>
<li> <a href="http://wiki4.caucho.com/Application_Server:_Native_PHP_With_CGIServlet">wiki: Native PHP With CGIServlet</a> </li>
<li> <a href="http://wiki4.caucho.com/Application_Server:_Native_PHP_With_FastCGIServlet">wiki: Native PHP With FastCGIServlet</a> </li>
<p>The example use PHP as the CGI executable, but they can be easily adapted to any CGI script.  </p>
<p><i>Of course Resin includes <a href="http://quercus.caucho.com/">Quercus, a 100% pure Java PHP interpreter</a>.  These examples demonstrate how to execute the native PHP interpreter without the need for Apache.</i></p>
<p>I also included instruction on setting up <a href="http://wordpress.org/">WordPress</a> with CGI and FastCGI.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/02/03/php-with-cgi-and-fastcgi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Resin Custom URL Rewriting</title>
		<link>http://blog.caucho.com/2012/01/25/resin-custom-url-rewriting/</link>
		<comments>http://blog.caucho.com/2012/01/25/resin-custom-url-rewriting/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 23:20:09 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1048</guid>
		<description><![CDATA[I added a new cookbook to create a custom URL rewrite rule.
wiki: Resin Application Server: Custom Rewrite Rules
Resin&#8217;s URL rewriting is similar to Apache&#8217;s mod_rewrite, using regexp matching and the CDI XML syntax for built-in rules like resin:Redirect, resin:MovedPermanently and resin:Dispatch. In addition to the build-in rules, you can create your own custom rules for [...]]]></description>
			<content:encoded><![CDATA[<p>I added a new cookbook to create a custom URL rewrite rule.</p>
<p><a href="http://wiki4.caucho.com/Resin:_Application_Server:_Custom_Rewrite_Rule">wiki: Resin Application Server: Custom Rewrite Rules</a></p>
<p>Resin&#8217;s URL rewriting is similar to Apache&#8217;s mod_rewrite, using regexp matching and the CDI XML syntax for built-in rules like resin:Redirect, resin:MovedPermanently and resin:Dispatch. In addition to the build-in rules, you can create your own custom rules for more sophisticated<br />
URL management. This wiki cookbook gives a quick example of one of those rules.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/25/resin-custom-url-rewriting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Resin Clustered Application Server Configuration</title>
		<link>http://blog.caucho.com/2012/01/19/resin-clustered-application-server-configuration/</link>
		<comments>http://blog.caucho.com/2012/01/19/resin-clustered-application-server-configuration/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 02:44:34 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1046</guid>
		<description><![CDATA[A new cookbook showing the new parameterized configuration for resin.xml. The resin.xml can now import a properties file and use the properties as EL expressions like ${http} to create clean configurations. The example shows a simple, but complete cluster of three Resin servers acting as http servers, including the health system.
wiki4: Resin Application Server: Parameterized [...]]]></description>
			<content:encoded><![CDATA[<p>A new cookbook showing the new parameterized configuration for resin.xml. The resin.xml can now import a properties file and use the properties as EL expressions like ${http} to create clean configurations. The example shows a simple, but complete cluster of three Resin servers acting as http servers, including the health system.</p>
<p><a href="http://wiki4.caucho.com/Resin:_Application_Server:_Parameterized_Web_Server_Cluster">wiki4: Resin Application Server: Parameterized Web Server Cluster</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/19/resin-clustered-application-server-configuration/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Resin Messaging: CDI and JMS configuration</title>
		<link>http://blog.caucho.com/2012/01/13/resin-messaging-cdi-and-jms-configuration/</link>
		<comments>http://blog.caucho.com/2012/01/13/resin-messaging-cdi-and-jms-configuration/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 01:53:22 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1043</guid>
		<description><![CDATA[Another cookbook at wiki4: Resin Messaging: JMS Topic Configuration with CDI and JNDI as requested by a customer.
The cookbook will be interesting if you want to see a relatively-complicated Resin CDI configuration which includes JNDI for the purpose of Spring integration, and also showing how custom facades can be combined with a standard JMS Topic [...]]]></description>
			<content:encoded><![CDATA[<p>Another cookbook at <a href="http://wiki4.caucho.com/Resin_Messaging:_JMS_Memory_Topic_Configuration_with_CDI_and_JNDI">wiki4: Resin Messaging: JMS Topic Configuration with CDI and JNDI</a> as requested by a customer.</p>
<p>The cookbook will be interesting if you want to see a relatively-complicated Resin CDI configuration which includes JNDI for the purpose of Spring integration, and also showing how custom facades can be combined with a standard JMS Topic configuration. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/13/resin-messaging-cdi-and-jms-configuration/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WebSocket and Hessian</title>
		<link>http://blog.caucho.com/2012/01/12/websocket-and-hessian/</link>
		<comments>http://blog.caucho.com/2012/01/12/websocket-and-hessian/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 02:35:34 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1041</guid>
		<description><![CDATA[I&#8217;ve added a wiki cookbook on Resin WebSockets and Hessian.
wiki4: Resin Messaging: WebSockets with Hessian
Note, that this is a binary websocket protocol, so it would be used with a custom websocket client, not a browser. Since the browsers currently prefer speaking text websockets, the equivalent would be a JSON server.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve added a wiki cookbook on Resin WebSockets and Hessian.</p>
<p><a href="http://wiki4.caucho.com/Resin_Messaging_:_WebSockets_with_Hessian">wiki4: Resin Messaging: WebSockets with Hessian</a></p>
<p>Note, that this is a binary websocket protocol, so it would be used with a custom websocket client, not a browser. Since the browsers currently prefer speaking text websockets, the equivalent would be a JSON server.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/12/websocket-and-hessian/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Resin Web Server: Using URL Write to Forbid non-SSL Requests</title>
		<link>http://blog.caucho.com/2012/01/11/resin-web-server-using-url-write-to-forbid-non-ssl-requests/</link>
		<comments>http://blog.caucho.com/2012/01/11/resin-web-server-using-url-write-to-forbid-non-ssl-requests/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 01:49:27 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1039</guid>
		<description><![CDATA[As a request from a user, I&#8217;ve written up a short wiki cookbook for Resin 4.0&#8217;s URL rewrite for a security rule to require SSL for a section of a website.
Wiki: Resin Web Server: URL Rewrite Forbidding non-SSL Requests
The example is pretty simple, since it just needs the  as the action rule, and a [...]]]></description>
			<content:encoded><![CDATA[<p>As a request from a user, I&#8217;ve written up a short wiki cookbook for Resin 4.0&#8217;s URL rewrite for a security rule to require SSL for a section of a website.</p>
<p><a href="http://wiki4.caucho.com/Resin:_Web_Server:_URL_Rewrite_Forbidding_Non-SSL_Requests">Wiki: Resin Web Server: URL Rewrite Forbidding non-SSL Requests</a></p>
<p>The example is pretty simple, since it just needs the <resin:Forbidden> as the action rule, and a single predicate, <resin:IfSecure> to test the request. Because it&#8217;s simple, it&#8217;s a good introductory example of Resin&#8217;s URL rewriting for people who haven&#8217;t looked into it yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/11/resin-web-server-using-url-write-to-forbid-non-ssl-requests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>javax.cache and CDI</title>
		<link>http://blog.caucho.com/2012/01/05/javaxcache-and-cdi/</link>
		<comments>http://blog.caucho.com/2012/01/05/javaxcache-and-cdi/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 19:24:22 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/2012/01/05/javaxcache-and-cdi/</guid>
		<description><![CDATA[I&#8217;ve written up a quick how-to for configuring a Resin jCache ClusterCache and injecting it with CDI. The application code uses standard classes and CDI annotations and uses the Resin jCache implementation.
http://wiki4.caucho.com/Resin_Java_Cache_using_CDI_Inject
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written up a quick how-to for configuring a Resin jCache ClusterCache and injecting it with CDI. The application code uses standard classes and CDI annotations and uses the Resin jCache implementation.</p>
<p><a href="http://wiki4.caucho.com/Resin_Java_Cache_using_CDI_Inject">http://wiki4.caucho.com/Resin_Java_Cache_using_CDI_Inject</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/05/javaxcache-and-cdi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hessian2Output streaming</title>
		<link>http://blog.caucho.com/2012/01/03/hessian2output-streaming/</link>
		<comments>http://blog.caucho.com/2012/01/03/hessian2output-streaming/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 01:11:31 +0000</pubDate>
		<dc:creator>ferg</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/2012/01/03/hessian2output-streaming/</guid>
		<description><![CDATA[When you&#8217;re using Hessian in a streaming environment like WebSockets, you can improve performance by saving the serialization reflection and reusing the input and output streams.
See  http://wiki4.caucho.com/Hessian_Performance_OutputStream for a short cookbook example.
]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re using Hessian in a streaming environment like WebSockets, you can improve performance by saving the serialization reflection and reusing the input and output streams.</p>
<p>See <a href="http://wiki4.caucho.com/Hessian_Performance_OutputStream"> http://wiki4.caucho.com/Hessian_Performance_OutputStream</a> for a short cookbook example.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/03/hessian2output-streaming/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introducing Resin Command Line Part 2</title>
		<link>http://blog.caucho.com/2012/01/02/introducing-resin-command-line-part-2/</link>
		<comments>http://blog.caucho.com/2012/01/02/introducing-resin-command-line-part-2/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 19:08:47 +0000</pubDate>
		<dc:creator>alex</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=882</guid>
		<description><![CDATA[Since I published Part 1 of the Resin Command Line Overview we&#8217;ve added a few more commands. The added commands allows to enable or disable a server, add a license, deploy new configuration files and generate admin password. Today I hope to cover commands I did not cover in part on and the new commands. [...]]]></description>
			<content:encoded><![CDATA[<p>Since I published Part 1 of the Resin Command Line Overview we&#8217;ve added a few more commands. The added commands allows to enable or disable a server, add a license, deploy new configuration files and generate admin password. Today I hope to cover commands I did not cover in part on and the new commands.  <span id="more-882"></span> List of new commands:</p>
<table border="1">
<thead>
<tr>
<th>Command</th>
<th>Description</th>
<th>Resin / Resin Pro</th>
</tr>
</thead>
<tbody>
<tr>
<td>start-all</td>
<td>starts all servers listening to the machine&#8217;s IP interfaces</td>
<td>Resin</td>
</tr>
<tr>
<td>license-add</td>
<td>adds a Resin-Professional license to an installation</td>
<td>Resin Pro</td>
</tr>
<tr>
<td>enable</td>
<td>enable a Resin server to receive load-balance requests</td>
<td>Resin Pro</td>
</tr>
<tr>
<td>disable</td>
<td>disables a server for load-balancing</td>
<td>Resin Pro</td>
</tr>
<tr>
<td>disable-soft</td>
<td>allows existing sessions to finish and disables the server</td>
<td>Resin Pro</td>
</tr>
<tr>
<td>generate-password</td>
<td>generates an administrator user and password</td>
<td>Resin</td>
</tr>
</tbody>
</table>
<h2>Command start-all</h2>
<p>The command simply starts all Resin servers that bind to machine&#8217;s interfaces. Before explaining in detail what this command does I have to delve into explaining new feature of Resin Pro 4.0.24. Starting version 4.0.24 Resin introduces a new configuration tag that allows to configure multiple servers at once. The tag works with resin.properties that allows specifying the list of addresses that the new servers will bind to. Using resin.properties allows to localize the changes to a single short file and makes editing configuration a bit easier compared to XML based files. The new <em>server-multi</em> tag will look as below:</p>
<pre>
<div class="codesnip-container" >&lt;cluster id="app_tier"&gt;

    &lt;!-- define the servers in the cluster --&gt;
    &lt;server-multi id-prefix="app-" address-list="${app_tier}" port="6800"/&gt;</div>
</pre>
<p>Property <em>app_tier</em> is imported from resin.properties:</p>
<pre>
<div class="codesnip-container" >app_tier      : 192.168.1.16;192.168.1.17</div>
</pre>
<p>Command start-all will examine the IPs and if they are assigned to any of the local interfaces will start appropriate server. The server names are assigned dynamically by adding an index to id-prefix of the server-multi tag. The index is derived from position of a particular IP in address-list. Such, for the two IPs defined in the example above app-0 and app-1 will be started.</p>
<div class="codesnip-container" >
<pre>bin/resin.sh help start-all
starts all servers listening to the machine's IP interfaces
where options include:
   -conf &lt;file&gt;            : select a configuration file
   -data-directory &lt;dir&gt;   : select a resin-data directory
   -join-cluster &lt;cluster&gt; : join a cluster as a dynamic server
   -log-directory &lt;dir&gt;    : select a logging directory
   -resin-home &lt;dir&gt;       : select a resin home directory
   -root-directory &lt;dir&gt;   : select a root directory
   -server &lt;id&gt;            : select a &lt;server&gt; to run
   -watchdog-port &lt;port&gt;   : override the watchdog-port
   -verbose                : print verbose starting information
   -preview                : run as a preview server
   -debug-port &lt;port&gt;      : configure a debug port
   -jmx-port &lt;port&gt;        : configure an unauthenticated jmx port</pre>
</div>
<p>Once the servers are started you can shut them down with a resin shutdown command (bin/resin.sh shutdown). Don&#8217;t forget about status command to check on status of the servers.</p>
<h2>Commands enable, disable and disable-soft</h2>
<p>When a need arises to take a server out of rotation with the load-balancer or bring the server back into rotation commands disable(-soft) or enable come into play. Resin&#8217;s Load-Balancer (configured in resin.xml with web-tier attributes) integrates with the app-tier&#8217;s dynamic capabilities. Web-tier and app-tier&#8217;s knowing of each other allow for Resin&#8217;s Cloud Elasticity (growing or shrinking). Taking a server out is can be done with either disable or disable-soft commands. Disable-soft allows server to finish sessions that it&#8217;s serving. Once the disable-soft command is issued web-tier will no longer distribute any new client&#8217;s requests to a that server. The commands take the exact same list of arguments at the moment, available with bin/resin.sh help enable|disable|disable-soft</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help enable
bin/resin.sh help enable
usage: bin/resin.sh [-conf &lt;file&gt;] -server &lt;triad-server&gt; enable -address &lt;address&gt; -port &lt;port&gt; -user &lt;user&gt; \
-password &lt;password&gt; &lt;server&gt;

description:
   enables specified in &lt;server&gt; argument server

options:
   -server &lt;triad-server&gt; : one of the servers in the triad
   -address &lt;address&gt;     : ip or host name of the server
   -port &lt;port&gt;           : server http port
   -user &lt;user&gt;           : user name used for authentication to the server
   -password &lt;password&gt;   : password used for authentication to the server</div>
</pre>
<h2>Command jmx-dump, jmx-list, jmx-set and jmx-call</h2>
<p>The set of Jmx commands helps query and execute actions on objects that are published via JMX. The easiest of the set is <em>jmx-dump</em> command. It only accepts the standart arguments and prints all registered MBeans with attributes and values. After executing the command you will see output similar to below:</p>
<pre>
<div class="codesnip-container" >resin $bin/resin.sh jmx-dump
{"create_time": "Fri Dec 02 10:24:48 PST 2011"
, "jmx": {
"JMImplementation:type=MBeanServerDelegate" : {
  "ImplementationName": "Resin-JMX",
  "ImplementationVendor": "Caucho Technology",
  "ImplementationVersion": "Resin-4.0.s111202",
  "MBeanServerId": "Resin-JMX",
  "SpecificationName": "Java Management Extensions",
  "SpecificationVendor": "Sun Microsystems",
  "SpecificationVersion": "1.4"
},
...</div>
</pre>
<p>If you&#8217;d like to query for a specific MBean or a set of MBeans you might want to use command jmx-list. This command accepts a pattern that queries only the MBeans that match the pattern. On the other hand, <em>jmx-list</em> command with *:* argument can be quite helpful when you don&#8217;t really know what you are  looking for. Piping the output to <em>grep</em> makes combing through a vast amount of data a breeze. The <em>jmx-list</em> command can also print MBeans attributes and values, and, operatons.  e.g.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh  jmx-list *:*
JMImplementation:type=MBeanServerDelegate
com.sun.management:type=HotSpotDiagnostic
java.lang:type=ClassLoading
java.lang:type=Compilation
java.lang:type=GarbageCollector,name=ConcurrentMarkSweep
java.lang:type=GarbageCollector,name=ParNew
java.lang:type=Memory
java.lang:type=MemoryManager,name=CodeCacheManager
java.lang:type=MemoryPool,name=CMS Old Gen
java.lang:type=MemoryPool,name=CMS Perm Gen
java.lang:type=MemoryPool,name=Code Cache
java.lang:type=MemoryPool,name=Par Eden Space
java.lang:type=MemoryPool,name=Par Survivor Space
java.lang:type=OperatingSystem
java.lang:type=Runtime
java.lang:type=Threading
java.util.logging:type=Logging
resin:type=AccessLog,Host=default
resin:type=BlockManager
resin:type=CacheStore
resin:type=Cluster,name=app_tier
resin:type=Cluster,name=cache_tier
resin:type=Cluster,name=web_tier
resin:type=ClusterServer,name=app-0
resin:type=ClusterServer,name=app-1
resin:type=ClusterServer,name=web-0</div>
</pre>
<p>Command&#8217;s distinct options include the following:</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help jmx-list
usage: resinctl [--options] jmx-list [&lt;pattern&gt;]

  lists the JMX MBeans in a Resin server (Resin Pro)
 ... [common-remote-command-options]
  --all                  : when &lt;pattern&gt; not specified sets the wildcard pattern (*:*)
  --attributes           : prints MBean's attributes
  --operations           : prints operations
  --platform             : when &lt;pattern&gt; not specified sets the pattern to (java.lang:*)
  --values               : prints attribute values</div>
</pre>
<div class="codesnip-container" ></div>
<p> Command <em>jmx-set</em> allows to change a value of a MBean attribute at run time. So the command options will include pattern, attribute and value. If the pattern matches multiple beans it will not perform updating of an attribute.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help jmx-set
usage: resinctl [--options] jmx-set value

  sets a JMX value for a server MBean (Resin Pro)

where options include:
 ... [common-remote-command-options]
  --attribute  : name of the attribute
  --pattern    : pattern to match MBean, adheres to the rules defined for javax.managment.ObjectName e.g. qa:type=Foo</div>
</pre>
<div class="codesnip-container" ></div>
<p> The command will perform necessary conversions converting attribute from String to type of the attribute.  Command <em>jmx-call</em> invokes MBean&#8217;s operation. Similarly to jmx-set, the command accepts a pattern that must uniquely identify MBean, operation name and a list of values that will be passed to the operation as parameters.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help jmx-call
usage: resinctl [--options] jmx-call value...

  calls a JMX operation on a server MBean (Resin Pro)

where options include:
 ... [common-remote-command-options]
  --operation &lt;operation&gt; : operation to invoke
  --pattern &lt;pattern&gt;     : pattern to match MBean</div>
</pre>
<p>Example of using <em>jmx-call</em> command to obtain a heap-dump</p>
<pre>
<div class="codesnip-container" >bin/resin.sh jmx-call -pattern com.sun.management:type=HotSpotDiagnostic -operation dumpHeap /tmp/heap.hprof true
method `dumpHeap(java.lang.String, boolean)' called on `com.sun.management:type=HotSpotDiagnostic' returned `null'.</div>
</pre>
<p>After the method completes you can view the heap dump with jvisualvm</p>
<pre>
<div class="codesnip-container" >jvisualvm --openfile /tmp/heap.hprof</div>
</pre>
<h2>Command pdf-report</h2>
<p>This command can be very instrumental in collecting various information from JVM and Resin into one document. I&#8217;ve uploaded a sample file for you to download and examine. The report is truly more then one can cover in one blog post, but here is a short list of info that it provides.</p>
<li>Report identifying information, when taken etc.</li>
<li>OS and process information</li>
<li>JVM information (version, build)</li>
<li>Resin information</li>
<li>Graphs for Requests, Netstats, CPU and Memory usage, Thread count, GC times, Database stats</li>
<li>Classloader heap dump(for debugging perm-gen issues)</li>
<li>Heap Dump Summary</li>
<li>Thread Dump</li>
<li>CPU Profile</li>
<li>JMX Snapshot</li>
<p>The command writes the pdf report into Resin&#8217;s log directory.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help pdf-report
usage: resinctl [--options] pdf-report

  creates a PDF report of a Resin server (Resin Pro)

where options include:
  --address &lt;ip&gt;          : IP address or host name of (triad) server
  --conf &lt;file&gt;           : alternate resin.xml file
  --logdir &lt;dir&gt;          : PDF output directory (default to resin log)
  --password &lt;password&gt;   : admin password for authentication
  --path &lt;file&gt;           : path to a PDF-generating .php file
  --period &lt;time&gt;         : specifies look-back period of time (default 7D)
  --port &lt;port&gt;           : IP port of (triad) server
  --profile-sample &lt;time&gt; : specifies profiling sampling frequency (100ms)
  --profile-time &lt;time&gt;   : turns code profiling on for a time before generating report
  --report &lt;value&gt;        : specifies the report-type key (default Snapshot)
  --resin-home &lt;dir&gt;      : alternate resin home
  --server &lt;id&gt;           : id of a server in the config file
  --snapshot              : saves heap-dump, thread-dump, jmx-dump before generating report
  --user &lt;user&gt;           : admin user name for authentication</div>
</pre>
<p>You can take a look at the report produced with the following command:</p>
<pre>
<div class="codesnip-container" >bin/resin.sh -server app-0 pdf-report -snapshot -report blog-sample -profile-time 30s -period 30m</div>
</pre>
<p>You can open the report for viewing by clicking on a link: <a href="http://blog.caucho.com/wp-content/uploads/2011/12/app-0-blog-sample-20111202t1339.pdf">Resin PDF Report</a>.</p>
<h2>Command generate-password</h2>
<p>This command allows to quickly generate password for inserting into a resin.properties file or admin-users.xml file.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh generate-password -user admin -password secret
admin_user : admin
admin_password : {SSHA}EsmhniwTx1zi5oSAn5etMsq7sFROhSmV</div>
</pre>
<h2>Command license-add</h2>
<p>This command deploys a license to resin server and restarts the server if -restart option is specified.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help license-add
usage: bin/resin.sh [-conf &lt;file&gt;] license-add -license &lt;license file&gt; [-to &lt;filename&gt;] [-overwrite] [-restart]

description:
   copies a license file to the appropriate license directory

options:
    ... [common-remote-command-options]
   -license &lt;license file&gt; : path to license file to add (required)
   -to &lt;filename&gt;          : file name license will be written to (defaults to name of license file)
   -overwrite              : overwrite existing license file if exists
   -restart                : restart Resin after license is added</div>
</pre>
<h2>Command log-level</h2>
<p>Command <em>log-level</em> is used to change the logging level at runtime. The logging level can be set to return to previous value automatically, after specified period of time.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help log-level
usage: resinctl [--options] log-level loggers...

  sets the java.util.logging level for debugging (Resin Pro)

where options include:
  --active-time &lt;time&gt;   : specifies temporary level active time (default permanent). e.g. 5s
  --address &lt;ip&gt;         : IP address or host name of (triad) server
  --all                  : all logs (rare to use)
  --conf &lt;file&gt;          : alternate resin.xml file
  --config               : configuration debugging logs
  --fine                 : finer debugging logs (admin/user-level)
  --finer                : finer debugging logs (developer-level)
  --finest               : finest debugging log
  --info                 : default logging level
  --off                  : disable logging
  --password &lt;password&gt;  : admin password for authentication
  --port &lt;port&gt;          : IP port of (triad) server
  --resin-home &lt;dir&gt;     : alternate resin home
  --server &lt;id&gt;          : id of a server in the config file
  --severe               : severe, typically fatal warnings
  --user &lt;user&gt;          : admin user name for authentication
  --warning              : non-fatal warnings

e.g.
bin/resin.sh log-level -finer com.caucho.server.session
Logger 'com.caucho.server.session' level is set to 'FINER'</div>
</pre>
<p>Be cautious setting a log level to finer logging permanently, as it may cause the logs to fill up the disk space very quickly! Especially on servers under load. Set -active-time option to make sure you don&#8217;t forget to reset logging level.</p>
<h2>Commands user-add, user-list and user-remove</h2>
<p>The commands help with Resin administration. The users managed by these commands are Resin administrators. This is not a facility that you can use to add users to your particular application.</p>
<pre>
<div class="codesnip-container" >bin/resin.sh help user-add
usage: bin/resin.sh [-conf &lt;file&gt;] user-add -user &lt;user&gt; -password &lt;password&gt; -u &lt;new user name&gt; [-p &lt;new user password&gt;]

description:
   adds an administrative user

options:
   -address &lt;address&gt;      : ip or host name of the server
   -port &lt;port&gt;            : server http port
   -user &lt;user&gt;            : specifies name to use for authorising the request.
   -password &lt;password&gt;    : specifies password to use for authorising the request.
   -u &lt;new user name&gt;      : specifies name for a new user.
   -p &lt;new user password&gt;  : specifies password for a new user.</div>
</pre>
<div class="codesnip-container" ></div>
<p> E.g. adding a foo user identified by &#8217;secret&#8217; password</p>
<pre>
<div class="codesnip-container" >$bin/resin.sh user-add -u foo -p secret
user `foo' added</div>
</pre>
<p>E.g. listing users</p>
<pre>
<div class="codesnip-container" >resin-pro-4.0.24 $bin/resin.sh user-list
foo</div>
</pre>
<p>E.g. removing a user:</p>
<pre>
<div class="codesnip-container" >resin-pro-4.0.24 $bin/resin.sh user-remove foo
user `foo' deleted
resin-pro-4.0.24 $</div>
</pre>
<p>Resin 4.0.25 will introduce new commands and we hope that the upcoming release finishes changes to CLI and at that point the CLI can be called &#8217;stable&#8217;. </p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2012/01/02/introducing-resin-command-line-part-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simplifying Resin XML With Dynamic Configuration - Part 2</title>
		<link>http://blog.caucho.com/2011/12/30/simplifying-resin-xml-with-dynamic-configuration-part-2/</link>
		<comments>http://blog.caucho.com/2011/12/30/simplifying-resin-xml-with-dynamic-configuration-part-2/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 15:32:45 +0000</pubDate>
		<dc:creator>Paul Cowan</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[=~]]></category>

		<category><![CDATA[configuration]]></category>

		<category><![CDATA[jmx]]></category>

		<category><![CDATA[jndi]]></category>

		<category><![CDATA[mbean]]></category>

		<category><![CDATA[regex]]></category>

		<category><![CDATA[resin:choose]]></category>

		<category><![CDATA[resin:if]]></category>

		<category><![CDATA[resin:when]]></category>

		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.caucho.com/?p=1014</guid>
		<description><![CDATA[Conditional Configuration Using Functions and Expressions
This second part of a multi-part article on Resin configuration examines how to employ conditional XML statements and EL functions to simplify Resin configuration.  When we&#8217;re done, you&#8217;ll understand how the same configuration could be shared between deployment environments with entirely different Resin operation by using some following concepts:


Null [...]]]></description>
			<content:encoded><![CDATA[<h3>Conditional Configuration Using Functions and Expressions</h3>
<p>This second part of a multi-part article on Resin configuration examines how to employ conditional XML statements and EL functions to simplify Resin configuration.  When we&#8217;re done, you&#8217;ll understand how the same configuration could be shared between deployment environments with entirely different Resin operation by using some following concepts:</p>
<ul>
<li>Conditional XML with &lt;resin:if>, &lt;resin:when>, &lt;resin:choose>, &lt;resin:otherwise></li>
<li>Null checking with “the Elvis Operator” ?:</li>
<li>Regular expression matching with =~</li>
<li>Resource access with mbean() and jndi()</li>
</ul>
<p><span id="more-1014"></span></p>
<h3>Background</h3>
<p>The <a href="http://wiki.caucho.com/Simplifying_Resin_XML_With_Dynamic_Configuration_Part_1">first part</a> of this series of articles began with background on the standard Resin configuration, the differences between server configuration and application configuration, and the usage of a registry to tie these two together.  It then presented the problem of maintaining configuration across deployment environments, and discussed specific functionality Resin provides to alleviate this problem.  The remainder of the article went into more detail on how to use file imports and variable substitution in Resin configuration.</p>
<p>In addition to variable substitution and imports, there are a number of other means an admin can employ to design more powerful and simple Resin configuration.  Resin supports a variety of classic conditional programming statements such as if-else, when, and not.  As introduced in Part 1, the basis of dynamic configuration is <a href="http://java.sun.com/products/jsp/reference/techart/unifiedEL.html">Unified Express Language</a> (EL).  However Resin goes beyond standard EL by providing a few custom functions and operators specifically designed for usage in Resin configuration.  This part of the series will examine Resin configuration conditionals in combination with configuration appropriate EL operators and functions.</p>
<h3>&lt;resin:if> Conditional Configuration</h3>
<p>&lt;resin:if> executes part of the configuration file conditionally. Along with &lt;resin:choose>, which is discussed next, these elements are the basis for Resin conditional configuration.  &lt;resin:if> can be particularly powerful in combination with the special functions we&#8217;ll look at below.  </p>
<p>Probably the most common example of conditional configuration with &lt;resin:if> is checking for java command-line properties like -Ddev=true, to enable development mode debugging or elevated logging.  &lt;resin:if> takes 1 parameter, “test”, an EL expression that must evaluate to a Boolean result of true or false.</p>
<div class="codesnip-container" >
<pre>
&lt;resin:if test="${dev}">
  &lt;logger name="com.foo" level="finer"/>
&lt;/resin:if>
</pre>
</div>
<p>This example uses EL variables substitution and system properties to increase the logging level for a specific package.  Usage of EL variable substitution was described in details in <a href="http://wiki.caucho.com/Simplifying_Resin_XML_With_Dynamic_Configuration_Part_1">Part 1</a> of the article. Also, refer to the Resin documentation on <a href="http://caucho.com/resin-4.0/admin/config-el.xtp">EL Variables and Functions</a> for more information.</p>
<p>You may notice that the configuration files packaged with the Resin distribution use &lt;resin:if> frequently in combination with ${resin.professional} to conditionally execute configuration that requires a license.  In general, the skipped configuration can be executed safely in Resin Open-Source but will result in license warnings in the logs.</p>
<p>There is no &lt;resin:else>.  For anything more complex that a simple if condition, use the &lt;resin:choose> conditional which is discussed next.</p>
<h3>&lt;resin:choose> Conditional Configuration</h3>
<p>&lt;resin:choose> executes parts of a configuration file conditionally.  In combination with &lt;resin:when> and &lt;resin:otherwise>, it implements a traditional if, else-if, and else structure.  </p>
<p>&lt;resin:choose> itself takes no parameters.  It only serves as a container for one or more &lt;resin:when> statements.  &lt;resin:when> executes a section of configuration when the test condition evaluates to Boolean true.  Only the statements following the first condition that is found to be true will be executed. All other &lt;resin:when> blocks will be skipped.  If none of the &lt;resin:when> conditions match, the catch-all &lt;resin:otherwise> will be executed if present.</p>
<p>Expanding on the example above, we can change –Ddev=true to –Denv=dev, and then match on the value of env, as show here:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:choose>
  &lt;resin:when test="${env=='dev'}">
    &lt;logger name="com.foo" level="finer"/>
  &lt;/resin:when>
  &lt;resin:when test="${env=='qa'}">
    &lt;logger name="com.foo" level="info"/>
  &lt;/resin:when>
  &lt;resin:otherwise>
    &lt;logger name="com.foo" level="warning"/>
  &lt;/resin:otherwise>
&lt;/resin:choose>
</pre>
</div>
<h3>&lt;resin:message> Configuration Logging</h3>
<p>Working with these more complex conditionals naturally elicits the question of how to test and debug.  This is where &lt;resin:message> proves useful.  &lt;resin:message> simply logs a message to the Resin log file.  The content of the XML element is the logged message, which can include evaluation of EL expressions.  This provides the ability to log helpful information describing configuration processing as it is occurring.  </p>
<p>Consider the following log level example from above, now with &lt;resin:message> statements inserted that describe how logging is being configured:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:choose>
  &lt;resin:when test="${env=='dev'}">
    &lt;logger name="com.foo" level="finer"/>
    &lt;resin:message>com.foo logging set to finer...&lt;/resin:message>
  &lt;/resin:when>
  &lt;resin:when test="${env=='qa'}">
    &lt;logger name="com.foo" level="info"/>
    &lt;resin:message> com.foo logging set to info...&lt;/resin:message>
  &lt;/resin:when>
  &lt;resin:otherwise>
    &lt;logger name="com.foo" level="warning"/>
    &lt;resin:message> com.foo logging set to warning...&lt;/resin:message>
  &lt;/resin:otherwise>
&lt;/resin:choose>
</pre>
</div>
<h3>&lt;resin:set> Variable Declaration</h3>
<p>&lt;resin:set> adds an EL variable to the EL or JNDI context.  We&#8217;ll discuss working with JNDI at the end of the article, and focus now only on setting an EL variable.  This element is useful anywhere declaring a value for later use is appropriate.  Usually this is only necessary in more complex situations where you need to indicate some processing occurred earlier in the configuration.</p>
<p>Continuing with the logging example, here it is modified to take advantage of &lt;resin:set>:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:choose>
  &lt;resin:when test="${env=='dev'}">
    &lt;resin:set var="level" value="finer"/>
  &lt;/resin:when>
  &lt;resin:when test="${env=='qa'}">
    &lt;resin:set var="level" value="finer"/>
  &lt;/resin:when>
  &lt;resin:otherwise>
    &lt;resin:set var="level" value="finer"/>
  &lt;/resin:otherwise>
&lt;/resin:choose>

&lt;logger name="com.foo" level="${level}"/>
&lt;resin:message>com.foo logging set to ${level}...&lt;/resin:message>
</pre>
</div>
<h3>?: Null Checking</h3>
<p>Recent versions of Resin include the so-called Elvis Operator (?:) as a convenient means to check for null in EL.  This is just a shortcut ternary operator that return an alternative value if the condition is null.  Resin includes full support for all the other <a href="http://docs.oracle.com/javaee/6/tutorial/doc/bnaik.html">Unified Expression Language operators</a> as well.</p>
<p>?: is used frequently in the Resin distribution configuration in combination with &lt;resin:properties> to provide a default value in case a property value is not set.  It works particularly well for configuration, as illustrated in the following example.  Here, we&#8217;re starting Resin with the logging level set as system property (-Dfoo_level=info), and defaulting to “finer” level just in case Resin is started without the parameter:</p>
<div class="codesnip-container" >
<pre>
&lt;logger name="com.foo" level="${foo_level?:'finer'}"/>
</pre>
</div>
<p>Notice in the example above, &#8216;finer&#8217; is enclosed in single quotes.  This is necessary for EL to interpret the value as a string literal!  Without the single quotes, the token “finer” will be interpreted as an EL variable, consequently assigning a null value for the unassigned variable with no warning!</p>
<h3>=~ Regular Expression Matching</h3>
<p>=~ is another powerful Resin extension to Unified EL.  This operator permits inline regular expression matching.  It should be a familiar to any Perl programmer. The following example demonstrates how to log a warning if Resin is being executed from any directory containing the string &#8216;tmp&#8217;.</p>
<div class="codesnip-container" >
<pre>
&lt;resin:if test="${resin.root =~ 'tmp'}">
  &lt;resin:message>
    WARNING: Resin is running from a temp directory: ${resin.root}
  &lt;/resin:message>
&lt;/resin:if>
</pre>
</div>
<p>Regular expression matching works particularly well with the health checking system, in combination with the mbean function discussed next.  Consider the following example, which sends an email upon startup if Java&#8217;s bootclasspath does not contain a required jar.</p>
<div class="codesnip-container" >
<pre>
&lt;health:SendMail>
  &lt;to>admin@yourdomain.com&lt;/to>
  &lt;health:Not>
    &lt;health:IfExpr
     test="${mbean('java.lang:type=Runtime').BootClassPath =~ 'resource-16.jar'}"/>
  &lt;/health:Not>
&lt;/health:SendMail>
</pre>
</div>
<p>By convention, the snippet above should be placed in health.xml rather than resin.xml.  Much more information on health checking configuration is available in the Resin <a href="http://caucho.com/resin-4.0/admin/health-checking.xtp">health checking documentation</a>.</p>
<h3>mbean() JMX Access</h3>
<p>The mbean() configuration utility function that provides access to any JMX MBean to retrieve attribute values.  This can be extremely powerful and convenient, since often information in available in JMX that in not available elsewhere, as part of the system or environment properties.  </p>
<p>Consider the following example that sets the thread pool max to a multiple of 2048 based on the number of available processors.  An elvis operator is also used in case the MBean attribute is not available:</p>
<div class="codesnip-container" >
<pre>
&lt;server-default>
  ...
  &lt;thread-max>
    ${(mbean('java.lang:type=OperatingSystem').AvailableProcessors ?: 1) * 2048}
  &lt;/thread-max>
</pre>
</div>
<h3>class_exists() Class Availability Checking</h3>
<p>The class_exists function is another handy utility that lets you conditionally execute configuration based on the availability of a Java class.  It simply does a “Class.forName” and returns a Boolean result.  You can see this used in the Resin distribution file cluster-default.xml, to load jsse-ssl HTTPS support only if JSSE libraries are available:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:if test="${class_exists('sun.security.x509.CertAndKeyGen')}">
  &lt;http address="*" port="443">
    &lt;jsse-ssl self-signed-certificate-name="resin@localhost"/>
  &lt;/http>
&lt;/resin:if>
</pre>
</div>
<p>In this example, CertAndKeyGen is a class known to exist in the JSSE library, thus if it&#8217;s found we can be fairly certain the entire JSSE jar is in the classpath.  Another common use-case is loading database resources on a backend server only if the JDBC driver is available.  This makes it possible to share configuration between frontend and backend server, simply by not including the database driver library on the front-end server.</p>
<div class="codesnip-container" >
<pre>
&lt;resin:if test="${class_exists('com.mysql.jdbc.Driver')}">
  &lt;resin:message>Configuring MySQL database resources...&lt;/resin:message>
  &lt;database jndi-name="jdbc/mysql">
    &lt;driver type="com.mysql.jdbc.Driver">
      &lt;url>jdbc:mysql://user:password@192.168.1.1:3306/dbname&lt;/url>
    &lt;/driver>
  &lt;/database>
&lt;/resin:if>
</pre>
</div>
<h3>jndi() JNDI Registry Lookup</h3>
<p>Any object or value registered in a JNDI context can be accessed using the jndi function.  It takes the JNDI name/URL as a parameter.  Note, all JNDI access in Resin is assumed to be from the parent context of “java:comp/env/” unless the full URL is specified.  So “jdbc/mysql” is simply shorthand for “java:comp/env/jdbc/mysql”.</p>
<p>The value returned by this function is the actual object bound in the registry, so you can even execute functions on it if necessary.  Consider the following resin-web.xml example that uses much of what we have already discussed in the article, to conditionally register a servlet filter if the URL of the database is not on the local machine.  The object retrieved from JNDI is a database pool registered in the server configuration:</p>
<div class="codesnip-container" >
<pre>
&lt;web-app xmlns="http://caucho.com/ns/resin"
        xmlns:ee="urn:java:ee"
        xmlns:resin="urn:java:com.caucho.resin">

  &lt;resin:if test="${!(jndi('jdbc/mysql').URL =~ '127.0.0.1|localhost')}">
    &lt;filter>
      &lt;filter-name>db_security&lt;/filter-name>
      &lt;filter-class>test.MyDbSecurity&lt;/filter-class>
    &lt;/filter>
    &lt;filter-mapping>
      &lt;filter-name>db_security&lt;/filter-name>
      &lt;url-pattern>/*&lt;/url-pattern>
    &lt;/filter-mapping>
  &lt;/resin:if>

&lt;/web-app>
</pre>
</div>
<p>Note: you may notice in Resin documentation that functions named “jndi_lookup” and “jndi:lookup” are mentioned.  These are just aliases for the same function discussed here.</p>
<p>The &lt;resin:set> section earlier in the article mentioned support for JNDI.  To supplement the var attribute, &lt;resin:set> also has a “jndi-name” attribute.  This provides the convenient ability to bind EL variables in JNDI.  The following example demonstrates a slick way to provide the number of CPUs as a JNDI variable:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:set jndi-name="os/cpuCount"
  value="${mbean('java.lang:type=OperatingSystem').AvailableProcessors}"/>
</pre>
</div>
<p>As another example, we could use &lt;resin:set> and jndi() rebind a JNDI resource to a different name:</p>
<div class="codesnip-container" >
<pre>
&lt;resin:set jndi-name="jdbc/mysql" value="${jndi('jdbc/wiki')}"/>
</pre>
</div>
<h3>Conclusion</h3>
<p>Resin provides conditional XML elements and handy utility functions to allow admins to design simple and powerful configuration.  The first part of this series of articles examined how to use EL variable substitution imports.  This part expanded on that concept by providing examples on conditional configuration with function. Maintaining configuration across deployment environments can be a cumbersome and error-prone without the proper tools.  Hopefully after reading to this point you have a better understanding of the tools Resin provides to simply configuration and make job easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caucho.com/2011/12/30/simplifying-resin-xml-with-dynamic-configuration-part-2/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

