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


Java BeanContextServicesSupport类代码示例

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


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

示例1: testSerialization

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void testSerialization() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.FRANCE, false, false);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            ctx, Locale.ITALY, true, true);
    BeanContextEvent event = new MockBeanContextEvent(ctx2);
    event.setPropagatedFrom(ctx);
    SerializationTest.verifySelf(event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:BeanContextEventTest.java

示例2: testSerializationComptibility

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void testSerializationComptibility() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            null, Locale.CHINA, true, true);
    
    BeanContextEvent event = new MockBeanContextEvent(ctx);
    event.setPropagatedFrom(ctx2);
    SerializationTest.verifyGolden(this, event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx2, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:BeanContextEventTest.java

示例3: testSerialization

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServicesSupport support = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l2"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l3"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support.addService(Collection.class,
            new MockBeanContextServiceProvider());
    support.addService(List.class,
            new MockBeanContextServiceProviderS("p1"));
    support
            .addService(Set.class,
                    new MockBeanContextServiceProviderS("p2"));
    support.addService(Map.class, new MockBeanContextServiceProvider());

    assertEqualsSerially(support,
            (BeanContextServicesSupport) SerializationTester
                    .getDeserilizedObject(support));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:BeanContextServicesSupportTest.java

示例4: test_serviceRevoked_LBeanContextServiceRevokedEvent

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
	BeanContextServicesSupport support = new BeanContextServicesSupport();

	support.add(new MySupport());
	support.addBeanContextServicesListener(new MyListener());
	Class c = Object.class;

	support.addService(c, new MyProvider());

	BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
			support, c, false);

	support.serviceRevoked(revokeEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);
       
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:BeanContextServicesSupportTest.java

示例5: test_serviceAvailable_LBeanContextServiceRevokedEvent

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
	BeanContextServicesSupport support = new BeanContextServicesSupport();

	support.add(new MySupport());
	support.addBeanContextServicesListener(new MyListener());
	Class c = Object.class;

	support.addService(c, new MyProvider());

	BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
			support, c);
    support.serviceAvailable(availableEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);
       
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:BeanContextServicesSupportTest.java

示例6: testGetBeanContextServicesPeer

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getBeanContextServicesPeer()
 */
public Result testGetBeanContextServicesPeer() throws Exception {

    context = new BeanContextServicesSupport();
    
    serviceBean = new ServiceBean();

    // Adding the component
    context.add(serviceBean);

    // Add service to the context
    if ((context.getBeanContextServicesPeer() instanceof BeanContextServicesSupport))

        return passed();
    else
        return failed("method testGetBeanContextServicesPeer");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:TestBeanContextServicesSupport.java

示例7: testGetCurrentServiceSelectors

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getCurrentServiceSelectors()
 */
public Result testGetCurrentServiceSelectors() throws Exception {

    context = new BeanContextServicesSupport();
    
    serviceBean = new ServiceBean();
    
    // Adding the component
    context.add(serviceBean);

    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);
    
    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);
    
    if ((context.getCurrentServiceSelectors(TestCounter.class) instanceof Iterator))
        return passed();
    else
        return failed("method testGetCurrentServiceSelectors");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:TestBeanContextServicesSupport.java

示例8: testGetService

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getService()
 */
public Result testGetService() throws Exception {
    
    context = new BeanContextServicesSupport();
    
    serviceBean = new ServiceBean();
    
    // Adding the component
    context.add(serviceBean);

    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);
    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);
    
    if ((serviceBean.service instanceof TestCounter))
        return passed();
    else
        return failed("method testGetService");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:25,代码来源:TestBeanContextServicesSupport.java

示例9: testAddBeanContextServicesListenerException

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#addBeanContextServicesListener()
 */
public Result testAddBeanContextServicesListenerException()
        throws Exception {

    context = new BeanContextServicesSupport();
    
    serviceBean = null;

    try {
        // Listen for new service
        context.addBeanContextServicesListener(serviceBean);
    } catch (NullPointerException e) {
        
                return passed();
    }
    return failed("testAddBeanContextServicesListenerException");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:TestBeanContextServicesSupportException.java

示例10: testGetServiceException

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getService()
 */
public Result testGetServiceException()    throws Exception {

    BeanContextChild child = null;
    Object requestor = null;
    Class serviceClass = null;
    Object serviceSelector = null;
    BeanContextServiceRevokedListener bcsrl = null;
    BeanContextServicesSupport context = new BeanContextServicesSupport();
    serviceBean = null;

    try {
        context.getService(child, requestor ,serviceClass,serviceSelector,bcsrl);
    } catch (NullPointerException e) {

        return passed();
    }
    return failed("testGetServiceException");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:TestBeanContextServicesSupportException.java

示例11: testReleaseServiceException

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#releaseService()
 */
public Result testReleaseServiceException()    throws Exception {

    BeanContextChild child = null;
    Object requestor = null;
    Object service = null;
    BeanContextServicesSupport context = new BeanContextServicesSupport();
    serviceBean = null;

    try {
        context.releaseService(child, requestor ,service);
    } catch (NullPointerException e) {
    
        return passed();
    }
    return failed("testGetServiceException");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:TestBeanContextServicesSupportException.java

示例12: testGetCurrentServiceSelectors

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServiceAvailableEvent#getCurrentServiceSelectors()
 * @see java.beans.beancontext.BeanContextServicesSupport#hasService()
 */
public Result testGetCurrentServiceSelectors() throws Exception {
    
    context = new BeanContextServicesSupport();

    serviceBean = new ServiceBean();

    // Add service to the context
    context.add(serviceBean);        
    
    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);

    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);

    if ((context.hasService(TestCounter.class))
            || (serviceBean.bcsae.getCurrentServiceSelectors() instanceof java.util.Iterator))
        return passed();
    else
        return failed("method getCurrentServiceSelectors");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:28,代码来源:TestBeanContextServiceAvailableEvent.java

示例13: main

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的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

示例14: initializeBeanContextResources

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test4328406.java

示例15: test

import java.beans.beancontext.BeanContextServicesSupport; //导入依赖的package包/类
public void test() {
    BeanContextServiceProvider bcsp = new BCSP();
    BCSS serviceSupport = new BCSS(new BeanContextServicesSupport());
    assertTrue("Expected first addService to return true", serviceSupport
            .addService(Boolean.TYPE, bcsp, false));
    assertFalse("Expected second addService to return false", serviceSupport
            .addService(Boolean.TYPE, bcsp, false));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:BeanContextServicesSupport2Test.java


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