Source Code Cross Referenced for CopletSource.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » source » 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.source 
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.source;
018:
019:        import java.io.ByteArrayInputStream;
020:        import java.io.ByteArrayOutputStream;
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:
024:        import org.apache.avalon.framework.context.Context;
025:        import org.apache.avalon.framework.context.ContextException;
026:        import org.apache.avalon.framework.context.Contextualizable;
027:        import org.apache.avalon.framework.service.ServiceException;
028:        import org.apache.avalon.framework.service.ServiceManager;
029:        import org.apache.avalon.framework.service.ServiceSelector;
030:        import org.apache.avalon.framework.service.Serviceable;
031:        import org.apache.cocoon.CascadingIOException;
032:        import org.apache.cocoon.components.ContextHelper;
033:        import org.apache.cocoon.portal.coplet.CopletInstanceData;
034:        import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
035:        import org.apache.cocoon.serialization.Serializer;
036:        import org.apache.excalibur.source.Source;
037:        import org.apache.excalibur.source.SourceNotFoundException;
038:        import org.apache.excalibur.source.SourceValidity;
039:        import org.apache.excalibur.xml.sax.XMLizable;
040:        import org.xml.sax.ContentHandler;
041:        import org.xml.sax.SAXException;
042:
043:        /**
044:         * This is the source implementation of the coplet source
045:         * 
046:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
047:         * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
048:         * 
049:         * @version CVS $Id: CopletSource.java 433543 2006-08-22 06:22:54Z crossley $
050:         */
051:        public class CopletSource implements  Source, XMLizable, Serviceable,
052:                Contextualizable {
053:
054:            protected ServiceManager manager;
055:
056:            protected Context context;
057:
058:            protected String uri;
059:            protected String copletControllerName;
060:            protected CopletInstanceData copletInstanceData;
061:
062:            /** The used protocol */
063:            protected String scheme;
064:
065:            /* (non-Javadoc)
066:             * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
067:             */
068:            public void service(ServiceManager manager) throws ServiceException {
069:                this .manager = manager;
070:            }
071:
072:            /* (non-Javadoc)
073:             * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
074:             */
075:            public void contextualize(Context context) throws ContextException {
076:                this .context = context;
077:            }
078:
079:            public CopletSource(String location, String protocol,
080:                    CopletInstanceData coplet) {
081:                this .uri = location;
082:                this .scheme = (protocol == null ? "coplet" : protocol);
083:                this .copletInstanceData = coplet;
084:                this .copletControllerName = this .copletInstanceData
085:                        .getCopletData().getCopletBaseData()
086:                        .getCopletAdapterName();
087:            }
088:
089:            /**
090:             * @see org.apache.excalibur.source.Source#getInputStream()
091:             */
092:            public InputStream getInputStream() throws IOException,
093:                    SourceNotFoundException {
094:                try {
095:                    ServiceManager sitemapManager = (ServiceManager) this .context
096:                            .get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
097:                    ServiceSelector serializerSelector = null;
098:                    Serializer serializer = null;
099:                    try {
100:                        serializerSelector = (ServiceSelector) sitemapManager
101:                                .lookup(Serializer.ROLE + "Selector");
102:                        serializer = (Serializer) serializerSelector
103:                                .select("xml");
104:                        ByteArrayOutputStream os = new ByteArrayOutputStream();
105:                        serializer.setOutputStream(os);
106:                        this .toSAX(serializer);
107:                        return new ByteArrayInputStream(os.toByteArray());
108:                    } catch (SAXException se) {
109:                        throw new CascadingIOException(
110:                                "Unable to stream content.", se);
111:                    } catch (ServiceException ce) {
112:                        throw new CascadingIOException(
113:                                "Unable to get components for serializing.", ce);
114:                    } finally {
115:                        if (serializer != null) {
116:                            serializerSelector.release(serializer);
117:                        }
118:                        sitemapManager.release(serializerSelector);
119:                    }
120:                } catch (ContextException ce) {
121:                    throw new CascadingIOException(
122:                            "Unable to get service manager.", ce);
123:                }
124:            }
125:
126:            /**
127:             * @see org.apache.excalibur.source.Source#getURI()
128:             */
129:            public String getURI() {
130:                return this .uri;
131:            }
132:
133:            /**
134:             * @see org.apache.excalibur.source.Source#getValidity()
135:             */
136:            public SourceValidity getValidity() {
137:                return null;
138:            }
139:
140:            /**
141:             * @see org.apache.excalibur.source.Source#refresh()
142:             */
143:            public void refresh() {
144:                // nothing to do 
145:            }
146:
147:            /**
148:             * @see org.apache.excalibur.source.Source#getMimeType()
149:             */
150:            public String getMimeType() {
151:                return null;
152:            }
153:
154:            /**
155:             * @see org.apache.excalibur.source.Source#getContentLength()
156:             */
157:            public long getContentLength() {
158:                return -1;
159:            }
160:
161:            /**
162:             * @see org.apache.excalibur.source.Source#getLastModified()
163:             */
164:            public long getLastModified() {
165:                return 0;
166:            }
167:
168:            /**
169:             * @see org.apache.excalibur.xml.sax.XMLizable#toSAX(ContentHandler)
170:             */
171:            public void toSAX(ContentHandler handler) throws SAXException {
172:                ServiceSelector copletAdapterSelector = null;
173:                CopletAdapter copletAdapter = null;
174:                try {
175:                    copletAdapterSelector = (ServiceSelector) this .manager
176:                            .lookup(CopletAdapter.ROLE + "Selector");
177:                    copletAdapter = (CopletAdapter) copletAdapterSelector
178:                            .select(this .copletControllerName);
179:
180:                    copletAdapter.toSAX(this .copletInstanceData, handler);
181:                } catch (ServiceException ce) {
182:                    throw new SAXException(
183:                            "Unable to lookup coplet adaptor or adaptor selector.",
184:                            ce);
185:                } finally {
186:                    if (null != copletAdapter) {
187:                        copletAdapterSelector.release(copletAdapter);
188:                    }
189:                    this .manager.release(copletAdapterSelector);
190:                }
191:
192:            }
193:
194:            /**
195:             * @see org.apache.excalibur.source.Source#exists()
196:             */
197:            public boolean exists() {
198:                return true;
199:            }
200:
201:            /**
202:             * @see org.apache.excalibur.source.Source#getScheme()
203:             */
204:            public String getScheme() {
205:                return this.scheme;
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.