You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2010/09/16 18:39:23 UTC
svn commit: r997833 - in /cayenne/main/trunk:
framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/
framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/
tutorials/tutorial-rop-clien...
Author: aadamchik
Date: Thu Sep 16 16:39:22 2010
New Revision: 997833
URL: http://svn.apache.org/viewvc?rev=997833&view=rev
Log:
cleaning up the distro for 3.1M1:
* fixing rop tutorial
* fixing SessionContextRequestHandler context retrieval
* renaming CayenneWebModule to WebModule to follow other modules naming conventions
Added:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/WebModule.java
- copied, changed from r997754, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneWebModule.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/WebModuleTest.java
- copied, changed from r997754, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneWebModuleTest.java
Removed:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneWebModule.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneWebModuleTest.java
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/SessionContextRequestHandler.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneFilterTest.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/ServletContextHandlerTest.java
cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
cayenne/main/trunk/tutorials/tutorial-rop-server/src/main/webapp/WEB-INF/web.xml
cayenne/main/trunk/tutorials/tutorial/src/main/webapp/WEB-INF/web.xml
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java Thu Sep 16 16:39:22 2010
@@ -36,7 +36,7 @@ import org.apache.cayenne.di.Module;
/**
* A filter that creates a Cayenne server runtime, possibly including custom modules. By
- * default runtime includes {@link ServerModule} and {@link CayenneWebModule}. Any
+ * default runtime includes {@link ServerModule} and {@link WebModule}. Any
* custom modules are loaded after the two standard ones to allow custom service
* overrides. Filter initialization parameters:
* <ul>
@@ -67,11 +67,12 @@ public class CayenneFilter implements Fi
WebConfiguration configAdapter = new WebConfiguration(config);
String configurationLocation = configAdapter.getConfigurationLocation();
- Collection<Module> modules = configAdapter.createModules(new CayenneWebModule());
+ Collection<Module> modules = configAdapter.createModules(new WebModule());
ServerRuntime runtime = new ServerRuntime(
configurationLocation,
modules);
+
WebUtil.setCayenneRuntime(config.getServletContext(), runtime);
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/SessionContextRequestHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/SessionContextRequestHandler.java?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/SessionContextRequestHandler.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/SessionContextRequestHandler.java Thu Sep 16 16:39:22 2010
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpSession;
import org.apache.cayenne.BaseContext;
import org.apache.cayenne.DataChannel;
import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.ObjectContextFactory;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.di.Injector;
@@ -47,6 +48,8 @@ public class SessionContextRequestHandle
.getName()
+ ".SESSION_CONTEXT";
+ // using injector to lookup services instead of injecting them directly for lazy
+ // startup and "late binding"
@Inject
private Injector injector;
@@ -65,7 +68,9 @@ public class SessionContextRequestHandle
context = (ObjectContext) session.getAttribute(SESSION_CONTEXT_KEY);
if (context == null) {
- context = injector.getInstance(ObjectContext.class);
+ context = injector
+ .getInstance(ObjectContextFactory.class)
+ .createContext();
session.setAttribute(SESSION_CONTEXT_KEY, context);
}
}
Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/WebModule.java (from r997754, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneWebModule.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/WebModule.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/WebModule.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneWebModule.java&r1=997754&r2=997833&rev=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneWebModule.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/WebModule.java Thu Sep 16 16:39:22 2010
@@ -24,7 +24,7 @@ import org.apache.cayenne.di.Module;
/**
* @since 3.1
*/
-public class CayenneWebModule implements Module {
+public class WebModule implements Module {
public void configure(Binder binder) {
binder
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneFilterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneFilterTest.java?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneFilterTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneFilterTest.java Thu Sep 16 16:39:22 2010
@@ -95,7 +95,7 @@ public class CayenneFilterTest extends T
RuntimeProperties.class).get(ServerModule.CONFIGURATION_LOCATION));
assertEquals(2, runtime.getModules().length);
assertTrue(runtime.getModules()[0] instanceof ServerModule);
- assertTrue(runtime.getModules()[1] instanceof CayenneWebModule);
+ assertTrue(runtime.getModules()[1] instanceof WebModule);
RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class);
assertTrue(handler instanceof SessionContextRequestHandler);
@@ -121,7 +121,7 @@ public class CayenneFilterTest extends T
assertEquals(4, runtime.getModules().length);
assertTrue(runtime.getModules()[0] instanceof ServerModule);
- assertTrue(runtime.getModules()[1] instanceof CayenneWebModule);
+ assertTrue(runtime.getModules()[1] instanceof WebModule);
assertTrue(runtime.getModules()[2] instanceof MockModule1);
assertTrue(runtime.getModules()[3] instanceof MockModule2);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/ServletContextHandlerTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/ServletContextHandlerTest.java?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/ServletContextHandlerTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/ServletContextHandlerTest.java Thu Sep 16 16:39:22 2010
@@ -25,6 +25,7 @@ import org.apache.cayenne.DataChannel;
import org.apache.cayenne.MockDataChannel;
import org.apache.cayenne.MockObjectContext;
import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.ObjectContextFactory;
import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.DIBootstrap;
import org.apache.cayenne.di.Injector;
@@ -41,11 +42,19 @@ public class ServletContextHandlerTest e
Module module = new Module() {
public void configure(Binder binder) {
- binder
- .bind(ObjectContext.class)
- .to(MockObjectContext.class)
- .withoutScope();
+
binder.bind(DataChannel.class).to(MockDataChannel.class);
+ binder.bind(ObjectContextFactory.class).toInstance(
+ new ObjectContextFactory() {
+
+ public ObjectContext createContext(DataChannel parent) {
+ return new MockObjectContext();
+ }
+
+ public ObjectContext createContext() {
+ return new MockObjectContext();
+ }
+ });
}
};
Injector injector = DIBootstrap.createInjector(module);
Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/WebModuleTest.java (from r997754, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneWebModuleTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/WebModuleTest.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/WebModuleTest.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneWebModuleTest.java&r1=997754&r2=997833&rev=997833&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/CayenneWebModuleTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/web/WebModuleTest.java Thu Sep 16 16:39:22 2010
@@ -23,11 +23,11 @@ import org.apache.cayenne.di.spi.Default
import junit.framework.TestCase;
-public class CayenneWebModuleTest extends TestCase {
+public class WebModuleTest extends TestCase {
public void testBind_Scopes() {
- Injector injector = new DefaultInjector(new CayenneWebModule());
+ Injector injector = new DefaultInjector(new WebModule());
RequestHandler handler = injector.getInstance(RequestHandler.class);
assertTrue(handler instanceof SessionContextRequestHandler);
Modified: cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java (original)
+++ cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java Thu Sep 16 16:39:22 2010
@@ -36,7 +36,7 @@ public class Main {
Map<String, String> properties = new HashMap<String, String>();
properties.put(ClientModule.ROP_SERVICE_URL,
- "http://localhost:8080/tutorial/cayenne-service");
+ "http://localhost:8080/tutorial-rop-server/cayenne-service");
properties.put(ClientModule.ROP_SERVICE_USER_NAME, "cayenne-user");
properties.put(ClientModule.ROP_SERVICE_PASSWORD, "secret");
Modified: cayenne/main/trunk/tutorials/tutorial-rop-server/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial-rop-server/src/main/webapp/WEB-INF/web.xml?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/tutorials/tutorial-rop-server/src/main/webapp/WEB-INF/web.xml (original)
+++ cayenne/main/trunk/tutorials/tutorial-rop-server/src/main/webapp/WEB-INF/web.xml Thu Sep 16 16:39:22 2010
@@ -23,12 +23,12 @@
<web-app>
<display-name>Cayenne Tutorial</display-name>
<servlet>
- <servlet-name>cayenne-service</servlet-name>
+ <servlet-name>cayenne-UntitledDomain</servlet-name>
<servlet-class>org.apache.cayenne.configuration.rop.server.ROPHessianServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
- <servlet-name>cayenne-service</servlet-name>
+ <servlet-name>cayenne-UntitledDomain</servlet-name>
<url-pattern>/cayenne-service</url-pattern>
</servlet-mapping>
Modified: cayenne/main/trunk/tutorials/tutorial/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial/src/main/webapp/WEB-INF/web.xml?rev=997833&r1=997832&r2=997833&view=diff
==============================================================================
--- cayenne/main/trunk/tutorials/tutorial/src/main/webapp/WEB-INF/web.xml (original)
+++ cayenne/main/trunk/tutorials/tutorial/src/main/webapp/WEB-INF/web.xml Thu Sep 16 16:39:22 2010
@@ -28,11 +28,11 @@
DataContext
-->
<filter>
- <filter-name>cayenne-UntiltledDomain</filter-name>
+ <filter-name>cayenne-UntitledDomain</filter-name>
<filter-class>org.apache.cayenne.configuration.web.CayenneFilter</filter-class>
</filter>
<filter-mapping>
- <filter-name>cayenne-UntiltledDomain</filter-name>
+ <filter-name>cayenne-UntitledDomain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>