Return-Path: Delivered-To: apmail-jakarta-hivemind-cvs-archive@www.apache.org Received: (qmail 71799 invoked from network); 4 Jan 2005 01:06:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 4 Jan 2005 01:06:25 -0000 Received: (qmail 55353 invoked by uid 500); 4 Jan 2005 01:06:25 -0000 Delivered-To: apmail-jakarta-hivemind-cvs-archive@jakarta.apache.org Received: (qmail 55318 invoked by uid 500); 4 Jan 2005 01:06:25 -0000 Mailing-List: contact hivemind-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: hivemind-dev@jakarta.apache.org Delivered-To: mailing list hivemind-cvs@jakarta.apache.org Received: (qmail 55298 invoked by uid 99); 4 Jan 2005 01:06:24 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 03 Jan 2005 17:06:23 -0800 Received: (qmail 71787 invoked by uid 1616); 4 Jan 2005 01:06:22 -0000 Date: 4 Jan 2005 01:06:22 -0000 Message-ID: <20050104010622.71786.qmail@minotaur.apache.org> From: hlship@apache.org To: jakarta-hivemind-cvs@apache.org Subject: cvs commit: jakarta-hivemind/src/documentation/content HiveMind-QuickReference.doc X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hlship 2005/01/03 17:06:22 Modified: src/documentation/content/xdocs index.xml site.xml framework/src/java/org/apache/hivemind/impl ProxyBuilder.java RegistryInfrastructureImpl.java . forrest.properties status.xml framework/src/java/org/apache/hivemind/test HiveMindTestCase.java library/src/test/hivemind/test/lib TestEJBProxyFactory.java framework/src/test/hivemind/test FrameworkTestCase.java framework/src/java/org/apache/hivemind/servlet HiveMindFilter.java src/documentation/content HiveMind-QuickReference.doc Added: framework/src/test/org/apache/hivemind/internal/ser Adder.java SerIntegration.xml TestServiceSerializationHelper.java AdderWrapper.java AdderImpl.java src/documentation/content/xdocs serializing.xml framework/src/java/org/apache/hivemind/internal/ser ServiceSerializationSupport.java SerMessages.java ServiceToken.java SerStrings.properties ServiceSerializationHelper.java package.html Log: Add ability to serialize service proxies. Revision Changes Path 1.1 jakarta-hivemind/framework/src/test/org/apache/hivemind/internal/ser/Adder.java Index: Adder.java =================================================================== package org.apache.hivemind.internal.ser; /** * @author Howard M. Lewis Ship * @since 1.1 */ public interface Adder { public int add(int arg0, int arg1); } 1.1 jakarta-hivemind/framework/src/test/org/apache/hivemind/internal/ser/SerIntegration.xml Index: SerIntegration.xml =================================================================== 1.1 jakarta-hivemind/framework/src/test/org/apache/hivemind/internal/ser/TestServiceSerializationHelper.java Index: TestServiceSerializationHelper.java =================================================================== package org.apache.hivemind.internal.ser; import hivemind.test.FrameworkTestCase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; import org.apache.hivemind.ApplicationRuntimeException; import org.apache.hivemind.Registry; /** * Tests for {@link org.apache.hivemind.internal.ser.ServiceSerializationHelper}. * * @author Howard M. Lewis Ship * @since 1.1 */ public class TestServiceSerializationHelper extends FrameworkTestCase { private ServiceSerializationSupport newSupport() { return (ServiceSerializationSupport) newMock(ServiceSerializationSupport.class); } public void testGetNoSupport() { try { ServiceSerializationHelper.getServiceSerializationSupport(); unreachable(); } catch (ApplicationRuntimeException ex) { assertEquals(SerMessages.noSupportSet(), ex.getMessage()); } } public void testStore() { ServiceSerializationSupport s = newSupport(); replayControls(); ServiceSerializationHelper.setServiceSerializationSupport(s); assertSame(s, ServiceSerializationHelper.getServiceSerializationSupport()); verifyControls(); } public void testOverwrite() { ServiceSerializationSupport sa = newSupport(); ServiceSerializationSupport sb = newSupport(); replayControls(); interceptLogging("org.apache.hivemind.internal.ser"); ServiceSerializationHelper.setServiceSerializationSupport(sa); ServiceSerializationHelper.setServiceSerializationSupport(sb); assertSame(sb, ServiceSerializationHelper.getServiceSerializationSupport()); assertLoggedMessage(SerMessages.supportAlreadySet(sb, sa)); verifyControls(); } public void testReset() { ServiceSerializationSupport s = newSupport(); replayControls(); ServiceSerializationHelper.setServiceSerializationSupport(s); ServiceSerializationHelper.resetServiceSerializationSupport(s); try { ServiceSerializationHelper.getServiceSerializationSupport(); unreachable(); } catch (ApplicationRuntimeException ex) { // Back to same as never set. } verifyControls(); } public void testResetMismatch() { ServiceSerializationSupport sa = newSupport(); ServiceSerializationSupport sb = newSupport(); replayControls(); interceptLogging("org.apache.hivemind.internal.ser"); ServiceSerializationHelper.setServiceSerializationSupport(sa); ServiceSerializationHelper.setServiceSerializationSupport(sb); ServiceSerializationHelper.resetServiceSerializationSupport(sa); assertSame(sb, ServiceSerializationHelper.getServiceSerializationSupport()); verifyControls(); } public void testIntegration() throws Exception { Registry r = buildFrameworkRegistry("SerIntegration.xml"); Adder a = (Adder) r.getService(Adder.class); AdderWrapper aw1 = new AdderWrapper(a); byte[] data = serialize(aw1); AdderWrapper aw2 = (AdderWrapper) deserialize(data); assertEquals(17, aw2.add(9, 8)); } private byte[] serialize(Object o) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(o); oos.close(); return bos.toByteArray(); } private Object deserialize(byte[] data) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(data); ObjectInputStream ois = new ObjectInputStream(bis); return ois.readObject(); } } 1.1 jakarta-hivemind/framework/src/test/org/apache/hivemind/internal/ser/AdderWrapper.java Index: AdderWrapper.java =================================================================== package org.apache.hivemind.internal.ser; import java.io.Serializable; /** * @author Howard M. Lewis Ship * @since 1.1 */ public class AdderWrapper implements Serializable { private Adder _adder; public AdderWrapper(Adder a) { _adder = a; } public int add(int arg0, int arg1) { return _adder.add(arg0, arg1); } } 1.1 jakarta-hivemind/framework/src/test/org/apache/hivemind/internal/ser/AdderImpl.java Index: AdderImpl.java =================================================================== package org.apache.hivemind.internal.ser; /** * @author Howard M. Lewis Ship * @since 1.1 */ public class AdderImpl implements Adder { public int add(int arg0, int arg1) { return arg0 + arg1; } } 1.24 +6 -2 jakarta-hivemind/src/documentation/content/xdocs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/index.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- index.xml 19 Dec 2004 15:44:33 -0000 1.23 +++ index.xml 4 Jan 2005 01:06:22 -0000 1.24 @@ -90,8 +90,12 @@

James Carman has just been voted on as a HiveMind committer.

HiveMind's final 1.0 release occured on Sep 22 2004. Work is already underway on a 1.1 release.

-

Added the AdapterRegistryFactory service implementation - factory.

+ + This documentation describes HiveMind 1.1, which is currently in an alpha state. + You may download HiveMind 1.0 to get stable + features and matching documentation. + +
Upgrade warnings (release 1.0 to release 1.1) 1.36 +1 -0 jakarta-hivemind/src/documentation/content/xdocs/site.xml Index: site.xml =================================================================== RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/site.xml,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- site.xml 30 Dec 2004 18:55:32 -0000 1.35 +++ site.xml 4 Jan 2005 01:06:22 -0000 1.36 @@ -35,6 +35,7 @@ + 1.1 jakarta-hivemind/src/documentation/content/xdocs/serializing.xml Index: serializing.xml =================================================================== %common-links; ]>
Serializing Services

It is often useful, especially in a web-based application, to serialize services. In HiveMind 1.0, objects that had references to HiveMind services could not be serialized ... the services were not serializable. You could make your service implemention implement Serializable, but that's not what client code sees ... client code sees the service proxy, which did not implement Serializable. End of story.

Service proxies are the objects that are obtained from the Registry, or injected into other services. The proxies implement the service interface, but are generated on the fly. These service proxies are part of how HiveMind handles just-in-time service instantiation.

Starting with HiveMind 1.1, service proxies are, themselves, serializable. If you create objects that have references to HiveMind services, those objects can be serialized. For example:

public class MyDataObject implements Serializable { private MyService _myService; . . . }

Here, the MyDataObject class has a reference to a HiveMind service in its _myService instance variable. An instance of MyDataObject may be serialized in one JVM and de-serialized in another. In the new JVM, the _myService instance variable will point to an equivalent HiveMind service.

Serialization involves a particular global static variable that stores the Registry. When a service proxy is serialized, the Registry manufactures a service token to take its place. It is this token that is actually serialized and deserialized -- not the service proxy itself. When the token is later deserialized, it accesses the Registry through the global variable to get the service proxy (in the new JVM) back. This causes a problem if you have multiple Registry instances ... they will try to overwrite each other. If you have multiple web applications that all use HiveMind, you need to ensure that the HiveMind framework JARs exist in each WAR's WEB-INF/lib folder ... that will ensure that each is loaded by a different class loader, and each will have its own static variable.

It is the service proxy that is serializable, not the service implementation. That means that a stateful service (one that uses the threaded or pooled service model) will likely not be in the same state in the new JVM. Again, the internal state of the service is not serialized ... just the service's id.

If your service acts as a factory (or otherwise provides access to itself), you must be careful to share the service proxy, not the implementation itself. For example:

public class MyServiceImpl implements MyService { private void MyService _myProxy; public void setMyProxy(MyService myProxy) { _myProxy = myProxy; } // Service method public MyDataObject newDataObject() { return new MyDataObject(_myProxy); } . . . }

Here, the implementation acts as a factory for MyDataObject instances. It connects each data object to the service proxy ( new MyDataObject(_myProxy) rather than new MyDataObject(this)). You will need to use the &hivemind.BuilderFactory; and include a <set-service> element to connect the implementation's myProxy property to the service proxy.

A final note: Services using the primitive service model do not have service proxies and therefore they are not serializable, even in release 1.1. The other service models (including the default service model, singleton), do use a proxy and are serializable, as discussed in this document.

1.9 +22 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java Index: ProxyBuilder.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ProxyBuilder.java 9 Nov 2004 20:58:20 -0000 1.8 +++ ProxyBuilder.java 4 Jan 2005 01:06:22 -0000 1.9 @@ -14,10 +14,13 @@ package org.apache.hivemind.impl; +import java.io.ObjectStreamException; +import java.io.Serializable; import java.lang.reflect.Modifier; import org.apache.hivemind.internal.Module; import org.apache.hivemind.internal.ServicePoint; +import org.apache.hivemind.internal.ser.ServiceSerializationHelper; import org.apache.hivemind.service.BodyBuilder; import org.apache.hivemind.service.ClassFab; import org.apache.hivemind.service.ClassFabUtils; @@ -61,6 +64,25 @@ Object.class); _classFab.addInterface(_serviceInterface); + + addSerializable(point.getExtensionPointId()); + } + + /** @since 1.1 */ + private void addSerializable(String pointId) + { + _classFab.addInterface(Serializable.class); + + BodyBuilder bb = new BodyBuilder(); + + bb.add( + "return {0}.getServiceSerializationSupport().getServiceTokenForService(\"{1}\");", + ServiceSerializationHelper.class.getName(), + pointId); + + MethodSignature sig = new MethodSignature(Object.class, "writeReplace", null, null); + + _classFab.addMethod(Modifier.PRIVATE, sig, bb.toString()); } public ClassFab getClassFab() 1.6 +57 -1 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java Index: RegistryInfrastructureImpl.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RegistryInfrastructureImpl.java 28 Dec 2004 22:43:14 -0000 1.5 +++ RegistryInfrastructureImpl.java 4 Jan 2005 01:06:22 -0000 1.6 @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hivemind.ApplicationRuntimeException; +import org.apache.hivemind.Defense; import org.apache.hivemind.ErrorHandler; import org.apache.hivemind.HiveMindMessages; import org.apache.hivemind.Location; @@ -35,6 +36,9 @@ import org.apache.hivemind.internal.RegistryInfrastructure; import org.apache.hivemind.internal.ServiceModelFactory; import org.apache.hivemind.internal.ServicePoint; +import org.apache.hivemind.internal.ser.ServiceSerializationHelper; +import org.apache.hivemind.internal.ser.ServiceSerializationSupport; +import org.apache.hivemind.internal.ser.ServiceToken; import org.apache.hivemind.order.Orderer; import org.apache.hivemind.schema.Translator; import org.apache.hivemind.service.ThreadEventNotifier; @@ -46,7 +50,8 @@ * * @author Howard Lewis Ship */ -public final class RegistryInfrastructureImpl implements RegistryInfrastructure +public final class RegistryInfrastructureImpl implements RegistryInfrastructure, + ServiceSerializationSupport { private static final String SYMBOL_SOURCES = "hivemind.SymbolSources"; @@ -74,6 +79,14 @@ private ShutdownCoordinator _shutdownCoordinator; /** + * Map of {@link org.apache.hivemind.internal.ser.ServiceToken}, keyed on service id. + * + * @since 1.1 + */ + + private Map _serviceTokens; + + /** * Map of {@link ServiceModelFactory}, keyed on service model name, loaded from * hivemind.ServiceModels configuration point. */ @@ -294,6 +307,9 @@ public synchronized void shutdown() { checkShutdown(); + + ServiceSerializationHelper.resetServiceSerializationSupport(this); + // Allow service implementations and such to shutdown. ShutdownCoordinator coordinatorService = (ShutdownCoordinator) getService( @@ -316,6 +332,7 @@ _variableSources = null; _serviceModelFactories = null; _threadEventNotifier = null; + _serviceTokens = null; // It is believed that the cache held by PropertyUtils can affect application shutdown // and reload in some servlet containers (such as Tomcat); this should clear that up. @@ -340,6 +357,10 @@ * locks down the Registry so that no further extension points may be added. This method may * only be invoked once. *

+ * This instance is stored into + * {@link ServiceSerializationHelper#setServiceSerializationSupport(ServiceSerializationSupport)}. + * This may cause errors (and incorrect behavior) if multiple Registries exist in a single JVM. + *

* In addition, the service hivemind.Startup is obtained and run() * is invoked on it. This allows additional startup, provided in the * hivemind.Startup configuration point, to be executed. @@ -348,6 +369,8 @@ { checkStarted(); + ServiceSerializationHelper.setServiceSerializationSupport(this); + _started = true; Runnable startup = (Runnable) getService("hivemind.Startup", Runnable.class, null); @@ -452,5 +475,38 @@ public Translator getTranslator(String translator) { return _translatorManager.getTranslator(translator); + } + + public Object getServiceFromToken(ServiceToken token) + { + Defense.notNull(token, "token"); + + checkShutdown(); + + String serviceId = token.getServiceId(); + + ServicePoint sp = (ServicePoint) _servicePoints.get(serviceId); + + return sp.getService(Object.class); + } + + public synchronized ServiceToken getServiceTokenForService(String serviceId) + { + Defense.notNull(serviceId, "serviceId"); + + checkShutdown(); + + if (_serviceTokens == null) + _serviceTokens = new HashMap(); + + ServiceToken result = (ServiceToken) _serviceTokens.get(serviceId); + + if (result == null) + { + result = new ServiceToken(serviceId); + _serviceTokens.put(serviceId, result); + } + + return result; } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/ServiceSerializationSupport.java Index: ServiceSerializationSupport.java =================================================================== package org.apache.hivemind.internal.ser; /** * Utility interface used to support serialization of services (really, service proxies). * * @author Howard M. Lewis Ship * @since 1.1 */ public interface ServiceSerializationSupport { /** * Returns a {@link ServiceToken}corresponding to the indicated serviceId. A ServiceToken takes * the place of a service (proxy) during serialization. */ public ServiceToken getServiceTokenForService(String serviceId); /** * Returns the service (proxy) for the indicated token. */ public Object getServiceFromToken(ServiceToken token); } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/SerMessages.java Index: SerMessages.java =================================================================== package org.apache.hivemind.internal.ser; import org.apache.hivemind.impl.MessageFormatter; /** * @author Howard M. Lewis Ship * @since 1.1 */ class SerMessages { private static final MessageFormatter _formatter = new MessageFormatter(SerMessages.class, "SerStrings"); public static String noSupportSet() { return _formatter.getMessage("no-support-set"); } public static String supportAlreadySet(Object newSupport, Object oldSupport) { return _formatter.format("support-already-set", newSupport, oldSupport); } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/ServiceToken.java Index: ServiceToken.java =================================================================== package org.apache.hivemind.internal.ser; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.ObjectStreamException; import org.apache.hivemind.Defense; /** * Instance used to replace actual service (proxies) during serialization. Note that this represents * a back-door into HiveMind's {@link org.apache.hivemind.internal.RegistryInfrastructure}, which * is less than ideal, and should not be used by end-user code! * * @author Howard M. Lewis Ship */ public class ServiceToken implements Externalizable { private String _serviceId; // Needed for Externalizable. public ServiceToken() { } public ServiceToken(String serviceId) { Defense.notNull(serviceId, "serviceId"); _serviceId = serviceId; } public String getServiceId() { return _serviceId; } public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(_serviceId); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { _serviceId = in.readUTF(); } Object readResolve() { return ServiceSerializationHelper.getServiceSerializationSupport() .getServiceFromToken(this); } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/SerStrings.properties Index: SerStrings.properties =================================================================== # # Copyright 2004 The Apache Software Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. no-support-set=The ServiceSerializationSupport instance has not been set; this indicates that the HiveMind Registry has not been created within this JVM. support-already-set=Replacing ServiceSerializationSupport instance {0} with {1}; this indicates that multiple HiveMind Registies have been created, and conflicts may occur. 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/ServiceSerializationHelper.java Index: ServiceSerializationHelper.java =================================================================== package org.apache.hivemind.internal.ser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hivemind.ApplicationRuntimeException; /** * Class used to hold a global instance of * {@link org.apache.hivemind.internal.ser.ServiceSerializationSupport}, so that * {@link org.apache.hivemind.internal.ser.ServiceToken}s may locate them. * * @author Howard M. Lewis Ship * @since 1.1 */ public class ServiceSerializationHelper { private static final Log LOG = LogFactory.getLog(ServiceSerializationHelper.class); private static ServiceSerializationSupport _serviceSerializationSupport; /** * Returns the previously stored SSS. * * @throws ApplicationRuntimeException * if no SSS has been stored. */ public static ServiceSerializationSupport getServiceSerializationSupport() { if (_serviceSerializationSupport == null) throw new ApplicationRuntimeException(SerMessages.noSupportSet()); return _serviceSerializationSupport; } /** * Stores the SSS instance for later access; if an existing SSS is already stored, then an error * is logged (should be just one SSS per class loader). */ public static void setServiceSerializationSupport( ServiceSerializationSupport serviceSerializationSupport) { if (serviceSerializationSupport != null && _serviceSerializationSupport != null) LOG.error(SerMessages.supportAlreadySet( serviceSerializationSupport, _serviceSerializationSupport)); _serviceSerializationSupport = serviceSerializationSupport; } /** * Invoked to clear the SSS, if it matches the provide parameter. This is necessary, rather than * blindly setting it to null, because of a tricky case related to * {@link org.apache.hivemind.servlet.HiveMindFilter}, which includes the ability to create a * new Registry on the fly and has to leave both Registry's running for a brief window. */ public static void resetServiceSerializationSupport( ServiceSerializationSupport serviceSerializationSupport) { if (_serviceSerializationSupport == serviceSerializationSupport) _serviceSerializationSupport = null; } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/ser/package.html Index: package.html =================================================================== Serialization of services. 1.7 +1 -1 jakarta-hivemind/forrest.properties Index: forrest.properties =================================================================== RCS file: /home/cvs/jakarta-hivemind/forrest.properties,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- forrest.properties 19 Nov 2004 20:28:49 -0000 1.6 +++ forrest.properties 4 Jan 2005 01:06:22 -0000 1.7 @@ -17,7 +17,7 @@ forrest.echo=on project.debuglevel=DEBUG -project.bugtracking-url=http://nagoya.apache.org/jira/browse/ +project.bugtracking-url=http://issues.apache.org/jira/browse/ project.configfile=${project.home}/src/documentation/conf/cli.xconf 1.89 +4 -0 jakarta-hivemind/status.xml Index: status.xml =================================================================== RCS file: /home/cvs/jakarta-hivemind/status.xml,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- status.xml 30 Dec 2004 18:55:32 -0000 1.88 +++ status.xml 4 Jan 2005 01:06:22 -0000 1.89 @@ -130,6 +130,10 @@ Add support for conditional contributions. + + Allow services to be serialized (that is, service proxies can be serialized and + deserialized). + 1.21 +3 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java Index: HiveMindTestCase.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HiveMindTestCase.java 28 Dec 2004 22:43:15 -0000 1.20 +++ HiveMindTestCase.java 4 Jan 2005 01:06:22 -0000 1.21 @@ -33,6 +33,7 @@ import org.apache.hivemind.impl.LocationImpl; import org.apache.hivemind.impl.RegistryBuilder; import org.apache.hivemind.impl.XmlModuleDescriptorProvider; +import org.apache.hivemind.internal.ser.ServiceSerializationHelper; import org.apache.hivemind.util.ClasspathResource; import org.apache.hivemind.util.PropertyUtils; import org.apache.hivemind.util.URLResource; @@ -220,6 +221,8 @@ } PropertyUtils.clearCache(); + + ServiceSerializationHelper.setServiceSerializationSupport(null); } /** 1.6 +13 -10 jakarta-hivemind/library/src/test/hivemind/test/lib/TestEJBProxyFactory.java Index: TestEJBProxyFactory.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/library/src/test/hivemind/test/lib/TestEJBProxyFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TestEJBProxyFactory.java 25 Jun 2004 20:20:00 -0000 1.5 +++ TestEJBProxyFactory.java 4 Jan 2005 01:06:22 -0000 1.6 @@ -1,4 +1,4 @@ -// Copyright 2004 The Apache Software Foundation +// Copyright 2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,8 +46,9 @@ context.bind("hivemind.test.lib.Simple", home); NameLookupHack._context = context; - SimpleRemote object = - (SimpleRemote) r.getService("hivemind.test.lib.SimpleRemote", SimpleRemote.class); + SimpleRemote object = (SimpleRemote) r.getService( + "hivemind.test.lib.SimpleRemote", + SimpleRemote.class); assertEquals(7, object.add(4, 3)); // Exercise several code paths where objects are ready or cached. @@ -72,8 +73,9 @@ NameLookupHack._context = context; - SimpleRemote object = - (SimpleRemote) r.getService("hivemind.test.lib.SimpleRemote", SimpleRemote.class); + SimpleRemote object = (SimpleRemote) r.getService( + "hivemind.test.lib.SimpleRemote", + SimpleRemote.class); try { @@ -84,8 +86,8 @@ catch (ApplicationRuntimeException ex) { assertExceptionSubstring( - ex, - "Unable to lookup 'hivemind.test.lib.Simple' in JNDI context"); + ex, + "Unable to lookup 'hivemind.test.lib.Simple' in JNDI context"); Throwable t = findNestedException(ex); @@ -106,8 +108,9 @@ NameLookupHack._context = context; - SimpleRemote object = - (SimpleRemote) r.getService("hivemind.test.lib.SimpleRemote", SimpleRemote.class); + SimpleRemote object = (SimpleRemote) r.getService( + "hivemind.test.lib.SimpleRemote", + SimpleRemote.class); try { @@ -121,4 +124,4 @@ } } -} +} \ No newline at end of file 1.18 +6 -6 jakarta-hivemind/framework/src/test/hivemind/test/FrameworkTestCase.java Index: FrameworkTestCase.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/FrameworkTestCase.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- FrameworkTestCase.java 16 Nov 2004 10:27:12 -0000 1.17 +++ FrameworkTestCase.java 4 Jan 2005 01:06:22 -0000 1.18 @@ -18,6 +18,7 @@ import org.apache.hivemind.Resource; import org.apache.hivemind.impl.DefaultClassResolver; import org.apache.hivemind.impl.DefaultErrorHandler; +import org.apache.hivemind.internal.ser.ServiceSerializationHelper; import org.apache.hivemind.parse.ConfigurationPointDescriptor; import org.apache.hivemind.parse.DependencyDescriptor; import org.apache.hivemind.parse.ModuleDescriptor; @@ -27,7 +28,7 @@ /** * Base class for framework tests. - * + * * @author Howard Lewis Ship */ public abstract class FrameworkTestCase extends HiveMindTestCase @@ -64,7 +65,7 @@ protected ModuleDescriptor createModuleDescriptor(String moduleId, String version) { ModuleDescriptor result = new ModuleDescriptor(_resolver, new DefaultErrorHandler()); - + result.setModuleId(moduleId); result.setVersion(version); result.setLocation(fabricateLocation(0)); @@ -78,11 +79,11 @@ protected DependencyDescriptor createDependencyDescriptor(String moduleId, String version) { DependencyDescriptor result = new DependencyDescriptor(); - + result.setModuleId(moduleId); result.setVersion(version); result.setLocation(fabricateLocation(0)); - + return result; } @@ -113,5 +114,4 @@ return result; } - -} +} \ No newline at end of file 1.16 +11 -9 jakarta-hivemind/framework/src/java/org/apache/hivemind/servlet/HiveMindFilter.java Index: HiveMindFilter.java =================================================================== RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/servlet/HiveMindFilter.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- HiveMindFilter.java 22 Dec 2004 00:11:02 -0000 1.15 +++ HiveMindFilter.java 4 Jan 2005 01:06:22 -0000 1.16 @@ -34,6 +34,7 @@ import org.apache.hivemind.impl.DefaultClassResolver; import org.apache.hivemind.impl.RegistryBuilder; import org.apache.hivemind.impl.XmlModuleDescriptorProvider; +import org.apache.hivemind.internal.ser.ServiceSerializationHelper; import org.apache.hivemind.util.ContextResource; /** @@ -109,6 +110,12 @@ addWebInfDescriptor(config.getServletContext(), resolver, builder); + // This avoids an error message when replacing the SSS (really, the RegistryInfrastructure). + // HiveMindFilter's reload-the-registry functionality is an exception to the rule + // that there should just be one Registry per JVM. + + ServiceSerializationHelper.setServiceSerializationSupport(null); + return builder.constructRegistry(getRegistryLocale()); } @@ -179,15 +186,6 @@ if (request.getAttribute(REBUILD_REQUEST_KEY) == null) return; - // This is so not threadsafe, but you don't do this very often. - // This method is synchronized, but other threads may be actively using - // the Registry we're shutting down. - - // What we really need is some good concurrence support to track the number - // of threads that may be using the old registry, set a write lock, and wait - // for that number to drop to one (this thread). Instead, we'll just swap in the - // new Registry and hope for the best. - Registry oldRegistry = _registry; // Replace the old Registry with a new one. All other threads, but this @@ -199,6 +197,10 @@ // Shutdown the old Registry. Perhaps we should sleep for a moment, first, // to help ensure that other threads have "cleared out". If not, we'll see some // instability at the instant we shutdown (i.e., all the proxies will get disabled). + // Alternately, we should create a WeakReference based monitor that shuts down the + // old registry when it is no longer used by any other threads. For the moment, + // this functionality is limited to development-time only (not production), so it isn't + // urgent. oldRegistry.shutdown(); } 1.2 +72 -66 jakarta-hivemind/src/documentation/content/HiveMind-QuickReference.doc <> --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org