Examples of PoolService


Examples of org.apache.turbine.services.pool.PoolService

     * @param data a RunData instance
     */
    private void populateWithRequestTools(Context context, RunData data)
    {
        // Get the PoolService to fetch object instances from
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);

        // Iterate the tools
        Iterator it = requestTools.iterator();
        while (it.hasNext())
        {
            ToolData toolData = (ToolData)it.next();
            try
            {
                Object tool = pool.getInstance(toolData.toolClass);
                if (tool instanceof ApplicationTool)
                {
                    // request tools are init'd with a RunData object
                    ((ApplicationTool)tool).init(data);
                }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     */
    private void populateWithSessionTools(List tools, Context context,
            RunData data, boolean usePerm)
    {
        // Get the PoolService to fetch object instances from
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);

        // Get the current user
        User user = data.getUser();
       
        // Iterate the tools
        Iterator it = tools.iterator();
        while (it.hasNext())
        {
            ToolData toolData = (ToolData)it.next();
            try
            {
                // ensure that tool is created only once for a user
                // by synchronizing against the user object
                synchronized (user)
                {
                    // first try and fetch the tool from the user's
                    // hashtable
                    Object tool = usePerm
                        ? user.getPerm(toolData.toolClassName)
                        : user.getTemp(toolData.toolClassName);
                   
                    if (tool == null)
                    {
                        // if not there, an instance must be fetched from
                        // the pool
                        tool = pool.getInstance(toolData.toolClass);
                        if (tool instanceof ApplicationTool)
                        {
                            // session tools are init'd with the User object
                            ((ApplicationTool)tool).init(user);
                        }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     * @param context the Velocity Context to release tools from
     */
    public void releaseTools(Context context)
    {
        // Get the PoolService to release object instances to
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);
      
        // only the request tools can be released - other scoped
        // tools will have continuing references to them
        releaseTools(context, pool, requestTools);
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     *
     * @throws Exception
     */
    public void testGetandPut() throws Exception
    {
        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        JetspeedLink jsLink = null;
        int beforeSize;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        String linkClassName = jsLink.getClass().getName();
        jsLink = null;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get/put loop - Got JetspeedLink", jsLink);
            assertTrue( "Get/put loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            beforeSize = poolService.getSize( linkClassName);
            JetspeedLinkFactory.putInstance(jsLink);
            assertTrue( "Class saved in pool", (beforeSize < poolService.getSize( linkClassName)));
            jsLink = null;
        }
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

    public void testFillPool() throws Exception
    {
        Stack jsLinkStack = new Stack();
        JetspeedLink jsLink = null;

        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        int poolCapacity;

        jsLink = JetspeedLinkFactory.getInstance();
        String linkClassName = jsLink.getClass().getName();
        poolCapacity = poolService.getCapacity( linkClassName);

        System.out.println("Class Name  " + linkClassName);
        System.out.println("Pool Capacity " + poolCapacity);

        // Fill stack with objects
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            jsLinkStack.push(jsLink);
        }
       
        // Fill up the pool
        while (jsLinkStack.empty() == false)
            JetspeedLinkFactory.putInstance( (JetspeedLink) jsLinkStack.pop());
        assertEquals( "Pool is full", poolCapacity, poolService.getSize(linkClassName));
       
        // Empty pool
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        assertEquals( "Pool is empty", 0, poolService.getSize(linkClassName));
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     *
     * @throws Exception
     */
    public void testGetandPut() throws Exception
    {
        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        JetspeedLink jsLink = null;
        int beforeSize;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        String linkClassName = jsLink.getClass().getName();
        jsLink = null;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get/put loop - Got JetspeedLink", jsLink);
            assertTrue( "Get/put loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            beforeSize = poolService.getSize( linkClassName);
            JetspeedLinkFactory.putInstance(jsLink);
            assertTrue( "Class saved in pool", (beforeSize < poolService.getSize( linkClassName)));
            jsLink = null;
        }
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

    public void testFillPool() throws Exception
    {
        Stack jsLinkStack = new Stack();
        JetspeedLink jsLink = null;

        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        int poolCapacity;

        jsLink = JetspeedLinkFactory.getInstance();
        String linkClassName = jsLink.getClass().getName();
        poolCapacity = poolService.getCapacity( linkClassName);

        System.out.println("Class Name  " + linkClassName);
        System.out.println("Pool Capacity " + poolCapacity);

        // Fill stack with objects
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            jsLinkStack.push(jsLink);
        }
       
        // Fill up the pool
        while (jsLinkStack.empty() == false)
            JetspeedLinkFactory.putInstance( (JetspeedLink) jsLinkStack.pop());
        assertEquals( "Pool is full", poolCapacity, poolService.getSize(linkClassName));
       
        // Empty pool
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        assertEquals( "Pool is empty", 0, poolService.getSize(linkClassName));
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     *
     * @throws Exception
     */
    public void testGetandPut() throws Exception
    {
        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        JetspeedLink jsLink = null;
        int beforeSize;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        String linkClassName = jsLink.getClass().getName();
        jsLink = null;
       
        for (int counter = 0; counter < 10; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get/put loop - Got JetspeedLink", jsLink);
            assertTrue( "Get/put loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            beforeSize = poolService.getSize( linkClassName);
            JetspeedLinkFactory.putInstance(jsLink);
            assertTrue( "Class saved in pool", (beforeSize < poolService.getSize( linkClassName)));
            jsLink = null;
        }
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

    public void testFillPool() throws Exception
    {
        Stack jsLinkStack = new Stack();
        JetspeedLink jsLink = null;

        PoolService poolService = (PoolService) TurbineServices.
        getInstance().getService(PoolService.SERVICE_NAME);
        int poolCapacity;

        jsLink = JetspeedLinkFactory.getInstance();
        String linkClassName = jsLink.getClass().getName();
        poolCapacity = poolService.getCapacity( linkClassName);

        System.out.println("Class Name  " + linkClassName);
        System.out.println("Pool Capacity " + poolCapacity);

        // Fill stack with objects
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
            jsLinkStack.push(jsLink);
        }
       
        // Fill up the pool
        while (jsLinkStack.empty() == false)
            JetspeedLinkFactory.putInstance( (JetspeedLink) jsLinkStack.pop());
        assertEquals( "Pool is full", poolCapacity, poolService.getSize(linkClassName));
       
        // Empty pool
        for (int counter = 0; counter < poolCapacity; counter++)
        {
            jsLink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jsLink);
            assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
        }
        assertEquals( "Pool is empty", 0, poolService.getSize(linkClassName));
    }
View Full Code Here

Examples of org.apache.turbine.services.pool.PoolService

     * @param data a RunData instance
     */
    private void populateWithRequestTools(Context context, RunData data)
    {
        // Get the PoolService to fetch object instances from
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);

        // Iterate the tools
        Iterator it = requestTools.iterator();
        while (it.hasNext())
        {
            ToolData toolData = (ToolData)it.next();
            try
            {
                Object tool = pool.getInstance(toolData.toolClass);
                if (tool instanceof ApplicationTool)
                {
                    // request tools are init'd with a RunData object
                    ((ApplicationTool)tool).init(data);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.