From f911ba985aa7fe0096c386c5be385ac5825ea527 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 16 Jul 2005 00:30:23 +0000 Subject: Initial revision From-SVN: r102074 --- .../java/beans/beancontext/BeanContext.java | 272 ++++++++++++ .../java/beans/beancontext/BeanContextChild.java | 174 ++++++++ .../BeanContextChildComponentProxy.java | 60 +++ .../beans/beancontext/BeanContextChildSupport.java | 381 +++++++++++++++++ .../beancontext/BeanContextContainerProxy.java | 63 +++ .../java/beans/beancontext/BeanContextEvent.java | 110 +++++ .../beancontext/BeanContextMembershipEvent.java | 112 +++++ .../beancontext/BeanContextMembershipListener.java | 70 ++++ .../java/beans/beancontext/BeanContextProxy.java | 65 +++ .../BeanContextServiceAvailableEvent.java | 95 +++++ .../beancontext/BeanContextServiceProvider.java | 138 +++++++ .../BeanContextServiceProviderBeanInfo.java | 60 +++ .../BeanContextServiceRevokedEvent.java | 110 +++++ .../BeanContextServiceRevokedListener.java | 62 +++ .../beans/beancontext/BeanContextServices.java | 216 ++++++++++ .../beancontext/BeanContextServicesListener.java | 56 +++ .../beancontext/BeanContextServicesSupport.java | 300 ++++++++++++++ .../java/beans/beancontext/BeanContextSupport.java | 460 +++++++++++++++++++++ .../classpath/java/beans/beancontext/package.html | 46 +++ 19 files changed, 2850 insertions(+) create mode 100644 libjava/classpath/java/beans/beancontext/BeanContext.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextChild.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextChildComponentProxy.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextChildSupport.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextContainerProxy.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextEvent.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextMembershipEvent.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextMembershipListener.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextProxy.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServiceAvailableEvent.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServiceProvider.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedEvent.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedListener.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServices.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServicesListener.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java create mode 100644 libjava/classpath/java/beans/beancontext/BeanContextSupport.java create mode 100644 libjava/classpath/java/beans/beancontext/package.html (limited to 'libjava/classpath/java/beans/beancontext') diff --git a/libjava/classpath/java/beans/beancontext/BeanContext.java b/libjava/classpath/java/beans/beancontext/BeanContext.java new file mode 100644 index 0000000..3d1be7f --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContext.java @@ -0,0 +1,272 @@ +/* java.beans.beancontext.BeanContext + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.beans.DesignMode; +import java.beans.Visibility; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; + +/** + * Acts as a container for sub-beans and as a sub-bean, + * so that an entire hierarchy of beans can be made up of + * BeanContexts. + *

+ * + * Since I can't sprinkle the Collections interface + * documentation with special information for BeanContext + * implementors, I'll have to document special requirements for + * implementors of those functions here. + *

+ * + * add() or addAll(): + *
+ *

    + *
  1. + * May add any Object into the hierarchy as well as a + * BeanContextChild, BeanContext or + * BeanContextProxy object. + * This way, any Bean can be in the hierarchy. + *
  2. + *
  3. + * Must synchronize on BeanContext.globalHierarchyLock. + *
  4. + *
  5. + * Don't add the Object if it's already there (only once + * per BeanContext). + *
  6. + *
  7. + * If it is a BeanContextChild implementor, call + * setBeanContext() on it. If it's a + * BeanContextProxy implementor, call + * getBeanContextProxy().setBeanContext() on it. + * If setBeanContext() vetoes the change, back out + * all changes so far and throw IllegalStateException. + *
  8. + *
  9. + * If it (or its proxy) implements Visibility, call + * dontUseGui() or okToUseGui() on it, + * depending on whether you (the BeanContext) feel like + * allowing it to use the GUI or not. + *
  10. + *
  11. + * If it implements BeanContextChild or + * BeanContextProxy, register yourself (the + * BeanContext) as both a + * PropertyChangeListener and + * VetoableChangeListener on the "beanContext" + * property (it may also add itself on any other properties it wishes + * to). + *
  12. + *
  13. + * If it is a listener or event source that you (the + * BeanContext) are interested in, you may register + * yourself to it or register it to you. + *
  14. + *
  15. + * Fire a java.beans.beancontext.BeanContextMembershipEvent + * before exiting. addAll() should wait until everything + * is done changing before firing the event (or events) so that if a + * failure occurs, the backing-out process can proceed without any + * events being fired at all. + *
  16. + *
+ *

+ * + * remove() or removeAll(): + *
+ *

    + *
  1. + * Must synchronize on BeanContext.globalHierarchyLock. + *
  2. + *
  3. + * If the specified Object is not a child of this + * BeanContext, just exit without performing any actions. + *
  4. + *
  5. + * Remove the Object from your collection of children. + *
  6. + *
  7. + * If it is a BeanContextChild implementor, call + * setBeanContext(null) on it. If it's a + * BeanContextProxy implementor, call + * getBeanContextProxy().setBeanContext(null) on it. + * If setBeanContext() vetoes the change, back out + * all changes so far and throw IllegalStateException. + *
  8. + *
  9. + * If you registered the Object to listen to you or + * registered yourself as a listener on the Object during + * add() or addAll(), undo the registration + * bycalling the appropriate removeListener() method. + *
  10. + *
  11. + * Fire a java.beans.beancontext.BeanContextMembershipEvent + * before exiting. removeAll() should wait until + * everything is done changing before firing the event (or events) so + * that if a failure occurs, the backing-out process can proceed + * without any events being fired at all. + *
  12. + *
+ *

+ * + * addAll(), removeAll(), + * retainAll() and clear() do not need to be + * implemented, but may be if so desired. + *

+ * + * Similarly, Visibility and DesignMode methods + * should propagate changed values to children that implement interfaces + * of the same name. + *

+ * + * A hierarchy of beans is mainly useful so that different sets of beans + * can be established, each with their own set of resources. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContext + extends Collection, BeanContextChild, Visibility, DesignMode { + + /** + * The global lock on changing any BeanContext hierarchy. + * It kinda sucks that there is only one lock, since there can be + * multiple hierarchies. Oh well, I didn't design, I just code. + *

+ * + * Methods that must (or do) synchronize on the global lock: + *
+ *

+ * @fixme fill in the rest of the methods which use the global lock. + */ + Object globalHierarchyLock = new Object(); + + /** + * Instantiate a Bean using this Bean's ClassLoader + * and this BeanContext as the parent. + *

+ * + * This method exists mainly so that BeanContext + * implementations can perform extra actions on Beans that are + * created within them. + * + * @param beanName the name of the bean to instantiate + * @return the created Bean + * + * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String) + * @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String,java.lang.BeanContext) + * @exception IOException if there is an I/O problem during + * instantiation. + * @exception ClassNotFoundException if a serialized Bean's class + * is not found. + */ + Object instantiateChild(String beanName) + throws IOException, + ClassNotFoundException; + + /** + * Get a resource. The BeanContext will typically + * call ClassLoader.getResource(), but may do it any + * way it wants to. This allows a BeanContext to + * have its own set of resources separate from the rest of the + * system. + *

+ * + * Beans should call this method on their parent rather than the + * associated ClassLoader method. + *

+ * + * I am assuming, but am not entirely sure, that if a + * BeanContext cannot find a resource, its + * responsibility is to call the getResource method + * of its parent BeanContext. + * + * @return a URL to the requested resource. + * @param resourceName the name of the resource requested. + * @param requestor a reference to the child requesting the resource. + * @see java.lang.ClassLoader#getResource(java.lang.String) + */ + URL getResource(String resourceName, BeanContextChild requestor); + + /** + * Get a resource as a stream. The BeanContext will + * typically call ClassLoader.getResourceAsStream(), + * but may do it any way it wants to. This allows a + * BeanContext's children to have their own set of + * resources separate from the rest of the system. + *

+ * + * Beans should call this method on their parent rather than the + * associated ClassLoader method. + *

+ * + * I am assuming, but am not entirely sure, that if a + * BeanContext cannot find a resource, its + * responsibility is to call the getResourceAsStream + * method of its parent BeanContext. + * + * @return the requested resource as a stream. + * @param resourceName the name of the resource requested. + * @param requestor a reference to the child requesting the resource. + * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String) + */ + InputStream getResourceAsStream(String resourceName, BeanContextChild requestor); + + /** + * Add a listener on changes to the membership of this + * BeanContext object. + * @param listener the listener to add. + */ + void addBeanContextMembershipListener(BeanContextMembershipListener listener); + + /** + * Remove a listener on changes to the membership of this + * BeanContext object. + * @param listener the listener to remove. + */ + void removeBeanContextMembershipListener(BeanContextMembershipListener listener); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextChild.java b/libjava/classpath/java/beans/beancontext/BeanContextChild.java new file mode 100644 index 0000000..d1115ef --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextChild.java @@ -0,0 +1,174 @@ +/* java.beans.beancontext.BeanContextChild + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; + +/** + * Beans implement this to get information about the execution environment and + * its services and to be placed in the hierarchy. + *

+ * + * The difference between a BeanContext and a + * BeanContextChild, mainly, is that a + * BeanContext may be a parent. + *

+ * + * BeanContextChild instances will be serialized at some + * point in their life, but you need to make sure your bean context does + * not contain a serializable reference (directly or indirectly) to the + * parent BeanContext, to any of the other + * BeanContexts in the tree, or to any resources obtained + * via the BeanContextServices interface. One way to do this + * is to mark any fields that contain such references as + * transient. Another way is to use a custom serializer. + *

+ * + * If you do not do this, when the BeanContext is serialized, + * all the other BeanContexts and other unnecessary things + * will be serialized along with it. + *

+ * + * Before dying, a BeanContextChild should call + * getBeanContext().remove(this) to detach from the + * hierarchy and exit cleanly. + * + * @author John Keiser + * @since JDK1.2 + * @see java.beans.beancontext.BeanContext + */ + +public interface BeanContextChild { + /** + * Set the parent BeanContext. + *

+ * + * This method is called from BeanContext.add() and + * should not be called directly. + *

+ * + * When this Object is being added to a new BeanContext or moved + * from an old one, a non-null value will be passed in. + *

+ * + * When this Object is being removed from the current + * BeanContext, setBeanContext() will + * receive the parameter null. + *

+ * + * When being removed from the current BeanContext, + * it is the BeanContextChild's responsibility to + * release all services it has obtained. + *

+ * + * This change should generate PropertyChangeEvent + * and VetoableChangeEvents with the property name + * "beanContext". If the change is vetoed, it must re-throw the + * exception and not change anything. In this way, the parent + * BeanContextChild, who has registered himself with + * you, will have a chance to remove this child from its + * collection. + *

+ * + * If the Bean does not wish to change the parent or be removed + * from one, it may throw the PropertyVetoException. + * If you veto a setBeanContext(null) call, then you + * should try your hardest to remedy whatever problem is keeping + * you from being removed from the BeanContext so + * that you can not veto it the next time. + * Otherwise, nasty pathological recursion stuff could occur in + * certain situations. + *

+ * + * If you do veto the change, you must first back out any changes + * you made prior to the veto. Best not to make any such changes + * prior to the veto in the first place. + *

+ * + * This method is called from BeanContext.add() and + * should not be called directly. + * + * @param parent the new parent for the BeanContextChild, + * or null to signify removal from a tree. + * @exception PropertyVetoException if the + * BeanContextChild implementor does not + * wish to have its parent changed. + */ + void setBeanContext(BeanContext parent) + throws PropertyVetoException; + + /** + * Get the parent BeanContext. + * @return the parent BeanContext. + */ + BeanContext getBeanContext(); + + /** + * Add a listener that will be notified when a specific property changes. + * @param prop the name of the property to listen on + * @param listener the listener to listen on the property. + */ + void addPropertyChangeListener(String prop, PropertyChangeListener listener); + + /** + * Remove a listener to a certain property. + * @param prop the name of the property being listened on + * @param listener the listener listening on the property. + */ + void removePropertyChangeListener(String prop, PropertyChangeListener listener); + + /** + * Add a listener that will be notified when a specific property + * change is requested (a PropertyVetoException may be thrown) as + * well as after the change is successfully made. + * + * @param prop the name of the property to listen on + * @param listener the listener to listen on the property. + */ + void addVetoableChangeListener(String prop, VetoableChangeListener listener); + + /** + * Remove a listener to a certain property. + * @param prop the name of the property being listened on + * @param listener the listener listening on the property. + */ + void removeVetoableChangeListener(String prop, VetoableChangeListener listener); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextChildComponentProxy.java b/libjava/classpath/java/beans/beancontext/BeanContextChildComponentProxy.java new file mode 100644 index 0000000..a8d6e34 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextChildComponentProxy.java @@ -0,0 +1,60 @@ +/* java.beans.beancontext.BeanContextChildComponentProxy + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.awt.Component; + +/** + * Interface for BeanContextChilds which wish to associate an + * AWT component with them. The proxy is provided because the + * addPropertyChangeListener() method would conflict with + * Component if you tried to extend. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextChildComponentProxy { + /** + * Get the Component associated with this BeanContextChild. + * @return the Component associated with this + * BeanContextChild. + */ + Component getComponent(); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextChildSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextChildSupport.java new file mode 100644 index 0000000..4444ad7 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextChildSupport.java @@ -0,0 +1,381 @@ +/* java.beans.beancontext.BeanContextChildSupport + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.beans.VetoableChangeSupport; +import java.io.Serializable; + +/** + * Support for creating a BeanContextChild. + * This class contains the most common implementations of the methods in + * the BeanContextChild + * + * @specnote This class is not very well specified. I had to "fill in the + * blanks" in most places with what I thought was reasonable + * behavior. If there are problems, let me know. + * + * @author John Keiser + * @since 1.2 + * @see java.beans.beancontext.BeanContextChild + */ +public class BeanContextChildSupport + implements BeanContextChild, BeanContextServicesListener, Serializable +{ + static final long serialVersionUID = 6328947014421475877L; + + /** + * The peer on which to perform set actions. + * This is here so that this class can be used as a peer. + *

+ * + * When extending this class, this variable will be set to + * this. + */ + public BeanContextChild beanContextChildPeer; + + /** + * The parent BeanContext. + */ + protected transient BeanContext beanContext; + + /** + * If setBeanContext() was vetoed once before, this + * is set to true so that the next time, vetoes will + * be ignored. + */ + protected transient boolean rejectedSetBCOnce; + + /** + * Listeners are registered here and events are fired through here. + */ + protected PropertyChangeSupport pcSupport; + + /** + * Listeners are registered here and events are fired through here. + */ + protected VetoableChangeSupport vcSupport; + + /** + * Create a new BeanContextChildSupport with itself as the peer. + * This is meant to be used when you subclass + * BeanContextChildSupport to create your child. + */ + public BeanContextChildSupport() + { + this (null); + } + + /** + * Create a new BeanContextChildSupport with the specified peer. + * @param peer the peer to use, or null to specify + * this. + */ + public BeanContextChildSupport (BeanContextChild peer) + { + if (peer == null) + { + peer = this; + } + + beanContextChildPeer = peer; + pcSupport = new PropertyChangeSupport (peer); + vcSupport = new VetoableChangeSupport (peer); + } + + /** + * Set the parent BeanContext. + *

+ * + * When this Object is being added to a new BeanContext or moved + * from an old one, a non-null value will be passed in. + *

+ * + * When this Object is being removed from the current + * BeanContext, setBeanContext() will + * receive the parameter null. + *

+ * + * Order of events: + *

    + *
  1. + * If the new BeanContext is the same as the old + * one, nothing happens. + *
  2. + *
  3. + * If the change has not been rejected or vetoed before, call + * validatePendingSetBeanContext(). If this call + * returns false, the change is rejected and a + * PropertyVetoException is thrown. + *
  4. + *
  5. + * If the change has not been rejected or vetoed before, + * VetoableChangeEvents are fired with the name + * "beanContext", using the + * fireVetoableChange() method. If a veto + * occurs, reversion events are fired using the same method, + * the change is rejected, and the veto is rethrown. + *
  6. + *
  7. + * releaseBeanContextResources() is called. + *
  8. + *
  9. + * The change is made. + *
  10. + *
  11. + * PropertyChangeEvents are fired using the + * firePropertyChange() method. + *
  12. + *
  13. + * initializeBeanContextResources() is called. + *
  14. + *
+ *

+ * + * @param newBeanContext the new parent for the + * BeanContextChild, or null to + * signify removal from a tree. + * @exception PropertyVetoException if the + * BeanContextChild implementor does not + * wish to have its parent changed. + */ + public void setBeanContext(BeanContext newBeanContext) + throws PropertyVetoException + { + synchronized (beanContextChildPeer) + { + if (newBeanContext == beanContext) + return; + + if (!rejectedSetBCOnce) + { + if (!validatePendingSetBeanContext (newBeanContext)) + { + rejectedSetBCOnce = true; + throw new PropertyVetoException ("validatePendingSetBeanContext() rejected change", + new PropertyChangeEvent(beanContextChildPeer, "beanContext", beanContext, newBeanContext)); + } + + try + { + fireVetoableChange ("beanContext", beanContext, newBeanContext); + } + catch (PropertyVetoException e) + { + rejectedSetBCOnce = true; + throw e; + } + } + + releaseBeanContextResources (); + + beanContext = newBeanContext; + rejectedSetBCOnce = false; + + firePropertyChange ("beanContext", beanContext, newBeanContext); + + initializeBeanContextResources (); + } + } + + /** + * Get the parent BeanContext. + * @return the parent BeanContext. + */ + public BeanContext getBeanContext() + { + return beanContext; + } + + /** + * Get the peer (or this if there is no peer). + * @return the peer, or this if there is no peer. + */ + public BeanContextChild getBeanContextChildPeer() { + return beanContextChildPeer; + } + + /** + * Determine whether there is a peer. + * This is true iff getBeanContextChildPeer() == this. + * @return whether there is a peer. + */ + public boolean isDelegated() { + return beanContextChildPeer == this; + } + + /** + * Add a listener that will be notified when a specific property changes. + * @param propertyName the name of the property to listen on. + * @param listener the listener to listen on the property. + */ + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcSupport.addPropertyChangeListener(propertyName, listener); + } + + /** + * Remove a listener to a certain property. + * + * @param propertyName the name of the property being listened on. + * @param listener the listener listening on the property. + */ + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcSupport.removePropertyChangeListener(propertyName, listener); + } + + /** + * Add a listener that will be notified when a specific property + * change is requested (a PropertyVetoException may be thrown) as + * well as after the change is successfully made. + * + * @param propertyName the name of the property to listen on. + * @param listener the listener to listen on the property. + */ + public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) { + vcSupport.addVetoableChangeListener(propertyName, listener); + } + + /** + * Remove a listener to a certain property. + * + * @param propertyName the name of the property being listened on + * @param listener the listener listening on the property. + */ + public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener) { + vcSupport.removeVetoableChangeListener(propertyName, listener); + } + + /** + * Fire a property change. + * + * @param propertyName the name of the property that changed + * @param oldVal the old value of the property + * @param newVal the new value of the property + */ + public void firePropertyChange(String propertyName, Object oldVal, Object newVal) { + pcSupport.firePropertyChange(propertyName, oldVal, newVal); + } + + /** + * Fire a vetoable property change. + * + * @param propertyName the name of the property that changed + * @param oldVal the old value of the property + * @param newVal the new value of the property + * @exception PropertyVetoException if the change is vetoed. + */ + public void fireVetoableChange(String propertyName, Object oldVal, Object newVal) + throws PropertyVetoException { + vcSupport.fireVetoableChange(propertyName, oldVal, newVal); + } + + /** + * Called by BeanContextServices.revokeService() to indicate that a service has been revoked. + * If you have a reference to such a service, it should be + * discarded and may no longer function properly. + * getService() will no longer work on the specified + * service class after this event has been fired. + *

+ * + * This method is meant to be overriden. + * BeanContextChildSupport's implementation does + * nothing. + * + * @param event the service revoked event. + * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) + */ + public void serviceRevoked(BeanContextServiceRevokedEvent event) { + } + + /** + * Called by BeanContextServices whenever a service is made available. + *

+ * + * This method is meant to be overriden. + * BeanContextChildSupport's implementation does + * nothing. + * + * @param event the service revoked event, with useful information + * about the new service. + */ + public void serviceAvailable(BeanContextServiceAvailableEvent event) { + } + + /** + * Called by setBeanContext() to determine whether the set should be rejected. + *

+ * + * This method is meant to be overriden. + * BeanContextChildSupport's implementation simply + * returns true. + * + * @param newBeanContext the new parent. + * @return whether to allow the parent to be changed to the new + * value. + */ + public boolean validatePendingSetBeanContext(BeanContext newBeanContext) { + return true; + } + + /** + * Called by setBeanContext() to release resources of a what will soon no longer be the parent. + *

+ * + * This method is meant to be overriden. + * BeanContextChildSupport's implementation does + * nothing. + */ + protected void releaseBeanContextResources() { + } + + /** + * Called by setBeanContext() to grab resources when the parent has been set. + *

+ * + * This method is meant to be overriden. + * BeanContextChildSupport's implementation does + * nothing. + */ + protected void initializeBeanContextResources() { + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextContainerProxy.java b/libjava/classpath/java/beans/beancontext/BeanContextContainerProxy.java new file mode 100644 index 0000000..3df9103 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextContainerProxy.java @@ -0,0 +1,63 @@ +/* java.beans.beancontext.BeanContextContainerProxy + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.awt.Container; + +/** + * Interface for BeanContexts which wish to associate an + * AWT container with them. The proxy is provided because the + * addPropertyChangeListener() and add() methods + * would conflict with Component and Container + * if you tried to extend. + * + * @specnote It is unclear whether anything besides BeanContexts + * are allowed to implement this interface. + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextContainerProxy { + /** + * Get the Container associated with this BeanContext. + * @return the Container associated with this + * BeanContext. + */ + Container getContainer(); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextEvent.java b/libjava/classpath/java/beans/beancontext/BeanContextEvent.java new file mode 100644 index 0000000..f326541 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextEvent.java @@ -0,0 +1,110 @@ +/* java.beans.beancontext.BeanContextEvent + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.EventObject; + +/** + * Generic superclass for events fired by BeanContexts. + * + * @author John Keiser + * @since 1.2 + */ + +public abstract class BeanContextEvent extends EventObject +{ + private static final long serialVersionUID = 7267998073569045052L; + + /** + * The BeanContext that most recently passed this + * event on. + */ + protected BeanContext propagatedFrom; + + /** + * Create a new event, from the specified BeanContext. + * propagatedFrom will be initialized to + * null. + * + * @param source the source of the event. + */ + protected BeanContextEvent(BeanContext source) + { + super(source); + } + + /** + * Get the BeanContext that originated this event. + * @return the originator of this event. + */ + public BeanContext getBeanContext() + { + return (BeanContext)getSource(); + } + + /** + * Get the most recent propagator of this event. + * If this value is null, you have received the event + * straight from the source. + * + * @return the most recent propagator of this event. + */ + public BeanContext getPropagatedFrom() + { + return propagatedFrom; + } + + /** + * Tell whether this event has been propagated. + * @return true iff getPropagatedFrom() != null. + */ + public boolean isPropagated() + { + return propagatedFrom != null; + } + + /** + * Set the most recent propagator of this event. + * @param propagator the most recent propagator of this event. + */ + public void setPropagatedFrom(BeanContext propagator) + { + propagatedFrom = propagator; + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextMembershipEvent.java b/libjava/classpath/java/beans/beancontext/BeanContextMembershipEvent.java new file mode 100644 index 0000000..3176542 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextMembershipEvent.java @@ -0,0 +1,112 @@ +/* java.beans.beancontext.BeanContextMembershipEvent + Copyright (C) 1999, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; + +/** + * Event fired when children are added to or removed from a BeanContext. + * Whether they were added or removed depends entirely on which method + * of the listener interface was called. + * + * @author John Keiser + * @since 1.2 + * @see java.beans.beancontext.BeanContextMembershipListener + */ +public class BeanContextMembershipEvent extends BeanContextEvent { + /** + * The children that were added or removed. + */ + protected Collection children; + + /** + * Create a new membership event. + * @param context the event source. + * @param children the children added to or removed from the source. + */ + public BeanContextMembershipEvent(BeanContext context, Collection children) { + super(context); + this.children = children; + } + + /** + * Create a new membership event. + * @param context the event source. + * @param children the children added to or removed from the source. + */ + public BeanContextMembershipEvent(BeanContext context, Object[] children) { + super(context); + this.children = Arrays.asList(children); + } + + /** + * The number of children removed or added. + * @return the number of children removed or added. + */ + public int size() { + return children.size(); + } + + /** + * An iterator that will step through all the children. + * @return an iterator over all the children. + */ + public Iterator iterator() { + return children.iterator(); + } + + /** + * An array of the children. + * @return an array of the children. + */ + public Object[] toArray() { + return children.toArray(); + } + + /** + * Tell whether the Object is one of the children added or removed. + * @param child the child to check. + * @return whether the Object is added or removed. + */ + public boolean contains(Object child) { + return children.contains(child); + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextMembershipListener.java b/libjava/classpath/java/beans/beancontext/BeanContextMembershipListener.java new file mode 100644 index 0000000..d39c36c --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextMembershipListener.java @@ -0,0 +1,70 @@ +/* java.beans.beancontext.BeanContextMembershipListener + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.EventListener; + +/** + * This is the interface to which BeanContextMembershipEvents are sent. + * This happens when children are added to or removed from a + * BeanContext. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextMembershipListener extends EventListener { + /** + * When beans are added to a BeanContext, + * this method is called to fire the event. + * + * @param event the event, including which children were added. + * @see java.beans.beancontext.BeanContext#add(java.lang.Object) + */ + void childrenAdded(BeanContextMembershipEvent event); + + /** + * When beans are removed from a BeanContext, + * this method is called to fire the event. + * + * @param event the event, including which children were removed. + * @see java.beans.beancontext.BeanContext#remove(java.lang.Object) + */ + void childrenRemoved(BeanContextMembershipEvent event); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextProxy.java b/libjava/classpath/java/beans/beancontext/BeanContextProxy.java new file mode 100644 index 0000000..49dd7a7 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextProxy.java @@ -0,0 +1,65 @@ +/* java.beans.beancontext.BeanContextProxy + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +/** + * Beans that wish to have a BeanContextChild or BeanContext associated with them + * but do not wish to implement those interfaces directly, can implement this interface. + *

+ * + * Don't shoot yourself in the foot: if you already implement + * BeanContextChild, directly or indirectly, the whole + * workings of this package will be unpredictable because it is + * indeterminate as to whether the BeanContextChild is used + * in preference to its proxy or vice versa. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextProxy { + /** + * Return the BeanContextChild associated with this + * Object. + * + * @return the BeanContextChild associated with this + * Object. + */ + BeanContextChild getBeanContextProxy(); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServiceAvailableEvent.java b/libjava/classpath/java/beans/beancontext/BeanContextServiceAvailableEvent.java new file mode 100644 index 0000000..eea10f2 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServiceAvailableEvent.java @@ -0,0 +1,95 @@ +/* java.beans.beancontext.BeanContextServiceAvailableEvent + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.Iterator; + +/** + * Event fired when new services become available through a BeanContextServices. + * + * @author John Keiser + * @since JDK1.2 + * @see java.beans.beancontext.BeanContextServicesListener + */ + +public class BeanContextServiceAvailableEvent extends BeanContextEvent { + /** + * The Class representing the service which is now + * available. + */ + protected Class serviceClass; + + /** + * Create a new service available event. + * @param services the BeanContextServices through + * which the service is available. This is also the source + * of the event. + * @param serviceClass the service class that is now available. + */ + public BeanContextServiceAvailableEvent(BeanContextServices services, Class serviceClass) { + super(services); + this.serviceClass = serviceClass; + } + + /** + * Get the current service selectors of the service class. + * This is identical to getSourceAsBeanContextServices().getCurrentServiceSelectors(getServiceClass()) + * @return the current service selectors of the service class. + */ + public Iterator getCurrentServiceSelectors() { + return getSourceAsBeanContextServices().getCurrentServiceSelectors(serviceClass); + } + + /** + * Get the newly available service class. + * @return the service class. + */ + public Class getServiceClass() { + return serviceClass; + } + + /** + * Get the BeanContextServices through which the new service is available. + * @return the BeanContextServices through which the + * new service is available. + */ + public BeanContextServices getSourceAsBeanContextServices() { + return (BeanContextServices)getSource(); + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServiceProvider.java b/libjava/classpath/java/beans/beancontext/BeanContextServiceProvider.java new file mode 100644 index 0000000..c09b581 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServiceProvider.java @@ -0,0 +1,138 @@ +/* java.beans.beancontext.BeanContextServiceProvider + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.Iterator; + +/** + * An actual factory for services. + *

+ * + * It is the BeanContextServiceProvider's responsibility to + * register itself with whatever BeanContextServices object + * it wishes to provide services through using the + * addService() method. + *

+ * + * If for some reason it can no longer provide services for a particular + * class, this class must invoke + * BeanContextServices.revokeService(serviceClass,this,true) + * for all the places it has registered the service. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextServiceProvider { + /** + * Get a service. + * Called from BeanContextServices.getService(). + * + *

If the requested service class is not available, or if this + * BeanContextServiceProvider chooses not honor the + * request for some reason, then this method will return + * null.

+ * + * This method may throw unchecked exceptions, so watch out. + * + * @param services the BeanContextServices that wants + * to get the service. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param requestor the actual requestor of the service. Only + * weak references to this will be retained, and it will + * never be changed, only queried in a read-only manner. + * @param serviceClass the Class of the service being + * requested. + * @param serviceSelector a parameter to customize the service + * returned with. + * @return an instance of serviceClass (such that + * instanceof serviceClass is true), or + * null. + * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener) + */ + Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector); + + /** + * Release the service. + *

+ * + * Called by BeanContextServices.releaseService(). + *

+ * + * Most BeanContextServiceProviders won't have to do + * anything here. + * + * @param services the BeanContextServices that wants + * to release the service. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param requestor the original requestor of the service. + * @param service the service to relinquish + * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object) + */ + void releaseService(BeanContextServices services, Object requestor, Object service); + + /** + * Get a list of valid service selectors for the specified service class. + * This method is called from + * BeanContextServices.getCurrentServiceSelectors(). + *

+ * + * If the specified service class does not have a finite number of + * valid service selectors, it should return null. + * If it takes a general Integer parameter, for + * example, you may as well return null or the poor + * soul who called this method will be iterating all day. + *

+ * + * If it has no valid service selectors, it should still return an empty + * Iterator. + * + * @param services the BeanContextServices that wants + * to get the service selectors. Only weak references to this will + * be retained, and it will never be changed, only queried + * in a read-only manner. + * @param serviceClass the service class to get selectors for. + * @return a list of valid service selectors for the service + * class, or null. + * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class) + */ + Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java b/libjava/classpath/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java new file mode 100644 index 0000000..690b94e --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServiceProviderBeanInfo.java @@ -0,0 +1,60 @@ +/* java.beans.beancontext.BeanContextServiceProviderBeanInfo + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.beans.BeanInfo; + +/** + * BeanContextServiceProviders implement this to provide information about all of the services they provide. + *

+ * + * This is apparently so that you can import a bunch of services into a + * RAD tool and it will know about all of them and export them to the + * user in a readable manner. + * + * @author John Keiser + * @since JDK1.2 + */ +public interface BeanContextServiceProviderBeanInfo extends BeanInfo { + /** + * Get BeanInfos for all of the service classes of this BeanInfoServiceProvider. + * @return BeanInfos for all provided service classes. + */ + BeanInfo[] getServicesBeanInfo(); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedEvent.java b/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedEvent.java new file mode 100644 index 0000000..dfa2b89 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedEvent.java @@ -0,0 +1,110 @@ +/* java.beans.beancontext.BeanContextServiceRevokedEvent + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +/** + * Event fired when services are revoked from a BeanContextServices. + * + * @author John Keiser + * @since JDK1.2 + * @see java.beans.beancontext.BeanContextServiceRevokedListener + */ + +public class BeanContextServiceRevokedEvent extends BeanContextEvent { + /** + * The Class representing the service which is now + * available. + */ + protected Class serviceClass; + private boolean invalidateRefs; + + /** + * Create a new service revoked event. + * @param services the BeanContextServices through + * which the service was available. This is also the source + * of the event. + * @param serviceClass the service class that is now revoked. + * @param revokeNow whether the revocation is immediate for all + * classes or just a suggestion. + */ + public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) { + super(services); + this.serviceClass = serviceClass; + invalidateRefs = revokeNow; + } + + /** + * Get the revoked service class. + * @return the service class. + */ + public Class getServiceClass() { + return serviceClass; + } + + /** + * Tell whether the revoked service class is the same as the specified class. + * Identical to getServiceClass().equals(c). + * @param c the class to compare. + * @return whether the clases are equal. + */ + public boolean isServiceClass(Class c) { + return serviceClass.equals(c); + } + + /** + * Get the BeanContextServices through which the service was available. + * @return the BeanContextServices through which the + * service was available. + */ + public BeanContextServices getSourceAsBeanContextServices() { + return (BeanContextServices)getSource(); + } + + /** + * Tell whether current instances of the revoked service are usable or not. + * This is determined by whether the service was revoked + * immediately. + * + * @return whether current instances of the revoked service are + * usable. + */ + public boolean isCurrentServiceInvalidNow() { + return invalidateRefs; + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedListener.java b/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedListener.java new file mode 100644 index 0000000..101e6e1 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServiceRevokedListener.java @@ -0,0 +1,62 @@ +/* java.beans.beancontext.BeanContextServiceRevokedListener + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.EventListener; + +/** + * Listens for service revoke events. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextServiceRevokedListener extends EventListener { + /** + * Called by BeanContextServices.revokeService() to indicate that a service has been revoked. + * If you have a reference to such a service, it should be + * discarded and may no longer function properly. + * getService() will no longer work on the specified + * service class after this event has been fired. + * + * @param event the service revoked event. + * @see java.beans.beancontext.BeanContextServices#revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean) + */ + void serviceRevoked(BeanContextServiceRevokedEvent event); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServices.java b/libjava/classpath/java/beans/beancontext/BeanContextServices.java new file mode 100644 index 0000000..cb19503 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServices.java @@ -0,0 +1,216 @@ +/* java.beans.beancontext.BeanContextServices + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.util.Iterator; +import java.util.TooManyListenersException; + +/** + * Allows a BeanContext to provide services to its children. + * + * @specnote it is unclear whether a BeanContextServices + * should delegate unhandled requests to parents. I assume so. + * @author John Keiser + * @since 1.2 + */ + +public interface BeanContextServices + extends BeanContext, BeanContextServicesListener +{ + /** + * Register a service to make it available to others. + * This class may refuse to add the service based on whatever + * information it can gather, including whether the service + * provider is trusted. + * + * @param serviceClass the service class. + * @param provider the factory that will actually provide the service. + * @return whether the service was added or not. + */ + boolean addService (Class serviceClass, + BeanContextServiceProvider provider); + + /** + * Make it so that no one else can use this service. + *

+ * + * If revokeNow is false, the only + * effect of this method is to make all subsequent calls to + * getService() on this service class fail. + *

+ * + * If it is true, a message is also sent out to all + * listeners on the service and all references to it are released. + * + * @param serviceClass the service class to revoke. + * @param provider the service provider providing the service class. + * @param revokeNow whether to release all current references to + * the service. + */ + void revokeService (Class serviceClass, + BeanContextServiceProvider provider, + boolean revokeNow); + + /** + * Release your copy of this service. + *

+ * + * If all copies of the service's class have been relinquished by + * the requestor, the BeanContextServiceRevokedListener + * previously registered by getService() will be + * unregistered. + * + * @param requestorChild the original BeanContextChild + * requesting the service. + * @param requestor the original requestor of the service. + * @param service the service to relinquish + * @see #getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener) + */ + void releaseService (BeanContextChild requestorChild, Object requestor, + Object service); + + /** + * Get a service from this BeanContextServices. + *

+ * + * The specified listener will be registered to receive a + * revocation notice for the specified serviceClass. One + * notification per service class per requestor object will be + * sent. + *

+ * + * The listener will be unregistered when all services that were + * obtained by that requestor for that service class are released. + *

+ * + * If the requested service class is not available, or if this + * BeanContextServices object chooses not honor the + * request because the service class has been revoked or for some + * other reason, then this method will return null. + *

+ * + * This method may throw unchecked exceptions, so watch out. + * + * @specnote it is not specified what happens when two subsequent + * calls are made to getService() with the + * same requestor object and service class but different + * listeners. Which listener is to be notified? + * + * @param requestorChild the BeanContextChild + * associated with the requestor. Typically this will be + * the same as the requestor itself, but since any + * Object, even one outside the hierarchy, may + * make a request, this parameter is necessary. Only weak + * references to this will be retained, and it will never + * be changed, only queried in a read-only manner. + * @param requestor the actual requestor of the service. Only + * weak references to this will be retained, and it will + * never be changed, only queried in a read-only manner. + * @param serviceClass the Class of the service being + * requested. + * @param serviceSelector a parameter to customize the service + * returned with. + * @param listener a listener that will be notified if the service + * being requested is revoked. + * @return an instance of serviceClass (such that + * instanceof serviceClass is true), or + * null. + */ + Object getService (BeanContextChild requestorChild, Object requestor, + Class serviceClass, Object serviceSelector, + BeanContextServiceRevokedListener listener) + throws TooManyListenersException; + + /** + * Get a list of all service classes supported. + *

+ * + * This method must synchronize on + * BeanContext.globalHierarchyLock. + * + * @return a list of all service classes supported. + * @see java.beans.beancontext.BeanContext#globalHierarchyLock + */ + Iterator getCurrentServiceClasses (); + + /** + * Get a list of valid service selectors for the specified service class. + *

+ * + * If the specified service class does not have a finite number of + * valid service selectors, it should return null. + * If it takes a general Integer parameter, for + * example, you may as well return null or the poor + * soul who called this method will be iterating all day. + *

+ * + * If it has no valid service selectors, it should still return an empty + * Iterator. + * + * @param serviceClass the service class to get selectors for. + * @return a list of valid service selectors for the service + * class, or null. + */ + Iterator getCurrentServiceSelectors (Class serviceClass); + + /** + * Tell whether the specified service class is available. + * Iff getService() could return a non-null value for the + * specified service, this method will return true. + * + * @param serviceClass the service class to check on. + * @return whether the specified service class is available. + */ + boolean hasService (Class serviceClass); + + /** + * Add a listener on all adds and removes of services. + * @param listener the listener to add. + */ + void addBeanContextServicesListener (BeanContextServicesListener listener); + + /** + * Remove a listener on all adds and removes of services. + * @specnote it is not certain whether this should remove this + * listener if it was specified in + * getService(). + * @param listener the listener to add. + */ + void removeBeanContextServicesListener (BeanContextServicesListener listener); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServicesListener.java b/libjava/classpath/java/beans/beancontext/BeanContextServicesListener.java new file mode 100644 index 0000000..becc7cd --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServicesListener.java @@ -0,0 +1,56 @@ +/* java.beans.beancontext.BeanContextServicesListener + Copyright (C) 1999 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +/** + * Listens for service add and revoke events. + * + * @author John Keiser + * @since JDK1.2 + */ + +public interface BeanContextServicesListener extends BeanContextServiceRevokedListener { + /** + * Called by BeanContextServices whenever a service is made available. + * + * @param event the service revoked event, with useful information + * about the new service. + */ + void serviceAvailable(BeanContextServiceAvailableEvent event); +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java new file mode 100644 index 0000000..b7c4a49 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java @@ -0,0 +1,300 @@ +/* BeanContextServicesSupport.java -- + Copyright (C) 2003, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Locale; +import java.util.TooManyListenersException; + +/** + * @author Michael Koch + * @since 1.2 + */ +public class BeanContextServicesSupport + extends BeanContextSupport + implements BeanContextServices +{ + private static final long serialVersionUID = -8494482757288719206L; + + protected class BCSSChild + extends BeanContextSupport.BCSChild + { + private static final long serialVersionUID = -6848044915271367103L; + } + + protected class BCSSProxyServiceProvider + implements BeanContextServiceProvider, + BeanContextServiceRevokedListener + { + private static final long serialVersionUID = 7078212910685744490L; + + public Iterator getCurrentServiceSelectors (BeanContextServices bcs, + Class serviceClass) + { + throw new Error ("Not implemented"); + } + + public Object getService (BeanContextServices bcs, + Object requestor, + Class serviceClass, + Object serviceSelector) + { + throw new Error ("Not implemented"); + } + + public void releaseService (BeanContextServices bcs, + Object requestor, + Object service) + { + throw new Error ("Not implemented"); + } + + public void serviceRevoked (BeanContextServiceRevokedEvent bcsre) + { + throw new Error ("Not implemented"); + } + } + + protected static class BCSSServiceProvider + implements Serializable + { + private static final long serialVersionUID = 861278251667444782L; + + protected BeanContextServiceProvider serviceProvider; + + protected BeanContextServiceProvider getServiceProvider() + { + return serviceProvider; + } + } + + protected transient ArrayList bcsListeners; + + protected transient BCSSProxyServiceProvider proxy; + + protected transient int serializable; + + protected transient HashMap services; + + public BeanContextServicesSupport () + { + super(); + } + + public BeanContextServicesSupport (BeanContextServices peer) + { + super(peer); + } + + public BeanContextServicesSupport(BeanContextServices peer, Locale locale) + { + super(peer, locale); + } + + public BeanContextServicesSupport(BeanContextServices peer, Locale locale, + boolean dtime) + { + super(peer, locale, dtime); + } + + public BeanContextServicesSupport(BeanContextServices peer, Locale locale, + boolean dtime, boolean visible) + { + super(peer, locale, dtime, visible); + } + + public void addBeanContextServicesListener + (BeanContextServicesListener listener) + { + if (! bcsListeners.contains(listener)) + bcsListeners.add(listener); + } + + public boolean addService (Class serviceClass, BeanContextServiceProvider bcsp) + { + throw new Error ("Not implemented"); + } + + protected boolean addService (Class serviceClass, + BeanContextServiceProvider bcsp, + boolean fireEvent) + { + throw new Error ("Not implemented"); + } + + protected void bcsPreDeserializationHook (ObjectInputStream ois) + throws ClassNotFoundException, IOException + { + throw new Error ("Not implemented"); + } + + protected void bcsPreSerializationHook (ObjectOutputStream oos) + throws IOException + { + throw new Error ("Not implemented"); + } + + protected void childJustRemovedHook (Object child, + BeanContextSupport.BCSChild bcsc) + { + throw new Error ("Not implemented"); + } + + protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, + Object peer) + { + throw new Error ("Not implemented"); + } + + protected BeanContextServicesSupport.BCSSServiceProvider + createBCSSServiceProvider (Class sc, BeanContextServiceProvider bcsp) + { + throw new Error ("Not implemented"); + } + + protected final void fireServiceAdded (BeanContextServiceAvailableEvent bcssae) + { + throw new Error ("Not implemented"); + } + + protected final void fireServiceAdded (Class serviceClass) + { + throw new Error ("Not implemented"); + } + + protected final void fireServiceRevoked(BeanContextServiceRevokedEvent event) + { + throw new Error ("Not implemented"); + } + + protected final void fireServiceRevoked (Class serviceClass, + boolean revokeNow) + { + throw new Error ("Not implemented"); + } + + public BeanContextServices getBeanContextServicesPeer () + { + throw new Error ("Not implemented"); + } + + protected static final BeanContextServicesListener + getChildBeanContextServicesListener (Object child) + { + throw new Error ("Not implemented"); + } + + public Iterator getCurrentServiceClasses () + { + throw new Error ("Not implemented"); + } + + public Iterator getCurrentServiceSelectors (Class serviceClass) + { + throw new Error ("Not implemented"); + } + + public Object getService (BeanContextChild child, Object requestor, + Class serviceClass, Object serviceSelector, + BeanContextServiceRevokedListener bcsrl) + throws TooManyListenersException + { + throw new Error ("Not implemented"); + } + + public boolean hasService (Class serviceClass) + { + throw new Error ("Not implemented"); + } + + public void initialize () + { + super.initialize(); + + bcsListeners = new ArrayList(); + services = new HashMap(); + } + + protected void initializeBeanContextResources () + { + throw new Error ("Not implemented"); + } + + protected void releaseBeanContextResources () + { + throw new Error ("Not implemented"); + } + + public void releaseService (BeanContextChild child, Object requestor, + Object service) + { + throw new Error ("Not implemented"); + } + + public void removeBeanContextServicesListener + (BeanContextServicesListener listener) + { + int index = bcsListeners.indexOf(listener); + + if (index > -1) + bcsListeners.remove(index); + } + + public void revokeService (Class serviceClass, BeanContextServiceProvider bcsp, + boolean revokeCurrentServicesNow) + { + throw new Error ("Not implemented"); + } + + public void serviceAvailable (BeanContextServiceAvailableEvent bcssae) + { + throw new Error ("Not implemented"); + } + + public void serviceRevoked (BeanContextServiceRevokedEvent bcssre) + { + throw new Error ("Not implemented"); + } +} diff --git a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java new file mode 100644 index 0000000..7e024e2 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java @@ -0,0 +1,460 @@ +/* BeanContextSupport.java -- + Copyright (C) 2003, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.beans.beancontext; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.beans.Visibility; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Locale; + +/** + * @author Michael Koch + * @since 1.2 + */ +public class BeanContextSupport extends BeanContextChildSupport + implements BeanContext, Serializable, PropertyChangeListener, + VetoableChangeListener +{ + private static final long serialVersionUID = -4879613978649577204L; + + private void readObject (ObjectInputStream s) + throws ClassNotFoundException, IOException + { + throw new Error ("Not implemented"); + } + + private void writeObject (ObjectOutputStream s) + throws ClassNotFoundException, IOException + { + throw new Error ("Not implemented"); + } + + protected class BCSChild implements Serializable + { + private static final long serialVersionUID = 3289144128843950629L; + } + + protected static final class BCSIterator implements Iterator + { + public boolean hasNext () + { + throw new Error ("Not implemented"); + } + + public Object next () + { + throw new Error ("Not implemented"); + } + + public void remove () + { + // This must be a noop remove operation. + } + } + + protected transient ArrayList bcmListeners; + + protected transient HashMap children; + + protected transient boolean designTime; + + protected transient Locale locale; + + protected transient boolean okToUseGui; + + /** + * Construct a BeanContextSupport instance. + */ + public BeanContextSupport () + { + this (null, null, true, true); + } + + /** + * Construct a BeanContextSupport instance. + */ + public BeanContextSupport (BeanContext peer) + { + this (peer, null, true, true); + } + + /** + * Construct a BeanContextSupport instance. + */ + public BeanContextSupport (BeanContext peer, Locale lcle) + { + this (peer, lcle, true, true); + } + + /** + * Construct a BeanContextSupport instance. + */ + public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime) + { + this (peer, lcle, dtime, true); + } + + /** + * Construct a BeanContextSupport instance. + */ + public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime, + boolean visible) + { + locale = lcle; + designTime = dtime; + okToUseGui = visible; + + initialize (); + } + + public boolean add (Object targetChild) + { + if (targetChild == null) + throw new IllegalArgumentException(); + + if (children.containsKey(targetChild)) + return false; + + // FIXME: The second argument is surely wrong. + children.put(targetChild, targetChild); + return true; + } + + public boolean addAll (Collection c) + { + throw new UnsupportedOperationException(); + } + + public void addBeanContextMembershipListener + (BeanContextMembershipListener listener) + { + if (! bcmListeners.contains(listener)) + bcmListeners.add(listener); + } + + public boolean avoidingGui () + { + throw new Error ("Not implemented"); + } + + protected Iterator bcsChildren () + { + throw new Error ("Not implemented"); + } + + protected void bcsPreDeserializationHook (ObjectInputStream ois) + throws ClassNotFoundException, IOException + { + throw new Error ("Not implemented"); + } + + protected void bcsPreSerializationHook (ObjectOutputStream oos) + throws IOException + { + throw new Error ("Not implemented"); + } + + protected void childDeserializedHook (Object child, BeanContextSupport.BCSChild bcsc) + { + throw new Error ("Not implemented"); + } + + protected void childJustAddedHook (Object child, BeanContextSupport.BCSChild bcsc) + { + throw new Error ("Not implemented"); + } + + protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc) + { + throw new Error ("Not implemented"); + } + + protected static final boolean classEquals (Class first, Class second) + { + throw new Error ("Not implemented"); + } + + public void clear () + { + throw new UnsupportedOperationException(); + } + + public boolean contains (Object o) + { + throw new Error ("Not implemented"); + } + + public boolean containsAll (Collection c) + { + throw new Error ("Not implemented"); + } + + public boolean containsKey (Object o) + { + throw new Error ("Not implemented"); + } + + protected final Object[] copyChildren () + { + throw new Error ("Not implemented"); + } + + protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer) + { + throw new Error ("Not implemented"); + } + + protected final void deserialize (ObjectInputStream ois, Collection coll) + throws ClassNotFoundException, IOException + { + throw new Error ("Not implemented"); + } + + public void dontUseGui () + { + throw new Error ("Not implemented"); + } + + protected final void fireChildrenAdded (BeanContextMembershipEvent bcme) + { + throw new Error ("Not implemented"); + } + + protected final void fireChildrenRemoved (BeanContextMembershipEvent bcme) + { + throw new Error ("Not implemented"); + } + + public BeanContext getBeanContextPeer () + { + throw new Error ("Not implemented"); + } + + protected static final BeanContextChild getChildBeanContextChild (Object child) + { + throw new Error ("Not implemented"); + } + + protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child) + { + throw new Error ("Not implemented"); + } + + protected static final PropertyChangeListener getChildPropertyChangeListener (Object child) + { + throw new Error ("Not implemented"); + } + + protected static final Serializable getChildSerializable (Object child) + { + throw new Error ("Not implemented"); + } + + protected static final VetoableChangeListener getChildVetoableChangeListener (Object child) + { + throw new Error ("Not implemented"); + } + + protected static final Visibility getChildVisibility (Object child) + { + throw new Error ("Not implemented"); + } + + public Locale getLocale () + { + return locale; + } + + public URL getResource (String name, BeanContextChild bcc) + { + throw new Error ("Not implemented"); + } + + public InputStream getResourceAsStream (String name, BeanContextChild bcc) + { + throw new Error ("Not implemented"); + } + + protected void initialize () + { + bcmListeners = new ArrayList(); + children = new HashMap(); + } + + public Object instantiateChild (String beanName) + throws IOException, ClassNotFoundException + { + throw new Error ("Not implemented"); + } + + public boolean isDesignTime () + { + throw new Error ("Not implemented"); + } + + public boolean isEmpty () + { + throw new Error ("Not implemented"); + } + + public boolean isSerializing () + { + throw new Error ("Not implemented"); + } + + public Iterator iterator () + { + return children.keySet().iterator(); + } + + public boolean needsGui () + { + throw new Error ("Not implemented"); + } + + public void okToUseGui () + { + throw new Error ("Not implemented"); + } + + public void propertyChange (PropertyChangeEvent pce) + { + throw new Error ("Not implemented"); + } + + public final void readChildren (ObjectInputStream ois) + throws IOException, ClassNotFoundException + { + throw new Error ("Not implemented"); + } + + public boolean remove (Object targetChild) + { + return remove(targetChild, true); + } + + protected boolean remove (Object targetChild, boolean callChildSetBC) + { + if (targetChild == null) + throw new IllegalArgumentException(); + + throw new Error ("Not implemented"); + } + + public boolean removeAll (Collection c) + { + throw new UnsupportedOperationException(); + } + + public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml) + { + throw new Error ("Not implemented"); + } + + public boolean retainAll (Collection c) + { + throw new UnsupportedOperationException(); + } + + protected final void serialize (ObjectOutputStream oos, Collection coll) + throws IOException + { + throw new Error ("Not implemented"); + } + + public void setDesignTime (boolean dtime) + { + throw new Error ("Not implemented"); + } + + public void setLocale (Locale newLocale) + throws PropertyVetoException + { + throw new Error ("Not implemented"); + } + + public int size () + { + throw new Error ("Not implemented"); + } + + public Object[] toArray () + { + return children.keySet().toArray(); + } + + public Object[] toArray(Object[] array) + { + return children.keySet().toArray(array); + } + + protected boolean validatePendingAdd (Object targetChild) + { + throw new Error ("Not implemented"); + } + + protected boolean validatePendingRemove (Object targetChild) + { + throw new Error ("Not implemented"); + } + + public void vetoableChange (PropertyChangeEvent pce) + throws PropertyVetoException + { + throw new Error ("Not implemented"); + } + + public final void writeChildren (ObjectOutputStream oos) + throws IOException + { + throw new Error ("Not implemented"); + } +} diff --git a/libjava/classpath/java/beans/beancontext/package.html b/libjava/classpath/java/beans/beancontext/package.html new file mode 100644 index 0000000..55e3bd7 --- /dev/null +++ b/libjava/classpath/java/beans/beancontext/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - java.beans.beancontext + + +

Containers and execution environments for beans.

+ + + -- cgit v1.1