Merge pull request 'ee-mvc' (#6) from ee-mvc into master

Support for Jakarta EE MVC
ccm-docs
jensp 2020-09-16 11:25:18 +02:00
commit 1d399a299b
17 changed files with 1046 additions and 3 deletions

View File

@ -123,6 +123,12 @@
<artifactId>undertow</artifactId> <artifactId>undertow</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-wildfly</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>

View File

@ -24,6 +24,12 @@
<url>http://www.libreccm.org/modules/web/wildfly</url> <url>http://www.libreccm.org/modules/web/wildfly</url>
<dependencies> <dependencies>
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-wildfly</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.webjars</groupId> <groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId> <artifactId>font-awesome</artifactId>
@ -202,6 +208,22 @@
<include>assets/</include> <include>assets/</include>
</includes> </includes>
</overlay> </overlay>
<overlay>
<groupId>org.libreccm</groupId>
<artifactId>ccm-core</artifactId>
<type>jar</type>
<includes>
<include>views/</include>
</includes>
</overlay>
<overlay>
<groupId>org.libreccm</groupId>
<artifactId>ccm-core</artifactId>
<type>jar</type>
<includes>
<include>resources/</include>
</includes>
</overlay>
<overlay> <overlay>
<groupId>org.librecms</groupId> <groupId>org.librecms</groupId>
<artifactId>ccm-cms</artifactId> <artifactId>ccm-cms</artifactId>
@ -244,6 +266,9 @@
<configuration> <configuration>
<skip>false</skip> <skip>false</skip>
<propertiesFile>${project.basedir}/wildfly.properties</propertiesFile> <propertiesFile>${project.basedir}/wildfly.properties</propertiesFile>
<java-opts>
<java-opt>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787</java-opt>
</java-opts>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -4,4 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<application>
<resource-handler>org.libreccm.ui.CcmFaceletsResourceHandler</resource-handler>
</application>
</faces-config> </faces-config>

View File

@ -102,6 +102,21 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.mvc</groupId>
<artifactId>javax.mvc-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.krazo.ext</groupId>
<artifactId>krazo-freemarker</artifactId>
<scope>provided</scope>
</dependency>
<!-- <!--
Flyway framework for database schema migrations Flyway framework for database schema migrations
--> -->
@ -398,6 +413,7 @@
<author>true</author> <author>true</author>
<keywords>true</keywords> <keywords>true</keywords>
<failOnError>false</failOnError> <failOnError>false</failOnError>
<additionalOptions>--frames</additionalOptions>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -0,0 +1,142 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.facelets;
import org.libreccm.theming.ThemeInfo;
import org.libreccm.theming.ThemeVersion;
import org.libreccm.theming.Themes;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.Objects;
/**
* Special {@link URLConnection} for loading Facelets templates from a LibreCCM
* theme.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
class CcmThemeUrlConnection extends URLConnection {
/**
* Themes instance used as interface to the theme system
*/
private final Themes themes;
/**
* Path of the template to load.
*/
private final String path;
/**
* Theme to use. Initialized by {@link #connect()}.
*/
private ThemeInfo themeInfo;
/**
* Path of the file relative to the theme root. Initialized by
* {@link #connect()}
*/
private String filePath;
/**
* Constructor for initalizing the instance, providing the required
* parameters.
*
* @param themes Themes instance to use.
* @param url URL of the template to load.
*/
public CcmThemeUrlConnection(final Themes themes, final URL url) {
super(url);
this.themes = themes;
final String urlPath = url.getPath();
if (urlPath.startsWith("/")) {
path = urlPath.substring(1);
} else {
path = urlPath;
}
}
/**
* Called by Java to connect to the source of the URL. In this case we
* retrieve the {@link ThemeInfo} for the theme to use, and initalize the
* {@link #filePath} property.
*
* @throws IOException If the theme is not found or if the URL is malformed.
*/
@Override
public void connect() throws IOException {
final String[] tokens = path.split("/");
if (tokens.length >= 4) {
final String themeName = tokens[1];
final ThemeVersion version = ThemeVersion.valueOf(tokens[2]);
filePath = String.join(
"/",
Arrays.copyOfRange(
tokens, 3, tokens.length, String[].class
)
);
themeInfo = themes.getTheme(themeName, version)
.orElseThrow(() -> new IOException(
String.format(
"Theme %s is available as %s version.",
themeName,
Objects.toString(version)
)));
} else {
throw new IOException(
"Malformed URL for loading a facelets template from a theme."
);
}
}
/**
* Get an {@link InputStream} for the resource to which the URL points. In
* this case we delagate the retrieval of the the template to
* {@link Themes#getFileFromTheme(org.libreccm.theming.ThemeInfo, java.lang.String)}.
*
* @return An {@code InputStream} for the requested template.
*
* @throws IOException If the template was not found in the theme.
*/
@Override
public InputStream getInputStream() throws IOException {
return themes
.getFileFromTheme(themeInfo, filePath)
.orElseThrow(
() -> new IOException(
String.format(
"Template %s not found in %s version of the theme %s.",
filePath,
themeInfo.getVersion(),
themeInfo.getName()
)
)
);
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.facelets;
import org.libreccm.theming.Themes;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
/**
* Implementation of {@link URLStreamHandler} for handling URLs to LibreCCM
* theme templates.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
class CcmThemeUrlStreamHandler extends URLStreamHandler {
private final Themes themes;
public CcmThemeUrlStreamHandler(final Themes themes) {
this.themes = themes;
}
@Override
protected URLConnection openConnection(final URL url) throws IOException {
return new CcmThemeUrlConnection(themes, url);
}
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.facelets;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.theming.Themes;
import java.net.MalformedURLException;
import java.net.URL;
import javax.faces.application.ViewResource;
/**
* A {@link ViewResource} implementation for templates from LibreCCM themes.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
class CcmThemeViewResource extends ViewResource {
private final String path;
private final Themes themes;
/**
* Constructor for the {@code ViewResource} instance.
*
* @param themes Interface to the theme system
* @param path The path of the template.
*/
public CcmThemeViewResource(final Themes themes, final String path) {
this.themes = themes;
this.path = path;
}
/**
* Gets the URL of the URL of the template as {@code ViewResource}.
*
* @return The URL of the {@code ViewResource}.
*/
@Override
public URL getURL() {
// The URL build here is a "pseudo" URL. Most of the parts of the URL
// are no relevant. An special URLStreamHandler implementation is
// also passed to the URL. This URLStreamHandler implementation takes
// care of retrieving the template from the theme.
try {
return new URL(
"libreccm",
null,
0,
path,
new CcmThemeUrlStreamHandler(themes)
);
} catch (MalformedURLException ex) {
throw new UnexpectedErrorException(ex);
}
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.facelets;
import org.libreccm.theming.Themes;
import javax.faces.application.ResourceHandler;
import javax.faces.application.ResourceHandlerWrapper;
import javax.faces.application.ViewResource;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
/**
* A Facelets resource handler that loads Facelets templates from LibreCCM
* themes.
*
* This handler only works for view resources. Only resource path which are
* starting with {@code @themes} or {@code /@themes} are used processed. All
* other paths are delegated to the wrapped resource handler.
*
* To enable this resource handler to following snippet must be present in the
* {@code faces-config.xml} file of the WAR (bundle):
*
* <pre>
* &lt;application&gt;
&tl;resource-handler&gt;org.libreccm.ui.CcmFaceletsResourceHandler&lt;/resource-handler&gt;
&lt;/application&gt;
* </pre>
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CcmViewResourceHandler extends ResourceHandlerWrapper {
@Inject
private Themes themes;
private final ResourceHandler wrapped;
public CcmViewResourceHandler(final ResourceHandler wrapped) {
super(wrapped);
this.wrapped = wrapped;
}
@Override
public ViewResource createViewResource(
final FacesContext context, final String path
) {
if (path.startsWith("@themes") || path.startsWith("/@themes")) {
return new CcmThemeViewResource(themes, path);
} else {
return super.createViewResource(context, path);
}
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* Integration of the LibreCCM theme system with the Facelet ViewEngine of
* Eclipse Krazo. The integration allows it to load Facelets either from
* a theme using a {@link Themes} or from the default locations. To enable the
* integration the following snippet has to be added to the
* {@code faces-config.xml}:
* <pre>
* &lt;application&gt;
* &tl;resource-handler&gt;org.libreccm.ui.CcmFaceletsResourceHandler&lt;/resource-handler&gt;
* &lt;/application&gt;
* </pre>
*
*/
package org.libreccm.mvc.facelets;

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.freemarker;
import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.servlet.ServletContext;
/**
* A copy of the {@link TemplateLoader} used by Krazo.
*
* The {@code TemplateLoader} used by Krazo is defined as inner class. This
* class provides the same behaviour as this inner class so that we can use it
* with Freemarker's {@link MultiTemplateLoader}.
*
* As extension to Krazo's implementation this implementation of the
* {@code TemplateLoader} interface will not process template paths which start
* with {@code @themes/} or {@code /@themes/}. These path are processed by the
* {@link ThemesTemplateLoader} for the theming system.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
class KrazoTemplateLoader implements TemplateLoader {
private final ServletContext servletContext;
public KrazoTemplateLoader(final ServletContext servletContext) {
super();
this.servletContext = servletContext;
}
@Override
public Object findTemplateSource(final String name) throws IOException {
if (name.startsWith("@themes") || name.startsWith("/@themes")) {
return null;
} else {
// Freemarker drops "/"
return servletContext.getResourceAsStream(
String.format("/%s", name)
);
}
}
@Override
public long getLastModified(final Object templateSource) {
return -1;
}
@Override
public Reader getReader(
final Object templateSource, final String encoding
) throws IOException {
return new InputStreamReader((InputStream) templateSource, encoding);
}
@Override
public void closeTemplateSource(
final Object templateSource
) throws IOException {
final InputStream inputStream = (InputStream) templateSource;
inputStream.close();
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.freemarker;
import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.cache.WebappTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;
import org.eclipse.krazo.engine.ViewEngineConfig;
import org.eclipse.krazo.ext.freemarker.DefaultConfigurationProducer;
import org.libreccm.theming.Themes;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Specializes;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.ws.rs.Produces;
/**
* Extends the default configuration for Freemarker of Eclipse Krazo to
* support Freemarker templates in CCM themes.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationScoped
public class MvcFreemarkerConfigurationProducer
extends DefaultConfigurationProducer {
@Inject
private ServletContext servletContext;
@Inject
private Themes themes;
@Produces
@ViewEngineConfig
@Specializes
@Override
public Configuration getConfiguration() {
final Configuration configuration = new Configuration(
Configuration.VERSION_2_3_30
);
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(
TemplateExceptionHandler.RETHROW_HANDLER
);
configuration.setLogTemplateExceptions(false);
configuration.setWrapUncheckedExceptions(false);
configuration.setLocalizedLookup(false);
configuration.setTemplateLoader(
new MultiTemplateLoader(
new TemplateLoader[]{
new KrazoTemplateLoader(servletContext),
new ThemesTemplateLoader(themes),
// For loading Freemarker macro libraries from WEB-INF
// resources
new WebappTemplateLoader(
servletContext, "/themes/freemarker"
),
// For loading Freemarker macro libraries from classpath
// resources
new ClassTemplateLoader(getClass(), "/themes/freemarker")
}
)
);
return configuration;
}
}

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.mvc.freemarker;
import freemarker.cache.TemplateLoader;
import org.libreccm.theming.ThemeInfo;
import org.libreccm.theming.ThemeVersion;
import org.libreccm.theming.Themes;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.Optional;
/**
* Loads Freemarker templates from a theme.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
class ThemesTemplateLoader implements TemplateLoader {
private final Themes themes;
public ThemesTemplateLoader(final Themes themes) {
this.themes = themes;
}
/**
* Loads the template from a theme. The path of the theme file must follow
* the following format:
*
* {@code @themes/$themeName/$version/$path/$to/$file}
*
* The {@code @themes} prefix is mandantory. {@code $themeName} is the name
* of the theme from which the template is loaded. {@code $version} is the
* version of the theme to use. This token is converted to
* {@link ThemeVersion}. Valid values are therefore {@code DRAFT} and
* {@code LIVE}. The remainder of the path is the path to the file inside the
* theme.
*
* @param path The path of the file. The path must include the theme and its
* version.
*
* @return An {@link InputStream} for the template if the template was found
* in the theme. Otherwise {@code null} is returned.
*
* @throws IOException
*/
@Override
public Object findTemplateSource(final String path) throws IOException {
if (path.startsWith("@themes") || path.startsWith("/@themes")) {
final String[] tokens;
if (path.startsWith("/")) {
tokens = path.substring(1).split("/");
} else {
tokens = path.split("/");
}
return findTemplateSource(tokens);
} else {
return null;
}
}
private InputStream findTemplateSource(final String[] tokens) {
if (tokens.length >= 4) {
final String themeName = tokens[1];
final ThemeVersion themeVersion = ThemeVersion
.valueOf(tokens[2]);
final String filePath = String.join(
"/",
Arrays.copyOfRange(
tokens, 3, tokens.length, String[].class
)
);
return findTemplateSource(themeName, themeVersion, filePath);
} else {
return null;
}
}
private InputStream findTemplateSource(
final String themeName,
final ThemeVersion themeVersion,
final String filePath
) {
final Optional<ThemeInfo> themeInfo = themes.getTheme(
themeName, themeVersion
);
if (themeInfo.isPresent()) {
return findTemplateSource(themeInfo.get(), filePath);
} else {
return null;
}
}
private InputStream findTemplateSource(
final ThemeInfo themeInfo, final String filePath
) {
final Optional<InputStream> source = themes.getFileFromTheme(
themeInfo, filePath
);
if (source.isPresent()) {
return source.get();
} else {
return null;
}
}
@Override
public long getLastModified(Object templateSource) {
return -1;
}
@Override
public Reader getReader(
final Object templateSource, final String encoding
) throws IOException {
final InputStream inputStream = (InputStream) templateSource;
return new InputStreamReader(inputStream, encoding);
}
@Override
public void closeTemplateSource(
final Object templateSource
) throws IOException {
final InputStream inputStream = (InputStream) templateSource;
inputStream.close();
}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* Integration of the Freemarker View Engine of Eclipse Krazo with LibreCCM.
*/
package org.libreccm.mvc.freemarker;

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* The classes in this package integrate LibreCCM with Jakarta EE MVC and its
* reference implementation Eclipse Krazo.
*
* And the the moment the ViewEngines for Facelets and Freemarker are supported.
* The integration allows it to load templates for these ViewEngines either from
* the default locations or from a theme. If the path of template starts with
* {@code @themes/} or {@code /@themes/} the integration will delegate loading of
* the template to {@link Themes} of the theme. The path must follow the following
* pattern:
*
* <pre>
* @themes/$themeName/$version/$pathToTemplate
* </pre>
*
* Where {@code $themeName} is the name of the theme, {@code $version} is the
* version of the theme (either {@code live} or {@code draft} and
* {@code $pathToFile} is the path the template.
*
* If the path does not start with {@code @themes/} or {@code /@themes/} the
* template will be loaded from the default location(s) used by Jakarta EE
* MVC/Eclipse Krazo.
*
* @see https://www.mvc-spec.org/
*/
package org.libreccm.mvc;

177
ccm-wildfly/pom.xml 100644
View File

@ -0,0 +1,177 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.libreccm</groupId>
<artifactId>libreccm-parent</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<groupId>org.libreccm</groupId>
<artifactId>ccm-wildfly</artifactId>
<version>7.0.0-SNAPSHOT</version>
<name>CCM Wildfly Integration</name>
<description>
Wildfly specific stuff for CCM.
</description>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Lesser GPL 2.1</name>
<url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>javax.mvc</groupId>
<artifactId>javax.mvc-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-resteasy</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.krazo.ext</groupId>
<artifactId>krazo-freemarker</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>ccm-wildfly</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>org.libreccm.tests.categories.UnitTest</groups>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<detectLinks>false</detectLinks>
<detectJavaApiLinks>false</detectJavaApiLinks>
<show>private</show>
<docfilessubdirs>true</docfilessubdirs>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<breakiterator>true</breakiterator>
<version>true</version>
<author>true</author>
<keywords>true</keywords>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<targetJdk>1.8</targetJdk>
<!-- <rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/braces.xml</ruleset>
<ruleset>/rulesets/java/clone.xml</ruleset>
<ruleset>/rulesets/java/codesize.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
<ruleset>/rulesets/java/empty.xml</ruleset>
<ruleset>/rulesets/java/finalizers.xml</ruleset>
<ruleset>/rulesets/java/imports.xml</ruleset>
<ruleset>/rulesets/java/junit.xml</ruleset>
<ruleset>/rulesets/java/naming.xml</ruleset>
<ruleset>/rulesets/java/optimizations.xml</ruleset>
<ruleset>/rulesets/java/strictexception.xml</ruleset>
<ruleset>/rulesets/java/strings.xml</ruleset>
<ruleset>/rulesets/java/sunsecure.xml</ruleset>
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
</rulesets>-->
</configuration>
</plugin>
<!--<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
<!--<report>project-team</report>
<report>mailing-list</report>
<report>cim</report>
<report>issue-tracking</report>-->
<report>licenses</report>
<!--<report>scm</report>-->
</reports>
</reportSet>
</reportSets>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.wildfly;
/**
* Does nothing, only reuquired to get the Maven JAR working.
*
* To be removed when other classes are added to this module.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class LibreCcmWildfly {
}

47
pom.xml
View File

@ -95,8 +95,8 @@
<module>ccm-cms-archetype-contenttype</module> <module>ccm-cms-archetype-contenttype</module>
<!--<module>ccm-cms-js</module>--> <!--<module>ccm-cms-js</module>-->
<module>ccm-wildfly</module>
</modules> </modules>
<reporting> <reporting>
<excludeDefaults>true</excludeDefaults> <excludeDefaults>true</excludeDefaults>
@ -532,6 +532,47 @@
<artifactId>jaxb-runtime</artifactId> <artifactId>jaxb-runtime</artifactId>
<version>2.4.0-b180830.0438</version> <version>2.4.0-b180830.0438</version>
</dependency> </dependency>
<!--
Jakarta MVC is a thin layer ontop of JAX-RS providing a
MVC framework for Jakarta EE: https://www.mvc-spec.org
The reference implementation Krazo is available for
all major application servers. Krazo all provides several
extensions for template engines.
-->
<dependency>
<groupId>javax.mvc</groupId>
<artifactId>javax.mvc-api</artifactId>
<version>1.0.0</version>
</dependency>
<!--
Krazo core dependency. Should be used with the `provided` scope
if a module needs access to internals of Krazo
-->
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-core</artifactId>
<version>1.1.0-M1</version>
</dependency>
<!-- Krazo for Glassfish/Papaya -->
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-jersey</artifactId>
<version>1.1.0-M1</version>
</dependency>
<!-- Krazo for Wildfly and JBoss EAP -->
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-resteasy</artifactId>
<version>1.1.0-M1</version>
</dependency>
<!-- Krazo support for Freemarker -->
<dependency>
<groupId>org.eclipse.krazo.ext</groupId>
<artifactId>krazo-freemarker</artifactId>
<version>1.1.0-M1</version>
</dependency>
<!-- Shiro lib for security stuff --> <!-- Shiro lib for security stuff -->
<dependency> <dependency>
@ -912,4 +953,4 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
</project> </project>