Example usage for javax.enterprise.deploy.model DDBean getText

List of usage examples for javax.enterprise.deploy.model DDBean getText

Introduction

In this page you can find the example usage for javax.enterprise.deploy.model DDBean getText.

Prototype

public String[] getText(String xpath);

Source Link

Document

Return a list of text values for a given XPath in the deployment descriptor.

Usage

From source file:org.apache.geronimo.console.databasemanager.wizard.DatabasePoolPortlet.java

private ResourceAdapterParams loadConfigPropertiesByPath(PortletRequest request, String rarPath) {
    DeploymentManager mgr = ManagementHelper.getManagementHelper(request).getDeploymentManager();
    try {//from  ww  w  . j ava  2s.  c o m
        //URI uri = getRAR(request, rarPath).toURI();
        ConnectorDeployable deployable = new ConnectorDeployable(
                PortletManager.getRepositoryEntryBundle(request, rarPath));
        final DDBeanRoot ddBeanRoot = deployable.getDDBeanRoot();
        String adapterName = null, adapterDesc = null;
        String[] test = ddBeanRoot.getText("connector/display-name");
        if (test != null && test.length > 0) {
            adapterName = test[0];
        }
        test = ddBeanRoot.getText("connector/description");
        if (test != null && test.length > 0) {
            adapterDesc = test[0];
        }
        DDBean[] definitions = ddBeanRoot
                .getChildBean("connector/resourceadapter/outbound-resourceadapter/connection-definition");
        List<ConfigParam> configs = new ArrayList<ConfigParam>();
        if (definitions != null) {
            for (DDBean definition : definitions) {
                String iface = definition.getText("connectionfactory-interface")[0];
                if (iface.equals("javax.sql.DataSource")) {
                    DDBean[] beans = definition.getChildBean("config-property");
                    for (DDBean bean : beans) {
                        String name = bean.getText("config-property-name")[0].trim();
                        String type = bean.getText("config-property-type")[0].trim();
                        test = bean.getText("config-property-value");
                        String value = test == null || test.length == 0 ? null : test[0].trim();
                        test = bean.getText("description");
                        String desc = test == null || test.length == 0 ? null : test[0].trim();
                        configs.add(new ConfigParam(name, type, desc, value));
                    }
                }
            }
        }
        return new ResourceAdapterParams(adapterName, adapterDesc, rarPath.substring(11, rarPath.length() - 5),
                configs.toArray(new ConfigParam[configs.size()]));
    } catch (Exception e) {
        log.error("Unable to read configuration properties", e);
        return null;
    } finally {
        if (mgr != null)
            mgr.release();
    }
}