You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/03/05 19:27:52 UTC
svn commit: r514773 - in
/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal:
ModuleImpl.java OneShotServiceCreator.java
Author: hlship
Date: Mon Mar 5 10:27:51 2007
New Revision: 514773
URL: http://svn.apache.org/viewvc?view=rev&rev=514773
Log:
TAPESTRY-1291: Tighten up some synchronized collection access and add additional tests and checks for threading errors.
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java?view=diff&rev=514773&r1=514772&r2=514773
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java Mon Mar 5 10:27:51 2007
@@ -57,6 +57,7 @@
private final Log _log;
+ // Guarded by MUTEX
private Object _moduleBuilder;
private final static String INTERNAL_MODULE_ID = "tapestry.ioc";
@@ -70,8 +71,7 @@
// Set to true when invoking the module constructor. Used to
// detect endless loops caused by irresponsible dependencies in
- // the constructor.
-
+ // the constructor. Guarded by MUTEX.
private boolean _insideConstructor;
public ModuleImpl(InternalRegistry registry, ModuleDef moduleDef, Log log)
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java?view=diff&rev=514773&r1=514772&r2=514773
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java Mon Mar 5 10:27:51 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -12,48 +12,43 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.ObjectCreator;
-import org.apache.tapestry.ioc.def.ServiceDef;
-
-/**
- * Decorator for {@link org.apache.tapestry.ioc.ObjectCreator} that ensures the service is only
- * created once. This detects a situation where the service builder for a service directly or
- * indirectly invokes methods on the service itself. This would show up as a second call up the
- * ServiceCreator stack injected into the proxy.
- * <p>
- * We could use the {@link org.apache.tapestry.internal.annotations.OneShot} annotation, but this
- * implementation gives us a bit more flexibility to report the error.
- *
- *
- */
-public class OneShotServiceCreator implements ObjectCreator
-{
- private final ServiceDef _serviceDef;
-
- private final ObjectCreator _delegate;
-
- private boolean _locked;
-
- public OneShotServiceCreator(ServiceDef serviceDef, ObjectCreator delegate)
- {
- _serviceDef = serviceDef;
- _delegate = delegate;
- }
-
- /**
- * We could make this method synchronized, but in the context of creating a service for a proxy,
- * it will already be synchronized (inside the proxy).
- */
- public Object createObject()
- {
- if (_locked)
- throw new IllegalStateException(IOCMessages.recursiveServiceBuild(_serviceDef));
-
- _locked = true;
-
- return _delegate.createObject();
- }
-
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.def.ServiceDef;
+
+/**
+ * Decorator for {@link org.apache.tapestry.ioc.ObjectCreator} that ensures the service is only
+ * created once. This detects a situation where the service builder for a service directly or
+ * indirectly invokes methods on the service itself. This would show up as a second call up the
+ * ServiceCreator stack injected into the proxy.
+ */
+public class OneShotServiceCreator implements ObjectCreator
+{
+ private final ServiceDef _serviceDef;
+
+ private final ObjectCreator _delegate;
+
+ private boolean _locked;
+
+ public OneShotServiceCreator(ServiceDef serviceDef, ObjectCreator delegate)
+ {
+ _serviceDef = serviceDef;
+ _delegate = delegate;
+ }
+
+ /**
+ * We could make this method synchronized, but in the context of creating a service for a proxy,
+ * it will already be synchronized (inside the proxy).
+ */
+ public Object createObject()
+ {
+ if (_locked)
+ throw new IllegalStateException(IOCMessages.recursiveServiceBuild(_serviceDef));
+
+ _locked = true;
+
+ return _delegate.createObject();
+ }
+
+}