对于java.beans.beancontext.BeanContextMembershipEvent的实例源码感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍java.beans.intros
对于java.beans.beancontext.BeanContextMembershipEvent的实例源码感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍java.beans.introspection,并为您提供关于com.google.common.eventbus.SubscriberExceptionContext的实例源码、java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?、java.beans.beancontext.BeanContextChildSupport的实例源码、java.beans.beancontext.BeanContextChild的实例源码的有用信息。
本文目录一览:- java.beans.beancontext.BeanContextMembershipEvent的实例源码(java.beans.introspection)
- com.google.common.eventbus.SubscriberExceptionContext的实例源码
- java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?
- java.beans.beancontext.BeanContextChildSupport的实例源码
- java.beans.beancontext.BeanContextChild的实例源码
java.beans.beancontext.BeanContextMembershipEvent的实例源码(java.beans.introspection)
private void assertEqualsSerially(BeanContextMembershipEvent orig,BeanContextMembershipEvent 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 children Collection origChildren = (Collection) Utils.getField(orig,"children"); Collection serChildren = (Collection) Utils.getField(ser,"children"); assertEquals(origChildren,serChildren); }
private void assertMembershipEvent(BeanContextMembershipEvent evt,BeanContext ctx,BeanContext pFrom,Object changes) { assertSame(ctx,evt.getSource()); assertSame(ctx,evt.getBeanContext()); assertSame(pFrom,evt.getPropagatedFrom()); if (changes instanceof Collection) { Collection changeCollection = (Collection) changes; assertEquals(changeCollection.size(),evt.size()); for (Iterator iter = changeCollection.iterator(); iter.hasNext();) { assertTrue(evt.contains(iter.next())); } } else { assertEquals(1,evt.size()); assertTrue(evt.contains(changes)); } }
private void assertEqualsSerially(BeanContextMembershipEvent orig,serChildren); }
private void assertMembershipEvent(BeanContextMembershipEvent evt,evt.size()); assertTrue(evt.contains(changes)); } }
/** * @see java.beans.beancontext.BeanContextMembershipEvent */ public Result testNullPointerException1() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); // Adding the component context.add(bean); Object[] array = null; try { event = new BeanContextMembershipEvent(bean.getBeanContext(),array); } catch (java.lang.NullPointerException e) { return passed(); } return Failed("testNullPointerException1"); }
/** * @see java.beans.beancontext.BeanContextMembershipEvent */ public Result testNullPointerException2() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); // Adding the component context.add(bean); Collection[] array = null; try { event = new BeanContextMembershipEvent(bean.getBeanContext(),array); } catch (java.lang.NullPointerException e) { return passed(); } return Failed("testNullPointerException2"); }
/** * @see java.beans.beancontext.BeanContextMembershipEvent#contains() */ public Result testContainsBeanContextMembershipEvent() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); sBean = new ServiceBean(); // Adding the component context.add(bean); context.add(sBean); event = new BeanContextMembershipEvent(bean.getBeanContext(),context .toArray()); if ((event.contains(sBean)) || !(event.contains(context))) return passed(); else return Failed("testContainsBeanContextMembershipEvent"); }
/** * @see java.beans.beancontext.BeanContextSupport#iterator() */ public Result testIteratorBeanContextMembershipEvent() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); sBean = new ServiceBean(); // Adding the component context.add(bean); context.add(sBean); event = new BeanContextMembershipEvent(bean.getBeanContext(),context .toArray()); if ((event.iterator() instanceof java.util.Iterator)) return passed(); else return Failed("testIteratorBeanContextMembershipEvent"); }
/** * @see java.beans.beancontext.BeanContextSupport#size() */ public Result testSizeBeanContextMembershipEvent() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); sBean = new ServiceBean(); // Adding the component context.add(bean); context.add(sBean); event = new BeanContextMembershipEvent(bean.getBeanContext(),context .toArray()); // System.out.println(event.size()); if (event.size() == 2) return passed(); else return Failed("testSizeBeanContextMembershipEvent"); }
/** Listener method that is called when a bean is added to * the bean context. * @param bcme event describing the action */ public void childrenAdded (BeanContextMembershipEvent bcme) { InstanceChildren bc = ref.get (); if (bc != null) { bc.updateKeys(); } }
/** Listener method that is called when a bean is removed to * the bean context. * @param bcme event describing the action */ public void childrenRemoved (BeanContextMembershipEvent bcme) { InstanceChildren bc = ref.get (); if (bc != null) { bc.updateKeys (); } }
/** Method for BeanContextMembership interface */ public void childrenRemoved(BeanContextMembershipEvent bcme) { Iterator it = bcme.iterator(); while (it.hasNext()) { findAndUndo(it.next()); } }
/** * BeanContextMembershipListener method. Called when objects have been * removed from the parent BeanContext. If the ToolPanel finds a Tool in the * list,it removes it from the ToolPanel. * * @param bcme the event containing the iterator with removed objects. */ public void childrenRemoved(BeanContextMembershipEvent bcme) { Iterator<Object> it = bcme.iterator(); Object someObj; while (it.hasNext()) { someObj = it.next(); if (someObj instanceof Tool) { // do the initializing that need to be done here Debug.message("toolpanel","ToolPanel removing tool Object"); remove(((Tool) someObj).getKey()); } } }
public void testSerialization() throws IOException,ClassNotFoundException { ArrayList<String> things = new ArrayList<String>(); things.add("1"); things.add("2"); things.add("3"); BeanContextMembershipEvent event = new BeanContextMembershipEvent( new MockBeanContext(),things); event.setPropagatedFrom(new MockBeanContextDelegateS("from ID")); assertEqualsSerially(event,(BeanContextMembershipEvent) SerializationTester .getDeserilizedobject(event)); }
public void testSerialization_Compatibility() throws Exception { ArrayList<String> things = new ArrayList<String>(); things.add("1"); things.add("2"); things.add("3"); BeanContextMembershipEvent event = new BeanContextMembershipEvent( new MockBeanContext(),things); event.setPropagatedFrom(new MockBeanContextDelegateS("from ID")); SerializationTest.verifyGolden(this,event,new SerializableAssert(){ public void assertDeserialized(Serializable orig,Serializable ser) { assertEqualsSerially((BeanContextMembershipEvent) orig,(BeanContextMembershipEvent) ser); } }); }
/** Listener method that is called when a bean is added to * the bean context. * @param bcme event describing the action */ public void childrenAdded (BeanContextMembershipEvent bcme) { InstanceChildren bc = (InstanceChildren)ref.get (); if (bc != null) { bc.updateKeys(); } }
/** Listener method that is called when a bean is removed to * the bean context. * @param bcme event describing the action */ public void childrenRemoved (BeanContextMembershipEvent bcme) { InstanceChildren bc = (InstanceChildren)ref.get (); if (bc != null) { bc.updateKeys (); } }
public void testSerialization() throws IOException,(BeanContextMembershipEvent) SerializationTester .getDeserilizedobject(event)); }
public void testSerialization_Compatibility() throws Exception { ArrayList<String> things = new ArrayList<String>(); things.add("1"); things.add("2"); things.add("3"); BeanContextMembershipEvent event = new BeanContextMembershipEvent( new MockBeanContext(),things); event.setPropagatedFrom(new MockBeanContextDelegateS("from ID")); assertEqualsSerially( event,(BeanContextMembershipEvent) SerializationTester .readobject(event,"serialization/java/beans/beancontext/BeanContextMembershipEvent.ser")); }
public void testSerialization_Compatibility() throws Exception { ArrayList<String> things = new ArrayList<String>(); things.add("1"); things.add("2"); things.add("3"); BeanContextMembershipEvent event = new BeanContextMembershipEvent( new MockBeanContext(),(BeanContextMembershipEvent) ser); } }); }
/** * @see java.beans.beancontext.BeanContextSupport#toArray() */ public Result testtToArrayBeanContextMembershipEvent() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); sBean = new ServiceBean(); // Adding the component context.add(bean); context.add(sBean); event = new BeanContextMembershipEvent(bean.getBeanContext(),context .toArray()); Object[] array; array = new Object[context.size()]; array = event.toArray(); if ((array[0] instanceof BeanContextChildSupport) && (array[1] instanceof BeanContextChildSupport)) { return passed(); } else { return Failed("testtToArrayBeanContextMembershipEvent()"); } }
/** * BeanContextMembershipListener method. Called when a new object is added * to the BeanContext of this object. */ public void childrenAdded(BeanContextMembershipEvent bcme) { if (!isolated || bcme.getBeanContext().equals(getBeanContext())) { findAndInit(bcme.iterator()); } }
/** Method for BeanContextMembership interface */ public void childrenAdded(BeanContextMembershipEvent bcme) { Iterator it = bcme.iterator(); findAndInit(it); }
/** Method for BeanContextMembership interface. */ public void childrenAdded(BeanContextMembershipEvent bcme) { findAndInit(bcme.iterator()); }
/** Method for BeanContextMembership interface. */ public void childrenRemoved(BeanContextMembershipEvent bcme) { findAndUndo(bcme.iterator()); }
/** * BeanContextMembershipListener method. Called when a new object is added * to the BeanContext of this object. */ public void childrenAdded(BeanContextMembershipEvent bcme) { if (!isolated || bcme.getBeanContext().equals(getBeanContext())) { findAndInit(bcme.iterator()); } }
public void childrenAdded(BeanContextMembershipEvent bcme) { lastEventAdd = true; lastEvent = bcme; }
public void childrenRemoved(BeanContextMembershipEvent bcme) { lastEventRemove = true; lastEvent = bcme; }
public void childrenAdded(BeanContextMembershipEvent bcme) { lastEventAdd = true; lastEvent = bcme; }
public void childrenRemoved(BeanContextMembershipEvent bcme) { lastEventRemove = true; lastEvent = bcme; }
public void childrenAdded(BeanContextMembershipEvent bcme) { lastEventAdd = true; lastEvent = bcme; }
public void childrenRemoved(BeanContextMembershipEvent bcme) { lastEventRemove = true; lastEvent = bcme; }
public void childrenAdded(BeanContextMembershipEvent bcme) { lastEventAdd = true; lastEvent = bcme; }
public void childrenRemoved(BeanContextMembershipEvent bcme) { lastEventRemove = true; lastEvent = bcme; }
com.google.common.eventbus.SubscriberExceptionContext的实例源码
public LoadController(Loader loader) { this.loader = loader; this.masterChannel = new EventBus(new SubscriberExceptionHandler() { @Override public void handleException(Throwable exception,SubscriberExceptionContext context) { FMLLog.log("FMLMainChannel",Level.ERROR,exception,"Could not dispatch event: %s to %s",context.getEvent(),context.getSubscriberMethod()); } }); this.masterChannel.register(this); state = LoaderState.NOINIT; packageOwners = ArrayListMultimap.create(); }
@Test public void unhandledExceptionInEventThreadCallsSubscriberExceptionHandler() { SubscriberExceptionHandler handler = mock(SubscriberExceptionHandler.class); EventBus bus = new EventBus(handler); final IllegalStateException exception = new IllegalStateException("Excepted Unhandled Exception"); bus.register(new Object() { @Subscribe public void throwUnhandledException(TriggerUnhandledException event) { throw exception; } }); bus.post(new TriggerUnhandledException()); verify(handler).handleException(eq(exception),any(SubscriberExceptionContext.class)); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { loggers.get(context.getSubscriber().getClass()).log( Level.SEVERE,"Exception dispatching " + context.getEvent().getClass().getName() + " to " + context.getSubscriber().getClass().getName() + "#" + context.getSubscriberMethod().getName(),exception ); }
@Override public void handleException(Throwable throwable,SubscriberExceptionContext subscriberExceptionContext) { String eventName = subscriberExceptionContext.getEvent().getClass().getSimpleName(); Class<?> subscriber = subscriberExceptionContext.getSubscriber().getClass(); LogManager.getLogger(subscriber).error("An error occurred on event " + eventName + " in " + subscriber.getName(),throwable); }
@Subscribe public void buildModList(FMLLoadEvent event) { Builder<String,EventBus> eventBus = ImmutableMap.builder(); for (final ModContainer mod : loader.getModList()) { //Create mod logger,and make the EventBus logger a child of it. EventBus bus = new EventBus(new SubscriberExceptionHandler() { @Override public void handleException(final Throwable exception,final SubscriberExceptionContext context) { LoadController.this.errorOccurred(mod,exception); } }); boolean isActive = mod.registerBus(bus,this); if (isActive) { activeModList.add(mod); modStates.put(mod.getModId(),ModState.UNLOADED); eventBus.put(mod.getModId(),bus); FMLCommonHandler.instance().addModToResourcePack(mod); } else { FMLLog.log(mod.getModId(),Level.WARN,"Mod %s has been disabled through configuration",mod.getModId()); modStates.put(mod.getModId(),ModState.UNLOADED); modStates.put(mod.getModId(),ModState.disABLED); } modNames.put(mod.getModId(),mod.getName()); } eventChannels = eventBus.build(); }
MentorEventBus() { this(Executors.newWorkStealingPool(),new SubscriberExceptionHandler() { @Override public void handleException(Throwable exception,SubscriberExceptionContext context) { Log.error("Error in event handler ({})",context,exception); } }); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { String message = "Event: " + context.getEvent() + "\r\nSubscriber: " + context.getSubscriber() + "\r\nSubscriber method:" + context.getSubscriberMethod(); ErrorHandlerProvider.handle(context.getEventBus().toString(),message,exception); }
@Override public void handleException(final Throwable e,final SubscriberExceptionContext context) { if ((e instanceof ClassCastException) && e.getMessage().contains(PoisonPill.class.getName())) { LOG.debug("Poision Pill processed on: {}",context.getSubscriber().getClass().getSimpleName()); } else { String msg = String.format("Could not call %s/%s on bus %s",context.getSubscriber().getClass().getSimpleName(),context.getSubscriberMethod().getName(),name); LOG.error(msg,e); } }
@Override public void handleException(final Throwable exception,final SubscriberExceptionContext context) { String errmsg = "Could not dispatch event: " + context.getSubscriber() + " to " + context.getSubscriberMethod() + "\n Event: " + context.getEvent() + "\n Bus: " + context.getEventBus(); logger.error(errmsg,exception); }
protected void onSubscriberException(Throwable exception,@Nullable SubscriberExceptionContext exceptionContext) { if (exception instanceof InterruptedException) { logger.log(Level.FINE,"EventBus Subscriber threw InterruptedException",exception); Thread.currentThread().interrupt(); } else { logger.log(Level.SEVERE,"An event subscriber threw an exception",exception); eventBus.post(new UnexpectedThrowableEvent(exception,"An event subscriber threw an " + "exception on thread '" + Thread.currentThread().getName() + "'")); } }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { Class<?> listenerClass = context.getSubscriber().getClass(); String method = context.getSubscriberMethod().getName(); String event = context.getEvent().getClass().getSimpleName(); Logger logger = LoggerFactory.getLogger(listenerClass); logger.error("Error dispatching event '" + event + "' to '" + listenerClass.getSimpleName() + "." + method + "'",exception); }
public EventBusThatPublishesUnhandledExceptionEvents() { super(new SubscriberExceptionHandler() { @Override public void handleException(Throwable throwable,SubscriberExceptionContext subscriberExceptionContext) { postUncaughtExceptionEvent(throwable); } }); errorMessageBus.register(this); }
@Subscribe public void handleException(ExceptionEvent e) { if (log.isErrorEnabled()) { final String format = "当前事件为: %s\n当前订阅者为: %s\n订阅方法为: %s\nEventBus为: %s\n"; String msg = "\n"; log.error("检测到异常 :",e.getException()); msg += "===================================\n"; msg += "异常详细信息:\n"; SubscriberExceptionContext ctx = e.getContext(); if (ctx != null) { msg += String.format(format,ctx.getEvent(),ctx.getSubscriber(),ctx.getSubscriberMethod(),ctx .getEventBus()); } else msg += "无上下文信息.\n"; if (e.getExtra() != null) { msg += String.format("附加信息为: %s \n",e.getExtra()); } else msg += "无附加信息.\n"; msg += "==================================="; log.error(msg); } }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { if (context.getEvent() instanceof ExceptionEvent) { log.error("处理错误过程中发生错误 上下文:" + context,exception); return; } ExceptionEvent event = new ExceptionEvent(exception,context); bus.post(event); }
public AppEventBus() { eventbus = new EventBus(new SubscriberExceptionHandler() { @Override public void handleException(Throwable exception,SubscriberExceptionContext context) { log.error("Could not dispatch event: " + context.getSubscriber() + " to " + context.getSubscriberMethod()); exception.printstacktrace(); } }); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { handleError("error in thread '" + Thread.currentThread().getName() + "' dispatching event to " + context.getSubscriber().getClass() + "." + context.getSubscriberMethod().getName(),exception); }
@Override public void handleException(Throwable thrwbl,SubscriberExceptionContext sec) { com.gmt2001.Console.err.println("Failed to dispatch event " + sec.getEvent().toString() + " to " + sec.getSubscriberMethod().toString()); com.gmt2001.Console.err.printstacktrace(thrwbl); }
@Override public void handleException(Throwable exception,exception); }
@Override public void handleException(Throwable throwable,SubscriberExceptionContext subscriberExceptionContext) { throwable.printstacktrace(); }
@Override public final void handleException(final Throwable exception,final SubscriberExceptionContext context) { exception.printstacktrace(); }
@Override public final void handleException(final Throwable exception,final SubscriberExceptionContext context) { exception.printstacktrace(); }
private static void eventExceptionHandler(Throwable exception,SubscriberExceptionContext context) { log.warn("uncaught exception in event subscriber",exception); }
@Override public void handleException(final Throwable exception,final SubscriberExceptionContext context) { logger.error("Could not dispatch event {} to subscriber {} method [{}]",context.getSubscriber(),context.getSubscriberMethod(),exception); }
@Override public void handleException(Throwable thrwbl,SubscriberExceptionContext sec) { com.gmt2001.Console.err.println("Failed to dispatch event " + sec.getEvent().toString() + " to " + sec.getSubscriberMethod().toString()); com.gmt2001.Console.err.printstacktrace(thrwbl); }
@Override protected void onSubscriberException(Throwable exception,SubscriberExceptionContext exceptionContext) { // Do not call super,we don't want the default functionality subscriberExceptions.add(new SubscriberThrowablePair(exception,exceptionContext)); }
private SubscriberThrowablePair(Throwable exception,SubscriberExceptionContext exceptionContext) { this.exception = checkNotNull(exception,"Throwable cannot be null"); this.exceptionContext = checkNotNull(exceptionContext,"SubscriberExceptionContext cannot " + "be null"); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { logger.error("Hysterix EventBus exception",exception); }
@Override public void handleException(final Throwable e,final SubscriberExceptionContext context) { LOG.error(e,"Could not call %s/%s on bus %s",name); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { throw new TechnicalException(exception); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { logger.log(Level.SEVERE,"Failure in EventBus subscriber",exception); LoggingUtil.logToRemote(Level.SEVERE,"Failure in EventBus subscriber.",exception); }
@Override public void handleException(Throwable exception,SubscriberExceptionContext context) { BugReport.handleCrash(exception); }
public EventBusExceptionEvent (Throwable exception,SubscriberExceptionContext context) { this.exception = exception; this.context = context; }
public ExceptionEvent(Throwable exception,SubscriberExceptionContext context) { this(exception,null); }
public ExceptionEvent(Throwable exception,SubscriberExceptionContext context,Object extra) { this.exception = exception; this.context = context; this.extra = extra; }
java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <http auto-config="true" use-expressions="true"> <intercept-url pattern="/friends/**" access="hasRole('ROLE_USER')" /> <form-login login-page="/login.html" default-target-url="/index.html" always-use-default-target="true" authentication-failure-url="/login.html?authFailed=true" /> </http> <authentication-manager alias="authenticationManager"> <authentication-provider> <jdbc-user-service data-source-ref="dataSource" /> </authentication-provider> </authentication-manager> <beans:bean id="propertyConfigurer"https://www.jb51.cc/tag/fig/" target="_blank">fig.PropertyPlaceholderConfigurer"> <beans:property name="location" value="classpath:jdbc.properties" /> </beans:bean> <beans:bean id="dataSource"> <beans:property name="driverClassName" value="${database.driver}" /> <beans:property name="url" value="${database.url}" /> <beans:property name="username" value="${database.user}" /> <beans:property name="password" value="${database.password}" /> <beans:property name="initialSize" value="5" /> <beans:property name="maxActive" value="10" /> </beans:bean> </beans:beans>
解决方法
如果您的配置文件集中在其中一个扩展名称空间上 – 再次,让我们使用安全性作为示例 – 如果您将默认名称空间声明为扩展名称空间而不是标准bean名称空间,它可以清理该文件.那是什么
xmlns="http://www.springframework.org/schema/security"
确实 – 它使安全性成为默认命名空间,这意味着您不必使用sec:或security:作为前缀.
但是当您将安全性设置为默认值时,则在使用beans命名空间元素时必须明确.因此bean:前缀.
解.如果您更喜欢bean作为默认值,只需将默认命名空间更改为beans:
xmlns="http://www.springframework.org/schema/beans"
替代方案.或者,如果你想输入更短的东西,你可以这样做
xmlns:b="http://www.springframework.org/schema/beans"
代替
xmlns:beans="http://www.springframework.org/schema/beans"
这将允许你做的事情
<b:bean id="beanId"/>
java.beans.beancontext.BeanContextChildSupport的实例源码
public void testFirePropertyChange() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(5); support.addPropertychangelistener(propName,l1); support.addPropertychangelistener("xxx",l2); l1.clearLastEvent(); l2.clearLastEvent(); support.firePropertyChange(propName,oldValue,newValue); assertEquals(propName,l1.lastEvent.getPropertyName()); assertSame(oldValue,l1.lastEvent.getoldValue()); assertSame(newValue,l1.lastEvent.getNewValue()); assertSame(support,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFirePropertyChange_OldEqualsNew() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(1); support.addPropertychangelistener(propName,newValue); assertNull(l1.lastEvent); assertNull(l2.lastEvent); }
public void testFirePropertyChange_OldEqualsNew_IsNull() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = null; Object newValue = null; support.addPropertychangelistener(propName,l1.lastEvent.getPropertyName()); assertNull(l1.lastEvent.getoldValue()); assertNull(l1.lastEvent.getNewValue()); assertSame(support,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFireVetoableChange() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(5); support.addVetoablechangelistener(propName,l1); support.addVetoablechangelistener("xxx",l2); l1.clearLastEvent(); l2.clearLastEvent(); support.fireVetoableChange(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFireVetoableChange_OldEqualsNew() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(1); support.addVetoablechangelistener(propName,newValue); assertNull(l1.lastEvent); assertNull(l2.lastEvent); }
public void testFireVetoableChange_OldEqualsNew_IsNull() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = null; Object newValue = null; support.addVetoablechangelistener(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testSerialization_nopeer() throws IOException,ClassNotFoundException { BeanContextChildSupport support = new BeanContextChildSupport(); MockPropertychangelistener pcl1 = new MockPropertychangelistener(); MockPropertychangelistenerS pcl2 = new MockPropertychangelistenerS( "id of pcl2"); MockVetoablechangelistener vcl1 = new MockVetoablechangelistener(); MockVetoablechangelistenerS vcl2 = new MockVetoablechangelistenerS( "id of vcl2"); support.addPropertychangelistener("beanContext",pcl1); support.addPropertychangelistener("beanContext",pcl2); support.addVetoablechangelistener("beanContext",vcl1); support.addVetoablechangelistener("beanContext",vcl2); assertEqualsSerially(support,(BeanContextChildSupport) SerializationTester .getDeserilizedobject(support)); }
public void testSerialization_WithNonSerializablePeer() throws IOException,ClassNotFoundException { MockBeanContextChild peer = new MockBeanContextChild(); BeanContextChildSupport support = new BeanContextChildSupport(peer); MockPropertychangelistener pcl1 = new MockPropertychangelistener(); MockPropertychangelistenerS pcl2 = new MockPropertychangelistenerS( "id of pcl2"); MockVetoablechangelistener vcl1 = new MockVetoablechangelistener(); MockVetoablechangelistenerS vcl2 = new MockVetoablechangelistenerS( "id of vcl2"); support.addPropertychangelistener("beanContext",vcl2); try { SerializationTester.getDeserilizedobject(support); fail(); } catch (IOException e) { // expected } }
public void testSerialization_WithPeer() throws IOException,ClassNotFoundException { MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS( "id of peer"); BeanContextChildSupport support = peer.support; MockPropertychangelistener pcl1 = new MockPropertychangelistener(); MockPropertychangelistenerS pcl2 = new MockPropertychangelistenerS( "id of pcl2"); MockVetoablechangelistener vcl1 = new MockVetoablechangelistener(); MockVetoablechangelistenerS vcl2 = new MockVetoablechangelistenerS( "id of vcl2"); support.addPropertychangelistener("beanContext",(BeanContextChildSupport) SerializationTester .getDeserilizedobject(support)); }
public void testSerialization_Compatibility() throws IOException,ClassNotFoundException,Exception { MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS( "id of peer"); BeanContextChildSupport support = peer.support; MockPropertychangelistener pcl1 = new MockPropertychangelistener(); MockPropertychangelistenerS pcl2 = new MockPropertychangelistenerS( "id of pcl2"); MockVetoablechangelistener vcl1 = new MockVetoablechangelistener(); MockVetoablechangelistenerS vcl2 = new MockVetoablechangelistenerS( "id of vcl2"); support.addPropertychangelistener("beanContext",vcl2); SerializationTest.verifyGolden(this,support,new SerializableAssert(){ public void assertDeserialized(Serializable orig,Serializable ser) { assertEqualsSerially((BeanContextChildSupport) orig,(BeanContextChildSupport) ser); } }); }
public void testGetChildBeanContextChild_BeanContextChild() { MockBeanContextChild child = new MockBeanContextChild(); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(child); assertSame(child,result); // Regression for HARMONY-1393 class TestBeanException extends BeanContextChildSupport implements BeanContextProxy { private static final long serialVersionUID = -8544245159647566063L; private final BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } TestBeanException bean = new TestBeanException(); try { MockBeanContextSupport.publicGetChildBeanContextChild(bean); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } }
public void testFirePropertyChange() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(5); support.addPropertychangelistener(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFirePropertyChange_OldEqualsNew() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(1); support.addPropertychangelistener(propName,newValue); assertNull(l1.lastEvent); assertNull(l2.lastEvent); }
public void testFirePropertyChange_OldEqualsNew_IsNull() { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockPropertychangelistener l1 = new MockPropertychangelistener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); String propName = "property name"; Object oldValue = null; Object newValue = null; support.addPropertychangelistener(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFireVetoableChange() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(5); support.addVetoablechangelistener(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testFireVetoableChange_OldEqualsNew() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = new Integer(1); Object newValue = new Integer(1); support.addVetoablechangelistener(propName,newValue); assertNull(l1.lastEvent); assertNull(l2.lastEvent); }
public void testFireVetoableChange_OldEqualsNew_IsNull() throws PropertyVetoException { BeanContextChildSupport support = new MockBeanContextChildSupport(); MockVetoablechangelistener l1 = new MockVetoablechangelistener(); MockVetoablechangelistener l2 = new MockVetoablechangelistener(); String propName = "property name"; Object oldValue = null; Object newValue = null; support.addVetoablechangelistener(propName,l1.lastEvent.getSource()); assertNull(l2.lastEvent); }
public void testIsDelegated() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertFalse(support.isDelegated()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertTrue(support.isDelegated()); support.beanContextChildPeer = support; assertFalse(support.isDelegated()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertFalse("Child is not supposed to be delegated",sup.isDelegated()); }
public void testSerialization_nopeer() throws IOException,(BeanContextChildSupport) SerializationTester .getDeserilizedobject(support)); }
public void testSerialization_WithNonSerializablePeer() throws IOException,vcl2); try { SerializationTester.getDeserilizedobject(support); fail(); } catch (IOException e) { // expected } }
public void testSerialization_WithPeer() throws IOException,(BeanContextChildSupport) SerializationTester .getDeserilizedobject(support)); }
public void testSerialization_Compatibility() throws IOException,vcl2); assertEqualsSerially( support,(BeanContextChildSupport) SerializationTester .readobject(support,"serialization/java/beans/beancontext/BeanContextChildSupport.ser")); }
public void testGetChildBeanContextChild_BeanContextChild() { MockBeanContextChild child = new MockBeanContextChild(); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(child); assertSame(child,result); // Regression for HARMONY-1393 class TestBeanException extends BeanContextChildSupport implements BeanContextProxy { private static final long serialVersionUID = -8544245159647566063L; private final BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } TestBeanException bean = new TestBeanException(); try { MockBeanContextSupport.publicGetChildBeanContextChild(bean); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } }
public void testSerialization_Compatibility() throws IOException,(BeanContextChildSupport) ser); } }); }
/** * @see java.beans.beancontext.BeanContextSupport#retainAll(Collection) * @see java.beans.beancontext.BeanContextSupport#iterator() */ public Result testContainsAllBeanContext()throws Exception { bean = new BeanContextChildSupport(); beanWithContext = new BeanWithBeanContext(); subContext = new BeanContextSupport(); vector = new Vector(); // Adding the components context.add(bean); context.add(beanWithContext); context.add(subContext); // Adding the components from bean context to Vector for (int i = 0; i < context.size(); i++) { vector.add(context.iterator().next()); } // It's verified that objects in the specified Vector are children of this bean context if (context.containsAll(vector)) { return passed(); } else { return Failed("testCollectionContainsAll() - Failed "); } }
/** * @see java.beans.beancontext.BeanContextSupport#size() */ public Result testSize() throws Exception { // The BeanContext object to be checked by the test BeanContextSupport contextForSize = new BeanContextSupport(); // Components that should be added to context BeanContextSupport subContext = new BeanContextSupport(); BeanWithBeanContext beanWithContext = new BeanWithBeanContext(); BeanContextChildSupport bean = new BeanContextChildSupport(); // Adding the components contextForSize.add(subContext); contextForSize.add(beanWithContext); contextForSize.add(bean); // It's verified that the BeanContext contains 4 components if (contextForSize.size() == 4) { return passed(); } else { return Failed("testSize() - Failed "); } }
/** * @see java.beans.beancontext.BeanContextSupport#isEmpty() */ public Result testIsContextEmpty() throws Exception { // The BeanContext object to be checked by the test BeanContextSupport context = new BeanContextSupport(); // Components that should be added to context BeanContextSupport subContext = new BeanContextSupport(); BeanWithBeanContext beanWithContext = new BeanWithBeanContext(); BeanContextChildSupport bean = new BeanContextChildSupport(); // Adding the components context.add(subContext); context.add(beanWithContext); context.add(bean); // It's verified that the BeanContext isn't empty if (!context.isEmpty()) { return passed(); } else { return Failed("testIsContextEmpty() - Failed "); } }
/** * @see java.beans.beancontext.BeanContextMembershipEvent */ public Result testNullPointerException1() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); // Adding the component context.add(bean); Object[] array = null; try { event = new BeanContextMembershipEvent(bean.getBeanContext(),array); } catch (java.lang.NullPointerException e) { return passed(); } return Failed("testNullPointerException1"); }
/** * @see java.beans.beancontext.BeanContextMembershipEvent */ public Result testNullPointerException2() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); // Adding the component context.add(bean); Collection[] array = null; try { event = new BeanContextMembershipEvent(bean.getBeanContext(),array); } catch (java.lang.NullPointerException e) { return passed(); } return Failed("testNullPointerException2"); }
/** * @see java.beans.beancontext.BeanContextMembershipEvent#contains() */ public Result testContainsBeanContextMembershipEvent() throws Exception { context = new BeanContextSupport(); bean = new BeanContextChildSupport(); sBean = new ServiceBean(); // Adding the component context.add(bean); context.add(sBean); event = new BeanContextMembershipEvent(bean.getBeanContext(),context .toArray()); if ((event.contains(sBean)) || !(event.contains(context))) return passed(); else return Failed("testContainsBeanContextMembershipEvent"); }
java.beans.beancontext.BeanContextChild的实例源码
private void addComponent(int x,int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector<BeanConnection> associatedConnections = ((MetaBean) m_toolBarBean) .getAssociatedConnections(); BeanConnection.getConnections(m_mainKFPerspective.getCurrentTabIndex()) .addAll(associatedConnections); // ((MetaBean)m_toolBarBean).setXDrop(x); // ((MetaBean)m_toolBarBean).setYDrop(y); ((MetaBean) m_toolBarBean) .addPropertychangelistenersSubFlow(KNowledgeFlowApp.this); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout,m_toolBarBean,x,y,m_mainKFPerspective.getCurrentTabIndex()); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi,true); }
private void addComponent(int x,int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector associatedConnections = ((MetaBean)m_toolBarBean).getAssociatedConnections(); BeanConnection.getConnections(m_mainKFPerspective.getCurrentTabIndex()). addAll(associatedConnections); //((MetaBean)m_toolBarBean).setXDrop(x); //((MetaBean)m_toolBarBean).setYDrop(y); ((MetaBean)m_toolBarBean).addPropertychangelistenersSubFlow(KNowledgeFlowApp.this); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout,m_mainKFPerspective.getCurrentTabIndex()); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi,true); }
private void addComponent(int x,true); }
/** * Layer method,enhanced to check if the PlugIn is interested in being * added to the BeanContext. */ public boolean getAddToBeanContext() { boolean ret = false; if (plugin != null && (plugin instanceof BeanContextChild || plugin instanceof BeanContextMembershipListener)) { if (plugin instanceof AbstractPlugIn) { ret = ((AbstractPlugIn) plugin).getAddToBeanContext(); } else { ret = true; } } else { ret = super.getAddToBeanContext(); } if (Debug.debugging("plugin")) { Debug.output(getName() + ".addToBeanContext is " + ret); } return ret; }
/** * Gets the current BeanContext from itself,if it's been set and the * provided PlugIn wants/can be added to the BeanContext,it assumes it was * and removes it from the BeanContext. */ public void removePlugInFromBeanContext(PlugIn pi) { BeanContext bc = getBeanContext(); if (bc != null && pi != null && (pi instanceof BeanContextChild || (pi instanceof AbstractPlugIn && ((AbstractPlugIn) pi).getAddToBeanContext()))) { // Of course,we don't need all these conditions met to // order the removal,but they are the ones in place that would // cause it to be added,so we don't waste the effort // unless the same conditions are met. bc.remove(pi); } }
public void testAdd_BCC() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); MockVetoablechangelistener l3 = new MockVetoablechangelistener(); support.addBeanContextMembershipListener(l1); support.addPropertychangelistener("children",l2); support.addVetoablechangelistener("children",l3); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize",null); support.records.assertRecord("validatePendingAdd",child,Boolean.TRUE); support.records.assertRecord("createBCSChild",null,support .children().get(child)); support.records.assertRecord("childJustAddedHook",support .children().get(child),null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent,support,child); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertSame(support,child.getBeanContext()); }
public void testGetChildBeanContextChild_BeanContextChild() { MockBeanContextChild child = new MockBeanContextChild(); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(child); assertSame(child,result); // Regression for HARMONY-1393 class TestBeanException extends BeanContextChildSupport implements BeanContextProxy { private static final long serialVersionUID = -8544245159647566063L; private final BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } TestBeanException bean = new TestBeanException(); try { MockBeanContextSupport.publicGetChildBeanContextChild(bean); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } }
private void addComponent(int x,int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector associatedConnections = ((MetaBean) m_toolBarBean) .getAssociatedConnections(); BeanConnection.getConnections().addAll(associatedConnections); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout,y); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi,true); }
public void testIsDelegated() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertFalse(support.isDelegated()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertTrue(support.isDelegated()); support.beanContextChildPeer = support; assertFalse(support.isDelegated()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertFalse("Child is not supposed to be delegated",sup.isDelegated()); }
public void testAdd_BCC() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); MockVetoablechangelistener l3 = new MockVetoablechangelistener(); support.addBeanContextMembershipListener(l1); support.addPropertychangelistener("children",child.getBeanContext()); }
public void testGetChildBeanContextChild_BeanContextChild() { MockBeanContextChild child = new MockBeanContextChild(); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(child); assertSame(child,result); // Regression for HARMONY-1393 class TestBeanException extends BeanContextChildSupport implements BeanContextProxy { private static final long serialVersionUID = -8544245159647566063L; private final BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } TestBeanException bean = new TestBeanException(); try { MockBeanContextSupport.publicGetChildBeanContextChild(bean); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } }
/** * @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"); }
/** * @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,service); } catch (NullPointerException e) { return passed(); } return Failed("testGetServiceException"); }
private void annotateCurrentPosition(final JPDAThread currentThread,final SourcePath sourcePath,final CallStackFrame csf,final String language,final String url,final int lineNumber) { final Runnable updateCurrentAnnotation = new Runnable () { @Override public void run () { // show current line synchronized (currentPCLock) { if (currentPC != null) EditorContextBridge.getContext().removeAnnotation (currentPC); if (csf != null && sourcePath != null && currentThread != null && url != null && lineNumber >= 0) { // annotate current line currentPC = sourcePath.annotate (currentThread,language,url,lineNumber); } else { currentPC = null; } } } }; Propertychangelistener operationsUpdateListener = new Propertychangelistener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (PROP_OPERATIONS_UPDATE.equals(name)) { SwingUtilities.invokelater (updateCurrentAnnotation); } if (PROP_OPERATIONS_SET.equals(name)) { ((BeanContextChild) currentThread).removePropertychangelistener(PROP_OPERATIONS_UPDATE,this); ((BeanContextChild) currentThread).removePropertychangelistener(PROP_OPERATIONS_SET,this); } } }; ((BeanContextChild) currentThread).addPropertychangelistener(PROP_OPERATIONS_UPDATE,operationsUpdateListener); ((BeanContextChild) currentThread).addPropertychangelistener(PROP_OPERATIONS_SET,operationsUpdateListener); SwingUtilities.invokelater (updateCurrentAnnotation); }
private static Children getChildren(Object bean) { if (bean instanceof BeanContext) { return new BeanChildren((BeanContext) bean); } if (bean instanceof BeanContextProxy) { BeanContextChild bch = ((BeanContextProxy) bean).getBeanContextProxy(); if (bch instanceof BeanContext) { return new BeanChildren((BeanContext) bch); } } return Children.LEAF; }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
/** * Gets the current BeanContext from itself,it will be added.. */ public void addplugInToBeanContext(PlugIn pi) { BeanContext bc = getBeanContext(); if (bc != null && pi != null && (pi instanceof BeanContextChild || (pi instanceof AbstractPlugIn && ((AbstractPlugIn) pi).getAddToBeanContext()))) { bc.add(pi); } }
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); } }
/** * @param bcc */ public MockBeanContextChildSupport(BeanContextChild bcc) { super(bcc); assertNull(this.beanContext); assertSame(bcc,this.beanContextChildPeer); assertFalse(this.rejectedSetBCOnce); }
public void testGetBeanContextChildPeer() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertSame(support,support.beanContextChildPeer); assertSame(support,support.getBeanContextChildPeer()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertSame(mockChild,support.beanContextChildPeer); assertSame(mockChild,support.getBeanContextChildPeer()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertEquals(sup,sup.getBeanContextChildPeer()); }
public void testIsDelegated() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertFalse(support.isDelegated()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertTrue(support.isDelegated()); support.beanContextChildPeer = support; assertFalse(support.isDelegated()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertFalse("Child is not supposed to be delegated",sup.isDelegated()); }
public void testAdd_BCP() { MockBeanContextSupport support = new MockBeanContextSupport(); support.waitOnChildInHooks = false; MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); MockVetoablechangelistener l3 = new MockVetoablechangelistener(); support.addBeanContextMembershipListener(l1); support.addPropertychangelistener("children",l3); BeanContextChild childPeer = new MockBeanContextChild(); BeanContextProxy child = new MockBeanContextProxy(childPeer); support.add(child); support.records.assertRecord("initialize",childPeer,support.children().get(child)); support.records.assertRecord("createBCSChild",support.children().get(childPeer)); support.records.assertRecord("childJustAddedHook",null); support.records.assertRecord("childJustAddedHook",support .children().get(childPeer),Arrays .asList(new Object[] { child,childPeer })); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertSame(support,childPeer.getBeanContext()); assertEquals(2,support.size()); }
public void testAdd_Veto() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertychangelistener l2 = new MockPropertychangelistener(); MockVetoablechangelistener l3 = new MockVetoablechangelistener(); support.addBeanContextMembershipListener(l1); support.addPropertychangelistener("children",l3); support.vetoAddRemove = true; BeanContextChild child = new MockBeanContextChild(); try { support.add(child); fail(); } catch (IllegalStateException e) { // expected } support.records.assertRecord("initialize",null); support.records .assertRecord("validatePendingAdd",Boolean.FALSE); support.records.assertEndOfRecords(); assertNull(l1.lastEvent); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertNull(child.getBeanContext()); }
public void testGetChildBeanContextChild_BeanContextProxy() { MockBeanContextChild child = new MockBeanContextChild(); MockBeanContextProxy proxy = new MockBeanContextProxy(child); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(proxy); assertSame(child,result); }
public void testRemoveObject_BCC() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize",child); support.records.clear(); l1.clearLastEvent(); Object bcsChild = support.children().get(child); support.remove(child); support.records.assertRecord("validatePendingRemove",Boolean.TRUE); support.records.assertRecord("childJustRemovedHook",bcsChild,null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventRemove); assertMembershipEvent(l1.lastEvent,child); assertNull(child.getBeanContext()); assertEquals(0,support.size()); }
public void testRemoveObject_Veto() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize",child); support.records.clear(); l1.clearLastEvent(); support.children().get(child); support.vetoAddRemove = true; try { support.remove(child); fail("IllegalStateException expected"); } catch (IllegalStateException e) { // expected } support.records.assertRecord("validatePendingRemove",Boolean.FALSE); support.records.assertEndOfRecords(); assertNull(l1.lastEvent); assertSame(support,child.getBeanContext()); assertEquals(1,support.size()); }
public void testRemoveObjectboolean() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize",child); support.records.clear(); l1.clearLastEvent(); Object bcsChild = support.children().get(child); support.publicRemove(child,false); // don't call child's setBeanContext support.records.assertRecord("validatePendingRemove",child); assertSame(support,child.getBeanContext()); assertEquals(0,support.size()); }
public void testSize() { @SuppressWarnings("serial") class TestBean extends Component implements BeanContextProxy { public BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } // Regression test for HARMONY-1829 BeanContextSupport obj = new BeanContextSupport(); obj.add(new TestBean()); assertEquals(2,obj.size()); }
public Object getService(BeanContextChild child,Object requestor,Class serviceClass,Object serviceSelector,BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { // Auto-generated method stub return null; }
private void integrateFlow(Vector beans,Vector connections) { java.awt.Color bckC = getBackground(); m_bcSupport = new BeanContextSupport(); m_bcSupport.setDesignTime(true); // register this panel as a property change listener with each // bean for (int i = 0; i < beans.size(); i++) { BeanInstance tempB = (BeanInstance) beans.elementAt(i); if (tempB.getBean() instanceof Visible) { ((Visible) (tempB.getBean())).getVisual().addPropertychangelistener( this); // A workaround to account for JPanel's with their default // background colour not being serializable in Apple's JRE ((Visible) (tempB.getBean())).getVisual().setBackground(bckC); ((JComponent) (tempB.getBean())).setBackground(bckC); } if (tempB.getBean() instanceof BeanCommon) { ((BeanCommon) (tempB.getBean())).setLog(m_logPanel); } if (tempB.getBean() instanceof BeanContextChild) { m_bcSupport.add(tempB.getBean()); } } BeanInstance.setBeanInstances(beans,m_beanLayout); BeanConnection.setConnections(connections); m_beanLayout.revalidate(); m_beanLayout.repaint(); }
关于java.beans.beancontext.BeanContextMembershipEvent的实例源码和java.beans.introspection的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于com.google.common.eventbus.SubscriberExceptionContext的实例源码、java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?、java.beans.beancontext.BeanContextChildSupport的实例源码、java.beans.beancontext.BeanContextChild的实例源码等相关内容,可以在本站寻找。
本文标签: