当前位置: 首页>>代码示例>>Java>>正文


Java BeanContextServiceProvider类代码示例

本文整理汇总了Java中com.googlecode.openbeans.beancontext.BeanContextServiceProvider的典型用法代码示例。如果您正苦于以下问题:Java BeanContextServiceProvider类的具体用法?Java BeanContextServiceProvider怎么用?Java BeanContextServiceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanContextServiceProvider类属于com.googlecode.openbeans.beancontext包,在下文中一共展示了BeanContextServiceProvider类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notifyServiceRevokedToServiceUsers

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Notify the given child that a service has been revoked.
 */
private void notifyServiceRevokedToServiceUsers(Class serviceClass,
        BeanContextServiceProvider serviceProvider,
        boolean revokeCurrentServicesNow, BCSSChild bcssChild) {
    if (bcssChild.serviceRecords == null
            || bcssChild.serviceRecords.isEmpty()) {
        return;
    }
    synchronized (bcssChild.child) {
        for (Iterator it = bcssChild.serviceRecords.iterator(); it
                .hasNext();) {
            ServiceRecord rec = (ServiceRecord) it.next();
            if (rec.serviceClass == serviceClass
                    && rec.provider == serviceProvider
                    && rec.revokedListener != null && !rec.isDelegate) {
                rec.revokedListener
                        .serviceRevoked(new BeanContextServiceRevokedEvent(
                                getBeanContextServicesPeer(), serviceClass,
                                revokeCurrentServicesNow));
                // prevent duplicate notification
                rec.revokedListener = null;
            }
        }
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:28,代码来源:BeanContextServicesSupport.java

示例2: ServiceRecord

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
ServiceRecord(BeanContextServiceProvider provider,
        BeanContextChild child, Object requestor, Class serviceClass,
        BeanContextServiceRevokedListener revokedListener,
        Object service, boolean isDelegate) {
    this.provider = provider;
    this.child = child;
    this.requestor = requestor;
    this.serviceClass = serviceClass;
    this.revokedListener = revokedListener;
    this.service = service;
    this.isDelegate = isDelegate;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:13,代码来源:BeanContextServicesSupport.java

示例3: addService

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Add a service to this context.
 * <p>
 * If the service already exists in the context, simply return false.
 * Otherwise, the service is added and event is fired if required.
 * </p>
 * 
 * @param serviceClass
 *            the service class
 * @param provider
 *            the provider of the service
 * @param fireEvent
 *            the flag indicating to fire event or not
 * @return true if the service is added; or false if the context already has
 *         this service
 */
protected boolean addService(Class serviceClass,
        BeanContextServiceProvider provider, boolean fireEvent) {
    if (serviceClass == null || provider == null) {
        throw new NullPointerException();
    }

    synchronized (globalHierarchyLock) {
        synchronized (services) {
            if (services.containsKey(serviceClass)) {
                return false;
            }
            // add to services
            services.put(serviceClass, createBCSSServiceProvider(
                    serviceClass, provider));
            // count Serializable
            if (provider instanceof Serializable) {
                serializable++;
            }
        }
    }

    if (fireEvent) {
        // notify all listeners and BeanContextServices children
        notifyServiceAvailable(new BeanContextServiceAvailableEvent(this,
                serviceClass));
    }
    return true;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:45,代码来源:BeanContextServicesSupport.java

示例4: getCurrentServiceSelectors

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Returns the service selectors of the specified service. The iterator's
 * <code>remove()</code> operation is disabled.
 * 
 * @see com.googlecode.openbeans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class)
 */
public Iterator getCurrentServiceSelectors(Class serviceClass) {
    BeanContextServiceProvider provider = getLocalServiceProvider(serviceClass);
    return provider == null ? null : new BCSIterator(provider
            .getCurrentServiceSelectors(getBeanContextServicesPeer(),
                    serviceClass));
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:13,代码来源:BeanContextServicesSupport.java

示例5: getLocalServiceProvider

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
private BeanContextServiceProvider getLocalServiceProvider(
        Class serviceClass) {
    synchronized (services) {
        BCSSServiceProvider bcssProvider = (BCSSServiceProvider) services
                .get(serviceClass);
        if (bcssProvider != null) {
            return bcssProvider.getServiceProvider();
        }
        return null;
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:12,代码来源:BeanContextServicesSupport.java

示例6: revokeService

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Revokes a service in this bean context.
 * <p>
 * The given service provider is unregistered and a
 * <code>BeanContextServiceRevokedEvent</code> is fired. All registered
 * service listeners and current service users get notified.
 * </p>
 * 
 * @param serviceClass
 *            the service class
 * @param serviceProvider
 *            the service provider
 * @param revokeCurrentServicesNow
 *            true if service should be terminated immediantly
 * @see com.googlecode.openbeans.beancontext.BeanContextServices#revokeService(java.lang.Class,
 *      com.googlecode.openbeans.beancontext.BeanContextServiceProvider, boolean)
 */
public void revokeService(Class serviceClass,
        BeanContextServiceProvider serviceProvider,
        boolean revokeCurrentServicesNow) {
    if (serviceClass == null || serviceProvider == null) {
        throw new NullPointerException();
    }

    synchronized (globalHierarchyLock) {
        synchronized (services) {
            BCSSServiceProvider bcssProvider = (BCSSServiceProvider) services
                    .get(serviceClass);
            if (bcssProvider == null) { // non-exist service
                return;
            }
            if (bcssProvider.getServiceProvider() != serviceProvider) {
                throw new IllegalArgumentException(
                        Messages.getString("beans.66"));
            }

            services.remove(serviceClass);

            if (serviceProvider instanceof Serializable) {
                serializable--;
            }
        }
    }

    // notify listeners
    fireServiceRevoked(serviceClass, revokeCurrentServicesNow);

    // notify service users
    notifyServiceRevokedToServiceUsers(serviceClass, serviceProvider,
            revokeCurrentServicesNow);
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:52,代码来源:BeanContextServicesSupport.java

示例7: BCSSServiceProvider

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
BCSSServiceProvider(BeanContextServiceProvider provider) {
    this.serviceProvider = provider;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:4,代码来源:BeanContextServicesSupport.java

示例8: getService

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Get a service instance on behalf of the specified child of this context,
 * by calling the registered service provider, or by delegating to the
 * parent context.
 * 
 * @param child
 *            the child that request service
 * @param requestor
 *            the requestor object
 * @param serviceClass
 *            the service class
 * @param serviceSelector
 *            the service selectors
 * @param bcsrl
 *            the <code>BeanContextServiceRevokedListener</code>
 * @return a service instance on behalf of the specified child of this
 *         context
 * @throws IllegalArgumentException
 *             if <code>child</code> is not a child of this context
 * @throws TooManyListenersException
 * @see com.googlecode.openbeans.beancontext.BeanContextServices#getService(com.googlecode.openbeans.beancontext.BeanContextChild,
 *      java.lang.Object, java.lang.Class, java.lang.Object,
 *      com.googlecode.openbeans.beancontext.BeanContextServiceRevokedListener)
 */
public Object getService(BeanContextChild child, Object requestor,
        Class serviceClass, Object serviceSelector,
        BeanContextServiceRevokedListener bcsrl)
        throws TooManyListenersException {
    if (child == null || requestor == null || serviceClass == null
            || bcsrl == null) {
        throw new NullPointerException();
    }

    BCSSChild bcssChild = null;
    BeanContextServiceProvider provider = null;
    Object service = null;
    boolean isDelegate = false;

    synchronized (globalHierarchyLock) {
        // check child
        synchronized (children) {
            bcssChild = (BCSSChild) children.get(child);
        }
        if (bcssChild == null) {
            throw new IllegalArgumentException(
                    Messages.getString("beans.65"));
        }

        // try local service
        provider = getLocalServiceProvider(serviceClass);
        if (provider != null) {
            service = provider.getService(getBeanContextServicesPeer(),
                    requestor, serviceClass, serviceSelector);
        }

        // no local service, try delegate
        if (service == null && proxy != null) {
            provider = proxy;
            service = proxy.getService(getBeanContextServicesPeer(),
                    requestor, serviceClass, serviceSelector, bcsrl);
            isDelegate = true;
        }
    }

    if (service != null) {
        // save record
        synchronized (child) {
            if (bcssChild.serviceRecords == null) {
                bcssChild.serviceRecords = new ArrayList<ServiceRecord>();
            }
            bcssChild.serviceRecords.add(new ServiceRecord(provider, child,
                    requestor, serviceClass, bcsrl, service, isDelegate));
        }
    }

    return service;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:78,代码来源:BeanContextServicesSupport.java

示例9: addService

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
public boolean addService(Class serviceClass,
BeanContextServiceProvider serviceProvider);
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:3,代码来源:BeanContextServices.java

示例10: revokeService

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
public void revokeService(Class serviceClass,
BeanContextServiceProvider serviceProvider,
boolean revokeCurrentServicesNow);
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:4,代码来源:BeanContextServices.java

示例11: getServiceProvider

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Returns the service provider of the related service.
 * 
 * @return the service provider of the related service
 */
protected BeanContextServiceProvider getServiceProvider() {
    return serviceProvider;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:9,代码来源:BeanContextServicesSupport.java

示例12: createBCSSServiceProvider

import com.googlecode.openbeans.beancontext.BeanContextServiceProvider; //导入依赖的package包/类
/**
 * Creates a <code>BCSSServiceProvider</code> to company the given
 * service.
 * 
 * @param serviceClass
 *            the service class
 * @param provider
 *            the service provider
 * @return a <code>BCSSServiceProvider</code> to company the given service
 */
protected BCSSServiceProvider createBCSSServiceProvider(Class serviceClass,
        BeanContextServiceProvider provider) {
    return new BCSSServiceProvider(provider);
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:15,代码来源:BeanContextServicesSupport.java


注:本文中的com.googlecode.openbeans.beancontext.BeanContextServiceProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。