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


Java BeanContextServices类代码示例

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


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

示例1: serviceAvailable

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
/**
 * @param bcsae the BeanContextServiceAvailableEvent
 */
public void serviceAvailable(BeanContextServiceAvailableEvent bcsae) {
    // Get a reference to the context
    BeanContextServices context = bcsae.getSourceAsBeanContextServices();
    // Use the service, if it's available
    if (context.hasService(TestCounter.class)) {
        // System.out.println("Attempting to use the service...");
        try {
            // Got the service
            service = (TestCounter) context.getService(this,
                    this, TestCounter.class, str, this);
            service.counter();
        } catch (Exception e) {
        }

        this.bcsae = bcsae;
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:ServiceBean.java

示例2: main

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:Test4328406.java

示例3: testBeanContextServiceRevokedEvent

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testBeanContextServiceRevokedEvent() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertSame(BeanContext.class, event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
    assertTrue(event.isCurrentServiceInvalidNow());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:BeanContextServiceRevokedEventTest.java

示例4: testIsServiceClass

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testIsServiceClass() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isServiceClass(BeanContext.class));
    assertFalse(event.isServiceClass(Integer.class));

    // Regression for HARMONY-1516
    assertFalse(event.isServiceClass(null));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:BeanContextServiceRevokedEventTest.java

示例5: testIsCurrentServiceInvalidNow

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testIsCurrentServiceInvalidNow() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isCurrentServiceInvalidNow());
    event = new MockBeanContextServiceRevokedEvent(services,
            BeanContext.class, false);
    assertFalse(event.isCurrentServiceInvalidNow());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:BeanContextServiceRevokedEventTest.java

示例6: testConstructor

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testConstructor() throws Exception {
    BeanContextServices bcs = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            bcs, ArrayList.class, true);
    assertEquals(null, event.getPropagatedFrom());
    assertEquals(ArrayList.class, event.getServiceClass());
    assertSame(bcs, event.getSource());
    assertSame(bcs, event.getBeanContext());
    assertSame(bcs, event.getSourceAsBeanContextServices());
    assertFalse(event.isPropagated());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:BeanContextServiceRevokedEventTest.java

示例7: testBeanContextServiceAvailableEvent_NullParam

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testBeanContextServiceAvailableEvent_NullParam() {
    BeanContextServices services = new MockBeanContextServices();

    try {
        new MockBeanContextServiceAvailableEvent(null, BeanContext.class);
        fail("IAE expected");
    } catch (IllegalArgumentException e) {
        // expected
    }

    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, null);
    assertNull(event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:BeanContextServiceAvailableEventTest.java

示例8: testBeanContextServiceAvailableEvent

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testBeanContextServiceAvailableEvent() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);
    assertSame(BeanContext.class, event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:BeanContextServiceAvailableEventTest.java

示例9: testGetSourceAsBeanContextServices

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testGetSourceAsBeanContextServices() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:BeanContextServiceAvailableEventTest.java

示例10: testGetCurrentServiceSelectors

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public void testGetCurrentServiceSelectors() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);

    Iterator expectedIt = services
            .getCurrentServiceSelectors(BeanContext.class);
    Iterator it = event.getCurrentServiceSelectors();
    while (expectedIt.hasNext()) {
        assertSame(expectedIt.next(), it.next());
    }
    assertFalse(expectedIt.hasNext());
    assertFalse(it.hasNext());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:BeanContextServiceAvailableEventTest.java

示例11: getService

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public Object getService(BeanContextServices bcs, Object requestor,
        Class serviceClass, Object serviceSelector) {
    Object result = Collections.EMPTY_SET;
    records.add("getService", bcs, requestor, serviceClass,
            serviceSelector, result);
    return result;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:MockBeanContextServiceProvider.java

示例12: getService

import java.beans.beancontext.BeanContextServices; //导入依赖的package包/类
public Object getService(BeanContextServices bcs, 
                         Object requestor,
                         Class serviceClass,
                         Object serviceSelector) {

    final String str = (String)serviceSelector;

    return new TestCounter() {
        public void counter() {
                String res = str;
                System.out.println(str);                
        }
    };
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:15,代码来源:TestServiceProvider.java


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