|
From: <ls...@us...> - 2007-01-07 08:32:01
|
Revision: 3011
http://jnode.svn.sourceforge.net/jnode/?rev=3011&view=rev
Author: lsantha
Date: 2007-01-07 00:31:59 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/applet/AppletContext.java
trunk/core/src/classpath/java/java/beans/BeanDescriptor.java
trunk/core/src/classpath/java/java/beans/Beans.java
trunk/core/src/classpath/java/java/beans/DefaultPersistenceDelegate.java
trunk/core/src/classpath/java/java/beans/DesignMode.java
trunk/core/src/classpath/java/java/beans/Encoder.java
trunk/core/src/classpath/java/java/beans/EventHandler.java
trunk/core/src/classpath/java/java/beans/EventSetDescriptor.java
trunk/core/src/classpath/java/java/beans/FeatureDescriptor.java
trunk/core/src/classpath/java/java/beans/IndexedPropertyDescriptor.java
trunk/core/src/classpath/java/java/beans/Introspector.java
trunk/core/src/classpath/java/java/beans/PersistenceDelegate.java
trunk/core/src/classpath/java/java/beans/PropertyDescriptor.java
trunk/core/src/classpath/java/java/beans/PropertyEditorManager.java
trunk/core/src/classpath/java/java/beans/SimpleBeanInfo.java
trunk/core/src/classpath/java/java/beans/Statement.java
trunk/core/src/classpath/java/java/beans/XMLEncoder.java
trunk/core/src/classpath/java/java/beans/beancontext/BeanContextServicesSupport.java
trunk/core/src/classpath/java/java/beans/beancontext/BeanContextSupport.java
trunk/core/src/classpath/java/java/lang/Math.java
trunk/core/src/classpath/java/java/lang/String.java
trunk/core/src/classpath/java/java/lang/instrument/ClassDefinition.java
trunk/core/src/classpath/java/java/lang/instrument/ClassFileTransformer.java
trunk/core/src/classpath/java/java/lang/ref/Reference.java
trunk/core/src/classpath/java/java/lang/ref/ReferenceQueue.java
trunk/core/src/classpath/java/java/sql/Array.java
trunk/core/src/classpath/java/java/sql/CallableStatement.java
trunk/core/src/classpath/java/java/sql/Connection.java
trunk/core/src/classpath/java/java/sql/DriverManager.java
trunk/core/src/classpath/java/java/sql/Ref.java
trunk/core/src/classpath/java/java/sql/ResultSet.java
trunk/core/src/classpath/java/java/sql/Struct.java
trunk/core/src/classpath/java/java/sql/Timestamp.java
trunk/core/src/classpath/java/java/text/AttributedCharacterIterator.java
trunk/core/src/classpath/java/java/text/AttributedString.java
trunk/core/src/classpath/java/java/text/AttributedStringIterator.java
trunk/core/src/classpath/java/java/text/Bidi.java
trunk/core/src/classpath/java/java/text/BreakIterator.java
trunk/core/src/classpath/java/java/text/CollationKey.java
trunk/core/src/classpath/java/java/text/Collator.java
trunk/core/src/classpath/java/java/text/DateFormatSymbols.java
trunk/core/src/classpath/java/java/text/DecimalFormat.java
trunk/core/src/classpath/java/java/text/DecimalFormatSymbols.java
trunk/core/src/classpath/java/java/text/MessageFormat.java
trunk/core/src/classpath/java/java/text/NumberFormat.java
trunk/core/src/classpath/java/java/util/AbstractCollection.java
trunk/core/src/classpath/java/java/util/AbstractMap.java
trunk/core/src/classpath/java/java/util/Arrays.java
trunk/core/src/classpath/java/java/util/Calendar.java
trunk/core/src/classpath/java/java/util/Collections.java
trunk/core/src/classpath/java/java/util/Currency.java
trunk/core/src/classpath/java/java/util/Date.java
trunk/core/src/classpath/java/java/util/Formatter.java
trunk/core/src/classpath/java/java/util/IdentityHashMap.java
trunk/core/src/classpath/java/java/util/LinkedList.java
trunk/core/src/classpath/java/java/util/ListResourceBundle.java
trunk/core/src/classpath/java/java/util/Locale.java
trunk/core/src/classpath/java/java/util/PriorityQueue.java
trunk/core/src/classpath/java/java/util/PropertyResourceBundle.java
trunk/core/src/classpath/java/java/util/ResourceBundle.java
trunk/core/src/classpath/java/java/util/StringTokenizer.java
trunk/core/src/classpath/java/java/util/TreeMap.java
trunk/core/src/classpath/java/java/util/TreeSet.java
trunk/core/src/classpath/java/java/util/UUID.java
trunk/core/src/classpath/java/java/util/Vector.java
trunk/core/src/classpath/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
trunk/core/src/classpath/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
trunk/core/src/classpath/java/java/util/logging/LogManager.java
Added Paths:
-----------
trunk/core/src/classpath/java/java/util/ServiceConfigurationError.java
trunk/core/src/classpath/java/java/util/ServiceLoader.java
Modified: trunk/core/src/classpath/java/java/applet/AppletContext.java
===================================================================
--- trunk/core/src/classpath/java/java/applet/AppletContext.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/applet/AppletContext.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -52,7 +52,7 @@
*
* @author Aaron M. Renn (ar...@ur...)
* @since 1.0
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public interface AppletContext
{
@@ -90,7 +90,7 @@
*
* @return a list of all the applets
*/
- Enumeration getApplets();
+ Enumeration<Applet> getApplets();
/**
* Displays the web page pointed to by the specified URL in the window
@@ -150,5 +150,5 @@
* @return an iterator over the association keys
* @since 1.4
*/
- Iterator getStreamKeys();
+ Iterator<String> getStreamKeys();
} // interface AppletContext
Modified: trunk/core/src/classpath/java/java/beans/BeanDescriptor.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/BeanDescriptor.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/BeanDescriptor.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -48,14 +48,14 @@
**/
public class BeanDescriptor extends FeatureDescriptor {
- Class beanClass;
- Class customizerClass;
+ Class<?> beanClass;
+ Class<?> customizerClass;
/** Create a new BeanDescriptor with the given beanClass and
** no customizer class.
** @param beanClass the class of the Bean.
**/
- public BeanDescriptor(Class beanClass) {
+ public BeanDescriptor(Class<?> beanClass) {
this(beanClass,null);
}
@@ -64,7 +64,7 @@
** @param beanClass the class of the Bean.
** @param customizerClass the class of the Bean's Customizer.
**/
- public BeanDescriptor(Class beanClass, Class customizerClass) {
+ public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) {
this.beanClass = beanClass;
this.customizerClass = customizerClass;
@@ -78,12 +78,12 @@
}
/** Get the Bean's class. **/
- public Class getBeanClass() {
+ public Class<?> getBeanClass() {
return beanClass;
}
/** Get the Bean's customizer's class. **/
- public Class getCustomizerClass() {
+ public Class<?> getCustomizerClass() {
return customizerClass;
}
}
Modified: trunk/core/src/classpath/java/java/beans/Beans.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/Beans.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/Beans.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -295,7 +295,7 @@
* @return the Bean as a new view, or if the operation
* could not be performed, the Bean itself.
*/
- public static Object getInstanceOf(Object bean, Class newClass)
+ public static Object getInstanceOf(Object bean, Class<?> newClass)
{
return bean;
}
@@ -314,7 +314,7 @@
* @return whether the Bean can be cast to the class type
* in question.
*/
- public static boolean isInstanceOf(Object bean, Class newBeanClass)
+ public static boolean isInstanceOf(Object bean, Class<?> newBeanClass)
{
return newBeanClass.isInstance(bean);
}
Modified: trunk/core/src/classpath/java/java/beans/DefaultPersistenceDelegate.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/DefaultPersistenceDelegate.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/DefaultPersistenceDelegate.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -154,8 +154,8 @@
return new Expression(oldInstance, oldInstance.getClass(), "new", args);
}
- protected void initialize(Class type, Object oldInstance, Object newInstance,
- Encoder out)
+ protected void initialize(Class<?> type, Object oldInstance,
+ Object newInstance, Encoder out)
{
// Calling the supertype's implementation of initialize makes it
// possible that descendants of classes like AbstractHashMap
Modified: trunk/core/src/classpath/java/java/beans/DesignMode.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/DesignMode.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/DesignMode.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -1,5 +1,5 @@
/* java.beans.DesignMode
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,8 @@
package java.beans;
/**
- * <code>BeanContextChild</code> implementors implement this to get information about whether they are in a design time or runtime environment.
+ * <code>BeanContextChild</code> implementors implement this to get information
+ * about whether they are in a design time or runtime environment.
* The reason this is restricted to <code>BeanContextChild</code>ren is that
* only things in the <code>BeanContext</code> hierarchy are given this
* information in the first place.
@@ -48,11 +49,11 @@
* @since JDK1.2
* @see java.beans.beancontext.BeanContextChild
*/
+public interface DesignMode
+{
-public interface DesignMode {
/**
* Use this name when firing <code>PropertyChangeEvent</code>s from your Bean.
- * @fixme Check whether PROPERTYNAME is set to same value as Sun.
*/
String PROPERTYNAME = "designTime";
@@ -78,7 +79,7 @@
* the BeanContext can <em>change</em> the status of the Bean from
* design time to runtime. But it appears that it may be so.
*
- * @see java.util.PropertyChangeEvent
+ * @see java.beans.PropertyChangeEvent
* @see java.beans.beancontext.BeanContext
* @see #PROPERTYNAME
*/
@@ -90,4 +91,5 @@
* runtime.
*/
boolean isDesignTime();
+
}
Modified: trunk/core/src/classpath/java/java/beans/Encoder.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/Encoder.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/Encoder.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -181,7 +181,7 @@
return exceptionListener;
}
- public PersistenceDelegate getPersistenceDelegate(Class type)
+ public PersistenceDelegate getPersistenceDelegate(Class<?> type)
{
// This is not specified but the JDK behaves like this.
if (type == null)
@@ -215,7 +215,8 @@
* access is thread safe.
* </p>
*/
- public void setPersistenceDelegate(Class type, PersistenceDelegate delegate)
+ public void setPersistenceDelegate(Class<?> type,
+ PersistenceDelegate delegate)
{
// If the argument is null this will cause a NullPointerException
// which is expected behavior.
Modified: trunk/core/src/classpath/java/java/beans/EventHandler.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/EventHandler.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/EventHandler.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -463,7 +463,8 @@
* @param action Target property or method to invoke.
* @return A constructed proxy object.
*/
- public static Object create(Class listenerInterface, Object target, String action)
+ public static <T> T create(Class<T> listenerInterface, Object target,
+ String action)
{
return create(listenerInterface, target, action, null, null);
}
@@ -552,7 +553,7 @@
* @param eventPropertyName Name of property to extract from event.
* @return A constructed proxy object.
*/
- public static Object create(Class listenerInterface, Object target,
+ public static <T> T create(Class<T> listenerInterface, Object target,
String action, String eventPropertyName)
{
return create(listenerInterface, target, action, eventPropertyName, null);
@@ -587,7 +588,7 @@
* @param listenerMethodName Listener method to implement.
* @return A constructed proxy object.
*/
- public static Object create(Class listenerInterface, Object target,
+ public static <T> T create(Class<T> listenerInterface, Object target,
String action, String eventPropertyName,
String listenerMethodName)
{
@@ -597,10 +598,9 @@
// Create proxy object passing in the event handler
Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(),
- new Class[] {listenerInterface},
+ new Class<?>[] {listenerInterface},
eh);
- return proxy;
+ return (T) proxy;
}
-
}
Modified: trunk/core/src/classpath/java/java/beans/EventSetDescriptor.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/EventSetDescriptor.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/EventSetDescriptor.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -164,8 +164,8 @@
* if listenerType is not an EventListener, or if methods are not
* found or are invalid.
*/
- public EventSetDescriptor(Class eventSourceClass, String eventSetName,
- Class listenerType, String listenerMethodName)
+ public EventSetDescriptor(Class<?> eventSourceClass, String eventSetName,
+ Class<?> listenerType, String listenerMethodName)
throws IntrospectionException
{
setName(eventSetName);
@@ -225,8 +225,8 @@
* if listenerType is not an EventListener or if methods are not
* found or are invalid.
*/
- public EventSetDescriptor(Class eventSourceClass, String eventSetName,
- Class listenerType, String[] listenerMethodNames,
+ public EventSetDescriptor(Class<?> eventSourceClass, String eventSetName,
+ Class<?> listenerType, String[] listenerMethodNames,
String addListenerMethodName,
String removeListenerMethodName)
throws IntrospectionException
@@ -287,8 +287,8 @@
* found or are invalid.
* @since 1.4
*/
- public EventSetDescriptor(Class eventSourceClass, String eventSetName,
- Class listenerType, String[] listenerMethodNames,
+ public EventSetDescriptor(Class<?> eventSourceClass, String eventSetName,
+ Class<?> listenerType, String[] listenerMethodNames,
String addListenerMethodName,
String removeListenerMethodName,
String getListenerMethodName)
@@ -357,7 +357,7 @@
* methods are invalid.
* @since 1.4
*/
- public EventSetDescriptor(String eventSetName, Class listenerType,
+ public EventSetDescriptor(String eventSetName, Class<?> listenerType,
Method[] listenerMethods, Method addListenerMethod,
Method removeListenerMethod,
Method getListenerMethod)
@@ -402,7 +402,7 @@
* if the listenerType is not an EventListener, or any of the
* methods are invalid.
*/
- public EventSetDescriptor(String eventSetName, Class listenerType,
+ public EventSetDescriptor(String eventSetName, Class<?> listenerType,
Method[] listenerMethods, Method addListenerMethod,
Method removeListenerMethod)
throws IntrospectionException
@@ -449,7 +449,7 @@
* if the listenerType is not an EventListener, or any of the
* methods are invalid.
*/
- public EventSetDescriptor(String eventSetName, Class listenerType,
+ public EventSetDescriptor(String eventSetName, Class<?> listenerType,
MethodDescriptor[] listenerMethodDescriptors,
Method addListenerMethod,
Method removeListenerMethod)
@@ -484,7 +484,7 @@
/** Returns the class that contains the event firing methods.
*/
- public Class getListenerType()
+ public Class<?> getListenerType()
{
return listenerType;
}
Modified: trunk/core/src/classpath/java/java/beans/FeatureDescriptor.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/FeatureDescriptor.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/FeatureDescriptor.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -68,14 +68,14 @@
boolean hidden;
boolean preferred;
- Hashtable valueHash;
+ Hashtable<String,Object> valueHash;
/**
* Instantiate this FeatureDescriptor with appropriate default values.
*/
public FeatureDescriptor()
{
- valueHash = new Hashtable();
+ valueHash = new Hashtable<String,Object>();
}
/**
@@ -225,7 +225,7 @@
* @return an Enumerator over all the programmatic key names associated
* with this feature.
*/
- public Enumeration attributeNames()
+ public Enumeration<String> attributeNames()
{
return valueHash.keys();
}
Modified: trunk/core/src/classpath/java/java/beans/IndexedPropertyDescriptor.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/IndexedPropertyDescriptor.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/IndexedPropertyDescriptor.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -76,7 +76,7 @@
*/
public class IndexedPropertyDescriptor extends PropertyDescriptor
{
- private Class indexedPropertyType;
+ private Class<?> indexedPropertyType;
private Method setIndex;
private Method getIndex;
@@ -112,7 +112,7 @@
* @exception IntrospectionException if the methods are not found or
* invalid.
*/
- public IndexedPropertyDescriptor(String name, Class beanClass)
+ public IndexedPropertyDescriptor(String name, Class<?> beanClass)
throws IntrospectionException
{
super(name);
@@ -161,7 +161,7 @@
*
* @exception IntrospectionException if the methods are not found or invalid.
*/
- public IndexedPropertyDescriptor(String name, Class beanClass,
+ public IndexedPropertyDescriptor(String name, Class<?> beanClass,
String getMethodName, String setMethodName,
String getIndexName, String setIndexName)
throws IntrospectionException
@@ -272,7 +272,7 @@
: Array.newInstance(this.indexedPropertyType,0).getClass());
}
- public Class getIndexedPropertyType()
+ public Class<?> getIndexedPropertyType()
{
return indexedPropertyType;
}
Modified: trunk/core/src/classpath/java/java/beans/Introspector.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/Introspector.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/Introspector.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -182,7 +182,8 @@
public static final int IGNORE_ALL_BEANINFO = 3;
static String[] beanInfoSearchPath = {"gnu.java.beans.info"};
- static Hashtable beanInfoCache = new Hashtable();
+ static Hashtable<Class<?>,BeanInfo> beanInfoCache =
+ new Hashtable<Class<?>,BeanInfo>();
private Introspector() {}
@@ -195,13 +196,13 @@
* @param beanClass the class to get BeanInfo about.
* @return the BeanInfo object representing the class.
*/
- public static BeanInfo getBeanInfo(Class beanClass)
+ public static BeanInfo getBeanInfo(Class<?> beanClass)
throws IntrospectionException
{
BeanInfo cachedInfo;
synchronized(beanClass)
{
- cachedInfo = (BeanInfo)beanInfoCache.get(beanClass);
+ cachedInfo = beanInfoCache.get(beanClass);
if(cachedInfo != null)
{
return cachedInfo;
@@ -245,7 +246,7 @@
* @throws IntrospectionException If something goes wrong while retrieving
* the bean data.
*/
- public static BeanInfo getBeanInfo(Class beanClass, int flag)
+ public static BeanInfo getBeanInfo(Class<?> beanClass, int flag)
throws IntrospectionException
{
IntrospectionIncubator ii;
@@ -312,7 +313,7 @@
* @throws NullPointerException if clz is null.
* @since 1.2
*/
- public static void flushFromCaches(Class clz)
+ public static void flushFromCaches(Class<?> clz)
{
synchronized (clz)
{
@@ -394,7 +395,7 @@
* @param stopClass the class to stop at.
* @return the BeanInfo object representing the class.
*/
- public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
+ public static BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass)
throws IntrospectionException
{
ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
Modified: trunk/core/src/classpath/java/java/beans/PersistenceDelegate.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/PersistenceDelegate.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/PersistenceDelegate.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -52,8 +52,8 @@
public abstract class PersistenceDelegate
{
- protected void initialize(Class type, Object oldInstance, Object newInstance,
- Encoder out)
+ protected void initialize(Class<?> type, Object oldInstance,
+ Object newInstance, Encoder out)
{
if (type != Object.class)
{
Modified: trunk/core/src/classpath/java/java/beans/PropertyDescriptor.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/PropertyDescriptor.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/PropertyDescriptor.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -65,11 +65,11 @@
**/
public class PropertyDescriptor extends FeatureDescriptor
{
- Class propertyType;
+ Class<?> propertyType;
Method getMethod;
Method setMethod;
- Class propertyEditorClass;
+ Class<?> propertyEditorClass;
boolean bound;
boolean constrained;
@@ -103,7 +103,7 @@
** @exception IntrospectionException if the methods are not found
** or invalid.
**/
- public PropertyDescriptor(String name, Class beanClass)
+ public PropertyDescriptor(String name, Class<?> beanClass)
throws IntrospectionException
{
setName(name);
@@ -159,7 +159,7 @@
**/
public PropertyDescriptor(
String name,
- Class beanClass,
+ Class<?> beanClass,
String getMethodName,
String setMethodName)
throws IntrospectionException
@@ -213,7 +213,7 @@
** This is the type the get method returns and the set method
** takes in.
**/
- public Class getPropertyType()
+ public Class<?> getPropertyType()
{
return propertyType;
}
@@ -330,7 +330,7 @@
}
/** Get the PropertyEditor class. Defaults to null. **/
- public Class getPropertyEditorClass()
+ public Class<?> getPropertyEditorClass()
{
return propertyEditorClass;
}
@@ -341,7 +341,7 @@
** @param propertyEditorClass the PropertyEditor class for this
** class to use.
**/
- public void setPropertyEditorClass(Class propertyEditorClass)
+ public void setPropertyEditorClass(Class<?> propertyEditorClass)
{
this.propertyEditorClass = propertyEditorClass;
}
@@ -516,10 +516,10 @@
* @return The common property type of the two method.
* @throws IntrospectionException If any of the above requirements are not met.
*/
- private Class checkMethods(Method readMethod, Method writeMethod)
+ private Class<?> checkMethods(Method readMethod, Method writeMethod)
throws IntrospectionException
{
- Class newPropertyType = propertyType;
+ Class<?> newPropertyType = propertyType;
// a valid read method has zero arguments and a non-void return type.
if (readMethod != null)
Modified: trunk/core/src/classpath/java/java/beans/PropertyEditorManager.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/PropertyEditorManager.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/PropertyEditorManager.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -83,7 +83,8 @@
public class PropertyEditorManager
{
- static java.util.Hashtable editors = new java.util.Hashtable();
+ static java.util.Hashtable<Class<?>,Class<?>> editors =
+ new java.util.Hashtable<Class<?>,Class<?>>();
static String[] editorSearchPath = { "gnu.java.beans.editors",
"sun.beans.editors" };
@@ -118,7 +119,7 @@
* will edit.
* @param editorClass the PropertyEditor class.
*/
- public static void registerEditor(Class editedClass, Class editorClass)
+ public static void registerEditor(Class<?> editedClass, Class<?> editorClass)
{
editors.put(editedClass, editorClass);
}
@@ -132,7 +133,7 @@
* @return a PropertyEditor instance that can edit the
* specified class.
*/
- public static PropertyEditor findEditor(Class editedClass)
+ public static PropertyEditor findEditor(Class<?> editedClass)
{
try
{
Modified: trunk/core/src/classpath/java/java/beans/SimpleBeanInfo.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/SimpleBeanInfo.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/SimpleBeanInfo.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -1,5 +1,5 @@
/* java.beans.SimpleBeanInfo
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@
import java.awt.Image;
import java.awt.Toolkit;
+import java.net.URL;
/**
** SimpleBeanInfo is a class you may extend to more easily
@@ -130,10 +131,16 @@
** and its BeanInfo are both loaded by the same
** ClassLoader, generally a reasonable assumption.
** @param location the URL relative
- ** @return the Image in question.
+ ** @return the Image in question (possibly <code>null</code>).
**/
- public Image loadImage(String location) {
- return Toolkit.getDefaultToolkit().getImage(getClass().getResource(location));
+ public Image loadImage(String location)
+ {
+ if (location == null)
+ return null;
+ URL url = getClass().getResource(location);
+ if (url == null)
+ return null;
+ return Toolkit.getDefaultToolkit().getImage(url);
}
}
Modified: trunk/core/src/classpath/java/java/beans/Statement.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/Statement.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/Statement.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -1,5 +1,5 @@
/* Statement.java
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -346,16 +346,20 @@
/** Return the statement object. */
public Object getTarget() { return target; }
- /** Return a string representation. */
+ /**
+ * Returns a string representation of this <code>Statement</code>.
+ *
+ * @return A string representation of this <code>Statement</code>.
+ */
public String toString()
{
StringBuffer result = new StringBuffer();
- String targetName = target.getClass().getName();
- if ( targetName.startsWith("java"))
- {
- targetName = targetName.substring(targetName.lastIndexOf('.') + 1);
- }
+ String targetName;
+ if (target != null)
+ targetName = target.getClass().getSimpleName();
+ else
+ targetName = "null";
result.append(targetName);
result.append(".");
@@ -369,10 +373,10 @@
result.append(
( arguments[i] == null ) ? "null" :
( arguments[i] instanceof String ) ? "\"" + arguments[i] + "\"" :
- arguments[i].getClass().getName());
+ arguments[i].getClass().getSimpleName());
sep = ", ";
}
- result.append(")");
+ result.append(");");
return result.toString();
}
Modified: trunk/core/src/classpath/java/java/beans/XMLEncoder.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/XMLEncoder.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/XMLEncoder.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -248,7 +248,7 @@
scanEngine.writeObject(o);
- if (get(o) == null);
+ if (get(o) == null)
super.writeObject(o);
accessCounter--;
Modified: trunk/core/src/classpath/java/java/beans/beancontext/BeanContextServicesSupport.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/beancontext/BeanContextServicesSupport.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/beancontext/BeanContextServicesSupport.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -46,12 +46,21 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
+import java.util.Set;
import java.util.TooManyListenersException;
/**
+ * This is a helper class for implementing a bean context which
+ * supplies services. It is intended to be used either by
+ * subclassing or by calling methods of this implementation
+ * from another.
+ *
* @author Michael Koch
+ * @author Andrew John Hughes (gnu...@me...)
* @since 1.2
*/
public class BeanContextServicesSupport
@@ -77,38 +86,39 @@
{
private static final long serialVersionUID = 7078212910685744490L;
- private BCSSProxyServiceProvider()
+ private BeanContextServiceProvider provider;
+
+ private BCSSProxyServiceProvider(BeanContextServiceProvider p)
{
+ provider = p;
}
public Iterator getCurrentServiceSelectors (BeanContextServices bcs,
Class serviceClass)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return provider.getCurrentServiceSelectors(bcs, serviceClass);
}
public Object getService (BeanContextServices bcs,
Object requestor,
Class serviceClass,
Object serviceSelector)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return provider.getService(bcs, requestor, serviceClass,
+ serviceSelector);
}
public void releaseService (BeanContextServices bcs,
Object requestor,
Object service)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ provider.releaseService(bcs, requestor, service);
}
public void serviceRevoked (BeanContextServiceRevokedEvent bcsre)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ if (provider instanceof BeanContextServiceRevokedListener)
+ ((BeanContextServiceRevokedListener) provider).serviceRevoked(bcsre);
}
}
@@ -119,51 +129,233 @@
protected BeanContextServiceProvider serviceProvider;
- private BCSSServiceProvider()
+ private Class serviceClass;
+
+ private BCSSServiceProvider(Class serviceClass,
+ BeanContextServiceProvider provider)
{
+ this.serviceClass = serviceClass;
+ serviceProvider = provider;
}
protected BeanContextServiceProvider getServiceProvider()
{
return serviceProvider;
}
+
+ private Class getServiceClass()
+ {
+ return serviceClass;
+ }
+
}
+ /**
+ * Represents a request for a service. This is
+ * a common superclass used by the classes which maintain
+ * the listener-requestor and service-requestor relationships.
+ *
+ * @author Andrew John Hughes (gnu...@me...)
+ */
+ private static abstract class Request
+ {
+ private Object requestor;
+
+ public Request(Object requestor)
+ {
+ this.requestor = requestor;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof Request)
+ {
+ Request req = (Request) obj;
+ return req.getRequestor().equals(requestor);
+ }
+ return false;
+ }
+
+ public Object getRequestor()
+ {
+ return requestor;
+ }
+
+ }
+
+ /**
+ * Represents a relationship between a service requestor
+ * and a revocation listener.
+ *
+ * @author Andrew John Hughes (gnu...@me...)
+ */
+ private static class ServiceRequest
+ extends Request
+ {
+
+ private BeanContextServiceRevokedListener listener;
+
+ public ServiceRequest(Object requestor,
+ BeanContextServiceRevokedListener listener)
+ {
+ super(requestor);
+ this.listener = listener;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ServiceRequest)
+ {
+ ServiceRequest sr = (ServiceRequest) obj;
+ return (super.equals(obj) &&
+ sr.getListener().equals(listener));
+ }
+ return false;
+ }
+
+ public BeanContextServiceRevokedListener getListener()
+ {
+ return listener;
+ }
+ }
+
+ /**
+ * Represents a relationship between a service requestor
+ * and a service instance.
+ *
+ * @author Andrew John Hughes (gnu...@me...)
+ */
+ private static class ServiceLease
+ extends Request
+ {
+
+ private Object service;
+
+ public ServiceLease(Object requestor, Object service)
+ {
+ super(requestor);
+ this.service = service;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ServiceLease)
+ {
+ ServiceLease sl = (ServiceLease) obj;
+ return (super.equals(obj) &&
+ sl.getService().equals(service));
+ }
+ return false;
+ }
+
+ public Object getService()
+ {
+ return service;
+ }
+ }
+
+ /**
+ * A collection of listeners who receive availability
+ * and revocation notifications.
+ */
protected transient ArrayList bcsListeners;
protected transient BCSSProxyServiceProvider proxy;
+ /**
+ * The number of serializable service providers.
+ */
protected transient int serializable;
+ /**
+ * A map of registered services, linking the service
+ * class to its associated {@link BCSSServiceProvider}.
+ */
protected transient HashMap services;
+ /**
+ * A map of children to a list of services they
+ * have obtained.
+ */
+ private transient HashMap serviceUsers;
+
+ /**
+ * A map of services to {@link ServiceRequest}s.
+ */
+ private transient HashMap serviceRequests;
+
+ /**
+ * A map of {@link ServiceLease}s to providers.
+ */
+ private transient HashMap serviceLeases;
+
+ /**
+ * Construct a {@link BeanContextServicesSupport} instance.
+ */
public BeanContextServicesSupport ()
{
super();
}
+ /**
+ * Construct a {@link BeanContextServicesSupport} instance.
+ *
+ * @param peer the bean context services peer (<code>null</code> permitted).
+ */
public BeanContextServicesSupport (BeanContextServices peer)
{
super(peer);
}
+ /**
+ * Construct a {@link BeanContextServicesSupport} instance.
+ *
+ * @param peer the bean context peer (<code>null</code> permitted).
+ * @param locale the locale (<code>null</code> permitted, equivalent to
+ * the default locale).
+ */
public BeanContextServicesSupport(BeanContextServices peer, Locale locale)
{
super(peer, locale);
}
+ /**
+ * Construct a {@link BeanContextServicesSupport} instance.
+ *
+ * @param peer the bean context peer (<code>null</code> permitted).
+ * @param locale the locale (<code>null</code> permitted, equivalent to
+ * the default locale).
+ * @param dtime a flag indicating whether or not the bean context is in
+ * design time mode.
+ */
public BeanContextServicesSupport(BeanContextServices peer, Locale locale,
boolean dtime)
{
super(peer, locale, dtime);
}
+ /**
+ * Construct a {@link BeanContextServicesSupport} instance.
+ *
+ * @param peer the bean context peer (<code>null</code> permitted).
+ * @param locale the locale (<code>null</code> permitted, equivalent to
+ * the default locale).
+ * @param dtime a flag indicating whether or not the bean context is in
+ * design time mode.
+ * @param visible initial value of the <code>okToUseGui</code> flag.
+ */
public BeanContextServicesSupport(BeanContextServices peer, Locale locale,
boolean dtime, boolean visible)
{
super(peer, locale, dtime, visible);
}
+ /**
+ * Adds a new listener for service availability and
+ * revocation events.
+ *
+ * @param listener the listener to add.
+ */
public void addBeanContextServicesListener
(BeanContextServicesListener listener)
{
@@ -174,60 +366,168 @@
}
}
+ /**
+ * Registers a new service from the specified service provider.
+ * The service is internally associated with the service provider
+ * and a <code>BeanContextServiceAvailableEvent</code> is fired. If
+ * the service is already registered, then this method instead
+ * returns <code>false</code>. This is equivalent to calling
+ * <code>addService(serviceClass, bcsp, true)</code>.
+ *
+ * @param serviceClass the class of the service to be registered.
+ * @param bcsp the provider of the given service.
+ * @return true if the service was registered successfully.
+ * @see #addService(Class, BeanContextServiceProvider, boolean)
+ */
public boolean addService (Class serviceClass,
BeanContextServiceProvider bcsp)
{
return addService(serviceClass, bcsp, true);
}
+ /**
+ * Registers a new service from the specified service provider.
+ * The service is internally associated with the service provider
+ * and (if <code>fireEvent</code> is true) a
+ * <code>BeanContextServiceAvailableEvent</code> is fired. If
+ * the service is already registered, then this method instead
+ * returns <code>false</code>.
+ *
+ * @param serviceClass the class of the service to be registered.
+ * @param bcsp the provider of the given service.
+ * @param fireEvent true if a service availability event should
+ * be fired.
+ * @return true if the service was registered successfully.
+ */
protected boolean addService (Class serviceClass,
BeanContextServiceProvider bcsp,
boolean fireEvent)
{
+ synchronized (globalHierarchyLock)
+ {
synchronized (services)
{
if (services.containsKey(serviceClass))
return false;
- services.put(serviceClass, bcsp);
+ services.put(serviceClass,
+ createBCSSServiceProvider(serviceClass, bcsp));
if (bcsp instanceof Serializable)
++serializable;
+ if (fireEvent)
fireServiceAdded(serviceClass);
return true;
}
}
+ }
+ /**
+ * Deserializes any service providers which are serializable. This
+ * method is called by the <code>readObject</code> method of
+ * {@link BeanContextSupport} prior to deserialization of the children.
+ * Subclasses may envelope its behaviour in order to read further
+ * serialized data to the stream.
+ *
+ * @param oos the stream from which data is being deserialized.
+ * @throws IOException if an I/O error occurs.
+ * @throws ClassNotFoundException if the class of a deserialized object
+ * can not be found.
+ */
protected void bcsPreDeserializationHook (ObjectInputStream ois)
- throws ClassNotFoundException, IOException, NotImplementedException
+ throws ClassNotFoundException, IOException
{
- throw new Error ("Not implemented");
+ serializable = ois.readInt();
+ for (int a = 0; a < serializable; ++a)
+ {
+ BCSSServiceProvider bcsssp = (BCSSServiceProvider) ois.readObject();
+ addService(bcsssp.getServiceClass(), bcsssp.getServiceProvider());
+ }
}
+ /**
+ * Serializes any service providers which are serializable. This
+ * method is called by the <code>writeObject</code> method of
+ * {@link BeanContextSupport} prior to serialization of the children.
+ * Subclasses may envelope its behaviour in order to add further
+ * serialized data to the stream.
+ *
+ * @param oos the stream to which data is being serialized.
+ * @throws IOException if an I/O error occurs.
+ */
protected void bcsPreSerializationHook (ObjectOutputStream oos)
- throws IOException, NotImplementedException
+ throws IOException
{
- throw new Error ("Not implemented");
+ oos.writeInt(serializable);
+ synchronized (services)
+ {
+ Iterator i = services.values().iterator();
+ while (i.hasNext())
+ {
+ BCSSServiceProvider bcsssp = (BCSSServiceProvider) i.next();
+ if (bcsssp.getServiceProvider() instanceof Serializable)
+ oos.writeObject(bcsssp);
+ }
+ }
}
+ /**
+ * Revokes any services used by a child that has just been removed.
+ * The superclass ({@link BeanContextSupport}) calls this method
+ * when a child has just been successfully removed. Subclasses can
+ * extend this method in order to perform additional operations
+ * on child removal.
+ *
+ * @param child the child being removed.
+ * @param bcsc the support object for the child.
+ */
protected void childJustRemovedHook (Object child,
BeanContextSupport.BCSChild bcsc)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ if (child instanceof BeanContextChild)
+ {
+ BeanContextChild bcchild = (BeanContextChild) child;
+ Iterator childServices = ((List) serviceUsers.get(bcchild)).iterator();
+ while (childServices.hasNext())
+ releaseService(bcchild, this, childServices.next());
+ serviceUsers.remove(bcchild);
+ }
}
+ /**
+ * Overrides the {@link BeanContextSupport#createBCSChild} method
+ * so as to use a {@link BCSSChild} instead.
+ *
+ * @param targetChild the child to create the child for.
+ * @param peer the peer which relates to the child if a proxy is used.
+ * @return a new instance of {@link BCSSChild}.
+ */
protected BeanContextSupport.BCSChild createBCSChild (Object targetChild,
Object peer)
{
return new BCSSChild(targetChild, peer);
}
+ /**
+ * Provides a hook so that subclasses can replace the
+ * {@link BCSSServiceProvider} class, used to store registered
+ * service providers, with a subclass without replacing the
+ * {@link #addService(Class, BeanContextServiceProvider)} method.
+ *
+ * @param sc the class of service being registered.
+ * @param bcsp the provider of the service.
+ * @return a instance of {@link BCSSServiceProvider} wrapping the provider.
+ */
protected BeanContextServicesSupport.BCSSServiceProvider
createBCSSServiceProvider (Class sc, BeanContextServiceProvider bcsp)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return new BCSSServiceProvider(sc, bcsp);
}
+ /**
+ * Sends a <code>BeanContextServiceAvailableEvent</code> to all
+ * registered listeners.
+ *
+ * @param bcssae the event to send.
+ */
protected final void fireServiceAdded (BeanContextServiceAvailableEvent bcssae)
{
synchronized (bcsListeners)
@@ -242,12 +542,25 @@
}
}
+ /**
+ * Sends a <code>BeanContextServiceAvailableEvent</code> to all
+ * registered listeners.
+ *
+ * @param serviceClass the service that is now available.
+ * @see #fireServiceAdded(BeanContextServiceAvailableEvent)
+ */
protected final void fireServiceAdded (Class serviceClass)
{
fireServiceAdded(new BeanContextServiceAvailableEvent(this,
serviceClass));
}
+ /**
+ * Sends a <code>BeanContextServiceRevokedEvent</code> to all
+ * registered listeners.
+ *
+ * @param event the event to send.
+ */
protected final void fireServiceRevoked(BeanContextServiceRevokedEvent event)
{
synchronized (bcsListeners)
@@ -259,9 +572,26 @@
= (BeanContextServicesListener) bcsListeners.get(i);
bcsl.serviceRevoked(event);
}
+ List requests = (List) serviceRequests.get(event.getServiceClass());
+ if (requests != null)
+ {
+ Iterator i = requests.iterator();
+ while (i.hasNext())
+ {
+ ServiceRequest r = (ServiceRequest) i.next();
+ r.getListener().serviceRevoked(event);
+ }
+ }
}
}
+ /**
+ * Sends a <code>BeanContextServiceRevokedEvent</code> to all
+ * registered listeners.
+ *
+ * @param serviceClass the service that has been revoked.
+ * @see #fireServiceRevoked(BeanContextServiceRevokedEvent)
+ */
protected final void fireServiceRevoked (Class serviceClass,
boolean revokeNow)
{
@@ -269,53 +599,168 @@
revokeNow));
}
+ /**
+ * Returns the services peer given at construction time,
+ * or <code>null</code> if no peer was given.
+ *
+ * @return the {@link BeanContextServices} peer.
+ */
public BeanContextServices getBeanContextServicesPeer ()
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return (BeanContextServices) beanContextChildPeer;
}
+ /**
+ * Returns <code>child</code> as an instance of
+ * {@link BeanContextServicesListener}, or <code>null</code> if
+ * <code>child</code> does not implement that interface.
+ *
+ * @param child the child (<code>null</code> permitted).
+ *
+ * @return The child cast to {@link BeanContextServicesListener}.
+ */
protected static final BeanContextServicesListener
- getChildBeanContextServicesListener (Object child)
- throws NotImplementedException
+ getChildBeanContextServicesListener(Object child)
{
- throw new Error ("Not implemented");
+ if (child instanceof BeanContextServicesListener)
+ return (BeanContextServicesListener) child;
+ else
+ return null;
}
+ /**
+ * Returns an iterator over the currently available
+ * services.
+ *
+ * @return an iterator over the currently available services.
+ */
public Iterator getCurrentServiceClasses ()
{
+ synchronized (globalHierarchyLock)
+ {
synchronized (services)
{
return services.keySet().iterator();
}
}
+ }
+ /**
+ * Returns an iterator over the service selectors of the service
+ * provider for the given service. The iterator is actually
+ * obtained by calling the
+ * {@link BeanContextServiceProvider#getCurrentServiceSelectors}
+ * of the provider itself. If the specified service is not available,
+ * <code>null</code> is returned.
+ *
+ * @param serviceClass the service whose provider's selectors should
+ * be iterated over.
+ * @return an {@link Iterator} over the service selectors of the
+ * provider of the given service.
+ */
public Iterator getCurrentServiceSelectors (Class serviceClass)
{
+ synchronized (globalHierarchyLock)
+ {
synchronized (services)
{
- // FIXME: what if service does not exist? Must write a test.
BeanContextServiceProvider bcsp
- = (BeanContextServiceProvider) services.get(serviceClass);
+ = ((BCSSServiceProvider)
+ services.get(serviceClass)).getServiceProvider();
+ if (bcsp == null)
+ return null;
+ else
return bcsp.getCurrentServiceSelectors(this, serviceClass);
}
}
+ }
+ /**
+ * Retrieves the specified service. If a provider for the service
+ * is registered in this context, then the request is passed on to
+ * the provider and the service returned. Otherwise, the request
+ * is delegated to a parent {@link BeanContextServices}, if possible.
+ * If the service can not be found at all, then <code>null</code>
+ * is returned.
+ *
+ * @param child the child obtaining the reference.
+ * @param requestor the requestor of the service, which may be the
+ * child itself.
+ * @param serviceClass the service being requested.
+ * @param serviceSelector an additional service-dependent parameter
+ * (may be <code>null</code> if not appropriate).
+ * @param bcsrl a listener used to notify the requestor that the service
+ * has since been revoked.
+ * @return a reference to the service requested, or <code>null</code>.
+ * @throws TooManyListenersException according to Sun's documentation.
+ */
public Object getService (BeanContextChild child, Object requestor,
Class serviceClass, Object serviceSelector,
BeanContextServiceRevokedListener bcsrl)
- throws TooManyListenersException, NotImplementedException
+ throws TooManyListenersException
{
- throw new Error ("Not implemented");
+ synchronized (globalHierarchyLock)
+ {
+ synchronized (services)
+ {
+ Object service;
+ BeanContextServiceProvider provider = ((BCSSServiceProvider)
+ services.get(serviceClass)).getServiceProvider();
+ if (provider != null)
+ {
+ service = provider.getService(this, requestor, serviceClass,
+ serviceSelector);
+ List childServices = (List) serviceUsers.get(child);
+ if (childServices == null)
+ {
+ childServices = new ArrayList();
+ serviceUsers.put(child, childServices);
+ }
+ childServices.add(serviceClass);
+ }
+ else
+ {
+ BeanContextServices peer = getBeanContextServicesPeer();
+ if (peer != null)
+ service = peer.getService(child, requestor, serviceClass,
+ serviceSelector, bcsrl);
+ else
+ service = null;
+ }
+ if (service != null)
+ {
+ ServiceRequest request = new ServiceRequest(requestor, bcsrl);
+ Set requests = (Set) serviceRequests.get(serviceClass);
+ if (requests == null)
+ {
+ requests = new HashSet();
+ serviceRequests.put(serviceClass, requests);
+ }
+ requests.add(request);
+ ServiceLease lease = new ServiceLease(requestor, service);
+ serviceLeases.put(lease, provider);
+ }
+ return service;
+ }
+ }
}
+ /**
+ * Returns true if the specified service is available.
+ *
+ * @param serviceClass the service to check for.
+ * @return true if the service is available.
+ */
public boolean hasService (Class serviceClass)
{
+ synchronized (globalHierarchyLock)
+ {
synchronized (services)
{
return services.containsKey(serviceClass);
}
}
+ }
public void initialize ()
{
@@ -323,25 +768,62 @@
bcsListeners = new ArrayList();
services = new HashMap();
+ serviceUsers = new HashMap();
+ serviceRequests = new HashMap();
+ serviceLeases = new HashMap();
}
- protected void initializeBeanContextResources ()
- throws NotImplementedException
+ /**
+ * Subclasses may override this method to allocate resources
+ * from the nesting bean context.
+ */
+ protected void initializeBeanContextResources()
{
- throw new Error ("Not implemented");
+ /* Purposefully left empty */
}
- protected void releaseBeanContextResources ()
- throws NotImplementedException
+ /**
+ * Relinquishes any resources obtained from the parent context.
+ * Specifically, those services obtained from the parent are revoked.
+ * Subclasses may override this method to deallocate resources
+ * from the nesting bean context.
+ */
+ protected void releaseBeanContextResources()
{
- throw new Error ("Not implemented");
+ /* Purposefully left empty */
}
+ /**
+ * Releases the reference to a service held by a
+ * {@link BeanContextChild} (or an arbitrary object associated
+ * with it). It simply calls the appropriate method on the
+ * underlying provider.
+ *
+ * @param child the child who holds the reference.
+ * @param requestor the object that requested the reference.
+ * @param service the service being released.
+ */
public void releaseService (BeanContextChild child, Object requestor,
Object service)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ synchronized (globalHierarchyLock)
+ {
+ synchronized (services)
+ {
+ ServiceLease lease = new ServiceLease(requestor, service);
+ BeanContextServiceProvider provider = (BeanContextServiceProvider)
+ serviceLeases.get(lease);
+ if (provider != null)
+ provider.releaseService(this, requestor, service);
+ else
+ {
+ BeanContextServices peer = getBeanContextServicesPeer();
+ if (peer != null)
+ peer.releaseService(child, requestor, service);
+ }
+ serviceLeases.remove(lease);
+ }
+ }
}
public void removeBeanContextServicesListener
@@ -349,17 +831,35 @@
{
synchronized (bcsListeners)
{
- int index = bcsListeners.indexOf(listener);
- if (index > -1)
- bcsListeners.remove(index);
+ bcsListeners.remove(listener);
}
}
+ /**
+ * Revokes the given service. A {@link BeanContextServiceRevokedEvent} is
+ * emitted to all registered {@link BeanContextServiceRevokedListener}s
+ * and {@link BeanContextServiceListener}s. If <code>revokeCurrentServicesNow</code>
+ * is true, termination of the service is immediate. Otherwise, prior
+ * acquisitions of the service by requestors remain valid.
+ *
+ * @param serviceClass the service to revoke.
+ * @param bcsp the provider of the revoked service.
+ * @param revokeCurrentServicesNow true if this is an exceptional circumstance
+ * where service should be immediately revoked.
+ */
public void revokeService (Class serviceClass, BeanContextServiceProvider bcsp,
boolean revokeCurrentServicesNow)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ synchronized (globalHierarchyLock)
+ {
+ synchronized (services)
+ {
+ fireServiceRevoked(serviceClass, revokeCurrentServicesNow);
+ services.remove(serviceClass);
+ if (bcsp instanceof Serializable)
+ --serializable;
+ }
+ }
}
public void serviceAvailable (BeanContextServiceAvailableEvent bcssae)
Modified: trunk/core/src/classpath/java/java/beans/beancontext/BeanContextSupport.java
===================================================================
--- trunk/core/src/classpath/java/java/beans/beancontext/BeanContextSupport.java 2007-01-07 08:30:02 UTC (rev 3010)
+++ trunk/core/src/classpath/java/java/beans/beancontext/BeanContextSupport.java 2007-01-07 08:31:59 UTC (rev 3011)
@@ -38,8 +38,6 @@
package java.beans.beancontext;
-import gnu.classpath.NotImplementedException;
-
import java.beans.Beans;
import java.beans.DesignMode;
import java.beans.PropertyChangeEvent;
@@ -57,6 +55,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
/**
@@ -74,20 +73,52 @@
{
private static final long serialVersionUID = -4879613978649577204L;
- // This won't show up in japi, but we mark it as a stub anyway,
- // so that searches for NotImplementedException will find it.
+ /**
+ * Deserializes a stored bean context. Hook methods are provided to allow
+ * subclasses to perform their own deserialization after the default
+ * deserialization but prior to the deserialization of the children. Note that
+ * {@link #readChildren(ObjectInputStream)} is only called if there
+ * is no distinct peer. If there is, the peer is expected to call
+ * the method instead.
+ *
+ * @param s the stream to deserialize.
+ * @throws ClassNotFoundException if the class of an object being deserialized
+ * could not be found.
+ * @throws IOException if an I/O error occurs.
+ */
private void readObject (ObjectInputStream s)
- throws ClassNotFoundException, IOException, NotImplementedException
+ throws ClassNotFoundException, IOException
{
- throw new Error ("Not implemented");
+ s.defaultReadObject();
+ bcsPreDeserializationHook(s);
+ BeanContext peer = getBeanContextPeer();
+ if (peer == null || peer == this)
+ readChildren(s);
}
- // This won't show up in japi, but we mark it as a stub anyway,
- // so that searches for NotImplementedException will find it.
+ /**
+ * Serializes a bean context. Hook methods are provided to allow
+ * subclasses to perform their own serialization after the default
+ * serialization but prior to serialization of the children. Note that
+ * {@link #writeChildren(ObjectOutputStream)} is only called if there
+ * is no distinct peer. If there is, the peer is expected to call
+ * the method instead.
+ *
+ * @param s the stream to serialize.
+ * @throws ClassNotFoundException if the class of an object being deserialized
+ * could not be found.
+ * @throws IOException if an I/O error occurs.
+ */
private void writeObject (ObjectOutputStream s)
- throws ClassNotFoundException, IOException, NotImplementedException
+ throws ClassNotFoundException, IOException
{
- throw new Error ("Not implemented");
+ serializing = true;
+ s.defaultWriteObject();
+ bcsPreSerializationHook(s);
+ BeanContext peer = getBeanContextPeer();
+ if (peer == null || peer == this)
+ writeChildren(s);
+ serializing = false;
}
protected class BCSChild implements Serializable
@@ -102,6 +133,12 @@
this.targetChild = targetChild;
this.peer = peer;
}
+
+ private Object getTargetChild()
+ {
+ return targetChild;
+ }
+
}
protected static final class BCSIterator implements Iterator
@@ -139,47 +176,68 @@
protected transient boolean okToUseGui;
+ private transient boolean serializing;
+
/**
* Construct a BeanContextSupport instance.
*/
public BeanContextSupport ()
{
- this (null, null, true, true);
+ this (null, null, false, true);
}
/**
* Construct a BeanContextSupport instance.
+ *
+ * @param peer the bean context peer (<code>null</code> permitted).
*/
- public BeanContextSupport (BeanContext peer)
+ public BeanContextSupport(BeanContext peer)
{
- this (peer, null, true, true);
+ this (peer, null, false, true);
}
/**
* Construct a BeanContextSupport instance.
+ *
+ * @param peer the bean context peer (<code>null</code> permitted).
+ * @param locale the locale (<code>null</code> permitted, equivalent to
+ * the default locale).
*/
- ...
[truncated message content] |