Author: gk
Date: Mon Nov 7 15:43:42 2016
New Revision: 1768538
URL: http://svn.apache.org/viewvc?rev=1768538&view=rev
Log:
- use JNDI instead of SharedPoolDataSourceFactory (with jetty)
- add archetype generate goals in README.txt
- fix injection bug in SecureScreen.java, cft. README.txt
Added:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
(with props)
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/META-INF/maven/archetype-metadata.xml
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/test/resources/projects/first/archetype.properties
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
(original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
Mon Nov 7 15:43:42 2016
@@ -25,6 +25,9 @@
<body>
<release version="1.0.1" date="in Subversion">
+ <action dev="gk" type="update">
+ JNDI Jetty Update
+ </action>
<action dev="gk" type="update">
Fulcrum Torque Security added manager, om classes
</action>
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/META-INF/maven/archetype-metadata.xml
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/META-INF/maven/archetype-metadata.xml
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/META-INF/maven/archetype-metadata.xml
Mon Nov 7 15:43:42 2016
@@ -37,7 +37,7 @@
<defaultValue>auto</defaultValue>
</requiredProperty>
<requiredProperty key="turbine_database_jndipath">
- <defaultValue>java:comp/env/jdbc/Turbine</defaultValue>
+ <defaultValue>jdbc/turbine</defaultValue>
</requiredProperty>
<requiredProperty key="turbine_database_driver">
<defaultValue>com.mysql.jdbc.Driver</defaultValue>
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
Mon Nov 7 15:43:42 2016
@@ -27,6 +27,7 @@ Turbine Version: Turbine 4.0-M2. Be awar
(because of some minor bugs in Fulcrum Security 1.1.0, which should be fixed
in v 1.1.1/Turbine 4.0)
- LogoutAction is included (fixed getUserFromSession)
- om stub classes are included (until configurable in schema with Torque
version 2.1)
+ - (in SecureScreen) TurbineConfiguration returns a Commons configuration
object, even if field is not assignable (will be fixed in Turbine 4.0, you can
then assign e.g. to String instead)
Quick Guide to using the new Turbine 4.0-M2 maven archetype
@@ -51,10 +52,12 @@ mvn archetype:generate \
-Dturbine_database_adapter=mysql \
-Dturbine_database_user=db_username \
-Dturbine_database_password=db_password \
- -Dturbine_database_name=helloWorld
+ -Dturbine_database_name=helloWorld \
+ -Dgoals=generate-sources,sql:execute
-Note that the database URL will be appended with your database name
+Note that the database URL (turbine_database_url=jdbc:mysql://localhost:3306/)
+will be appended with your database name
in the final pom.xml, so you do not need to specify that in
the configuration.
@@ -67,6 +70,9 @@ Next, you need to create the database in
cd helloWorld
+You can skip the next two mvn commands, if you have already set the goals
+when invoking archetype:generate.
+
mvn generate-sources ## This will generate the OM layer and SQL
## code for creating the corresponding
## database tables
@@ -75,8 +81,9 @@ mvn sql:execute ## This executes t
## the application schema defined
## in src/main/torque-schema
-You should now insert the sample data file provided as Torque 4.0
-has disabled the datasql task.
+You should now check the database tables and if some data is missing
+insert the sample data file provided
+as Torque 4.0 has disabled the datasql task.
mvn jetty:run ## Now you can launch your new Turbine application
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
Mon Nov 7 15:43:42 2016
@@ -99,7 +99,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>torque-sql-${turbine_database_adapter}</id>
+ <id>torque-sql-mysql</id><!-- ${turbine_database_adapter} -->
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
@@ -108,11 +108,11 @@ under the License.
<packaging>classpath</packaging>
<configPackage>org.apache.torque.templates.sql</configPackage>
<sourceDir>#var("basedir")/src/main/torque-schema</sourceDir>
-
<defaultOutputDir>#var("project.build.directory")/generated-sql/torque/${turbine_database_adapter}</defaultOutputDir>
+
<defaultOutputDir>#var("project.build.directory")/generated-sql/torque/mysql</defaultOutputDir>
<defaultOutputDirUsage>none</defaultOutputDirUsage>
<loglevel>error</loglevel>
<options>
- <torque.database>${turbine_database_adapter}</torque.database>
+ <torque.database>mysql</torque.database>
</options>
</configuration>
</execution>
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
Mon Nov 7 15:43:42 2016
@@ -28,6 +28,7 @@ import org.apache.turbine.om.security.Us
import org.apache.turbine.pipeline.PipelineData;
import org.apache.turbine.services.security.SecurityService;
import org.apache.velocity.context.Context;
+import org.apache.commons.configuration.Configuration;
/**
* This class provides a sample implementation for creating a secured screen
@@ -37,11 +38,11 @@ public class SecureScreen extends Veloci
@TurbineService
protected SecurityService securityService;
- @TurbineConfiguration( TurbineConstants.TEMPLATE_LOGIN )
- private String templateLogin;
+ @TurbineConfiguration( TurbineConstants.TEMPLATE_LOGIN )
+ private Configuration templateLogin;
- @TurbineConfiguration( TurbineConstants.TEMPLATE_HOMEPAGE )
- private String templateHomepage;
+ @TurbineConfiguration( TurbineConstants.TEMPLATE_HOMEPAGE )
+ private Configuration templateHomepage;
@Override
protected boolean isAuthorized(PipelineData data) throws Exception
@@ -56,7 +57,8 @@ public class SecureScreen extends Veloci
if (acl == null)
{
- getRunData(data).setScreenTemplate(templateLogin);
+ // commons configuration getProperty: prefix removed, the key for the
value .. is an empty string, the result an object
+ getRunData(data).setScreenTemplate( (String)
templateLogin.getProperty("") );
isAuthorized = false;
}
else if (acl.hasRole("turbineadmin"))
@@ -65,7 +67,7 @@ public class SecureScreen extends Veloci
}
else
{
- getRunData(data).setScreenTemplate(templateHomepage);
+ getRunData(data).setScreenTemplate( (String)
templateHomepage.getProperty("") );
getRunData(data).setMessage("You do not have access to
this part of the site.");
isAuthorized = false;
}
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties
Mon Nov 7 15:43:42 2016
@@ -41,9 +41,9 @@
# For JNDI configuration please see:
https://db.apache.org/torque/torque-4.0/documentation/orm-reference/initialisation-configuration.html
#
#
-#torque.dsfactory.${turbine_database_name}.factory=org.apache.torque.dsfactory.JndiDataSourceFactory
-#torque.dsfactory.${turbine_database_name}.jndi.path=${turbine_database_jndipath}
-#torque.dsfactory.${turbine_database_name}.jndi.ttl=300000
+torque.dsfactory.${turbine_database_name}.factory=org.apache.torque.dsfactory.JndiDataSourceFactory
+torque.dsfactory.${turbine_database_name}.jndi.path=java:comp/env/${turbine_database_jndipath}
+torque.dsfactory.${turbine_database_name}.jndi.ttl=300000
# -------------------------------------------------------------------
#
@@ -52,8 +52,9 @@
# -------------------------------------------------------------------
#torque.database.default=${turbine_database_name}
torque.database.${turbine_database_name}.adapter=${turbine_database_adapter}
-torque.database.${turbine_database_name}.user=${turbine_database_user}
-torque.database.${turbine_database_name}.password=${turbine_database_password}
+
+#torque.database.${turbine_database_name}.user=${turbine_database_user}
+#torque.database.${turbine_database_name}.password=${turbine_database_password}
#
#torque.defaults.pool.maxActive = 30
#torque.defaults.pool.testOnBorrow = true
@@ -64,11 +65,11 @@ torque.database.${turbine_database_name}
#torque.defaults.connection.user = ${turbine_database_user}
#torque.defaults.connection.password = ${turbine_database_password}
#
-torque.dsfactory.${turbine_database_name}.connection.driver =
${turbine_database_driver}
-torque.dsfactory.${turbine_database_name}.connection.url =
${turbine_database_url}${turbine_database_name}
-torque.dsfactory.${turbine_database_name}.connection.user =
${turbine_database_user}
-torque.dsfactory.${turbine_database_name}.connection.password =
${turbine_database_password}
-torque.dsfactory.${turbine_database_name}.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
+#torque.dsfactory.${turbine_database_name}.connection.driver =
${turbine_database_driver}
+#torque.dsfactory.${turbine_database_name}.connection.url =
${turbine_database_url}${turbine_database_name}
+#torque.dsfactory.${turbine_database_name}.connection.user =
${turbine_database_user}
+#torque.dsfactory.${turbine_database_name}.connection.password =
${turbine_database_password}
+#torque.dsfactory.${turbine_database_name}.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
# -------------------------------------------------------------------
# Determines if the quantity column of the IDBroker's id_table should
Added:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml?rev=1768538&view=auto
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
(added)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
Mon Nov 7 15:43:42 2016
@@ -0,0 +1,15 @@
+<Configure class="org.eclipse.jetty.webapp.WebAppContext">
+ <New id="Turbine" class="org.eclipse.jetty.plus.jndi.Resource">
+ <Arg></Arg> <!-- reference to WebAppContext requires jetty 9.x only -->
+ <Arg>${turbine_database_jndipath}</Arg>
+ <Arg>
+ <New class="org.apache.commons.dbcp.BasicDataSource">
+ <Set name="driverClassName">${turbine_database_driver}</Set>
+ <Set
name="url">${turbine_database_url}${turbine_database_name}</Set>
+ <Set name="username">${turbine_database_user}</Set>
+ <Set name="password">${turbine_database_password}</Set>
+ <Set name="validationQuery">SELECT 1</Set>
+ </New>
+ </Arg>
+ </New>
+</Configure>
\ No newline at end of file
Propchange:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jetty-env.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
Mon Nov 7 15:43:42 2016
@@ -71,6 +71,18 @@
<welcome-file-list>
<welcome-file>app</welcome-file>
</welcome-file-list>
+
+
+ <!-- ========================================================================
-->
+<!--
-->
+<!-- JNDI Ressource
-->
+<!-- ========================================================================
-->
+
+ <resource-ref>
+ <res-ref-name>${turbine_database_jndipath}</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
<!-- ========================================================================
-->
<!--
-->
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/test/resources/projects/first/archetype.properties
URL:
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/test/resources/projects/first/archetype.properties?rev=1768538&r1=1768537&r2=1768538&view=diff
==============================================================================
---
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/test/resources/projects/first/archetype.properties
(original)
+++
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/test/resources/projects/first/archetype.properties
Mon Nov 7 15:43:42 2016
@@ -6,7 +6,7 @@ turbine_app_name=My Turbine Web Applicat
turbine_intake_file=intake.xml
turbine_database_name=turbine
turbine_database_adapter=auto
-turbine_database_jndipath=java:comp/env/jdbc/Turbine
+turbine_database_jndipath=jdbc/turbine
turbine_database_driver=com.mysql.jdbc.Driver
turbine_database_url=jdbc:mysql://localhost:3306/
turbine_database_user=db_user