Permalink
Browse files

revert to JavaEE6 only (no Seam)

  • Loading branch information...
mmazi committed Sep 13, 2011
1 parent f6133d7 commit f4e51d981bdf60b488029568334b5e7b3d993198
View
96 pom.xml
@@ -15,105 +15,9 @@
<type>pom</type>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.5.8</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.5.8</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.seam.faces</groupId>
- <artifactId>seam-faces-api</artifactId>
- <version>3.0.0.Final</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.faces</groupId>
- <artifactId>seam-faces-impl</artifactId>
- <version>3.0.0.Final</version>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.seam.international</groupId>
- <artifactId>seam-international</artifactId>
- </exclusion>
- </exclusions>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.international</groupId>
- <artifactId>seam-international-api</artifactId>
- <version>3.0.0.Final</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.international</groupId>
- <artifactId>seam-international-impl</artifactId>
- <version>3.0.0.Final</version>
- <scope>runtime</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.jboss.seam.cron</groupId>
- <artifactId>seam-cron-api</artifactId>
- <version>3.0.0.Alpha1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.cron</groupId>
- <artifactId>seam-cron-scheduling-quartz</artifactId>
- <version>3.0.0.Alpha1</version>
- <scope>runtime</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.jboss.seam.mail</groupId>
- <artifactId>seam-mail-core-api</artifactId>
- <version>3.0.0.Beta1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam.mail</groupId>
- <artifactId>seam-mail-freemarker-impl</artifactId>
- <version>3.0.0.Beta1-SNAPSHOT</version>
- </dependency>
-
-
</dependencies>
<build>
<finalName>demo</finalName>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- <resource>
- <directory>src/main/mail</directory>
- <targetPath>mail</targetPath>
- <filtering>false</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.jboss.as.plugins</groupId>
- <artifactId>jboss-as-maven-plugin</artifactId>
- <version>7.0.0.Final</version>
- <executions>
- <execution>
- <phase>install</phase>
- <goals>
- <goal>deploy</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
</build>
</project>
@@ -1,8 +1,6 @@
package com.parsek.test;
import com.parsek.test.model.Member;
-import com.parsek.test.seam.MailSender;
-import com.parsek.test.seam.Messages;
import javax.annotation.PostConstruct;
import javax.ejb.Stateful;
@@ -18,8 +16,6 @@
public class MemberRegistration {
@PersistenceContext private EntityManager em;
@Inject private Event<Member> memberEventSrc;
- @Inject private Messages messages;
- @Inject private MailSender mailSender;
private Member newMember;
@@ -36,14 +32,11 @@ public Member getNewMember() {
public void register() throws Exception {
em.persist(newMember);
memberEventSrc.fire(newMember);
- mailSender.sayWelcome(newMember);
- messages.addInfo("member.created", newMember.getName());
initNewMember();
}
public void delete(Member m) {
em.remove(em.getReference(Member.class, m.getId()));
- messages.addInfo("member.deleted", m.getName());
memberEventSrc.fire(m);
}
}
@@ -1,27 +0,0 @@
-package com.parsek.test.seam;
-
-import org.jboss.seam.cron.api.scheduling.Every;
-import org.jboss.seam.cron.api.scheduling.Interval;
-import org.jboss.seam.cron.api.scheduling.Scheduled;
-import org.jboss.seam.cron.api.scheduling.Trigger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.enterprise.event.Observes;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-public class CronExample {
- private static final Logger log = LoggerFactory.getLogger(CronExample.class);
-
- @PersistenceContext private EntityManager em;
-
- public void countMembers(@Observes @Every(nth = 5, value = Interval.SECOND) Trigger t) {
- log.info("We have {} members.", em.createQuery("select count(m) from Member m").getSingleResult());
- }
-
- public void daily(@Observes @Scheduled("0 0 15 ? * * *") Trigger trigger) {
- log.info("It is time.");
- }
-}
-
@@ -1,26 +0,0 @@
-package com.parsek.test.seam;
-
-import org.jboss.seam.international.Alter;
-import org.jboss.seam.solder.core.Client;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.util.Locale;
-
-/**
- * @author Matija Mazi <br/>
- * @created 12.9.11 15:49
- */
-@ApplicationScoped @Named
-public class LocaleSelector {
- @Inject @Alter @Client private Event<Locale> localeEvent;
- @Inject private Messages messages;
-
- public void setUserLocale(String lang) {
- Locale newUserLocale = new Locale(lang);
- messages.addInfo("user.locale.changed", newUserLocale);
- localeEvent.fire(newUserLocale);
- }
-}
@@ -1,30 +0,0 @@
-package com.parsek.test.seam;
-
-import com.parsek.test.model.Member;
-import org.jboss.seam.mail.api.MailMessage;
-import org.jboss.seam.mail.templating.freemarker.FreeMarkerTemplate;
-import org.jboss.seam.solder.resourceLoader.Resource;
-
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import java.io.InputStream;
-import java.io.Serializable;
-
-public class MailSender implements Serializable {
-
- @PersistenceContext private EntityManager entityManager;
- @Inject @Resource("mail/welcome.ftl") private InputStream templateStream;
- @Inject private MailMessage mailMessage;
-// @javax.annotation.Resource(mappedName = "java:/Mail") private Session session;
-
- public void sayWelcome(Member member) {
- mailMessage
- .from("no-reply@example.com", "Seam 3 Example App")
- .to(member.getEmail())
- .subject("Welcome!")
- .bodyHtml(new FreeMarkerTemplate(templateStream))
- .put("member", member)
- .send();
- }
-}
@@ -1,37 +0,0 @@
-package com.parsek.test.seam;
-
-import org.jboss.seam.international.status.MessageFactory;
-import org.jboss.seam.international.status.builder.BundleKey;
-
-import javax.faces.application.FacesMessage;
-import javax.inject.Inject;
-import java.io.Serializable;
-
-/**
- * User: Matic<br/>
- * Date: 3.7.11<br/>
- */
-public class Messages implements Serializable {
- @Inject org.jboss.seam.international.status.Messages seamMsgs;
- @Inject private MessageFactory msgFactory;
-
- public void addError(String key, Object... params) {
- seamMsgs.error(createBundleKey(key), params);
- }
-
- public void addWarn(String key, Object... params) {
- seamMsgs.warn(createBundleKey(key), params);
- }
-
- public void addInfo(String key, Object... params) {
- seamMsgs.info(createBundleKey(key), params);
- }
-
- private BundleKey createBundleKey(String key) {
- return new BundleKey("messages", key);
- }
-
- public FacesMessage createError(String msgKey) {
- return new FacesMessage(FacesMessage.SEVERITY_ERROR, msgFactory.error(createBundleKey(msgKey)).build().getText(), null);
- }
-}
@@ -1,35 +0,0 @@
-package com.parsek.test.seam;
-
-import javax.enterprise.context.RequestScoped;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-/**
- * User: Matic<br/>
- * Date: 1.7.11<br/>
- */
-@FacesValidator("unregisteredEmailValidator")
-@Named
-@RequestScoped
-public class UnregisteredEmailValidator implements Validator {
- @PersistenceContext private EntityManager entityManager;
- @Inject private Messages messages;
-
- @Override
- public void validate(FacesContext facesContext, UIComponent uiComponent, Object o) throws ValidatorException {
- Number result = entityManager
- .createQuery("select count(m) from Member m where m.email = :email", Number.class)
- .setParameter("email", o)
- .getSingleResult();
- if (result.intValue() > 0) {
- throw new ValidatorException(messages.createError("email.already.registered"));
- }
- }
-}
View
@@ -1,13 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>Welcome to Seam!</title>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
-</head>
-<body style="background-color:#fff;color:#000000;margin:0;padding:0;font-size:13px;line-height:1.5;font-family:Arial,Tahoma,Verdana,Helvetica,'Bitstream Vera Sans',sans-serif;">
-<div id="wrapper" style="background-color:#fff;text-align:left;width:100%;">
- <h1>Dear ${member.name},</h1>
-
- <p>Welcome to Seam 3!</p>
-</div>
-</body>
-</html>
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Dependencies: org.slf4j,javax.api,javax.ejb.api,javax.servlet.api,org.jodatime
@@ -1,5 +0,0 @@
-member.deleted=Member deleted: {0}
-member.created=New member created: {0}
-user.locale.changed=Set user locale to {0}.
-security.passwords.mismatch=Passwords don't match.
-email.already.registered=Email already registered.
@@ -1,5 +0,0 @@
-member.deleted=\u010clan ostranjen: {0}
-member.created=Nov \u010dlan shranjen: {0}
-user.locale.changed=Jezik spremenjen na {0}.
-security.passwords.mismatch=Gesli se ne ujemata.
-email.already.registered=Elektronski naslov je \u017ee registriran.
@@ -1,9 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faces-config version="2.0"
- 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-facesconfig_2_0.xsd">
-
-</faces-config>
+<faces-config version="2.0"/>
@@ -1,18 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core">
-<f:view locale="#{userLocale}">
<h:head>
<title>CDI Demo</title>
<h:outputStylesheet name="screen.css"/>
</h:head>
<h:body>
<div id="container">
- <h:form>
- <h:commandLink value="sl" action="#{localeSelector.setUserLocale('sl')}"/> |
- <h:commandLink value="en" action="#{localeSelector.setUserLocale('en')}"/>
- </h:form>
<div id="content">
- <h:messages globalOnly="true" styleClass="msgs"/>
<h:form id="reg">
<h2>Register</h2>
<h:panelGrid columns="3">
@@ -22,7 +16,7 @@
<h:message for="name" errorClass="invalid"/>
<h:outputLabel for="email" value="Email:"/>
- <h:inputText id="email" value="#{newMember.email}" validator="unregisteredEmailValidator"/>
+ <h:inputText id="email" value="#{newMember.email}"/>
<h:message for="email" errorClass="invalid"/>
<h:outputLabel for="phoneNumber" value="Phone:"/>
@@ -63,5 +57,4 @@
</div>
</div>
</h:body>
-</f:view>
</html>
@@ -52,6 +52,3 @@ span.invalid {
padding: 3px 17px;
}
-.msgs {
- background-color: #ccffcc;
-}

0 comments on commit f4e51d9

Please sign in to comment.