Package org.apache.avalon.framework.service

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


     * @return the created ComponentManager
     */
    public ComponentManager createComponentManager( final Object entry )
        throws Exception
    {
        final ServiceManager serviceManager = createServiceManager( entry );
        return new WrapperComponentManager( serviceManager );
    }
View Full Code Here


    protected Object makeNewServiceObject(
        MessageContext msgContext,
        String role)
        throws Exception
    {
        ServiceManager manager =
            (ServiceManager) msgContext
                .getAxisEngine()
                .getApplicationSession()
                .get( SERVICE_MANAGER );

        if (manager == null)
            throw new AxisFault("Could not access Avalon ServiceManager");

        return decorate(manager.lookup(role), manager);
    }
View Full Code Here

    protected Object makeNewServiceObject(
        MessageContext msgContext,
        String role)
        throws Exception
    {
        ServiceManager manager =
            (ServiceManager) msgContext
                .getAxisEngine()
                .getApplicationSession()
                .get( SERVICE_MANAGER );

        if (manager == null)
            throw new AxisFault("Could not access Avalon ServiceManager");

        return decorate(manager.lookup(role), manager);
    }
View Full Code Here

     *
     */
    public InputStream getInputStream()
    throws IOException {

        ServiceManager manager = null;
        ServiceSelector serializerSelector = null;
        Serializer serializer = null;
        // this.manager does not have Serializer
        try {
            manager = (ServiceManager) this.context.get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
            serializerSelector = (ServiceSelector) manager.lookup(Serializer.ROLE + "Selector");
            serializer = (Serializer)serializerSelector.select("xml");
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            serializer.setOutputStream(os);

            toSAX(serializer);

            return new ByteArrayInputStream(os.toByteArray());
        } catch (ServiceException e) {
            throw new CascadingIOException("Could not lookup pipeline components", e);
        } catch (ContextException ce) {
            throw new CascadingIOException("Could not get service manager.", ce);
        } catch (Exception e) {
            throw new CascadingIOException("Exception during processing of " + getURI(), e);
        } finally {
            if (serializer != null) {
                serializerSelector.release(serializer);
            }
            if (serializerSelector != null) {
                manager.release(serializerSelector);
            }
        }
    }
View Full Code Here

        }

        Object job = null;
        String jobrole = null;
       
        ServiceManager manager = (ServiceManager)data.get(QuartzJobScheduler.DATA_MAP_MANAGER);
    org.apache.cocoon.environment.Context envContext =
      (org.apache.cocoon.environment.Context)data.get(QuartzJobScheduler.DATA_MAP_ENV_CONTEXT);
        BackgroundEnvironment env;
    try {
      env = new BackgroundEnvironment(logger, envContext, manager);
    } catch (MalformedURLException mue) {
      // Unlikely to happen
      throw new JobExecutionException(mue);
    }
        CocoonComponentManager.enterEnvironment(env, env.getManager(), env.getProcessor());
        boolean release = false;
        try {
            jobrole = (String)data.get(QuartzJobScheduler.DATA_MAP_ROLE);

            if (null == jobrole) {
                job = data.get(QuartzJobScheduler.DATA_MAP_OBJECT);
            } else {
                job = manager.lookup(jobrole);
                release = true;
            }

            if (job instanceof ConfigurableCronJob) {
                final Parameters params = (Parameters)data.get(QuartzJobScheduler.DATA_MAP_PARAMETERS);
                final Map objects = (Map)data.get(QuartzJobScheduler.DATA_MAP_OBJECTMAP);
                ((ConfigurableCronJob)job).setup(params, objects);
            }

            data.put(DATA_MAP_KEY_ISRUNNING, Boolean.TRUE);

            if (job instanceof Job) {
                ((Job)job).execute(context);
            } else if (job instanceof CronJob) {
                ((CronJob)job).execute(name);
            } else if (job instanceof Runnable) {
                ((Runnable)job).run();
            } else {
                logger.error("job named '" + name + "' is of invalid class: " + job.getClass().getName());
            }
        } catch (final Throwable t) {
            logger.error("Cron job name '" + name + " died.", t);

            if (t instanceof JobExecutionException) {
                throw (JobExecutionException)t;
            }
        } finally {
            data.put(DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
           
            CocoonComponentManager.leaveEnvironment();

            if (release && null != manager) {
                manager.release(job);
            }
        }
    }
View Full Code Here

            DocumentFragment domTemplate = null;

            String src = bindingElm.getAttribute("src");
            if (!src.equals("")) {
                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 = bindingElm.getAttribute("xpath");
                    if (!xpath.equals("")) {
                        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.");
                            if (!(node instanceof Element))
                                throw new BindingException("XPath expression \"" + xpath + "\" did not return an element node.");
                            element = (Element)node;
                        } finally {
                            manager.release(xpathProcessor);
                        }
                    }
                    domTemplate = document.createDocumentFragment();
                    domTemplate.appendChild(element);
                } finally {
                    if (source != null)
                        sourceResolver.release(source);
                    manager.release(sourceResolver);
                }
            } else {
                domTemplate = bindingElm.getOwnerDocument().createDocumentFragment();
                NodeList nested = bindingElm.getChildNodes();
                int size = nested.getLength();
View Full Code Here

        this.configuration = configuration;
    }

    public void initialize() throws Exception {
        widgetDefinitionBuilderSelector = new SimpleServiceSelector("widget", WidgetDefinitionBuilder.class);
        widgetDefinitionBuilderSelector.service(new ServiceManager() {
            final String WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE = WidgetDefinitionBuilder.class.getName() + "Selector";

            public Object lookup(String name) throws ServiceException {
                if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
                    return widgetDefinitionBuilderSelector;
View Full Code Here

                (int)org.mozilla.javascript.Context.toNumber(args[2]);
        }
        WebContinuation wk;
        Scriptable scope = getTopLevelScope(c);
        FOM_Cocoon cocoon = (FOM_Cocoon)getProperty(scope, "cocoon");
        ServiceManager componentManager =  cocoon.getServiceManager();
        ContinuationsManager contMgr = (ContinuationsManager)
            componentManager.lookup(ContinuationsManager.ROLE);
        wk = contMgr.createWebContinuation(c,
                                           (parent == null ? null : parent.getWebContinuation()),
                                           timeToLive,
                                           null);
        result = new FOM_WebContinuation(wk);
View Full Code Here

    public void jsFunction_invalidate() throws Exception {
        ContinuationsManager contMgr = null;
        FOM_Cocoon cocoon =
            (FOM_Cocoon)getProperty(getTopLevelScope(this), "cocoon");
        ServiceManager componentManager = cocoon.getServiceManager();
        contMgr = (ContinuationsManager)
            componentManager.lookup(ContinuationsManager.ROLE);
        contMgr.invalidateWebContinuation(wk);
    }
View Full Code Here

        this.configuration = configuration;
    }

    public void initialize() throws Exception {
        widgetDefinitionBuilderSelector = new SimpleServiceSelector("widget", WidgetDefinitionBuilder.class);
        widgetDefinitionBuilderSelector.service(new ServiceManager() {
            final String WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE = WidgetDefinitionBuilder.class.getName() + "Selector";

            public Object lookup(String name) throws ServiceException {
                if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
                    return widgetDefinitionBuilderSelector;
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.