Skip to content

Commit

Permalink
Starting out with some basics
Browse files Browse the repository at this point in the history
  • Loading branch information
feminaexlux committed Aug 11, 2013
0 parents commit d310310
Show file tree
Hide file tree
Showing 13 changed files with 343 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/*
*.iml
target/*
70 changes: 70 additions & 0 deletions gallery-struts2.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="gallery-struts2">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
<facet type="Struts2" name="Struts 2">
<configuration>
<fileset id="s2fileset" name="Struts" removed="false">
<file>file://$MODULE_DIR$/src/main/resources/struts.xml</file>
<file>jar://$MAVEN_REPOSITORY$/org/apache/struts/struts2-core/2.3.4.1/struts2-core-2.3.4.1.jar!/struts-default.xml</file>
</fileset>
<propertiesKeys disabled="false" />
</configuration>
</facet>
</facet>
<facet type="hibernate" name="Hibernate">
<configuration>
<datasource-map>
<unit-entry name="hibernate.cfg.xml" value="658bc170-e91b-4947-8964-ce55d0ab9db4" />
</datasource-map>
<deploymentDescriptor name="hibernate.cfg.xml" url="file://$MODULE_DIR$/src/main/resources/hibernate.cfg.xml" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.struts:struts2-core:2.3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.struts.xwork:xwork-core:2.3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: ognl:ognl:3.0.5" level="project" />
<orderEntry type="library" name="Maven: javassist:javassist:3.11.0.GA" level="project" />
<orderEntry type="library" name="Maven: asm:asm:3.3" level="project" />
<orderEntry type="library" name="Maven: asm:asm-commons:3.3" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.19" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.0-beta8" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.0-beta8" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.2.3.Final" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.0.GA" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.25" level="project" />
</component>
</module>

38 changes: 38 additions & 0 deletions log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug" strict="true" name="XMLConfigTest"
packages="org.apache.logging.log4j.test">
<properties>
<property name="filename">target/gallery-struts2.log</property>
</properties>

<appenders>
<appender type="Console" name="STDOUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</appender>
<appender type="File" name="File" fileName="${filename}">
<layout type="PatternLayout">
<pattern>%d %p %C{1.} [%t] %m%n</pattern>
</layout>
</appender>
</appenders>

<loggers>
<logger name="net.feminaexlux" level="trace" additivity="false">
<appender-ref ref="File"/>
</logger>
<root level="trace">
<appender-ref ref="Console"/>
</root>

<logger name="com.opensymphony">
<level value="DEBUG"/>
<appender-ref ref="Console"/>
</logger>

<logger name="org.apache.struts2">
<level value="DEBUG"/>
<appender-ref ref="Console"/>
</logger>
</loggers>

</configuration>
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>gallery-strust2</groupId>
<artifactId>gallery-struts2</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.3.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.feminaexlux.gallery.struts2.controller;

import com.opensymphony.xwork2.ActionSupport;
import net.feminaexlux.gallery.struts2.model.Resource;

import java.util.List;

public class Gallery extends ActionSupport {
private List<Resource> resources;

@Override
public String execute() throws Exception {
return SUCCESS;
}
}
13 changes: 13 additions & 0 deletions src/main/java/net/feminaexlux/gallery/struts2/dao/ResourceDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.feminaexlux.gallery.struts2.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

public abstract class ResourceDAO {
protected EntityManager entityManager;

@PersistenceContext
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
}
66 changes: 66 additions & 0 deletions src/main/java/net/feminaexlux/gallery/struts2/model/Resource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package net.feminaexlux.gallery.struts2.model;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "resource")
public class Resource {
protected int id;
protected ResourceType type;
protected String name;
protected Date created;
protected Date updated;
protected Date deleted;

@Id
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

@ManyToOne
@PrimaryKeyJoinColumn(name = "type", referencedColumnName = "type")
public ResourceType getType() {
return type;
}

public void setType(ResourceType type) {
this.type = type;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Date getCreated() {
return created;
}

public void setCreated(Date created) {
this.created = created;
}

public Date getUpdated() {
return updated;
}

public void setUpdated(Date updated) {
this.updated = updated;
}

public Date getDeleted() {
return deleted;
}

public void setDeleted(Date deleted) {
this.deleted = deleted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.feminaexlux.gallery.struts2.model;

import javax.persistence.*;

@Entity
@Table(name = "resource_type")
public class ResourceType {
protected String type;

@Id
@Column(name = "type", nullable = false, length = 50)
public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

ResourceType that = (ResourceType) o;

if (type != null ? !type.equals(that.type) : that.type != null) return false;

return true;
}

@Override
public int hashCode() {
return type != null ? type.hashCode() : 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.feminaexlux.gallery.struts2.service;

import com.opensymphony.xwork2.inject.Inject;
import net.feminaexlux.gallery.struts2.dao.ResourceDAO;

public abstract class ResourceService {
@Inject
private ResourceDAO resourceDAO;
}
12 changes: 12 additions & 0 deletions src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://Tianne:3306/gallery</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">gallery</property>
<property name="connection.password">gallery</property>
</session-factory>
</hibernate-configuration>
18 changes: 18 additions & 0 deletions src/main/resources/struts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.devMode" value="true"/>

<package name="gallery-struts2" extends="struts-default">

<action name="index">
<result>/index.jsp</result>
</action>

</package>

</struts>
16 changes: 16 additions & 0 deletions web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
9 changes: 9 additions & 0 deletions web/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html lang="en">
<head>
<title>Gallery -- Struts 2</title>
</head>
<body>
<h1>Test</h1>
<p>Hello world</p>
</body>
</html>

0 comments on commit d310310

Please sign in to comment.