cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r997754 - in /cayenne/main/trunk: docs/doc/src/main/resources/ tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/ tutorials/tutorial-rop-client/src/main/resources/ tutorials/tutorial-rop-server/src/ma...
Date Thu, 16 Sep 2010 14:04:49 GMT
Author: aadamchik
Date: Thu Sep 16 14:04:49 2010
New Revision: 997754

URL: http://svn.apache.org/viewvc?rev=997754&view=rev
Log:
cleaning up the distro for 3.1M1:

* detailed upgrade notes
* converting tutorials

Added:
    cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/resources/
    cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/resources/.gitignore
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
    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/detail.jsp
    cayenne/main/trunk/tutorials/tutorial/src/main/webapp/index.jsp

Modified: cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt?rev=997754&r1=997753&r2=997754&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt Thu Sep 16 14:04:49 2010
@@ -1,22 +1,92 @@
 Apache Cayenne Upgrade Information
 ==================================
 
-UPGRADING FROM 3.0-final
+IMPORTANT: be sure to read all notes for the intermediate releases between your
+           current release and the release you are upgrading to.
+-------------------------------------------------------------------------------
+
+UPGRADING TO 3.1M1
+
+The most essential change in Cayenne 3.1 is a new Dependency-Injection (DI) based
+bootstrap and configuration mechanism, which is not backwards compatible with 3.0.
+Read on to learn about specific areas that require attention when upgrading your
+application.
+
+* Upgrading 3.0.x mapping files: Open each of your existing projects in the new 
+  CayenneModeler. Agree to perform an upgrade when asked. Note that Cayenne
+  3.1 only supports one DataDomain per project, so if multiple domains existed in 
+  the project, you'll end up with multiple project files  after the upgrade. Each 
+  will require instantiation of a separate ServerRuntime in the code.
+
+* Upgrading 2.0.x and earlier mappings files: Note that CayenneModeler
+  3.1 won't be able to upgrade projects created with a Modeler older than 3.0. To 
+  upgrade older projects do it in two steps - download Cayenne 3.0, and perform an
+  upgrade with 3.0 CayenneModeler. After that perform a second upgrade from 3.0 to
+  3.1.
+
+* Cayenne runtime bootstrap: In 3.1 all classes under "org.apache.cayenne.conf"
+  package were removed, superseded by dependency injection (DI) based configuration,
+  with main classes located under "org.apache.cayenne.configuration" and its 
+  subpackages. E.g. to instantiate the Cayenne stack in 3.1 you would do 
+  something like that:
 
-* Per CAY-1310 all API deprecated in 3.0 is removed. So this may require some code cleanup.
-  Also if custom class generation templates are used, doublecheck that they are no longer
-  using removed EntityUtil methods (those were replaced by variables placed directly into
-  Velocity context)
-
-* Custom DataSourceFactory: The interface used by Cayenne to load custom DataSource factories
has changed
-  from org.apache.cayenne.conf.DataSourceFactory to org.apache.cayenne.configuration.DataSourceFactory.

-  This new interface must be implemented by the custom factories. Note that now custom
-  implementations can rely on Cayenne to inject dependencies into them using @Inject annotation.
-
-* Custom DbAdapter / DbAdapterFactory: The interface used by Cayenne to allow custom DbAdapters
to be auto-detected 
-  with AutoAdapter has changed from org.apache.cayenne.dba.DbAdapterFactory to org.apache.cayenne.configuration.DbAdapterDetector.

-  Note that now custom implementations can rely on Cayenne to inject dependencies into them
using @Inject annotation.
-  To register a custom implementation with Cayenne DI container, one might do this in the
custom DI module:
+  ServerRuntime runtime = new ServerRuntime("cayenne-UntitledDomain.xml");
+  
+  To obtain a new ObjectContext, the following API is used:
+		
+  ObjectContext context = cayenneRuntime.getContext();
+
+* No static configuration singleton: Cayenne 3.1 completely gets rid of a (previously 
+  optional, but widely used) "Configuiration.sharedConfiguration" singleton. This 
+  change was done to acknowledge the fact that single configuration per application 
+  is just a special case, and generally user can instantiate as many configurations 
+  (or ServerRuntime's in 3.1 terms) as appropriate. This however means that the 
+  users must now decide themselves where in their application it is appropriate to 
+  store ServerRuntime instance (or instances). E.g. it can be stored as an attribute 
+  of ServletContext (check out "org.apache.cayenne.configuration.web.CayenneFilter" and 
+  "org.apache.cayenne.configuration.web.WebUtil"), reside in a user's favorite dependency
+  injection container (e.g. Spring), or even be saved in a user's own static singleton 
+  variable.
+
+* No static DataContext creation methods: Methods like DataContext.createDataContext()
+  were relying on static configuration singleton, which was removed (see above). Use
+  ServerRuntime instance methods to create context instances.
+
+* Webapp configuration changes: "org.apache.cayenne.conf.WebApplicationContextFilter"
+  was replaced by "org.apache.cayenne.configuration.web.CayenneFilter". See CayenneFilter
+  javadocs for details on of the init parameters.
+
+* ROP Server configuration changes: "org.apache.cayenne.remote.hessian.service.HessianServlet"
+  was replaced by "org.apache.cayenne.configuration.rop.server.ROPHessianServlet". See
+  ROPHessianServlet javadocs for details on its init parameters. 
+
+* ROP Client configuration changes: There is now a special DI "runtime" object -
+  "org.apache.cayenne.configuration.rop.client.ClientRuntime", so client connection
+  and channel can be (optionally) managed via DI, with connection parameters 
+  specified as properties. E.g.:
+  
+	Map<String, String> properties = new HashMap<String, String>();
+	properties.put(ClientModule.ROP_SERVICE_URL, "http://localhost:8080/tutorial/cayenne-service");
+	properties.put(ClientModule.ROP_SERVICE_USER_NAME, "cayenne-user");
+	properties.put(ClientModule.ROP_SERVICE_PASSWORD, "secret");
+
+	ClientRuntime runtime = new ClientRuntime(properties);
+	ObjectContext context = runtime.getContext();
+	
+  The advantage of this approach in that all the client stack objects are managed
+  by the DI container and a user can customize/override various pieces.
+
+* Deprecated API removal: All API deprecated as of 3.0 is removed. This may require 
+  some code cleanup. Since 3.0 javadocs for suggested replacements. Also if custom 
+  class generation templates are used, doublecheck that they do not reference removed 
+  EntityUtil methods, which were replaced by variables placed directly into Velocity context.
+
+* Custom DbAdapter / DbAdapterFactory: The interface used by Cayenne to allow custom 
+  DbAdapters to be auto-detected with AutoAdapter has changed from 
+  org.apache.cayenne.dba.DbAdapterFactory to org.apache.cayenne.configuration.DbAdapterDetector.

+  Note that now a custom implementation can rely on Cayenne DI to obtain Cayenne 
+  dependencies via @Inject annotation. To register a custom implementation with 
+  Cayenne DI container, one might do this in the custom DI module:
 
   ... 
   public void configure(Binder binder) {
@@ -24,13 +94,35 @@ UPGRADING FROM 3.0-final
      binder.bindList(DbAdapterFactory.class).add(new MyDbAdapterDetector());
   }
 
+* Custom DataSourceFactory: The interface used by Cayenne to load custom DataSource 
+  factories has changed from "org.apache.cayenne.conf.DataSourceFactory" to 
+  "org.apache.cayenne.configuration.DataSourceFactory". This new interface must be 
+  implemented by the custom factories. Note that now a custom implementation can 
+  rely on Cayenne DI to obtain Cayenne dependencies via @Inject annotation.
+
+* Replaced JNDI preferences hack with runtime properties: "JNDI hack", as it was 
+  known prior to 3.1, allowed to define a named database connection using CayenneModeler,

+  and then Cayenne would read this connection information from Modeler preferences 
+  and use it as a failover for JNDI DataNodes. The problem with this is that it 
+  required CayenneModeler and HSQLDB jars on the application classpath, and also that the

+  preferences database was prone to data corruption. In 3.1, preferences hack is no
+  longer available. Instead JNDI (or really any other type of DataSourceFactory) 
+  can be overridden via runtime properties (or by redefining DataSourceFactoryLoader
+  via DI). See org.apache.cayenne.configuration.server.PropertyDataSourceFactory javadocs
for
+  details. Here are some simple examples:
+
+  -Dcayenne.jdbc.url=jdbc://urloverride 
+  -Dcayenne.jdbc.driver=com.example.MyDriver 
+  -Dcayenne.jdbc.username=foo
+  -Dcayenne.jdbc.password=bar
 
-UPGRADING FROM 3.0M6
+
+UPGRADING TO 3.0B1
 
 * Per CAY-1281 pre-persist callback was renamed to post-add (while pre-persist now has a
different meaning).
   To upgrade your project, open it in the Modeler and agree to perform an automated upgrade.
 
-UPGRADING FROM 3.0M5
+UPGRADING TO 3.0M6
 
 * Per CAY-1154, org.apache.cayenne.access.reveng package was renamed to org.apache.cayenne.map.naming.
So, if you
   use your own naming strategies, you should update as well.
@@ -41,7 +133,7 @@ UPGRADING FROM 3.0M5
 * Per CAY-1175, 'columnNameCapitalization' property of SQLTemplate now takes an enum, not
a String. 
   Calling code should be fixed.
 
-UPGRADING FROM 3.0M4
+UPGRADING TO 3.0M5
 
 * Per CAY-1127, query "name" property is no longer used as an internal cache key. This change
should be transparent
   to most users, as Cayenne generates a correct cache key internally when needed, however
if a user code explicitly
@@ -49,21 +141,20 @@ UPGRADING FROM 3.0M4
     
   String cacheKey = query.getQueryMetadata(entityResolver).getCacheKey();
 
-UPGRADING FROM 3.0M3
+UPGRADING TO 3.0M4
 
 * Per CAY-1049 API of the internal classes that participate in SelectQuery translation has
changed in a way that
   is not backwards compatible. This should not affect regular users, however if you implemented
a custom DbAdapter,
   check for classes that directly or indirectly inherit from QueryAssembler and QueryAssemblerHelper
and fix them
   if needed.
 
-UPGRADING FROM 3.0M2
+UPGRADING TO 3.0M3
 
 * Java 5 is now required as a minimum for Cayenne Modeler and the Cayenne libraries.
 
 * After the move to Java 5, generics have been implemented in many of the Cayenne APIs. If
you don't use generics in your project this should not affect you, but if you do you will
need to review any new compiler errors or warnings. The effect of generics is at compile time
only, so their introduction will not change the runtime behaviour of your application once
compiled.
 
-
-UPGRADING FROM 3.0M1
+UPGRADING TO 3.0M2
 
 * Lifecycle Callbacks require no setup:
   Per CAY-843, lifecycle callback functionality is now built into DataContext and DataDomain,

@@ -71,7 +162,7 @@ UPGRADING FROM 3.0M1
   'org.apache.cayenne.intercept' package is removed from Cayenne.
   Further information can be found here: http://cayenne.apache.org/doc/lifecycle-callbacks.html
 
-UPGRADING FROM 2.0 AND OTHER APACHE RELEASES
+UPGRADING TO 3.0M1
 
 * Jar files:
   - all jar files now include version numbers in their names.
@@ -106,7 +197,7 @@ UPGRADING FROM 2.0 AND OTHER APACHE RELE
   ALTER TABLE AUTO_PK_SUPPORT CHANGE COLUMN NEXT_ID NEXT_ID BIGINT NOT NULL;
   
 
-UPGRADING FROM 1.2 AND OTHER OBJECTSTYLE RELEASES
+UPGRADING TO 2.0.x
 
 Since 2.0, Cayenne is an Apache project, so all "org.objectstyle.*" java packages 
 where renamed to "org.apache.*" analogues. Since 1.2.x and 2.0.x release lines maintain

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=997754&r1=997753&r2=997754&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 14:04:49 2010
@@ -18,28 +18,31 @@
  ****************************************************************/
 package org.apache.cayenne.tutorial.persistent.client;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.cayenne.CayenneContext;
-import org.apache.cayenne.DataChannel;
-import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.Cayenne;
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.configuration.rop.client.ClientModule;
+import org.apache.cayenne.configuration.rop.client.ClientRuntime;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.remote.ClientChannel;
-import org.apache.cayenne.remote.ClientConnection;
-import org.apache.cayenne.remote.hessian.HessianConnection;
 
 public class Main {
 
 	public static void main(String[] args) {
 
-		ClientConnection connection = new HessianConnection(
-				"http://localhost:8080/tutorial/cayenne-service",
-				"cayenne-user", "secret", null);
-		DataChannel channel = new ClientChannel(connection);
-		ObjectContext context = new CayenneContext(channel);
+		Map<String, String> properties = new HashMap<String, String>();
+		properties.put(ClientModule.ROP_SERVICE_URL,
+				"http://localhost:8080/tutorial/cayenne-service");
+		properties.put(ClientModule.ROP_SERVICE_USER_NAME, "cayenne-user");
+		properties.put(ClientModule.ROP_SERVICE_PASSWORD, "secret");
+
+		ClientRuntime runtime = new ClientRuntime(properties);
+
+		ObjectContext context = runtime.getContext();
 
 		newObjectsTutorial(context);
 		selectTutorial(context);
@@ -89,7 +92,7 @@ public class Main {
 		Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY,
 				"Pablo Picasso");
 		SelectQuery selectToDelete = new SelectQuery(Artist.class, qualifier);
-		Artist picasso = (Artist) DataObjectUtils.objectForQuery(context,
+		Artist picasso = (Artist) Cayenne.objectForQuery(context,
 				selectToDelete);
 
 		if (picasso != null) {

Added: cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/resources/.gitignore
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial-rop-client/src/main/resources/.gitignore?rev=997754&view=auto
==============================================================================
    (empty)

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=997754&r1=997753&r2=997754&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 14:04:49 2010
@@ -24,7 +24,7 @@
 	<display-name>Cayenne Tutorial</display-name>
 	<servlet>
 		<servlet-name>cayenne-service</servlet-name>
-		<servlet-class>org.apache.cayenne.remote.hessian.service.HessianServlet</servlet-class>
+		<servlet-class>org.apache.cayenne.configuration.rop.server.ROPHessianServlet</servlet-class>
 		<load-on-startup>0</load-on-startup>
 	</servlet>
 	<servlet-mapping>

Modified: cayenne/main/trunk/tutorials/tutorial/src/main/webapp/detail.jsp
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial/src/main/webapp/detail.jsp?rev=997754&r1=997753&r2=997754&view=diff
==============================================================================
--- cayenne/main/trunk/tutorials/tutorial/src/main/webapp/detail.jsp (original)
+++ cayenne/main/trunk/tutorials/tutorial/src/main/webapp/detail.jsp Thu Sep 16 14:04:49 2010
@@ -31,7 +31,7 @@
     // find artist for id
     Artist artist = null;
     if(id != null && id.trim().length() > 0) {
-        artist = DataObjectUtils.objectForPK(context, Artist.class, Integer.parseInt(id));
+        artist = Cayenne.objectForPK(context, Artist.class, Integer.parseInt(id));
     }
 
     if("POST".equals(request.getMethod())) {

Modified: cayenne/main/trunk/tutorials/tutorial/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/tutorials/tutorial/src/main/webapp/index.jsp?rev=997754&r1=997753&r2=997754&view=diff
==============================================================================
--- cayenne/main/trunk/tutorials/tutorial/src/main/webapp/index.jsp (original)
+++ cayenne/main/trunk/tutorials/tutorial/src/main/webapp/index.jsp Thu Sep 16 14:04:49 2010
@@ -44,7 +44,7 @@
         <% } else { 
         	for(Artist a : artists) {
         %>
-        <p><a href="detail.jsp?id=<%=DataObjectUtils.intPKForObject(a)%>">
<%=a.getName()%> </a></p>
+        <p><a href="detail.jsp?id=<%=Cayenne.intPKForObject(a)%>"> <%=a.getName()%>
</a></p>
         <%
             }
             } %>



Mime
View raw message