Package org.apache.felix.ipojo.handlers.dependency.ServiceUsage

Examples of org.apache.felix.ipojo.handlers.dependency.ServiceUsage.Usage


     * Reset the thread local cache if used.
     * For testing purpose only.
     */
    public void resetLocalCache() {
        if (m_usage != null) {
            Usage usage = (Usage) m_usage.get();
            if (usage.m_stack > 0) {
                createServiceObject(usage);
            }
        }
    }
View Full Code Here


        // Check that we're in proxy mode.
        if (!m_isProxy) {
            throw new IllegalStateException("The dependency has not enabled the `proxy` mode.");
        }

        Usage usage = (Usage) m_usage.get();
        if (usage.m_stack == 0) { // uninitialized usage.
            if (usage.m_componentStack > 0) {
                // We comes from the component who didn't touch the service.
                // So we initialize the usage.
                createServiceObject(usage);
                usage.inc(); // Start the caching, so set the stack level to 1
                m_usage.set(usage); // Required by Dalvik.
                if (isAggregate()) {
                    Object obj = usage.m_object;
                    if (obj instanceof Set) {
                        List<Object> list = new ArrayList<Object>();
View Full Code Here

     * @see org.apache.felix.ipojo.FieldInterceptor#onGet(java.lang.Object, java.lang.String, java.lang.Object)
     */
    public Object onGet(Object pojo, String fieldName, Object value) {

        // Initialize the thread local object is not already touched.
        Usage usage = m_usage.get();
        if (usage.m_stack == 0) { // uninitialized usage.
            createServiceObject(usage);
            usage.inc(); // Start the caching, so set the stack level to 1
            m_usage.set(usage); // Required by Dalvik
        }
        if (!m_isProxy) {
            return usage.m_object;
        } else {
View Full Code Here

     * @param args   : arguments
     * @see org.apache.felix.ipojo.MethodInterceptor#onEntry(java.lang.Object, java.lang.reflect.Member, java.lang.Object[])
     */
    public void onEntry(Object pojo, Member method, Object[] args) {
        if (m_usage != null) {
            Usage usage = m_usage.get();
            usage.incComponentStack(); // Increment the number of component access.
            if (usage.m_stack > 0) {
                usage.inc();
                m_usage.set(usage); // Set the Thread local as value has been modified
            }
        }
    }
View Full Code Here

     * @param method : Method object.
     * @see org.apache.felix.ipojo.MethodInterceptor#onFinally(java.lang.Object, java.lang.reflect.Member)
     */
    public void onFinally(Object pojo, Member method) {
        if (m_usage != null) {
            Usage usage = m_usage.get();
            usage.decComponentStack();
            if (usage.m_stack > 0) {
                if (usage.dec()) {
                    // Exit the method flow => Release all objects
                    usage.clear();
                    // Also remove the thread local object.
                    m_usage.remove();
                }
            }
        }
View Full Code Here

    /**
     * Reset the thread local cache if used.
     */
    public void resetLocalCache() {
        if (m_usage != null) {
            Usage usage = (Usage) m_usage.get();
            if (usage.m_stack > 0) {
                createServiceObject(usage);
            }
        }
    }
View Full Code Here

        // Check that we're in proxy mode.
        if (! m_isProxy) {
            throw new IllegalStateException("The dependency is not a proxied dependency");
        }

        Usage usage = (Usage) m_usage.get();
        if (usage.m_stack == 0) { // uninitialized usage.
            if (usage.m_componentStack > 0) {
                // We comes from the component who didn't touch the service.
                // So we initialize the usage.
                createServiceObject(usage);
                usage.inc(); // Start the caching, so set the stack level to 1
                m_usage.set(usage);
                if (isAggregate()) {
                    Object obj =  usage.m_object;
                    if (obj instanceof Set) {
                        List list = new ArrayList();
View Full Code Here

     * @see org.apache.felix.ipojo.FieldInterceptor#onGet(java.lang.Object, java.lang.String, java.lang.Object)
     */
    public Object onGet(Object pojo, String fieldName, Object value) {

        // Initialize the thread local object is not already touched.
        Usage usage = (Usage) m_usage.get();
        if (usage.m_stack == 0) { // uninitialized usage.
            createServiceObject(usage);
            usage.inc(); // Start the caching, so set the stack level to 1
            m_usage.set(usage);
        }
        if (! m_isProxy) {
            return usage.m_object;
        } else {
View Full Code Here

     * @param args : arguments
     * @see org.apache.felix.ipojo.MethodInterceptor#onEntry(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
     */
    public void onEntry(Object pojo, Method method, Object[] args) {
        if (m_usage != null) {
            Usage usage = (Usage) m_usage.get();
            usage.incComponentStack(); // Increment the number of component access.
            if (usage.m_stack > 0) {
                usage.inc();
                m_usage.set(usage); // Set the Thread local as value has been modified
            }
        }
    }
View Full Code Here

     * @param method : Method object.
     * @see org.apache.felix.ipojo.MethodInterceptor#onFinally(java.lang.Object, java.lang.reflect.Method)
     */
    public void onFinally(Object pojo, Method method) {
        if (m_usage != null) {
            Usage usage = (Usage) m_usage.get();
            usage.decComponentStack();
            if (usage.m_stack > 0) {
                if (usage.dec()) {
                    // Exit the method flow => Release all objects
                    usage.clear();
                    m_usage.set(usage); // Set the Thread local as value has been modified
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.handlers.dependency.ServiceUsage.Usage

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.