Package org.apache.avalon.framework.service

Examples of org.apache.avalon.framework.service.ServiceManager


            String serviceManagerComponentName = (String) fallbackServiceManagerList.get(i);
            serviceManagerComponent = this.getLocalServiceComponent(serviceManagerComponentName);

            if(serviceManagerComponent != null)
            {
                ServiceManager currServiceManager = (ServiceManager) serviceManagerComponent.getInstance();

                if (currServiceManager.hasService(name))
                {
                    result = currServiceManager.lookup(name);

                    if((result != null) && this.getLogger().isDebugEnabled())
                    {
                        String msg = "Located the service '" + name + "' using the fallback service manager '" + serviceManagerComponentName + "'";
                        this.getLogger().debug(msg);
View Full Code Here


            String serviceManagerComponentName = (String) fallbackServiceManagerList.get(i);
            serviceManagerComponent = this.getLocalServiceComponent(serviceManagerComponentName);

            if(serviceManagerComponent != null)
            {
                ServiceManager currServiceManager;

                try
                {
                    currServiceManager = (ServiceManager) serviceManagerComponent.getInstance();
                    if (currServiceManager.hasService(name))
                    {
                        return true;
                    }
                }
                catch (Exception e)
View Full Code Here

     * @return The application object.
     * @throws Exception If the application can't be found.
     */
    protected Application getApplication(final String appName)
    throws Exception {
        final ServiceManager current = (ServiceManager)
                   this.context.get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
        Object o = current.lookup(Application.class.getName() + '/' + appName);
        if ( o == null ) {
            throw new ConfigurationException(
                           "Application '" + appName + "' not found."
                       );
        }
        // to avoid messy release stuff later on, we just release the app now
        // as an application is thread safe this isn't really a problem
        current.release(o);
        return (Application)o;
    }
View Full Code Here

        if (pageLocal == null) {
            pageLocal = new PageLocalScopeHolder(getTopLevelScope(this));
        }
       
        // The call context will use the current sitemap's service manager when looking up components
        ServiceManager sitemapManager;
        try {
            sitemapManager = (ServiceManager)avalonContext.get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
        } catch (ContextException e) {
            throw new CascadingRuntimeException("Cannot get sitemap service manager", e);
        }
View Full Code Here

            DocumentFragment domTemplate = null;

            String src = DomHelper.getAttribute(bindingElm, "src", null);
            if (src != null) {
                ServiceManager manager = assistant.getServiceManager();
                SourceResolver sourceResolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
                Source source = null;
                try {
                    source = sourceResolver.resolveURI(src);
                    Document document = SourceUtil.toDOM(source);
                    Element element = document.getDocumentElement();

                    String xpath = DomHelper.getAttribute(bindingElm, "xpath", null);
                    if (xpath != null) {
                        XPathProcessor xpathProcessor = (XPathProcessor) manager.lookup(XPathProcessor.ROLE);
                        try {
                            Node node = xpathProcessor.selectSingleNode(document, xpath);
                            if (node == null) {
                                throw new BindingException("XPath expression '" + xpath + "' didn't return a result.",
                                                           DomHelper.getLocationObject(bindingElm));
                            }
                            if (!(node instanceof Element)) {
                                throw new BindingException("XPath expression '" + xpath + "' did not return an element node.",
                                                           DomHelper.getLocationObject(bindingElm));
                            }
                            element = (Element) node;
                        } finally {
                            manager.release(xpathProcessor);
                        }
                    }
                    domTemplate = document.createDocumentFragment();
                    domTemplate.appendChild(element);
                } finally {
                    if (source != null) {
                        sourceResolver.release(source);
                    }
                    manager.release(sourceResolver);
                }
            } else if (bindingElm.hasChildNodes()) {
                // FIXME: using the binding's document prevents it to be garbage collected.
                //        --> create a new Document and use doc.importNode();
                domTemplate = bindingElm.getOwnerDocument().createDocumentFragment();
View Full Code Here

            //TODO: LG, I do not see a good way to do this.
            if (BooleanUtils.isTrue(this.xmlize)) {
                if (val instanceof Node || val instanceof Node[] || val instanceof XMLizable)
                    Invoker.executeNode(consumer, val, stripRoot);
                else {
                    ServiceManager serviceManager = executionContext.getServiceManager();
                    SAXParser parser = null;
                    try {
                        parser = (SAXParser) serviceManager.lookup(SAXParser.ROLE);
                        InputSource source = new InputSource(new ByteArrayInputStream(val.toString().getBytes()));
                        IncludeXMLConsumer includeConsumer = new IncludeXMLConsumer(consumer);
                        includeConsumer.setIgnoreRootElement(stripRoot);
                        parser.parse(source, includeConsumer);
                    } finally {
                        serviceManager.release(parser);
                    }
                }
            } else
                Invoker.executeNode(consumer, val, stripRoot);
        } catch (Exception e) {
View Full Code Here

     * Standard matcher initialization.
     * Overriding classes must do a <CODE>super.init()</CODE>.
     */
    public void init() throws MessagingException {
        super.init();
        ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        try {
            mailServer = (MailServer) compMgr.lookup(MailServer.ROLE);
        } catch (ServiceException e) {
            log("Exception in getting the MailServer: " + e.getMessage() + e.getKey());
        }
        try {
            localusers = (UsersRepository) compMgr.lookup(UsersRepository.ROLE);
        } catch (ServiceException e) {
            log("Exception in getting the UsersStore: " + e.getMessage() + e.getKey());
        }
    }
View Full Code Here

    /**
     * Fetch the repository of users
     */
    protected void initUsersRepository() throws Exception {
        ServiceManager compMgr = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        UsersStore usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
        String repName = getInitParameter("repositoryName");

        usersRepository = usersStore.getRepository(repName);
        if (usersRepository == null) throw new Exception("Invalid user repository: " + repName);
    }
View Full Code Here

            }
            authUser = getInitParameter("gatewayusername");
            authPass = getInitParameter("gatewayPassword");
        }

        ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        String outgoingPath = getInitParameter("outgoing");
        if (outgoingPath == null) {
            outgoingPath = "file:///../var/mail/outgoing";
        }

        try {
            // Instantiate the a MailRepository for outgoing mails
            Store mailstore = (Store) compMgr.lookup(Store.ROLE);

            DefaultConfiguration spoolConf
                = new DefaultConfiguration("repository", "generated:RemoteDelivery.java");
            spoolConf.setAttribute("destinationURL", outgoingPath);
            spoolConf.setAttribute("type", "SPOOL");
View Full Code Here

    /**
     * Fetch the repository of users
     */
    protected void initUsersRepository() {
        ServiceManager compMgr = (ServiceManager) getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        try {
            UsersStore usersStore = (UsersStore) compMgr.lookup(UsersStore.ROLE);
            String repName = getInitParameter("repositoryName");

            usersRepository = usersStore.getRepository(repName);
        } catch (Exception e) {
            log("Failed to retrieve Store component:" + e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.service.ServiceManager

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.