Package org.apache.avalon.framework.component

Examples of org.apache.avalon.framework.component.ComponentManager


    public Object jsFunction_inputModuleGetAttribute(String type, String attribute)
        throws Exception
    {
        // since no new components can be declared on sitemap we could
        // very well use the 'other' one here. Anyway, since it's there...
        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
        ComponentSelector inputSelector = (ComponentSelector)sitemapManager
            .lookup(InputModule.ROLE + "Selector");
        InputModule input = (InputModule) inputSelector.select(type);
        Object result = null;
        try {
            result = input.getAttribute(attribute, null,
View Full Code Here


                                                    Object value)
        throws Exception
    {
        // since no new components can be declared on sitemap we could
        // very well use the 'other' one here. Anyway, since it's there...
        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
        ComponentSelector outputSelector = (ComponentSelector)sitemapManager
            .lookup(OutputModule.ROLE + "Selector");
        OutputModule output = (OutputModule) outputSelector.select(type);
        try {
            output.setAttribute(null, this.environment.getObjectModel(), attribute,
                                jsobjectToObject(value));
View Full Code Here

    public void jsFunction_outputModuleCommit(String type)
        throws Exception
    {
        // since no new components can be declared on sitemap we could
        // very well use the 'other' one here. Anyway, since it's there...
        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
        ComponentSelector outputSelector = (ComponentSelector)sitemapManager
            .lookup(OutputModule.ROLE + "Selector");
        OutputModule output = (OutputModule) outputSelector.select(type);
        try {
            output.commit(null, this.environment.getObjectModel());
        } finally {
View Full Code Here

    public void jsFunction_outputModuleRollback(String type)
        throws Exception
    {
        // since no new components can be declared on sitemap we could
        // very well use the 'other' one here. Anyway, since it's there...
        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
        ComponentSelector outputSelector = (ComponentSelector)sitemapManager
            .lookup(OutputModule.ROLE + "Selector");
        OutputModule output = (OutputModule) outputSelector.select(type);
        try {
            output.rollback(null, this.environment.getObjectModel(), null);
        } finally {
View Full Code Here

                                         Function ctorObj,
                                         boolean inNewExpr)
    throws Exception
  {
    JSCocoon cocoon = (JSCocoon)args[0];
    ComponentManager manager = cocoon.getComponentManager();

    ContinuationsManager contMgr
      = (ContinuationsManager)manager.lookup(ContinuationsManager.ROLE);

    Object kont = args[1];
    JSWebContinuation pjswk = (JSWebContinuation)args[2];
    WebContinuation pwk = (pjswk == null ? null : pjswk.wk);
View Full Code Here

                ModifiableSource ws = (ModifiableSource) source;

                frag.normalize();

                if ( null != serializerName) {
          ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();

                  ComponentSelector selector = null;
                  Serializer serializer = null;
                  OutputStream oStream = null;
                  try {
                       selector = (ComponentSelector)manager.lookup(Serializer.ROLE + "Selector");
                       serializer = (Serializer)selector.select(serializerName);
                       oStream = ws.getOutputStream();
                       serializer.setOutputStream(oStream);
                         serializer.startDocument();
                       DOMStreamer streamer = new DOMStreamer(serializer);
                       streamer.stream(frag);
                         serializer.endDocument();
                  } catch (ComponentException e) {
                    throw new ProcessingException("Unable to lookup serializer.", e);
          } finally {
                      if (oStream != null) {
                          oStream.flush();
                          try {
                              oStream.close();
                          } catch (Exception ignore) {
                            }
                        }
            if ( selector != null ) {
              selector.release( serializer );
              manager.release( selector );
            }
                  }
                } else {
                  final String content = XMLUtils.serializeNode(frag,
                                             XMLUtils.defaultSerializeToXMLFormat(false));
                  OutputStream oStream = ws.getOutputStream();
 
                  oStream.write(content.getBytes());
                  oStream.flush();
                  oStream.close();
                }
            } else {
              String content;
        if ( null != serializerName) {
          ComponentManager  manager = CocoonComponentManager.getSitemapComponentManager();
                   
                    ComponentSelector selector = null;
                    Serializer serializer = null;
                    ByteArrayOutputStream oStream = new ByteArrayOutputStream();
                    try {
                        selector = (ComponentSelector)manager.lookup(Serializer.ROLE + "Selector");
                        serializer = (Serializer)selector.select(serializerName);
                        serializer.setOutputStream(oStream);
                        serializer.startDocument();
                        DOMStreamer streamer = new DOMStreamer(serializer);
                        streamer.stream(frag);
                        serializer.endDocument();
          } catch (ComponentException e) {
            throw new ProcessingException("Unable to lookup serializer.", e);
                    } finally {
                        if (oStream != null) {
                            oStream.flush();
                            try {
                                oStream.close();
                            } catch (Exception ignore) {
                            }
                        }
            if ( selector != null ) {
              selector.release( serializer );
              manager.release( selector );
            }
                    }
          content = oStream.toString();
        } else {
                    content = XMLUtils.serializeNode(frag,
View Full Code Here

    protected Object makeNewServiceObject(
        MessageContext msgContext, String role
    )
        throws Exception
    {
        ComponentManager manager =
            (ComponentManager) msgContext.getProperty(COMPONENT_MANAGER);

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

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

        } catch (Exception e) {
            log("Invalid timeout setting: " + getInitParameter("timeout"));
        }
        gatewayServer = getInitParameter("gateway");
        gatewayPort = getInitParameter("gatewayPort");
        ComponentManager compMgr = (ComponentManager)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
            MailStore mailstore = (MailStore) compMgr.lookup("org.apache.james.services.MailStore");

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

     * If none is specified, the method returns <code>null</code>.
     *
     * @return the parent component manager, or <code>null</code>.
     */
    private synchronized ComponentManager getParentComponentManager() {
        ComponentManager parentComponentManager = null;
        if (parentComponentManagerClass != null) {
            try {
                String initParam = null;
                int dividerPos = parentComponentManagerClass.indexOf('/');
                if (dividerPos != -1) {
View Full Code Here

        if (config == null) {
            getLogger().debug("Sitemap has no components definition at " + tree.getLocation());
            config = new DefaultConfiguration("", "");
        }

        ComponentManager manager = new CocoonComponentManager(this.parentManager);

        LifecycleHelper.setupComponent(manager,
            getLogger(),
            this.context,
            this.parentManager,
            this.roleManager,
            this.logKit,
            config
        );

        // Set parent of all selectors.
        if (this.parentManager != null) {

            for (int i = 0; i < ComponentsSelector.SELECTOR_ROLES.length; i++) {

                String role = ComponentsSelector.SELECTOR_ROLES[i];

                ComponentSelector parentSelector = null;
                try {
                    parentSelector = (ComponentSelector)this.parentManager.lookup(role);
                } catch(Exception e) {
                    // ignore and keep it null
                }

                if (parentSelector != null) {

                    ExtendedComponentSelector localSelector = null;
                    try {
                        localSelector = (ExtendedComponentSelector)manager.lookup(role);

                        if (localSelector != parentSelector) {
                            // local selector wasn't given by chaining to the parent manager
                            localSelector.setParentSelector(parentSelector);
                        }
                        manager.release(localSelector);

                    } catch(Exception e) {
                        // ignore
                    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.component.ComponentManager

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.