Permalink
Browse files

initial commit

  • Loading branch information...
structr
structr committed Feb 1, 2011
0 parents commit 29ff6a7aefd1eb5c8c25f26f6c6ab1cfe06a47d6
Showing 2,605 changed files with 268,362 additions and 0 deletions.
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.structr</groupId>
<artifactId>structr</artifactId>
<packaging>pom</packaging>
<version>0.1.1</version>
<name>structr</name>
<url>http://structr.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>structr-core</module>
<!-- <module>structr-modules</module>-->
<module>structr-core-ui</module>
<module>structr-module-web</module>
<module>structr-webapp</module>
</modules>
</project>
@@ -0,0 +1,104 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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>
<parent>
<artifactId>structr</artifactId>
<groupId>org.structr</groupId>
<version>0.1.1</version>
</parent>
<groupId>org.structr</groupId>
<artifactId>structr-core-ui</artifactId>
<version>0.1.1</version>
<name>structr-core-ui</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.structr</groupId>
<artifactId>structr-core</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<type>jar</type>
<scope>provided</scope>
<optional>false</optional>
</dependency>
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<scope>test</scope>
<optional>false</optional>
</dependency>-->
<dependency>
<groupId>org.apache.click</groupId>
<artifactId>click</artifactId>
<version>2.3.0-RC1</version>
<!-- <type>jar</type>-->
<!-- <optional>false</optional>-->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.click</groupId>
<artifactId>click-extras</artifactId>
<version>2.3.0-RC1</version>
<!-- <type>jar</type>-->
<!-- <optional>false</optional>-->
<scope>compile</scope>
</dependency>
<!-- <dependency>
<groupId>org.apache.click</groupId>
<artifactId>click-mock</artifactId>
<version>2.3.0-RC1</version>
<type>jar</type>
<optional>false</optional>
</dependency>-->
<dependency>
<groupId>org.apache.click</groupId>
<artifactId>click-nodeps</artifactId>
<version>2.3.0-RC1</version>
<!-- <type>jar</type>-->
<!-- <optional>false</optional>-->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
</project>
@@ -0,0 +1,125 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.structr.context;
import java.io.FileInputStream;
import javax.servlet.http.HttpSessionEvent;
import org.structr.core.*;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionListener;
import org.structr.ui.page.StructrPage;
/**
* Web application lifecycle listener.
*
* @author cmorgner
*/
public class ApplicationContextListener implements ServletContextListener, HttpSessionListener {
private static final Logger logger = Logger.getLogger(ApplicationContextListener.class.getName());
@Override
public void contextInitialized(ServletContextEvent sce) {
logger.log(Level.INFO, "Servlet context created");
Map<String, Object> context = new ConcurrentHashMap<String, Object>();
ServletContext servletContext = sce.getServletContext();
String configFile = servletContext.getInitParameter(Services.CONFIG_FILE_PATH);
context.put(Services.CONFIG_FILE_PATH, configFile);
context.put(Services.SERVLET_CONTEXT, servletContext);
try {
// load config file
Properties properties = new Properties();
properties.load(new FileInputStream(configFile));
String appTitle = properties.getProperty(Services.APPLICATION_TITLE);
logger.log(Level.INFO, "Config file: Application title: {0}", appTitle);
String databasePath = properties.getProperty(Services.DATABASE_PATH_IDENTIFIER);
logger.log(Level.INFO, "Config file: Database path: {0}", databasePath);
String filesPath = properties.getProperty(Services.FILES_PATH_IDENTIFIER);
logger.log(Level.INFO, "Config file: Files path: {0}", filesPath);
String pluginsPath = properties.getProperty(Services.MODULES_PATH_IDENTIFIER);
logger.log(Level.INFO, "Config file: Plugins path: {0}", pluginsPath);
String entityPackages = properties.getProperty(Services.ENTITY_PACKAGES_IDENTIFIER);
logger.log(Level.INFO, "Config file: Entity Packages: {0}", entityPackages);
context.put(Services.APPLICATION_TITLE, appTitle);
context.put(Services.DATABASE_PATH_IDENTIFIER, databasePath);
context.put(Services.FILES_PATH_IDENTIFIER, filesPath);
context.put(Services.MODULES_PATH_IDENTIFIER, pluginsPath);
context.put(Services.ENTITY_PACKAGES_IDENTIFIER, entityPackages);
} catch (Throwable t) {
// handle error
// logger.log(Level.WARNING, "Problems reading config file, initializing with default values from servlet context", t);
context.put(Services.APPLICATION_TITLE, servletContext.getInitParameter(Services.APPLICATION_TITLE));
context.put(Services.DATABASE_PATH_IDENTIFIER, servletContext.getInitParameter(Services.DATABASE_PATH_IDENTIFIER));
context.put(Services.FILES_PATH_IDENTIFIER, servletContext.getInitParameter(Services.FILES_PATH_IDENTIFIER));
context.put(Services.MODULES_PATH_IDENTIFIER, servletContext.getInitParameter(Services.MODULES_PATH_IDENTIFIER));
context.put(Services.ENTITY_PACKAGES_IDENTIFIER, servletContext.getInitParameter(Services.ENTITY_PACKAGES_IDENTIFIER));
}
// register predicate that can decide whether a given Class object is a subclass of StructrPage
context.put(Services.STRUCTR_PAGE_PREDICATE, new Predicate<Class>()
{
@Override
public boolean evaluate(Class obj)
{
return(StructrPage.class.isAssignableFrom(obj));
}
});
// initialize services layzily, just set context parameter
//Services.initialize(context);
Services.setContext(context);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
logger.log(Level.INFO, "Servlet context destroyed");
// TODO: remove servlet context attributes? Is it necessary?
Services.shutdown();
}
@Override
public void sessionCreated(HttpSessionEvent se) {
logger.log(Level.FINE, "HTTP session created", se.getSession().getId());
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
logger.log(Level.FINE, "HTTP session destroyed, cleaning", se.getSession().getId());
// clean session..
// HttpSession session = se.getSession();
//
// // TODO: when running embedded under Winstone,
// // there's a ConcurrentModificationException thrown at logout
// // I tried to fix it by adding the 'synchronized() block, but
// // it didn't help. Must be investigated further ...
// synchronized (session) {
// for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) {
// String name = (String) e.nextElement();
// session.removeAttribute(name);
// }
// }
}
}
Oops, something went wrong.

0 comments on commit 29ff6a7

Please sign in to comment.