Skip to content

Commit 7d2974c

Browse files
committed
Enhancements to multi-domain example
1 parent 6e5f7bd commit 7d2974c

6 files changed

Lines changed: 67 additions & 97 deletions

File tree

showcase/multi-domain/src/main/java/com/ocpsoft/rewrite/showcase/domain/Domain.java renamed to showcase/multi-domain/src/main/java/com/ocpsoft/rewrite/showcase/domain/DomainEntity.java

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import javax.persistence.Version;
99

1010
@Entity
11-
public class Domain implements java.io.Serializable
11+
public class DomainEntity implements java.io.Serializable
1212
{
1313
private static final long serialVersionUID = 1L;
1414
@Id
@@ -52,32 +52,6 @@ public void setDescription(final String description)
5252
this.description = description;
5353
}
5454

55-
@Column
56-
private int annualRevenue;
57-
58-
public int getAnnualRevenue()
59-
{
60-
return this.annualRevenue;
61-
}
62-
63-
public void setAnnualRevenue(final int annualRevenue)
64-
{
65-
this.annualRevenue = annualRevenue;
66-
}
67-
68-
@Column
69-
private String location;
70-
71-
public String getLocation()
72-
{
73-
return this.location;
74-
}
75-
76-
public void setLocation(final String location)
77-
{
78-
this.location = location;
79-
}
80-
8155
@Column
8256
private String name;
8357

@@ -94,7 +68,6 @@ public void setName(final String name)
9468
@Override
9569
public String toString()
9670
{
97-
return "Domain [name=" + name + ", description=" + description + ", location=" + location + ", annualRevenue="
98-
+ annualRevenue + "]";
71+
return "Domain [name=" + name + ", description=" + description + "]";
9972
}
10073
}

‎showcase/multi-domain/src/main/java/com/ocpsoft/rewrite/showcase/domain/Domains.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
public class Domains
4141
{
4242
private String currentName;
43-
private Domain current;
43+
private DomainEntity current;
4444

4545
@PersistenceContext(type = PersistenceContextType.EXTENDED)
4646
private EntityManager em;
@@ -50,9 +50,9 @@ public Operation load()
5050
if (current == null)
5151
{
5252
try {
53-
TypedQuery<Domain> query = em.createQuery("from Domain where name = :name", Domain.class);
53+
TypedQuery<DomainEntity> query = em.createQuery("from DomainEntity where name = :name", DomainEntity.class);
5454
query.setParameter("name", currentName);
55-
Domain result = query.getSingleResult();
55+
DomainEntity result = query.getSingleResult();
5656

5757
current = result;
5858
}
@@ -78,12 +78,12 @@ public void performHttp(final HttpServletRewrite event, final EvaluationContext
7878
return null;
7979
}
8080

81-
public Domain getCurrent()
81+
public DomainEntity getCurrent()
8282
{
8383
return current;
8484
}
8585

86-
public void setCurrent(final Domain currentDomain)
86+
public void setCurrent(final DomainEntity currentDomain)
8787
{
8888
this.current = currentDomain;
8989
}

‎showcase/multi-domain/src/main/java/com/ocpsoft/rewrite/showcase/view/DomainBean.java‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
import javax.ejb.Stateful;
55
import javax.enterprise.context.RequestScoped;
66
import javax.inject.Named;
7-
import com.ocpsoft.rewrite.showcase.domain.Domain;
7+
import com.ocpsoft.rewrite.showcase.domain.DomainEntity;
88
import org.metawidget.forge.persistence.PaginationHelper;
99
import org.metawidget.forge.persistence.PersistenceUtil;
1010
import org.jboss.seam.transaction.Transactional;
1111
@Transactional @Named @Stateful @RequestScoped public class DomainBean extends PersistenceUtil {
1212
private static final long serialVersionUID=1L;
13-
private List<Domain> list=null;
14-
private Domain domain=new Domain();
13+
private List<DomainEntity> list=null;
14+
private DomainEntity domain=new DomainEntity();
1515
private long id=0;
16-
private PaginationHelper<Domain> pagination;
16+
private PaginationHelper<DomainEntity> pagination;
1717
public void load(){
18-
domain=findById(Domain.class,id);
18+
domain=findById(DomainEntity.class,id);
1919
}
2020
public String create(){
2121
create(domain);
@@ -38,29 +38,29 @@ public void setId( long id){
3838
load();
3939
}
4040
}
41-
public Domain getDomain(){
41+
public DomainEntity getDomain(){
4242
return domain;
4343
}
44-
public void setDomain( Domain domain){
44+
public void setDomain( DomainEntity domain){
4545
this.domain=domain;
4646
}
47-
public List<Domain> getList(){
47+
public List<DomainEntity> getList(){
4848
if (list == null) {
4949
list=getPagination().createPageDataModel();
5050
}
5151
return list;
5252
}
53-
public void setList( List<Domain> list){
53+
public void setList( List<DomainEntity> list){
5454
this.list=list;
5555
}
56-
public PaginationHelper<Domain> getPagination(){
56+
public PaginationHelper<DomainEntity> getPagination(){
5757
if (pagination == null) {
58-
pagination=new PaginationHelper<Domain>(10){
58+
pagination=new PaginationHelper<DomainEntity>(10){
5959
@Override public int getItemsCount(){
60-
return count(Domain.class);
60+
return count(DomainEntity.class);
6161
}
62-
@Override public List<Domain> createPageDataModel(){
63-
return new ArrayList<Domain>(findAll(Domain.class,getPageFirstItem(),getPageSize()));
62+
@Override public List<DomainEntity> createPageDataModel(){
63+
return new ArrayList<DomainEntity>(findAll(DomainEntity.class,getPageFirstItem(),getPageSize()));
6464
}
6565
}
6666
;

‎showcase/multi-domain/src/main/webapp/AL.xhtml‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎showcase/multi-domain/src/main/webapp/NZ.xhtml‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎showcase/multi-domain/src/main/webapp/index.xhtml‎

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
<ui:composition template="/resources/forge-template.xhtml">
88

9-
<ui:param name="pageTitle" value="Welcome to #{domains.current.name}'s subdomain" />
10-
9+
<ui:param name="pageTitle"
10+
value="Welcome to #{domains.current.name}'s subdomain" />
11+
1112
<ui:define name="header">
1213
Welcome to #{domains.current.name}'s sub-domain
1314
</ui:define>
@@ -16,19 +17,53 @@
1617
Your application is running with domain rewriting.
1718
</ui:define>
1819

19-
<ui:define name="main">
20-
<p><a target="_blank" href="http://ocpsoft.com/rewrite/">Documentation</a> | <a target="_blank" href="http://twitter.com/intent/tweet?text=I+just+deployed+a+webapp+using+domain+rewriting+with+@ocpsoft+%23URLRewrite!+(+http://ocpsoft.com/+)">Get Excited!</a><br/>
20+
<ui:define name="main">
21+
<p>
22+
<a target="_blank" href="http://ocpsoft.com/rewrite/">Documentation</a>
23+
| <a target="_blank"
24+
href="http://twitter.com/intent/tweet?text=I+just+deployed+a+webapp+using+domain+rewriting+with+@ocpsoft+%23URLRewrite!+(+http://ocpsoft.com/rewrite/+)">Get
25+
Excited!</a><br />
26+
</p>
27+
28+
<p>This example requires that you must edit your /etc/hosts file,
29+
adding a new domain alias for "localhost", e.g:</p>
30+
<pre>127.0.0.1 localhost foo.example.com</pre>
31+
32+
<p>
33+
Now you must <h:link value="add a domain" outcome="/scaffold/domain/list" />
34+
with the same sub-name, in this case: "foo", for example.
35+
</p>
36+
37+
Then access the site using one of the configured sub-domains: (you must have
38+
<h:link value="added a domain" outcome="/scaffold/domain/list" /> in the previous step
39+
before this list will be populated.)
40+
41+
<ul>
42+
<ui:repeat var="domain" value="#{domainBean.list}">
43+
<li><a
44+
href="http://#{domain.name}.example.com:8080/rewrite-showcase-multi-domain/">#{domain.name}</a>
45+
</li>
46+
</ui:repeat>
47+
</ul>
48+
<p>
49+
<a target="_blank" href="http://ocpsoft.com"><br /> OCPsoft
50+
Website</a> | <a target="_blank"
51+
href="http://ocpsoft.com/support/forum/rewrite">Support Forums</a> |
52+
<a target="_blank" href="https://github.com/ocpsoft/rewrite/issues">Report
53+
an issue</a>
54+
</p>
2155

22-
<a target="_blank" href="http://ocpsoft.com"><br/>
23-
Seam Forge Project</a> | <a target="_blank" href="http://ocpsoft.com/support/forum/rewrite">Support Forums</a> | <a target="_blank" href=
24-
"https://github.com/ocpsoft/rewrite/issues">Report an issue</a></p>
2556
</ui:define>
2657

2758
<ui:define name="footer">
28-
<p class="logos">
29-
<a target="_blank" href="http://jboss.org"><img src="#{resource['jboss-community.png']}" alt="JBoss and JBoss Community" width="254" height="31" border="0"/></a>
30-
</p>
31-
<p class="note">To replace this page, edit 'src/main/webapp/index.xhtml', or keep Forging!</p>
59+
<p class="logos">
60+
<a target="_blank" href="http://jboss.org"><img
61+
src="#{resource['jboss-community.png']}"
62+
alt="JBoss and JBoss Community" width="254" height="31" border="0" />
63+
</a>
64+
</p>
65+
<p class="note">To replace this page, edit
66+
'src/main/webapp/index.xhtml', or keep Forging!</p>
3267
</ui:define>
3368

3469
</ui:composition>

0 commit comments

Comments
 (0)