Source Code Cross Referenced for AbstractContentEventAspect.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » event » aspect » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.portal.event.aspect.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.portal.event.aspect.impl;
018:
019:        import java.util.StringTokenizer;
020:
021:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
022:        import org.apache.avalon.framework.service.ServiceException;
023:        import org.apache.avalon.framework.service.ServiceManager;
024:        import org.apache.avalon.framework.service.Serviceable;
025:        import org.apache.avalon.framework.thread.ThreadSafe;
026:        import org.apache.cocoon.environment.ObjectModelHelper;
027:        import org.apache.cocoon.environment.Request;
028:        import org.apache.cocoon.portal.PortalService;
029:        import org.apache.cocoon.portal.event.Event;
030:        import org.apache.cocoon.portal.event.EventManager;
031:        import org.apache.cocoon.portal.event.aspect.EventAspect;
032:        import org.apache.cocoon.portal.event.aspect.EventAspectContext;
033:        import org.apache.cocoon.portal.layout.Layout;
034:
035:        /**
036:         *
037:         * @author <a href="mailto:juergen.seitz@basf-it-services.com">J&uuml;rgen Seitz</a>
038:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
039:         * 
040:         * @version CVS $Id: AbstractContentEventAspect.java 433543 2006-08-22 06:22:54Z crossley $
041:         */
042:        public abstract class AbstractContentEventAspect extends
043:                AbstractLogEnabled implements  EventAspect, ThreadSafe,
044:                Serviceable {
045:
046:            protected ServiceManager manager;
047:
048:            /* (non-Javadoc)
049:             * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
050:             */
051:            public void service(ServiceManager manager) throws ServiceException {
052:                this .manager = manager;
053:            }
054:
055:            protected abstract String getRequestParameterName();
056:
057:            protected abstract int getRequiredValueCount();
058:
059:            /**
060:             * Custom publishing of an event.
061:             * The real values for the event are contained in the array
062:             * starting with index 2!
063:             * @param layout  The corresponding layout
064:             * @param values  The values contained in the request
065:             */
066:            protected abstract void publish(EventManager publisher,
067:                    Layout layout, String[] values);
068:
069:            /**
070:             * Publish the event.
071:             * This method gets the layout object from the first two
072:             * values and invokes {@link #publish(EventManager, Layout, String[])}.
073:             * @param values The values contained in the request
074:             */
075:            protected void publish(PortalService service,
076:                    EventManager publisher, String[] values) {
077:                Layout layout = service.getComponentManager()
078:                        .getProfileManager().getPortalLayout(values[0],
079:                                values[1]);
080:                if (layout != null) {
081:                    this .publish(publisher, layout, values);
082:                }
083:            }
084:
085:            /* (non-Javadoc)
086:             * @see org.apache.cocoon.portal.event.aspect.EventAspect#process(org.apache.cocoon.portal.event.aspect.EventAspectContext, org.apache.cocoon.portal.PortalService)
087:             */
088:            public void process(EventAspectContext context,
089:                    PortalService service) {
090:                final Request request = ObjectModelHelper.getRequest(context
091:                        .getObjectModel());
092:                String[] values = request.getParameterValues(this 
093:                        .getRequestParameterName());
094:                if (values != null) {
095:                    final EventManager publisher = service
096:                            .getComponentManager().getEventManager();
097:                    for (int i = 0; i < values.length; i++) {
098:                        // first try to make an event out of the value of the parameter
099:                        final String value = values[i];
100:                        Event e = null;
101:                        try {
102:                            e = context.getEventConverter().decode(value);
103:                            if (null != e) {
104:                                publisher.send(e);
105:                            }
106:                        } catch (Exception ignore) {
107:                            // ignroe it
108:                        }
109:                        // the event could not be generated, so try different approach
110:                        if (e == null) {
111:                            // Use '|' character as delimiter between Group, ID and URI
112:                            StringTokenizer tokenizer = new StringTokenizer(
113:                                    value, "|");
114:                            int tokenNumber = 0;
115:                            int tokenCount = tokenizer.countTokens();
116:                            // if only 2 params are in the String
117:                            // the groupKey is missing and defaults to null
118:                            if (tokenCount == this .getRequiredValueCount() - 1) {
119:                                tokenNumber = tokenNumber + 1;
120:                                tokenCount++;
121:                            }
122:
123:                            if (tokenCount == this .getRequiredValueCount()) {
124:                                String[] eventValues = new String[tokenCount];
125:
126:                                while (tokenizer.hasMoreTokens()) {
127:                                    eventValues[tokenNumber] = tokenizer
128:                                            .nextToken();
129:
130:                                    tokenNumber = tokenNumber + 1;
131:                                }
132:
133:                                this .publish(service, publisher, eventValues);
134:
135:                            } else {
136:                                this .getLogger().warn(
137:                                        "Data for Event is not set correctly");
138:                            }
139:                        }
140:                    }
141:                }
142:                // and invoke next one
143:                context.invokeNext(service);
144:            }
145:
146:        }
w_w_w__.j__a__va2s_.__c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.