本文整理汇总了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;
}
}
示例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);
}
}
示例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());
}
示例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));
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
};
}