Package org.apache.avalon.framework.service

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


        throws Exception
    {
        final String key = Role3.ROLE;
        final String type = "PerThread";

        final ServiceManager serviceManager = getServiceManager();
        final BaseRole object1 = (BaseRole) serviceManager.lookup( key );
        final BaseRole object2 = (BaseRole) serviceManager.lookup( key );

        assertEquals( type + " object IDs (1 vs 2)", object1.getID(), object2.getID() );

        final Thread thread = new Thread()
        {
            public void run()
            {
                try
                {
                    final BaseRole object3 = (BaseRole) serviceManager.lookup( key );
                    final BaseRole object4 = (BaseRole) serviceManager.lookup( key );

                    assertTrue( type + " object IDs (1 vs 3)", object1.getID() != object3.getID() );
                    assertTrue( type + " object IDs (2 vs 4)", object2.getID() != object4.getID() );
                    assertEquals( type + " object IDs (3 vs 4)", object3.getID(), object4.getID() );
                }
View Full Code Here


        throws Exception
    {
        final String key = Role4.ROLE;
        final String type = "Factory";

        final ServiceManager serviceManager = getServiceManager();
        final BaseRole object1 = (BaseRole) serviceManager.lookup( key );
        final BaseRole object2 = (BaseRole) serviceManager.lookup( key );

        assertTrue( type + " object IDs (1 vs 2)", object1.getID() != object2.getID() );

        final Thread thread = new Thread()
        {
            public void run()
            {
                try
                {
                    final BaseRole object3 = (BaseRole) serviceManager.lookup( key );
                    final BaseRole object4 = (BaseRole) serviceManager.lookup( key );

                    assertTrue( type + " object IDs (1 vs 3)", object1.getID() != object3.getID() );
                    assertTrue( type + " object IDs (2 vs 4)", object2.getID() != object4.getID() );
                    assertTrue( type + " object IDs (3 vs 4)", object3.getID() != object4.getID() );
                }
View Full Code Here

    }

    public void testPoolable()
        throws Exception
    {
        final ServiceManager serviceManager = getServiceManager();
        final String key = Role2.ROLE;
        final BaseRole object1 = (BaseRole) serviceManager.lookup( key );
        final BaseRole object2 = (BaseRole) serviceManager.lookup( key );
        final BaseRole object3 = (BaseRole) serviceManager.lookup( key );

        serviceManager.release( object1 );
        serviceManager.release( object2 );
        serviceManager.release( object3 );
    }
View Full Code Here

        final ContainerManager cm = new DefaultContainerManager( config.getContext() );
        ContainerUtil.initialize( cm );

        final DefaultContainer container = (DefaultContainer) cm.getContainer();
        final ServiceManager serviceManager = container.getServiceManager();
        return serviceManager;
    }
View Full Code Here

     *
     * @throws Exception when there is an error.
     */
    protected void initializeServiceManager() throws Exception
    {
        final ServiceManager parent = (ServiceManager) get( m_rootContext, SERVICE_MANAGER, null );
        final DefaultServiceManager manager = new EAServiceManager( parent, getLogger().getChildLogger("compat") );

        /**
         * If there is a parent ServiceManager, we need to see if it has a SourceResolver,
         * and if not, make sure that one is available to fortress
         */

        if ( parent == null || !parent.hasService( SourceResolver.ROLE ) )
        {
            manager.put( SourceResolver.ROLE, m_defaultSourceResolver );
        }

        Object lem = get( m_rootContext, LifecycleExtensionManager.ROLE, null);
View Full Code Here

        try
        {
            final Context implContext = m_contextManager.getChildContext();

            final ServiceManager serviceManager =
                    (ServiceManager) getContextEntry( managerContext, SERVICE_MANAGER );
            final LoggerManager loggerManager =
                    (LoggerManager) serviceManager.lookup( LoggerManager.ROLE );

            ContainerUtil.enableLogging( instance, loggerManager.getDefaultLogger() );
            ContainerUtil.contextualize( instance, implContext );

            ContainerUtil.service( instance, serviceManager );
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

        if (wk != null) {
            appleContext.put("continuation-id", wk.getId());
        }
       
//      Use the current sitemap's service manager for 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

                (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,
                                           cocoon.getInterpreterId(),
                                           null);
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

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.