本文整理汇总了Java中java.beans.beancontext.BeanContextServiceAvailableEvent类的典型用法代码示例。如果您正苦于以下问题:Java BeanContextServiceAvailableEvent类的具体用法?Java BeanContextServiceAvailableEvent怎么用?Java BeanContextServiceAvailableEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeanContextServiceAvailableEvent类属于java.beans.beancontext包,在下文中一共展示了BeanContextServiceAvailableEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFireServiceAddedBeanContextServiceAvailableEvent
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testFireServiceAddedBeanContextServiceAvailableEvent() {
MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
support.add(childSupport);
MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
support.addBeanContextServicesListener(l1);
childSupport.addBeanContextServicesListener(l2);
support.records.assertRecord("initialize", null);
childSupport.records.assertRecord("initialize", null);
BeanContextServiceAvailableEvent evt = new BeanContextServiceAvailableEvent(
support, Collection.class);
support.publicFireServiceAdded(evt);
support.records.assertEndOfRecords();
childSupport.records.assertEndOfRecords();
assertSame(evt, l1.lastAvailableEvent);
assertNull(l2.lastAvailableEvent);
}
示例2: test_serviceAvailable_LBeanContextServiceRevokedEvent
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的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);
}
示例3: assertEqualsSerially
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
private void assertEqualsSerially(BeanContextServiceAvailableEvent orig,
BeanContextServiceAvailableEvent ser) {
assertNull(ser.getSource());
// check propagatedFrom
if (orig.getPropagatedFrom() instanceof Serializable) {
BeanContext origFrom = orig.getPropagatedFrom();
BeanContext serFrom = ser.getPropagatedFrom();
assertEquals(origFrom.getClass(), serFrom.getClass());
if (origFrom instanceof MockBeanContextDelegateS) {
assertEquals(((MockBeanContextDelegateS) origFrom).id,
((MockBeanContextDelegateS) serFrom).id);
}
}
// check serviceClass
assertEquals(orig.getServiceClass(), ser.getServiceClass());
}
示例4: serviceAvailable
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的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;
}
}
示例5: testAddServiceClassBeanContextServiceProvider_ParentContext
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testAddServiceClassBeanContextServiceProvider_ParentContext() {
MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
support.add(childSupport);
MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
support.addBeanContextServicesListener(l1);
childSupport.addBeanContextServicesListener(l2);
support.records.assertRecord("initialize", null);
childSupport.records.assertRecord("initialize", null);
MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
boolean result = support.addService(Collection.class, provider);
assertTrue(result);
assertEquals(1, support.services().size());
assertEquals(0, childSupport.services().size());
Object bcssProvider = support.services().get(Collection.class);
support.records.assertRecord("createBCSSServiceProvider",
Collection.class, provider, bcssProvider);
support.records.assertEndOfRecords();
BeanContextServiceAvailableEvent evt = (BeanContextServiceAvailableEvent) childSupport.records
.getArg(0);
childSupport.records.assertRecord("serviceAvailable", evt, null);
assertSame(support, evt.getSourceAsBeanContextServices());
assertSame(Collection.class, evt.getServiceClass());
childSupport.records.assertEndOfRecords();
assertSame(support, l1.lastAvailableEvent
.getSourceAsBeanContextServices());
assertSame(Collection.class, l1.lastAvailableEvent.getServiceClass());
assertSame(support, l2.lastAvailableEvent
.getSourceAsBeanContextServices());
assertSame(Collection.class, l2.lastAvailableEvent.getServiceClass());
}
示例6: testBeanContextServiceAvailableEvent_NullParam
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的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());
}
示例7: testBeanContextServiceAvailableEvent
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的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());
}
示例8: testGetSourceAsBeanContextServices
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testGetSourceAsBeanContextServices() {
BeanContextServices services = new MockBeanContextServices();
BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
services, BeanContext.class);
assertSame(services, event.getSource());
assertSame(services, event.getSourceAsBeanContextServices());
}
示例9: testGetCurrentServiceSelectors
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的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());
}
示例10: testSerialization
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testSerialization() throws IOException, ClassNotFoundException {
BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
new MockBeanContextServices(), ArrayList.class);
event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
assertEqualsSerially(event,
(BeanContextServiceAvailableEvent) SerializationTester
.getDeserilizedObject(event));
}
示例11: testSerialization_Compatibility
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
new MockBeanContextServices(), ArrayList.class);
event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
SerializationTest.verifyGolden(this, event, new SerializableAssert(){
public void assertDeserialized(Serializable orig, Serializable ser) {
assertEqualsSerially((BeanContextServiceAvailableEvent) orig,
(BeanContextServiceAvailableEvent) ser);
}
});
}
示例12: testSerialization_Compatibility
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
new MockBeanContextServices(), ArrayList.class);
event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
assertEqualsSerially(
event,
(BeanContextServiceAvailableEvent) SerializationTester
.readObject(event,
"serialization/java/beans/beancontext/BeanContextServiceAvailableEvent.ser"));
}
示例13: serviceAvailable
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void serviceAvailable(BeanContextServiceAvailableEvent p0) {
return;
}
示例14: publicFireServiceAdded
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
public void publicFireServiceAdded(BeanContextServiceAvailableEvent evt) {
fireServiceAdded(evt);
}
示例15: serviceAvailable
import java.beans.beancontext.BeanContextServiceAvailableEvent; //导入依赖的package包/类
@Override
public void serviceAvailable(BeanContextServiceAvailableEvent bcssae) {
super.serviceAvailable(bcssae);
records.add("serviceAvailable", bcssae, null);
}