Package org.apache.geronimo.gbean

Examples of org.apache.geronimo.gbean.AbstractName


        if(managerURI != null) actionResponse.setRenderParameter(PARM_MANAGER_URI, managerURI);
        if(containerURI != null) actionResponse.setRenderParameter(PARM_CONTAINER_URI, containerURI);
        WebContainer webContainer  = null;
        String server = null;
        if(containerURI != null) {
            webContainer = PortletManager.getWebContainer(actionRequest, new AbstractName(URI.create(containerURI)));
            server = getWebServerType(webContainer.getClass());
        } else {
            server = "unknown";
        }
        actionResponse.setRenderParameter(PARM_SERVER, server);
        if(mode.equals("new")) {
            // User selected to add a new connector, need to show criteria portlet
            actionResponse.setRenderParameter(PARM_MODE, "new");
            String connectorType = actionRequest.getParameter(PARM_CONNECTOR_TYPE);
            actionResponse.setRenderParameter(PARM_CONNECTOR_TYPE, connectorType);
        } else if(mode.equals("add")) { // User just submitted the form to add a new connector
            // Create and configure the connector
            WebManager manager = PortletManager.getWebManager(actionRequest, new AbstractName(URI.create(managerURI)));
            ConnectorType connectorType = new ConnectorType(actionRequest.getParameter(PARM_CONNECTOR_TYPE));
           
            String uniqueName = actionRequest.getParameter(PARM_DISPLAY_NAME);
            actionResponse.setRenderParameter(PARM_DISPLAY_NAME, uniqueName);
            // set the connector attributes from the form post
            List<ConnectorAttribute> connectorAttributes = manager.getConnectorAttributes(connectorType);
            for (ConnectorAttribute attribute : connectorAttributes) {
                String name = attribute.getAttributeName();
                String value = actionRequest.getParameter(name);
               
                // handle booelan type special
                if (attribute.getAttributeClass().equals(Boolean.class)) {
                    // browser sends value of checked checkbox as "on" or "checked"
                    if ("on".equalsIgnoreCase(value) || "checked".equalsIgnoreCase(value)) {
                        value=Boolean.toString(true);
                    } else {
                        value=Boolean.toString(false);
                    }
                }
                // set the string form of the attribute's value as submitted by the browser
                if (value == null || value.trim().length()<1) {
                    // special case for KeystoreManager gbean
                    if ("trustStore".equals(attribute.getAttributeName())) {
                        attribute.setValue(null);
                    }
                } else {
                    attribute.setStringValue(value.trim());
                }
            }
            // create the connector gbean based on the configuration data
            AbstractName newConnectorName = manager.getConnectorConfiguration(connectorType, connectorAttributes, webContainer, uniqueName);
           
            // set the keystore properties if its a secure connector
            setKeystoreProperties(actionRequest, newConnectorName);
           
            // Start the connector
            try {
                GeronimoManagedBean managedBean = PortletManager.getManagedBean(actionRequest, newConnectorName);
                managedBean.startRecursive();
            } catch (Exception e) {
                log.error("Unable to start connector", e); //TODO: get into rendered page
            }
            actionResponse.setRenderParameter(PARM_MODE, "list");
        } else if(mode.equals("save")) { // User just submitted the form to update a connector
            // Get submitted values
            //todo: lots of validation
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            // Identify and update the connector
            AbstractName connectorName = new AbstractName(URI.create(connectorURI));
            NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, connectorName);
            if(connector != null) {
                WebManager manager = PortletManager.getWebManager(actionRequest, new AbstractName(URI.create(managerURI)));
                ConnectorType connectorType = manager.getConnectorType(connectorName);
               
                // set the connector attributes from the form post
                for (ConnectorAttribute attribute : manager.getConnectorAttributes(connectorType)) {
                    String name = attribute.getAttributeName();
                    String value = actionRequest.getParameter(name);
                   
                    // handle booelan type special
                    if (attribute.getAttributeClass().equals(Boolean.class)) {
                        // browser sends value of checked checkbox as "on" or "checked"
                        if ("on".equalsIgnoreCase(value) || "checked".equalsIgnoreCase(value)) {
                            value=Boolean.toString(true);
                        } else {
                            value=Boolean.toString(false);
                        }
                    }
                    // set the string form of the attribute's value as submitted by the browser
                    if (value == null || value.trim().length()<1) {
                        // special case for KeystoreManager gbean
                        if ("trustStore".equals(attribute.getAttributeName())) {
                            setProperty(connector,name,null);
                        }
                    } else {
                        // set the string value on the ConnectorAttribute so
                        // it can handle type conversion via getValue()
                        try {
                            attribute.setStringValue(value);
                            setProperty(connector,name,attribute.getValue());
                        } catch (Exception e) {
                            log.error("Unable to set property " + attribute.getAttributeName(), e);
                        }
                    }
                }
               
                // set the keystore properties if its a secure connector
                setKeystoreProperties(actionRequest, connectorName);
            }
            actionResponse.setRenderParameter(PARM_MODE, "list");
        } else if(mode.equals("start")) {
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            // work with the current connector to start it.
            NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
            if(connector != null) {
                try {
                    ((GeronimoManagedBean)connector).startRecursive();
                } catch (Exception e) {
                    log.error("Unable to start connector", e); //todo: get into rendered page somehow?
                }
            }
            else {
                log.error("Incorrect connector reference"); //Replace this with correct error processing
            }
            actionResponse.setRenderParameter(PARM_CONNECTOR_URI, connectorURI);
            actionResponse.setRenderParameter(PARM_MODE, "list");
        } else if(mode.equals("stop")) {
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            // work with the current connector to stop it.
            NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
            if(connector != null) {
                try {
                    ((GeronimoManagedBean)connector).stop();
                } catch (Exception e) {
                    log.error("Unable to stop connector", e); //todo: get into rendered page somehow?
                }
            }
            else {
                log.error("Incorrect connector reference"); //Replace this with correct error processing
            }
            actionResponse.setRenderParameter(PARM_CONNECTOR_URI, connectorURI);
            actionResponse.setRenderParameter(PARM_MODE, "list");
        } else if(mode.equals("restart")) {
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            // work with the current connector to restart it.
            NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
            if(connector != null) {
                try {
                    ((GeronimoManagedBean)connector).stop();
                    ((GeronimoManagedBean)connector).start();
                } catch (Exception e) {
                    log.error("Unable to restart connector", e); //todo: get into rendered page somehow?
                }
            } else {
                log.error("Incorrect connector reference"); //Replace this with correct error processing
            }
            actionResponse.setRenderParameter(PARM_CONNECTOR_URI, connectorURI);
            actionResponse.setRenderParameter(PARM_MODE, "list");
        } else if(mode.equals("edit")) {
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            actionResponse.setRenderParameter(PARM_CONNECTOR_URI, connectorURI);
            actionResponse.setRenderParameter(PARM_MODE, "edit");

        } else if(mode.equals("delete")) { // User chose to delete a connector
            String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
            PortletManager.getWebManager(actionRequest, new AbstractName(URI.create(managerURI))).removeConnector(new AbstractName(URI.create(connectorURI)));
            actionResponse.setRenderParameter(PARM_MODE, "list");
        }
    }
View Full Code Here


            String managerURI = renderRequest.getParameter(PARM_MANAGER_URI);
            String containerURI = renderRequest.getParameter(PARM_CONTAINER_URI);
            if(managerURI != null) renderRequest.setAttribute(PARM_MANAGER_URI, managerURI);
            if(containerURI != null) renderRequest.setAttribute(PARM_CONTAINER_URI, containerURI);

            WebContainer container = PortletManager.getWebContainer(renderRequest, new AbstractName(URI.create(containerURI)));
            String server = getWebServerType(container.getClass());
            renderRequest.setAttribute(PARM_SERVER, server);

            if(mode.equals("new")) {
                String connectorType = renderRequest.getParameter(PARM_CONNECTOR_TYPE);
                WebManager webManager = PortletManager.getWebManager(renderRequest, new AbstractName(URI.create(managerURI)));
                ConnectorType type = new ConnectorType(connectorType);
                List<ConnectorAttribute> connectorAttributes = webManager.getConnectorAttributes(type);
                sortConnectorAttributes(connectorAttributes);
                renderRequest.setAttribute(PARM_CONNECTOR_ATTRIBUTES, connectorAttributes);
                renderRequest.setAttribute(PARM_CONNECTOR_TYPE, connectorType);
                renderRequest.setAttribute(PARM_MODE, "add");
                populateEnumAttributes(renderRequest);
                editConnectorView.include(renderRequest, renderResponse);
            } else if(mode.equals("edit")) {
                String connectorURI = renderRequest.getParameter(PARM_CONNECTOR_URI);
                NetworkConnector connector = PortletManager.getNetworkConnector(renderRequest, new AbstractName(URI.create(connectorURI)));
                if(connector == null) {
                    doList(renderRequest, renderResponse);
                } else {
                    AbstractName connectorName = new AbstractName(URI.create(connectorURI));
                    String uniqueName = connectorName.getName().get("name").toString();
                    renderRequest.setAttribute(PARM_DISPLAY_NAME, uniqueName);
                    WebManager webManager = PortletManager.getWebManager(renderRequest, new AbstractName(URI.create(managerURI)));
                    ConnectorType connectorType = webManager.getConnectorType(connectorName);
                    List<ConnectorAttribute> connectorAttributes = webManager.getConnectorAttributes(connectorType);
                    sortConnectorAttributes(connectorAttributes);
                   
                    // populate the connector attributes from the connector
View Full Code Here

    private void doList(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
        WebManager[] managers = PortletManager.getWebManagers(renderRequest);
        List<ContainerInfo> all = new ArrayList<ContainerInfo>();
        for (int i = 0; i < managers.length; i++) {
            WebManager manager = managers[i];
            AbstractName webManagerName = PortletManager.getNameFor(renderRequest, manager);
           
            WebContainer[] containers = (WebContainer[]) manager.getContainers();
            for (int j = 0; j < containers.length; j++) {
                List<ConnectorInfo> beans = new ArrayList<ConnectorInfo>();
                WebContainer container = containers[j];
                AbstractName containerName = PortletManager.getNameFor(renderRequest, container);
                String id;
                if(containers.length == 1) {
                    id = manager.getProductName();
                } else {
                    id = manager.getProductName() + " (" + containerName.getName().get(NameFactory.J2EE_NAME) + ")";
                }
                ContainerInfo result = new ContainerInfo(id, webManagerName.toString(), containerName.toString());

                for (NetworkConnector connector : manager.getConnectorsForContainer(container)) {
                    ConnectorInfo info = new ConnectorInfo();
                    AbstractName connectorName = PortletManager.getNameFor(renderRequest, connector);
                    info.setConnectorURI(connectorName.toString());
                    info.setDescription(PortletManager.getGBeanDescription(renderRequest, connectorName));
                    info.setUniqueName((String)connectorName.getName().get(NameFactory.J2EE_NAME));
                    info.setState(((GeronimoManagedBean)connector).getState());
                    info.setPort(connector.getPort());
                    try {
                        info.setProtocol(connector.getProtocol());
                    } catch (IllegalStateException e) {
View Full Code Here

   
    // get the special keystore properties from the request and set them on the connector
    // TODO: need a more generic way to handle this
    private void setKeystoreProperties(PortletRequest request, AbstractName connectorName) throws PortletException {
        String containerURI = request.getParameter(PARM_CONTAINER_URI);
        WebContainer container = PortletManager.getWebContainer(request, new AbstractName(URI.create(containerURI)));
        String server = getWebServerType(container.getClass());
        NetworkConnector connector = PortletManager.getNetworkConnector(request, connectorName);

        // return if not a secure connector
        if (!(connector instanceof SecureConnector)) {
View Full Code Here

    public void build(XmlObject container, DeploymentContext applicationContext, DeploymentContext moduleContext) throws DeploymentException {
        GerClusteringWadiType clusteringWadiType = getWadiClusterConfig(container);
        if (clusteringWadiType != null) {
            GBeanData webModuleData = extractWebModule(moduleContext);
            try {
                AbstractName sessionManagerName = addSessionManager(clusteringWadiType, webModuleData, moduleContext);
                addSessionHandlerFactory(moduleContext, webModuleData, sessionManagerName);
                addPreHandlerFactory(moduleContext, webModuleData, sessionManagerName);
            } catch (GBeanAlreadyExistsException e) {
                throw new DeploymentException("Duplicate GBean", e);
            }
View Full Code Here

    }

    protected AbstractName addSessionManager(GerClusteringWadiType clustering,
            GBeanData webModuleData,
            DeploymentContext moduleContext) throws GBeanAlreadyExistsException {
        AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
                "WADISessionManager", NameFactory.GERONIMO_SERVICE);

        GBeanData beanData = new GBeanData(name, BasicWADISessionManager.GBEAN_INFO);

        setConfigInfo(clustering, webModuleData, beanData);
View Full Code Here

        beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY, patterns);
    }

    protected AbstractName addPreHandlerFactory(DeploymentContext moduleContext,
            GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
        AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
                "WADIClusteredPreHandlerFactory", NameFactory.GERONIMO_SERVICE);

        GBeanData beanData = new GBeanData(name, WADIClusteredPreHandlerFactory.GBEAN_INFO);
        beanData.setReferencePattern(WADIClusteredPreHandlerFactory.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName);
View Full Code Here

        return name;
    }

    protected AbstractName addSessionHandlerFactory(DeploymentContext moduleContext,
            GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
        AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
                "ClusteredSessionHandlerFactory", NameFactory.GERONIMO_SERVICE);

        GBeanData beanData = new GBeanData(name, ClusteredSessionHandlerFactory.GBEAN_INFO);
        beanData.setReferencePattern(ClusteredSessionHandlerFactory.GBEAN_REF_SESSION_MANAGER, sessionManagerName);
View Full Code Here

        return doc;
    }

    private void actionLoadExistingRealm(PortletRequest request, RealmData data) {
        SecurityRealm realm = (SecurityRealm) PortletManager.getManagedBean(request, new AbstractName(URI.create(data.getAbstractName())));
        data.name = realm.getRealmName();
        List list = new ArrayList();
        JaasLoginModuleChain node = realm.getLoginModuleChain();
        while (node != null) {
            LoginModuleDetails details = new LoginModuleDetails();
View Full Code Here

                }
            } catch (IOException e) {
                log.error("Unable to save security realm", e);
            }
        } else {
            SecurityRealm realm = (SecurityRealm) PortletManager.getManagedBean(request, new AbstractName(URI.create(data.getAbstractName())));
            // index existing modules
            Map nodes = new HashMap();
            JaasLoginModuleChain node = realm.getLoginModuleChain();
            while (node != null) {
                LoginModuleSettings module = node.getLoginModule();
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gbean.AbstractName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.