Java 类java.beans.beancontext.BeanContextServices 实例源码

项目:freeVM    文件:ServiceBean.java   
/**
 * @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;
    }
}
项目:jdk8u-jdk    文件:Test4328406.java   
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);
    }
}
项目:openjdk-jdk10    文件:Test4328406.java   
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);
    }
}
项目:openjdk9    文件:Test4328406.java   
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);
    }
}
项目:jdk8u_jdk    文件:Test4328406.java   
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test4328406.java   
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);
    }
}
项目:infobip-open-jdk-8    文件:Test4328406.java   
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);
    }
}
项目:jdk8u-dev-jdk    文件:Test4328406.java   
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);
    }
}
项目:jdk7-jdk    文件:Test4328406.java   
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);
    }
}
项目:openjdk-source-code-learn    文件:Test4328406.java   
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);
    }
}
项目:OLD-OpenJDK8    文件:Test4328406.java   
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);
    }
}
项目:cn1    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:cn1    文件:BeanContextServiceRevokedEventTest.java   
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));
}
项目:cn1    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:cn1    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:cn1    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:cn1    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:cn1    文件:BeanContextServiceAvailableEventTest.java   
public void testGetSourceAsBeanContextServices() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
项目:cn1    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:cn1    文件:MockBeanContextServiceProvider.java   
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;
}
项目:JAVA_UNIT    文件:Test4328406.java   
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);
    }
}
项目:openjdk-jdk7u-jdk    文件:Test4328406.java   
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);
    }
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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));
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
public void testGetSourceAsBeanContextServices() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:MockBeanContextServiceProvider.java   
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;
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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));
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceRevokedEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
public void testGetSourceAsBeanContextServices() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
            services, BeanContext.class);
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
}
项目:freeVM    文件:BeanContextServiceAvailableEventTest.java   
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());
}
项目:freeVM    文件:MockBeanContextServiceProvider.java   
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;
}
项目:freeVM    文件:TestServiceProvider.java   
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);                
        }
    };
}