Quercus:Resin module
From Resin 3.0
Contents |
jndi_lookup
Returns an object located using a jndi name, or null if no object matches the name.
$hogwarts = jndi_lookup("java:comp/env/persistence/PersistenceContext/hogwarts");
If the name begins with "java:comp/env/", then the "java:comp/env/" does not need to be included in the name.
$hogwarts = jndi_lookup("persistence/PersistenceContext/hogwarts")
mbean_explode
Explode an object name into an array. The domain is stored under the key named ":".
<?php $webappName = "resin:type=WebApp,Server=default,Host=default,name=/foo" $exploded = mbean_explode($name); var_dump($exploded); ?>
array(5) { [":"]=> string(5) "resin" ["Host"]=> string(7) "default" ["name"]=> string(4) "/foo" ["type"]=> string(6) "WebApp" ["Server"]=> string(7) "default" }
mbean_implode
Implode an array into an object name. The domain is stored under the key named ":".
<?php $array = array(":" => "resin", "Host" => "default", "name" => "/foo", "type" => "WebApp", "Server" => "default") ; $webappName = mbean_implode($array); var_dump($webappName); ?>
string(55) "resin:Host=default,Server=default,name=/foo,type=WebApp"
MBeanServer
An MBeanServer provides access to the MBean's stored on the local or a remote server.
$mbeanServer = new MBeanServer();
The Resin administration application in php/admin/ in the stabdard distribution provides many examples of using MBeanServer.
$mbeanServer->lookup()
Returns an MBean located using a jmx name, or null if no mbean matches the name.
$hogwartsApp = $mbeanServer->lookup("resin:type=WebApp,name=/hogwarts,Host=default");
If the name does not contain a `:', then it is a partial name and the lookup is done as if the name contained the fully qualified name of the current web application. For example, the following are equivalent if performed from the web-app /hogwarts:
$mbeanServer = new MBeanServer(); $foo = $mbeanServer->lookup("resin:Host=default,WebApp=/hogwarts,type=MyMBean,name=foo"); $foo = $mbeanServer->lookup("type=MyMBean,name=foo");
$mbeanServer->query()
Returns an array of MBean that match a JMX query.
<?php $mbeanServer = new MBeanServer(); $webapps = $mbeanServer->query("resin:type=WebApp,*"); foreach ($webapps as $webapp) { echo $webapp->ContextPath . " " . $webapp->RootDirectory . "\n"; } ?>
resin:type=WebApp,Host=default,name=/ resin:type=WebApp,Host=default,name=/gryffindor
MBean
$mbeanServer->lookup() and $mbeanServer->query() return MBean objects.
attributes
Attributes are accessed using php syntax.
$value = $bean->AttributeName $bean->AttributeName = $value
echo $webapp->Level; $logger->Level = "finer";
operations
Operations are performed using php syntax.
$bean->operationName() $bean->operationName(arg)
$proxyCache->clearCache(); $proxyCache->clearCacheByPattern(NULL, "^/gryffindor/.*");
mbean_name
The attribute mbean_name always returns the ObjectName for an MBean
$bean->mbean_name
echo $webapp->mbean_name => resin:type=WebApp,Host=default,name=/
mbean_info
The attribute mbean_info always returns the MBeanInfo for an MBean
$bean->mbean_name
echo $webapp->mbean_info->description => The web-app management interface
All attributes for a bean can be introspected and their values listed:
foreach ($bean->mbean_info->attributes as $attribute) { $name = $attribute->name; echo "$name = "; var_dump($bean->$name); }
xa_begin
xa_begin() throws Exception
Begin distributed transaction.
xa_commit
xa_commit() throws Exception
Commit distributed transaction.
xa_rollback
xa_rollback() throws Exception
Rollback distributed transaction.
xa_rollback_only
xa_rollback_only() throws Exception
Marks transactions as rollback only, commit is no longer possible.
xa_set_timeout
xa_set_timeout(int timeoutSeconds) throws Exception
xa_status
int xa_status() throws Exception
Returns one of XA_STATUS_NO_TRANSACTION, XA_STATUS_ACTIVE, XA_STATUS_MARKED_ROLLBACK, XA_STATUS_PREPARING, XA_STATUS_PREPARED, XA_STATUS_COMMITTING, XA_STATUS_COMMITTED, XA_STATUS_ROLLING_BACK, XA_STATUS_ROLLEDBACK, XA_STATUS_UNKNOWN.