[jbpm-commits] JBoss JBPM SVN: r3214 - in projects/balalaika/trunk: core/src/main/java/org/jboss/balalaika and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Dec 5 05:02:01 EST 2008
Author: heiko.braun at jboss.com
Date: 2008-12-05 05:02:01 -0500 (Fri, 05 Dec 2008)
New Revision: 3214
Added:
projects/balalaika/trunk/war/
projects/balalaika/trunk/war/pom.xml
projects/balalaika/trunk/war/src/
projects/balalaika/trunk/war/src/main/
projects/balalaika/trunk/war/src/main/java/
projects/balalaika/trunk/war/src/main/java/org/
projects/balalaika/trunk/war/src/main/java/org/jboss/
projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/
projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ReportFacade.java
projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ServerApplication.java
projects/balalaika/trunk/war/src/main/resources/
projects/balalaika/trunk/war/src/main/webapp/
projects/balalaika/trunk/war/src/main/webapp/WEB-INF/
projects/balalaika/trunk/war/src/main/webapp/WEB-INF/jboss-web.xml
projects/balalaika/trunk/war/src/main/webapp/WEB-INF/web.xml
projects/balalaika/trunk/war/src/main/webapp/index.html
Removed:
projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/ConfigAdapter.java
projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/IntegrationConfig.java
Modified:
projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/BirtService.java
projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/RenderMetaData.java
projects/balalaika/trunk/pom.xml
Log:
Added server component (REST) to the project
Modified: projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/BirtService.java
===================================================================
--- projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/BirtService.java 2008-12-05 09:26:04 UTC (rev 3213)
+++ projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/BirtService.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -23,6 +23,8 @@
import org.eclipse.birt.report.engine.api.*;
import org.eclipse.birt.core.framework.Platform;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* jBPM BIRT integration.
@@ -31,17 +33,21 @@
*/
public class BirtService
{
+ private static final Log log = LogFactory.getLog(BirtService.class);
+
private IReportEngine engine;
private IntegrationConfig iConfig;
public BirtService()
{
- this.iConfig = new ConfigAdapter();
+ // TODO: runtime configuration
+ this.iConfig = new IntegrationConfig();
}
public void create()
{
this.engine = BirtEngineFactory.newInstance(iConfig);
+ log.info("Service created: " +this.engine);
}
public void start()
@@ -58,13 +64,16 @@
{
if(engine!=null)
engine.destroy();
- Platform.shutdown();
+ Platform.shutdown();
+ log.info("Service destroyed");
}
public String render(RenderMetaData metaData)
{
String outputFileName = null;
+ log.debug("Render " + metaData);
+
try
{
//Open a report design
@@ -96,7 +105,9 @@
if( options.getOutputFormat().equalsIgnoreCase("html"))
{
HTMLRenderOption htmlOptions = new HTMLRenderOption( options);
- htmlOptions.setImageDirectory(iConfig.getOutputDir()+"image");
+ htmlOptions.setImageHandler(new HTMLServerImageHandler());
+ htmlOptions.setImageDirectory(iConfig.getImageDirectory());
+ htmlOptions.setBaseImageURL(iConfig.getImageBaseUrl());
htmlOptions.setHtmlPagination(false);
htmlOptions.setHtmlRtLFlag(false);
//Setting this to true removes html and body tags
@@ -110,7 +121,7 @@
pdfOptions.setOption( IPDFRenderOption.PAGEBREAK_PAGINATION_ONLY, new Boolean(true) );
runRenderTask.setRenderOption(pdfOptions);
}
-
+
// ------------------
if(runRenderTask.getRenderOption()==null)
runRenderTask.setRenderOption(options);
Deleted: projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/ConfigAdapter.java
===================================================================
--- projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/ConfigAdapter.java 2008-12-05 09:26:04 UTC (rev 3213)
+++ projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/ConfigAdapter.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.balalaika;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class ConfigAdapter implements IntegrationConfig
-{
- private String birtHome = "/Users/hbraun/dev/env/birt-runtime-2_2_2/ReportEngine/";
- private String reportDir = "/Users/hbraun/dev/prj/jbpm/projects/gwt-console/trunk/server/src/main/resources/";
- private String outputDir = "/Users/hbraun/balalaika/";
-
- public String getBirtHome()
- {
- return birtHome;
- }
-
- public void setBirtHome(String birtHome)
- {
- this.birtHome = birtHome;
- }
-
- public String getReportDir()
- {
- return reportDir;
- }
-
- public void setReportDir(String reportDir)
- {
- this.reportDir = reportDir;
- }
-
- public String getOutputDir()
- {
- return outputDir;
- }
-
- public void setOutputDir(String outputDir)
- {
- this.outputDir = outputDir;
- }
-}
Deleted: projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/IntegrationConfig.java
===================================================================
--- projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/IntegrationConfig.java 2008-12-05 09:26:04 UTC (rev 3213)
+++ projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/IntegrationConfig.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.balalaika;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface IntegrationConfig
-{
- String getBirtHome();
-
- void setBirtHome(String birtHome);
-
- String getReportDir();
-
- void setReportDir(String reportDir);
-
- String getOutputDir();
-
- void setOutputDir(String outputDir);
-}
Modified: projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/RenderMetaData.java
===================================================================
--- projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/RenderMetaData.java 2008-12-05 09:26:04 UTC (rev 3213)
+++ projects/balalaika/trunk/core/src/main/java/org/jboss/balalaika/RenderMetaData.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -36,11 +36,11 @@
{
}
- public RenderMetaData(ClassLoader classloader, String reportName, Format format)
+ public RenderMetaData(ClassLoader classloader, String reportName, Format format, String imageBaseUrl)
{
this.classloader = classloader;
this.reportName = reportName;
- this.format = format;
+ this.format = format;
}
public ClassLoader getClassloader()
@@ -72,4 +72,10 @@
{
this.format = format;
}
+
+
+ public String toString()
+ {
+ return "RenderMetaData {reportName="+reportName+", format="+format+"}";
+ }
}
Modified: projects/balalaika/trunk/pom.xml
===================================================================
--- projects/balalaika/trunk/pom.xml 2008-12-05 09:26:04 UTC (rev 3213)
+++ projects/balalaika/trunk/pom.xml 2008-12-05 10:02:01 UTC (rev 3214)
@@ -15,12 +15,14 @@
</parent>
<properties>
- <commons.logging.version>1.1.1</commons.logging.version>
+ <commons.logging.version>1.1.1</commons.logging.version>
<junit.version>3.8.1</junit.version>
+ <resteasy.version>1.0-beta-8</resteasy.version>
</properties>
<modules>
- <module>core</module>
+ <module>core</module>
+ <module>war</module>
</modules>
<dependencyManagement>
@@ -39,6 +41,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
@@ -59,6 +67,6 @@
<enabled>true</enabled>
</snapshots>
</repository>
- </repositories>
+ </repositories>
</project>
Added: projects/balalaika/trunk/war/pom.xml
===================================================================
--- projects/balalaika/trunk/war/pom.xml (rev 0)
+++ projects/balalaika/trunk/war/pom.xml 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <name>JBoss jBPM3 - Balalaika Server</name>
+ <groupId>org.jbpm</groupId>
+ <artifactId>balalaika-server</artifactId>
+ <packaging>war</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm</groupId>
+ <artifactId>balalaika-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>balalaika-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- Plugins -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ <finalName>report-server</finalName>
+ </build>
+</project>
Added: projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ReportFacade.java
===================================================================
--- projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ReportFacade.java (rev 0)
+++ projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ReportFacade.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.balalaika;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * BIRT integration facade.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("report")
+public class ReportFacade
+{
+ private static final Log log = LogFactory.getLog(ReportFacade.class);
+ private BirtService birtService;
+
+
+ public ReportFacade()
+ {
+ this.birtService = new BirtService();
+ this.birtService.create();
+ }
+
+ @GET
+ @Path("view/{fileName}")
+ @Produces("text/html")
+ public Response viewReportHtml(
+ @PathParam("fileName")
+ String fileName
+ )
+ {
+ RenderMetaData renderMeta = new RenderMetaData();
+ renderMeta.setReportName(fileName);
+ renderMeta.setFormat(RenderMetaData.Format.HTML);
+ renderMeta.setClassloader(Thread.currentThread().getContextClassLoader());
+
+ String outputFileName = birtService.render(renderMeta);
+ String absoluteFile = birtService.getIConfig().getOutputDir() + outputFileName;
+ log.info("Render " + absoluteFile);
+
+ File f = new File(absoluteFile);
+ return Response.ok(bytesFromFile(f)).type("text/html").build();
+ }
+
+ @GET
+ @Path("view/image/{fileName}")
+ public Response getImage(
+ @PathParam("fileName")
+ String fileName
+ )
+ {
+ String imageDir = birtService.getIConfig().getImageDirectory();
+ String absName = imageDir + fileName;
+ File imageFile = new File(absName);
+ if(!imageFile.exists())
+ throw new IllegalArgumentException("Image " +absName+" doesn't exist");
+ return Response.ok(bytesFromFile(imageFile)).build();
+ }
+
+ public static byte[] bytesFromFile(File file)
+ {
+ try
+ {
+ InputStream is = new FileInputStream(file);
+ long length = file.length();
+
+ byte[] bytes = new byte[(int)length];
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length && (numRead=is.read(bytes,
+ offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+ if (offset < bytes.length) {
+ throw new IOException("Could not completely read file "
+ + file.getName());
+ }
+ is.close();
+ return bytes;
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to read file " + file);
+ }
+ }
+
+}
Added: projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ServerApplication.java
===================================================================
--- projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ServerApplication.java (rev 0)
+++ projects/balalaika/trunk/war/src/main/java/org/jboss/balalaika/ServerApplication.java 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.balalaika;
+
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * JAX-RS core component.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ServerApplication extends Application
+{
+ HashSet<Object> singletons = new HashSet<Object>();
+
+ public ServerApplication()
+ {
+ singletons.add(new ReportFacade());
+ }
+
+ @Override
+ public Set<Class<?>> getClasses()
+ {
+ HashSet<Class<?>> set = new HashSet<Class<?>>();
+ return set;
+ }
+
+ @Override
+ public Set<Object> getSingletons()
+ {
+ return singletons;
+ }
+}
Added: projects/balalaika/trunk/war/src/main/webapp/WEB-INF/jboss-web.xml
===================================================================
--- projects/balalaika/trunk/war/src/main/webapp/WEB-INF/jboss-web.xml (rev 0)
+++ projects/balalaika/trunk/war/src/main/webapp/WEB-INF/jboss-web.xml 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 2.4//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+
+ <security-domain>java:/jaas/jbpm-console</security-domain>
+
+ <context-root>report-server</context-root>
+
+ <loader-repository>
+ org.bpm.console.server:report-server.war
+ </loader-repository>
+
+ <!--resource-ref>
+ <res-ref-name>jdbc/JbpmDataSource</res-ref-name>
+ <jndi-name>java:/JbpmDS</jndi-name>
+ </resource-ref>
+ -->
+
+</jboss-web>
Added: projects/balalaika/trunk/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- projects/balalaika/trunk/war/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ projects/balalaika/trunk/war/src/main/webapp/WEB-INF/web.xml 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,64 @@
+<!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>Report Server</display-name>
+
+ <context-param>
+ <param-name>javax.ws.rs.core.Application</param-name>
+ <param-value>org.jboss.balalaika.ServerApplication</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>resteasy.servlet.mapping.prefix</param-name>
+ <param-value>/rs</param-value>
+ </context-param>
+
+ <!--context-param>
+ <param-name>org.jboss.bpm.console.server.dao.ManagementFactory</param-name>
+ <param-value>org.jboss.bpm.console.server.dao.internal.JBPM3ManagementFactory</param-value>
+ </context-param-->
+
+ <listener>
+ <listener-class>
+ org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+ </listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>
+ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/rs/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Resteasy</web-resource-name>
+ <url-pattern>/rs/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>admin</role-name>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>Report Server</realm-name>
+ </login-config>
+
+ <security-role>
+ <role-name>admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
+</web-app>
Added: projects/balalaika/trunk/war/src/main/webapp/index.html
===================================================================
--- projects/balalaika/trunk/war/src/main/webapp/index.html (rev 0)
+++ projects/balalaika/trunk/war/src/main/webapp/index.html 2008-12-05 10:02:01 UTC (rev 3214)
@@ -0,0 +1,35 @@
+<html>
+<body>
+
+<h1>Report Server</h1>
+
+<h2>Published REST Url's </h2>
+
+<table border=1 cellpadding=5>
+<tr>
+ <th>Method</th>
+ <th>Context</th>
+ <th>Description</th>
+ <th>Mime Types</th>
+</tr>
+
+<tr>
+ <td colspan=4><h3>Report Management</h3></td>
+</tr>
+
+<tr>
+ <td>GET</td>
+ <td>/rs/report/view/{reportName}</td>
+ <td>Get an HTML report from file 'reportName' </td>
+ <td>text/html</td>
+</tr>
+
+<tr>
+ <td>GET</td>
+ <td>/rs/report/view/image/{image}</td>
+ <td>Get images associated with an HTML report (usally a private call)</td>
+ <td>image/jpg, image/gif, image/png</td>
+</tr>
+</table>
+</body>
+</html>
\ No newline at end of file
More information about the jbpm-commits
mailing list