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


Java BeanContextServicesSupport.addService方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: testSerialization_Compatibility

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
    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());
    SerializationTest.verifyGolden(this, support, new SerializableAssert(){
        public void assertDeserialized(Serializable initial, Serializable deserialized) {
            assertEqualsSerially((BeanContextServicesSupport) initial,
                    (BeanContextServicesSupport) deserialized);
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:BeanContextServicesSupportTest.java

示例9: testSerialization_Compatibility

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
    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
                    .readObject(support,
                            "serialization/java/beans/beancontext/BeanContextServicesSupport.ser"));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:BeanContextServicesSupportTest.java

示例10: testIsServiceClass

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServiceRevokedEvent#isServiceClass()
 */
public Result testIsServiceClass() 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 the service to the context
    context.addService(TestCounter.class, provider);

    // Revoke the service from the context
    context.revokeService(TestCounter.class, provider, true);

    if ((context.hasService(TestCounter.class))
            || (serviceBean.bcsre.isServiceClass(TestCounter.class)))
        return passed();
    else
        return failed("method testIsServiceClasss");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:30,代码来源:TestBeanContextServiceRevokedEvent.java

示例11: testIsCurrentServiceInvalidNow

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServiceRevokedEvent#isCurrentServiceInvalidNow()
 */
public Result testIsCurrentServiceInvalidNow() 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 the service to the context
    context.addService(TestCounter.class, provider);

    // Revoke the service from the context
    context.revokeService(TestCounter.class, provider, true);

    // Verified that the method isCurrentServiceInvalidNow return true if current service is revoked
    if ((context.hasService(TestCounter.class))
            || (serviceBean.bcsre.isCurrentServiceInvalidNow()))
        return passed();
    else
        return failed("method testIsCurrentServiceInvalidNow");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:31,代码来源:TestBeanContextServiceRevokedEvent.java

示例12: testGetSourceAsBeanContextServices

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServiceRevokedEvent#getSourceAsBeanContextServices()
 */
public Result testGetSourceAsBeanContextServices() 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 the service to the context
    context.addService(TestCounter.class, provider);

    // Revoke the service from the context
    context.revokeService(TestCounter.class, provider, true);

    // Verified that the method getSourceAsBeanContextServices return BeanContextServicesSupport object if current service is revoked
    if ((context.hasService(TestCounter.class))
            || serviceBean.bcsre.getSourceAsBeanContextServices() instanceof BeanContextServicesSupport)
        return passed();
    else
        return failed("method testGetSourceAsBeanContextServices");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:31,代码来源:TestBeanContextServiceRevokedEvent.java

示例13: testNumberRevokedEvents

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * Test for revoke events numbers
 * @see java.beans.beancontext.BeanContextServiceRevokedEvent
 */
public Result testNumberRevokedEvents() 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 the service to the context
    context.addService(TestCounter.class, provider);

    // Revoke the service from the context
    context.revokeService(TestCounter.class, provider, true);

    if ((context.hasService(TestCounter.class))
            || (serviceBean.counterRevokedEvent == 2))
        return passed();
    else
        return failed("method testNumberRevokedEvents");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:31,代码来源:TestBeanContextServiceRevokedEvent.java

示例14: testAddService

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#addService()
 */
public Result testAddService() 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);

    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:23,代码来源:TestBeanContextServicesSupport.java

示例15: testHasService

import java.beans.beancontext.BeanContextServicesSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#hasService()
 */
public Result testHasService() 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.hasService(TestCounter.class))

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


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