Package org.picocontainer

Examples of org.picocontainer.Startable


        pico.registerComponentImplementation(DefaultPicoContainerLifecycleTestCase.Two.class);
        pico.registerComponentImplementation(DefaultPicoContainerLifecycleTestCase.One.class);
        pico.registerComponentImplementation(DefaultPicoContainerLifecycleTestCase.Three.class);

        ProxyFactory proxyFactory = new StandardProxyFactory();
        Startable startable = (Startable) Multicaster.object(pico, true, proxyFactory);
        Startable stoppable = (Startable) Multicaster.object(pico, false, proxyFactory);
        Disposable disposable = (Disposable) Multicaster.object(pico, false, proxyFactory);

        startable.start();
        stoppable.stop();
        disposable.dispose();

        assertEquals("<One<Two<Three<FourFour>Three>Two>One>!Four!Three!Two!One", pico.getComponentInstance("recording").toString());
    }
View Full Code Here


                                 // The component has already been started
                                 return null;
                              }
                              try
                              {
                                 Startable startable = (Startable)adapter.getComponentInstance();
                                 startable.start();
                              }
                              finally
                              {
                                 alreadyStarted.put(adapter, adapter);
                              }
                           }
                        }
                        catch (Exception e)
                        {
                           error.compareAndSet(null, e);
                        }
                        finally
                        {
                           Thread.currentThread().setContextClassLoader(oldCl);
                           ExoContainerContext.setCurrentContainer(oldContainer);
                        }
                        return null;
                     }
                  });
               }
            };
            if (submittedTasks == null)
            {
               submittedTasks = new ArrayList<Future<?>>();
            }
            submittedTasks.add(executor.submit(task));
         }
         else
         {
            if (adapter instanceof ComponentAdapterDependenciesAware)
            {
               ComponentAdapterDependenciesAware<?> cada = (ComponentAdapterDependenciesAware<?>)adapter;
               startDependencies(alreadyStarted, startInProgress, error, cada);
            }
            if (!Startable.class.isAssignableFrom(adapter.getComponentImplementation()))
            {
               alreadyStarted.put(adapter, adapter);
               continue;
            }
            else if (alreadyStarted.containsKey(adapter))
            {
               // The component has already been started
               continue;
            }
            synchronized (adapter)
            {
               if (alreadyStarted.containsKey(adapter))
               {
                  // The component has already been started
                  continue;
               }
               try
               {
                  Startable startable = (Startable)adapter.getComponentInstance();
                  startable.start();
               }
               catch (Exception e)
               {
                  error.compareAndSet(null, e);
               }
View Full Code Here

TOP

Related Classes of org.picocontainer.Startable

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.