Repository: cayenne Updated Branches: refs/heads/STABLE-4.0 2f472cea0 -> cde78f0b4
http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/docbkx/webapp.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/docbkx/webapp.xml b/docs/docbook/getting-started/src/docbkx/webapp.xml deleted file mode 100644 index bab9815..0000000 --- a/docs/docbook/getting-started/src/docbkx/webapp.xml +++ /dev/null @@ -1,308 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?xml-model href="http://www.oasis-open.org/docbook/xml/5.0/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to you 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. ---> -<section xmlns="http://docbook.org/ns/docbook" - xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"> - <title>Converting to Web Application</title> - <para>This chapter shows how to work with Cayenne in a web application.</para> - <section xml:id="converting-to-webapp"> - <title>Converting Tutorial to a Web Application</title> - <para>The web part of the web application tutorial is done in JSP, which is the least common - denominator of the Java web technologies, and is intentionally simplistic from the UI - perspective, to concentrate on Cayenne integration aspect, rather than the interface. A - typical Cayenne web application works like this:</para> - <itemizedlist> - <listitem> - <para>Cayenne configuiration is loaded when an application context is started, using - a special servlet filter.</para> - </listitem> - <listitem> - <para>User requests are intercepted by the filter, and the DataContext is bound to - the request thread, so the application can access it easily from - anywhere.</para> - </listitem> - <listitem> - <para>The same DataContext instance is reused within a single user session; - different sessions use different DataContexts (and therefore different sets of - objects). <emphasis role="italic">The context can be scoped differently - depending on the app specifics. For the tutorial we'll be using a - session-scoped context.</emphasis></para> - </listitem> - </itemizedlist> - <para>So let's convert the tutorial that we created to a web application:</para> - <itemizedlist> - <listitem> - <para>In IDEA under "tutorial" project folder create a new folder - "<code>src/main/webapp/WEB-INF</code>".</para> - </listitem> - <listitem> - <para>Under "<code>WEB-INF</code>" create a new file "<code>web.xml</code>" (a standard web app descriptor): </para> - <para> - <emphasis role="bold">web.xml</emphasis> - <programlisting language="xml"><?xml version="1.0" encoding="utf-8"?> - <!DOCTYPE web-app - PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> - <display-name>Cayenne Tutorial</display-name> - - <!-- This filter bootstraps ServerRuntime and then provides each request thread - with a session-bound DataContext. Note that the name of the filter is important, - as it points it to the right named configuration file. - --> - <filter> - <filter-name>cayenne-project</filter-name> - <filter-class>org.apache.cayenne.configuration.web.CayenneFilter</filter-class> - </filter> - <filter-mapping> - <filter-name>cayenne-project</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - <welcome-file-list> - <welcome-file>index.jsp</welcome-file> - </welcome-file-list> -</web-app></programlisting></para> - </listitem> - <listitem> - <para>Create the artist browser page <code>src/main/webapp/index.jsp</code> file with the - following contents: </para> - <para><emphasis role="bold">webapp/index.jsp</emphasis> - <programlisting language="jsp"><%@ page language="java" contentType="text/html" %> -<%@ page import="org.example.cayenne.persistent.*" %> -<%@ page import="org.apache.cayenne.*" %> -<%@ page import="org.apache.cayenne.query.*" %> -<%@ page import="org.apache.cayenne.exp.*" %> -<%@ page import="java.util.*" %> - -<% - ObjectContext context = BaseContext.getThreadObjectContext(); - List<Artist> artists = ObjectSelect.query(Artist.class) - .orderBy(Artist.NAME.asc()) - .select(context); -%> - -<html> - <head> - <title>Main</title> - </head> - <body> - <h2>Artists:</h2> - - <% if(artists.isEmpty()) {%> - <p>No artists found</p> - <% } else { - for(Artist a : artists) { - %> - <p><a href="detail.jsp?id=<%=Cayenne.intPKForObject(a)%>"> <%=a.getName()%> </a></p> - <% - } - } %> - <hr> - <p><a href="detail.jsp">Create new artist...</a></p> - </body> -</html> </programlisting></para> - </listitem> - <listitem> - <para>Create the artist editor page <code>src/main/webapp/detail.jsp</code> with the following - content: </para> - <para><emphasis role="bold">webapp/detail.jsp</emphasis> - <programlisting language="jsp"><%@ page language="java" contentType="text/html" %> -<%@ page import="org.example.cayenne.persistent.*" %> -<%@ page import="org.apache.cayenne.*" %> -<%@ page import="org.apache.cayenne.query.*" %> -<%@ page import="java.util.*" %> -<%@ page import="java.text.*" %> -<%@ page import="java.time.format.DateTimeFormatter" %> - -<% - ObjectContext context = BaseContext.getThreadObjectContext(); - String id = request.getParameter("id"); - - // find artist for id - Artist artist = null; - if(id != null && id.trim().length() > 0) { - artist = SelectById.query(Artist.class, Integer.parseInt(id)).selectOne(context); - } - - if("POST".equals(request.getMethod())) { - // if no id is saved in the hidden field, we are dealing with - // create new artist request - if(artist == null) { - artist = context.newObject(Artist.class); - } - - // note that in a real application we would so dome validation ... - // here we just hope the input is correct - artist.setName(request.getParameter("name")); - artist.setDateOfBirthString(request.getParameter("dateOfBirth")); - - context.commitChanges(); - - response.sendRedirect("index.jsp"); - } - - if(artist == null) { - // create transient artist for the form response rendering - artist = new Artist(); - } - - String name = artist.getName() == null ? "" : artist.getName(); - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - String dob = artist.getDateOfBirth() == null - ? "" :artist.getDateOfBirth().format(formatter); -%> -<html> - <head> - <title>Artist Details</title> - </head> - <body> - <h2>Artists Details</h2> - <form name="EditArtist" action="detail.jsp" method="POST"> - <input type="hidden" name="id" value="<%= id != null ? id : "" %>" /> - <table border="0"> - <tr> - <td>Name:</td> - <td><input type="text" name="name" value="<%= name %>"/></td> - </tr> - <tr> - <td>Date of Birth (yyyyMMdd):</td> - <td><input type="text" name="dateOfBirth" value="<%= dob %>"/></td> - </tr> - <tr> - <td></td> - <td align="right"><input type="submit" value="Save" /></td> - </tr> - </table> - </form> - </body> -</html></programlisting></para> - </listitem> - </itemizedlist> - </section> - <section xml:id="running-webapp"> - <title>Running Web Application</title> - <para>We need to provide javax servlet-api for our application.</para> - <programlisting language="xml"><dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> - <scope>provided</scope> -</dependency></programlisting> - - <para>Also to run the web application we'll use "maven-jetty-plugin". To activate it, - let's add the following piece of code to the "<code>pom.xml</code>" file, following the "dependencies" - section and save the POM:</para> - <programlisting language="xml"><build> - <plugins> - <plugin> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-maven-plugin</artifactId> - <version>9.3.14.v20161028</version> - </plugin> - </plugins> -</build></programlisting> - <itemizedlist> - <listitem> - <para>Go to "Select Run/Debug Configuration" menu, and then "Edit Configuration..."</para> - <para><inlinemediaobject> - <imageobject> - <imagedata fileref="images/idea-edit-configurations.png"/> - </imageobject> - </inlinemediaobject> - </para> - </listitem> - <listitem> - <para>Click "+" button and select "Maven". Enter "Name" and "Command line" as shown on screenshot:</para> - <para><inlinemediaobject> - <imageobject> - <imagedata fileref="images/idea-run-configuration.png" scalefit="1" width="100%"/> - </imageobject> - </inlinemediaobject></para> - </listitem> - </itemizedlist> - <itemizedlist> - <listitem> - <para>Click "Apply" and "Run". On the first execution it may take a few minutes for - Jetty plugin to download all dependencies, but eventually you'll see the logs - like this:</para> - <screen>[INFO] ------------------------------------------------------------------------ -[INFO] Building tutorial 0.0.1-SNAPSHOT -[INFO] ------------------------------------------------------------------------ -... -[INFO] Configuring Jetty for project: tutorial -[INFO] webAppSourceDirectory not set. Trying src/main/webapp -[INFO] Reload Mechanic: automatic -[INFO] Classes = /.../tutorial/target/classes -[INFO] Logging initialized @1617ms -[INFO] Context path = / -[INFO] Tmp directory = /.../tutorial/target/tmp -[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml -[INFO] Web overrides = none -[INFO] web.xml file = file:/.../tutorial/src/main/webapp/WEB-INF/web.xml -[INFO] Webapp directory = /.../tutorial/src/main/webapp -[INFO] jetty-9.3.0.v20150612 -[INFO] Started o.e.j.m.p.JettyWebAppContext@6872f9c8{/,file:/.../tutorial/src/main/webapp/,AVAILABLE}{file:/.../tutorial/src/main/webapp/} -[INFO] Started ServerConnector@723875bc{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} -[INFO] Started @2367ms -[INFO] Started Jetty Server</screen> - </listitem> - </itemizedlist> - <itemizedlist> - <listitem> - <para>So the Jetty container just started.</para> - </listitem> - <listitem> - <para>Now go to <link xlink:href="http://localhost:8080/">http://localhost:8080/</link> - URL. You should see "No artists found message" in the web browser and - the following output in the IDEA console:</para> - <screen>INFO: Loading XML configuration resource from file:/.../tutorial/target/classes/cayenne-project.xml -INFO: loading user name and password. -INFO: Connecting to 'jdbc:derby:memory:testdb;create=true' as 'null' -INFO: +++ Connecting: SUCCESS. -INFO: setting DataNode 'datanode' as default, used by all unlinked DataMaps -INFO: Detected and installed adapter: org.apache.cayenne.dba.derby.DerbyAdapter -INFO: --- transaction started. -INFO: No schema detected, will create mapped tables -INFO: CREATE TABLE GALLERY (ID INTEGER NOT NULL, NAME VARCHAR (200), PRIMARY KEY (ID)) -INFO: CREATE TABLE ARTIST (DATE_OF_BIRTH DATE, ID INTEGER NOT NULL, NAME VARCHAR (200), PRIMARY KEY (ID)) -INFO: CREATE TABLE PAINTING (ARTIST_ID INTEGER, GALLERY_ID INTEGER, ID INTEGER NOT NULL, - NAME VARCHAR (200), PRIMARY KEY (ID)) -INFO: ALTER TABLE PAINTING ADD FOREIGN KEY (ARTIST_ID) REFERENCES ARTIST (ID) -INFO: ALTER TABLE PAINTING ADD FOREIGN KEY (GALLERY_ID) REFERENCES GALLERY (ID) -INFO: CREATE TABLE AUTO_PK_SUPPORT ( - TABLE_NAME CHAR(100) NOT NULL, NEXT_ID BIGINT NOT NULL, PRIMARY KEY(TABLE_NAME)) -... -INFO: SELECT t0.DATE_OF_BIRTH, t0.NAME, t0.ID FROM ARTIST t0 ORDER BY t0.NAME -INFO: === returned 0 rows. - took 17 ms. -INFO: +++ transaction committed.</screen> - </listitem> - </itemizedlist> - <itemizedlist> - <listitem> - <para>You can click on "Create new artist" link to create artists. Existing artists - can be edited by clicking on their name:</para> - <para><inlinemediaobject> - <imageobject> - <imagedata fileref="images/chrome-webapp.png" scalefit="1" width="100%"/> - </imageobject> - </inlinemediaobject></para> - </listitem> - </itemizedlist> - <para>You are done with the tutorial!</para> - </section> -</section> http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/base-datamap.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/base-datamap.png b/docs/docbook/getting-started/src/images/base-datamap.png deleted file mode 100644 index a12bc01..0000000 Binary files a/docs/docbook/getting-started/src/images/base-datamap.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/base-datanode.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/base-datanode.png b/docs/docbook/getting-started/src/images/base-datanode.png deleted file mode 100644 index 69939bb..0000000 Binary files a/docs/docbook/getting-started/src/images/base-datanode.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/chrome-webapp.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/chrome-webapp.png b/docs/docbook/getting-started/src/images/chrome-webapp.png deleted file mode 100644 index 603e1df..0000000 Binary files a/docs/docbook/getting-started/src/images/chrome-webapp.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/database-schema.jpg ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/database-schema.jpg b/docs/docbook/getting-started/src/images/database-schema.jpg deleted file mode 100644 index 9d4ee21..0000000 Binary files a/docs/docbook/getting-started/src/images/database-schema.jpg and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-attribute.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-attribute.png b/docs/docbook/getting-started/src/images/icon-attribute.png deleted file mode 100755 index 77a68eb..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-attribute.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-datamap.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-datamap.png b/docs/docbook/getting-started/src/images/icon-datamap.png deleted file mode 100755 index 2ea96ca..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-datamap.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-dbentity.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-dbentity.png b/docs/docbook/getting-started/src/images/icon-dbentity.png deleted file mode 100755 index 87d9d8a..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-dbentity.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-edit.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-edit.png b/docs/docbook/getting-started/src/images/icon-edit.png deleted file mode 100755 index 027c482..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-edit.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-new_objentity.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-new_objentity.png b/docs/docbook/getting-started/src/images/icon-new_objentity.png deleted file mode 100755 index 8735d7a..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-new_objentity.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-node.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-node.png b/docs/docbook/getting-started/src/images/icon-node.png deleted file mode 100755 index 2ff4383..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-node.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-relationship.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-relationship.png b/docs/docbook/getting-started/src/images/icon-relationship.png deleted file mode 100755 index 44ed7eb..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-relationship.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/icon-sync.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/icon-sync.png b/docs/docbook/getting-started/src/images/icon-sync.png deleted file mode 100755 index 03e8623..0000000 Binary files a/docs/docbook/getting-started/src/images/icon-sync.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/idea-edit-configurations.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/idea-edit-configurations.png b/docs/docbook/getting-started/src/images/idea-edit-configurations.png deleted file mode 100644 index df1d524..0000000 Binary files a/docs/docbook/getting-started/src/images/idea-edit-configurations.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/idea-file-run-menu.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/idea-file-run-menu.png b/docs/docbook/getting-started/src/images/idea-file-run-menu.png deleted file mode 100644 index 30cf05e..0000000 Binary files a/docs/docbook/getting-started/src/images/idea-file-run-menu.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/idea-generated-classes.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/idea-generated-classes.png b/docs/docbook/getting-started/src/images/idea-generated-classes.png deleted file mode 100644 index 504dce5..0000000 Binary files a/docs/docbook/getting-started/src/images/idea-generated-classes.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/idea-run-configuration.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/idea-run-configuration.png b/docs/docbook/getting-started/src/images/idea-run-configuration.png deleted file mode 100644 index 3ebbb62..0000000 Binary files a/docs/docbook/getting-started/src/images/idea-run-configuration.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/idea-xmlfiles.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/idea-xmlfiles.png b/docs/docbook/getting-started/src/images/idea-xmlfiles.png deleted file mode 100644 index 1b4707d..0000000 Binary files a/docs/docbook/getting-started/src/images/idea-xmlfiles.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/modeler-artistid.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/modeler-artistid.png b/docs/docbook/getting-started/src/images/modeler-artistid.png deleted file mode 100644 index fb8c1dd..0000000 Binary files a/docs/docbook/getting-started/src/images/modeler-artistid.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/modeler-dbrelationship.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/modeler-dbrelationship.png b/docs/docbook/getting-started/src/images/modeler-dbrelationship.png deleted file mode 100644 index 4b23eb5..0000000 Binary files a/docs/docbook/getting-started/src/images/modeler-dbrelationship.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/modeler-deleterule.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/modeler-deleterule.png b/docs/docbook/getting-started/src/images/modeler-deleterule.png deleted file mode 100644 index 86ada13..0000000 Binary files a/docs/docbook/getting-started/src/images/modeler-deleterule.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/modeler-started.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/modeler-started.png b/docs/docbook/getting-started/src/images/modeler-started.png deleted file mode 100644 index dbf8324..0000000 Binary files a/docs/docbook/getting-started/src/images/modeler-started.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/getting-started/src/images/tutorial-idea-project.png ---------------------------------------------------------------------- diff --git a/docs/docbook/getting-started/src/images/tutorial-idea-project.png b/docs/docbook/getting-started/src/images/tutorial-idea-project.png deleted file mode 100644 index 058dc1d..0000000 Binary files a/docs/docbook/getting-started/src/images/tutorial-idea-project.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/pom.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/pom.xml b/docs/docbook/pom.xml deleted file mode 100644 index b7c411b..0000000 --- a/docs/docbook/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <prerequisites> - <maven>3</maven> - </prerequisites> - - <parent> - <groupId>org.apache.cayenne.docs</groupId> - <artifactId>cayenne-docs-parent</artifactId> - <version>4.0.B3-SNAPSHOT</version> - </parent> - - <modules> - <module>docbook-stylesheets</module> - <module>cayenne-guide</module> - <module>getting-started</module> - <module>getting-started-rop</module> - <module>upgrade-guide</module> - </modules> - - <properties> - <project.stylesheetdir>${project.parent.basedir}/docbook-stylesheets/target/classes</project.stylesheetdir> - - <!-- This property allows to only expose major version in the docs metadata to avoid confusing SEO --> - <cayenne.version.major>4.0</cayenne.version.major> - </properties> - - <artifactId>cayenne-docbook</artifactId> - <packaging>pom</packaging> - <name>cayenne-docbook: Cayenne Docbook Documentation</name> - - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>com.agilejava.docbkx</groupId> - <artifactId>docbkx-maven-plugin</artifactId> - <version>2.0.17</version> - <dependencies> - <dependency> - <groupId>org.docbook</groupId> - <artifactId>docbook-xml</artifactId> - <version>4.4</version> - <scope>runtime</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </pluginManagement> - - - <plugins> - <plugin> - <groupId>com.agilejava.docbkx</groupId> - <artifactId>docbkx-maven-plugin</artifactId> - <configuration> - <xincludeSupported>true</xincludeSupported> - <highlightSource>true</highlightSource> - <targetDirectory>${basedir}/target/site/</targetDirectory> - <includes>index.xml</includes> - </configuration> - <executions> - <execution> - <id>build-pdf</id> - <configuration> - <foCustomization>${project.stylesheetdir}/stylesheets/pdf.xsl</foCustomization> - <postProcess> - <delete failonerror="false"> - <fileset dir="target/site/" includes="*.fo" /> - </delete> - <move file="target/site/index.pdf" tofile="target/site/${project.artifactId}.pdf" /> - </postProcess> - </configuration> - <phase>generate-resources</phase> - <goals> - <goal>generate-pdf</goal> - </goals> - </execution> - <execution> - <id>build-html</id> - <configuration> - <htmlCustomization>${project.stylesheetdir}/stylesheets/html.xsl</htmlCustomization> - <chunkedOutput>true</chunkedOutput> - <postProcess> - <move todir="${basedir}/target/site/index"> - <fileset dir="${basedir}/target/site/"> - <include name="*.html" /> - </fileset> - </move> - <copy todir="${basedir}/target/site/index/css"> - <fileset dir="${project.stylesheetdir}/css" /> - </copy> - <copy todir="${basedir}/target/site/index/images"> - <fileset dir="${basedir}/src/images" /> - </copy> - </postProcess> - </configuration> - <phase>generate-resources</phase> - <goals> - <goal>generate-html</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/upgrade-guide/pom.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/upgrade-guide/pom.xml b/docs/docbook/upgrade-guide/pom.xml deleted file mode 100644 index a3c5973..0000000 --- a/docs/docbook/upgrade-guide/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.apache.cayenne.docs</groupId> - <artifactId>cayenne-docbook</artifactId> - <version>4.0.B3-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>upgrade-guide</artifactId> - <name>upgrade-guide: Docbook - Cayenne New Features and Upgrade Guide</name> - - <build> - <resources> - <resource> - <directory>target/site</directory> - </resource> - </resources> - </build> -</project> http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/upgrade-guide/src/docbkx/index.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/upgrade-guide/src/docbkx/index.xml b/docs/docbook/upgrade-guide/src/docbkx/index.xml deleted file mode 100644 index 91b0609..0000000 --- a/docs/docbook/upgrade-guide/src/docbkx/index.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" - xml:id="upgrade-guide" xmlns:xi="http://www.w3.org/2001/XInclude"> - <info> - <title>Cayenne 4.0 New Features and Upgrade Guide</title> - <copyright> - <year>2011-<?dbtimestamp format="Y"?></year> - <holder>Apache Software Foundation and individual authors</holder> - </copyright> - <legalnotice> - <title>License</title> - <para>Licensed to the Apache Software Foundation (ASF) under one or more contributor - license agreements. See the NOTICE file distributed with this work for additional - information regarding copyright ownership. The ASF licenses this file to you 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</para> - - <para>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.</para> - </legalnotice> - </info> - <xi:include href="new-features.xml"/> -</book> - http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/upgrade-guide/src/docbkx/new-features.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/upgrade-guide/src/docbkx/new-features.xml b/docs/docbook/upgrade-guide/src/docbkx/new-features.xml deleted file mode 100644 index 6481ae3..0000000 --- a/docs/docbook/upgrade-guide/src/docbkx/new-features.xml +++ /dev/null @@ -1,238 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to you 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. ---> -<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://docbook.org/ns/docbook http://docbook.org/xml/5.0/xsd/docbook.xsd"> - <title>Guide to 4.0 Features</title> - <para>This guide highlights the new features and changes introduced in Apache Cayenne 4.0. For a full list of changes consult - RELEASE-NOTES.txt included in Cayenne download. For release-specific upgrade instructions check UPGRADE.txt.</para> - <section xml:id="java-version"> - <title>Java Version</title> - <para>Minimum required JDK version is 1.7 or newer. Cayenne 4.0 is fully tested with Java 1.7, - 1.8. </para> - <para>The examples below often use Java 8 syntax. But those same examples should work without lambdas just as well.</para> - </section> - <section xml:id="cayenne-configuration"> - <title>Cayenne Configuration</title> - <section> - <title>ServerRuntimeBuilder</title> - <para>Cayenne 3.1 introduced dependency injection and ServerRuntime. 4.0 provides a very convenient utility to create a custom runtime - with various extensions. This reduces the code needed to integrate Cayenne in your environment to just a few lines and no - boilerplate. - E.g.:<programlisting language="java">ServerRuntime runtime = ServerRuntime.builder("myproject") - .addConfigs("cayenne-project1.xml", "cayenne-project2.xml") - .addModule(binder -> binder.bind(JdbcEventLogger.class).toInstance(myLogger)) - .dataSource(myDataSource) - .build();</programlisting></para> - </section> - <section> - <title>Mapping-free ServerRuntime</title> - <para>ServerRuntime can now be started without any ORM mapping at all. This is useful in situations when Cayenne is used as a stack to - execute raw SQL, in unit tests, etc.</para> - </section> - <section> - <title>DI Container Decorators</title> - <para>In addition to overriding services in DI container, Cayenne now allows to supply - decorators. True to the "smallest-footprint" DI philosophy, decorator approach is - very simple and does not require proxies or class enhancement. Just implement the - decorated interface and provide a constructor that takes a delegate instance being - decorated: - <programlisting language="java">public class MyInterfaceDecorator implements MyInterface { - - private MyInterface delegate; - - public MockInterface1_Decorator3(@Inject MyInterface delegate) { - this.delegate = delegate; - } - - @Override - public String getName() { - return "<" + delegate.getName() + ">"; - } -} - -Module module = binder -> - binder.decorate(MyInterface.class).before(MyInterfaceDecorator.class);</programlisting> - </para> - </section> - </section> - <section xml:id="framework-api"> - <title>Framework API</title> - <section> - <title>Fluent Query API</title> - <para>Fluent Query API is one of the most exciting new features in Cayenne 4.0. This syntax is "chainable" so you can write query - assembly and execution code on one line. The most useful fluent queries are ObjectSelect, SQLSelect and SelectById:</para> - <section> - <title>ObjectSelect</title> - <para>A "chainable" analog of SelectQuery. - <programlisting language="java">Artist a = ObjectSelect - .query(Artist.class) - .where(Artist.ARTIST_NAME.eq("Picasso")) - .selectOne(context);</programlisting></para> - </section> - <section> - <title>ColumnSelect</title> - <para> - This query allows you directly access individual properties of Objects and use functions (including aggregate) - via type-safe API. - <programlisting language="java"><![CDATA[List<String> names = ObjectSelect - .columnQuery(Artist.class, Artist.ARTIST_NAME) - .where(Artist.ARTIST_NAME.length().gt(6)) - .select(context);]]></programlisting> - </para> - </section> - <section> - <title>SQLSelect</title> - <para>A "chainable" analog of SQLTemplate used specifically to run selecting raw - SQL:<programlisting language="java">List<Long> ids = SQLSelect - .scalarQuery(Long.class, "SELECT ARTIST_ID FROM ARTIST ORDER BY ARTIST_ID") - .select(context);</programlisting></para> - </section> - <section> - <title>SelectById</title> - <para>There's really no good analog of SelectById in Cayenne prior to 4.0. Previously available ObjectIdQuery didn't support half of - the features of SelectById (e.g. caching consistent with other queries, prefetches, etc.) - :<programlisting language="java">Artist a = SelectById - .query(Artist.class, 3) - .useLocalCache("g1") - .selectOne(context)</programlisting></para> - </section> - </section> - <section xml:id="objectcontext"> - <title>ObjectContext</title> - <section> - <title>Callback-based Object Iterator</title> - <para>ObjectContext now features a simpler way to iterate over large result sets, based on callback interface that can be - implemented with a - lambda:<programlisting language="java">SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class); - -context.iterate(q, (Artist a) -> { - // do something with the object... - ... -});</programlisting></para> - </section> - </section> - <section> - <title>Generics in Expressions and Queries</title> - <para>We finished the work of "genericizing" Cayenne APIs started in 3.1. Now all APIs dealing with persistent objects (Expressions, - Queries, ObjectContext, etc.) support generics of Persistent object type or attribute property type.</para> - </section> - <section> - <title>Property API</title> - <para>Persistent superclasses (_MyEntity) now contain a set of static Property<T> variables generated from the model. These - metadata objects make possible to create type-safe Expressions and other query parts.</para> - </section> - <section> - <title>Positional Parameter Bindings </title> - <para>Expressions and SQLTemplate traditionally supported binding of parameters by name as a map. Cayenne 4.0 introduces a very easy - form of positional bindings. It works with the same named template format, only parameters are bound by position, left-to-right. - Here we showing a more complex example with the same parameter name being used more than once in the - query:<programlisting language="java">// two distinct names, 3 positional parameters. -// "price" is set to 23, "maxPrice" - to 50 -Expression e = ExpressionFactory.exp( - "price = $price or averagePrice = $price and maxPrice = $maxPrice", 23, 50);</programlisting>This - API is supported in Expressions, SQLTemplate as well as new SQLSelect and can be used interchnageably with named parameters with a - single template flavor.</para> - </section> - <section> - <title>Improved Transaction API</title> - <para>Transaction factory is now setup via DI (instead of being configured in the Modeler). There's a utility method on ServerRuntime - to perform multiple operations as one - transaction:<programlisting language="java">runtime.performInTransaction(() -> { - // ... do some changes - context.commitChanges(); - - // ... do more changes - context.commitChanges(); - - return true; -});</programlisting></para> - </section> - <section> - <title>Transparent Database Cryptography with "cayenne-crypto" Module</title> - <para>Cayenne includes a new module called "cayenne-crypto" that enables transparent cryptography for designated data columns. This is - a pretty cool feature that allows to enable encryption/decryption of your sensitive data pretty much declaratively using your - regular DB storage. Encrypted values can be stored in (VAR)BINARY and (VAR)CHAR columns. Currently "cayenne-crypto" supports - AES/CBC/PKCS5Padding encryption (though other cyphers can be added). It also supports encrypted data compression. Here is an example - of building a crypto DI module that can be added to - ServerRuntime:<programlisting language="java">Module cryptoExtensions = CryptoModule.extend() - .keyStore("file:///mykeystore", "keystorepassword".toCharArray(), "keyalias") - .compress() - .module();</programlisting></para> - </section> - </section> - <section xml:id="cayenne-modeler"> - <title>CayenneModeler</title> - <section> - <title>Improved UI</title> - <para>CayenneModeler features a number of UI improvements. Attributes and relationships are now edited in the same view (no need to - switch between the tabs). Project tree allows to easily filter elements by type and quickly collapse the tree.</para> - </section> - <section> - <title>Dropped Support for Mapping Listeners</title> - <para>Managing listeners in the DataMap XML model is counterproductive and confusing, so support for listeners was removed from both - the XML and the Modeler. If you previously had listeners mapped in the model, annotate their callback methods, and perform listener - registration in the code: <programlisting language="java">runtime.getDataDomain().addListener(myListener);</programlisting> - or via DI: <programlisting language="java"><![CDATA[Module module = binder -> ServerModule.contributeDomainListeners(myListener);]]></programlisting> - Entity callbacks on the other hand are managed in the Modeler as before.</para> - </section> - </section> - <section xml:id="build-tools"> - <title>Build Tools</title> - <section> - <title>cdbimport</title> - <para>"cdbimport" has evolved from an experiment to a full-featured production tool that significantly reduces (and sometimes - eliminates) the need for manual maintenance of the DataMaps in CayenneModeler. Two improvements made this possible. First, smart - merge algorithm will ensure that custom changes to the model are not overridden on subsequent runs of "cdbimport". Second, the - mechanism for specifing DB reverse-engineering parameters, such as name filtering, is made much more powerful with many new options. - E.g. we started supporting filters by catalogs and schemas, table name filters can be added per catalog/schema or at the top level, - etc. - </para> - </section> - <section> - <title>cgen</title> - <para>As was mentioned above, cgen now includes Property<T> static variables for expression building. It is also made smarter about - its defaults for "destDir" and "superPkg".</para> - </section> - <section> - <title>Gradle Plugin</title> - <para> - Cayenne now provides it's own Gradle Plugin that allows you easily integrate <code>cdbimport</code> - and <code>cgen</code> tools into your build process. - Here is example of it's usage: - <programlisting language="groovy"> -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath group: 'org.apache.cayenne.plugins', name: 'cayenne-gradle-plugin', version: '<?eval ${project.version}?>' - } -} - -apply plugin: 'org.apache.cayenne' - -cayenne.defaultDataMap 'datamap.map.xml' - -dependencies { - compile cayenne.dependency('server') - compile cayenne.dependency('java8') -}</programlisting> - </para> - </section> - </section> -</article> http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/docbook/upgrade-guide/src/images/.gitignore ---------------------------------------------------------------------- diff --git a/docs/docbook/upgrade-guide/src/images/.gitignore b/docs/docbook/upgrade-guide/src/images/.gitignore deleted file mode 100644 index 126477b..0000000 --- a/docs/docbook/upgrade-guide/src/images/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# keeping this here to ensure the empty folder is present -# it is expected by a shared docbook plugin config http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/docs/pom.xml ---------------------------------------------------------------------- diff --git a/docs/pom.xml b/docs/pom.xml index 0ad1709..21a6053 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -35,7 +35,7 @@ <modules> <module>doc</module> - <module>docbook</module> + <module>asciidoc</module> </modules> <build> http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/Main.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/Main.java b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/Main.java index 923c014..e4666be 100644 --- a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/Main.java +++ b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/Main.java @@ -48,11 +48,14 @@ public class Main { static void newObjectsTutorial(ObjectContext context) { // creating new Artist + // tag::new-artist[] Artist picasso = context.newObject(Artist.class); picasso.setName("Pablo Picasso"); picasso.setDateOfBirthString("18811025"); + // end::new-artist[] // Creating other objects + // tag::new-painting[] Gallery metropolitan = context.newObject(Gallery.class); metropolitan.setName("Metropolitan Museum of Art"); @@ -61,16 +64,21 @@ public class Main { Painting stein = context.newObject(Painting.class); stein.setName("Gertrude Stein"); + // end::new-painting[] // connecting objects together via relationships + // tag::link-objects[] picasso.addToPaintings(girl); picasso.addToPaintings(stein); girl.setGallery(metropolitan); stein.setGallery(metropolitan); + // end::link-objects[] // saving all the changes above + // tag::commit[] context.commitChanges(); + // end::commit[] } static void selectTutorial(ObjectContext context) { http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/Artist.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/Artist.java b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/Artist.java index 318ceb0..0084bd4 100644 --- a/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/Artist.java +++ b/tutorials/tutorial/src/main/java/org/apache/cayenne/tutorial/persistent/Artist.java @@ -24,6 +24,7 @@ import java.time.format.DateTimeParseException; import org.apache.cayenne.tutorial.persistent.auto._Artist; +// tag::content[] public class Artist extends _Artist { static final String DEFAULT_DATE_FORMAT = "yyyyMMdd"; @@ -38,13 +39,16 @@ public class Artist extends _Artist { LocalDate date; try { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT); + DateTimeFormatter formatter = DateTimeFormatter + .ofPattern(DEFAULT_DATE_FORMAT); date = LocalDate.parse(yearMonthDay, formatter); } catch (DateTimeParseException e) { - throw new IllegalArgumentException("A date argument must be in format '" - + DEFAULT_DATE_FORMAT + "': " + yearMonthDay); + throw new IllegalArgumentException( + "A date argument must be in format '" + + DEFAULT_DATE_FORMAT + "': " + yearMonthDay); } setDateOfBirth(date); } } } +// end::content[] http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/tutorials/tutorial/src/main/webapp/detail.jsp ---------------------------------------------------------------------- diff --git a/tutorials/tutorial/src/main/webapp/detail.jsp b/tutorials/tutorial/src/main/webapp/detail.jsp index 448a8eb..d5a2877 100644 --- a/tutorials/tutorial/src/main/webapp/detail.jsp +++ b/tutorials/tutorial/src/main/webapp/detail.jsp @@ -24,6 +24,7 @@ <%@ page import="java.text.*" %> <%@ page import="java.time.format.DateTimeFormatter"%> +// tag::content[] <% ObjectContext context = BaseContext.getThreadObjectContext(); String id = request.getParameter("id"); @@ -85,4 +86,5 @@ </table> </form> </body> -</html> \ No newline at end of file +</html> +// end::content[] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/cde78f0b/tutorials/tutorial/src/main/webapp/index.jsp ---------------------------------------------------------------------- diff --git a/tutorials/tutorial/src/main/webapp/index.jsp b/tutorials/tutorial/src/main/webapp/index.jsp index 36f630e..fe078fd 100644 --- a/tutorials/tutorial/src/main/webapp/index.jsp +++ b/tutorials/tutorial/src/main/webapp/index.jsp @@ -25,6 +25,7 @@ <%@ page import="org.apache.cayenne.exp.*" %> <%@ page import="java.util.*" %> +// tag::content[] <% ObjectContext context = BaseContext.getThreadObjectContext(); List<Artist> artists = ObjectSelect.query(Artist.class) @@ -50,4 +51,5 @@ <hr> <p><a href="detail.jsp">Create new artist...</a></p> </body> -</html> \ No newline at end of file +</html> +// end::content[] \ No newline at end of file