KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > applications > databeans > ComponentDeliveryContext


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.deliver.applications.databeans;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.infoglue.deliver.applications.actions.InfoGlueComponent;
30
31 /**
32  * @author Mattias Bogeblad
33  *
34  * This class is used to store the context of a page and get and set information that is central to it.
35  * TODO - write more
36  */

37
38 public class ComponentDeliveryContext implements UsageListener
39 {
40     private String JavaDoc componentKey = null;
41     private InfoGlueComponent infoGlueComponent;
42         
43     //This section has control over what contents and sitenodes are used where so the pagecache can be selectively updated.
44
private List JavaDoc usedContents = new ArrayList JavaDoc();
45     private List JavaDoc usedContentVersions = new ArrayList JavaDoc();
46     private List JavaDoc usedSiteNodes = new ArrayList JavaDoc();
47     private List JavaDoc usedSiteNodeVersions = new ArrayList JavaDoc();
48     
49     private DeliveryContext deliveryContext;
50     
51     public static ComponentDeliveryContext getComponentDeliveryContext(DeliveryContext deliveryContext, InfoGlueComponent infoGlueComponent)
52     {
53         return new ComponentDeliveryContext(deliveryContext, infoGlueComponent);
54     }
55     
56     private ComponentDeliveryContext(DeliveryContext deliveryContext, InfoGlueComponent infoGlueComponent)
57     {
58         this.deliveryContext = deliveryContext;
59         this.infoGlueComponent = infoGlueComponent;
60         this.componentKey = this.deliveryContext.getPageKey() + "_" + infoGlueComponent.getId();
61     }
62     
63     public void addUsedContent(String JavaDoc usedContent)
64     {
65         synchronized(usedContents)
66         {
67             this.usedContents.add(usedContent);
68         }
69     }
70
71     public void addUsedSiteNode(String JavaDoc usedSiteNode)
72     {
73         synchronized(usedSiteNodes)
74         {
75             this.usedSiteNodes.add(usedSiteNode);
76         }
77     }
78
79     public void addUsedContentVersion(String JavaDoc usedContentVersion)
80     {
81         synchronized(usedContentVersions)
82         {
83             this.usedContentVersions.add(usedContentVersion);
84         }
85     }
86
87     public void addUsedSiteNodeVersion(String JavaDoc usedSiteNodeVersion)
88     {
89         synchronized(usedSiteNodeVersions)
90         {
91             this.usedSiteNodeVersions.add(usedSiteNodeVersion);
92         }
93     }
94     
95     public String JavaDoc[] getAllUsedEntities()
96     {
97         List JavaDoc list = new ArrayList JavaDoc();
98         synchronized(usedContents)
99         {
100             list.addAll(this.usedContents);
101         }
102         
103         synchronized(usedContentVersions)
104         {
105             list.addAll(this.usedContentVersions);
106         }
107         
108         synchronized(usedSiteNodes)
109         {
110             list.addAll(this.usedSiteNodes);
111         }
112         
113         synchronized(usedSiteNodeVersions)
114         {
115             list.addAll(this.usedSiteNodeVersions);
116         }
117         
118         Object JavaDoc[] array = list.toArray();
119         String JavaDoc[] groups = new String JavaDoc[array.length];
120         for(int i=0; i<array.length; i++)
121             groups[i] = array[i].toString();
122         
123         return groups;
124     }
125     
126     public String JavaDoc getComponentKey()
127     {
128         return componentKey;
129     }
130
131     public String JavaDoc getPageKey()
132     {
133         return this.deliveryContext.getPageKey();
134     }
135 }
136
Popular Tags