001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014 package org.apache.tapestry.services.impl;
015
016 import org.apache.tapestry.IRequestCycle;
017 import org.apache.tapestry.asset.AssetFactory;
018 import org.apache.tapestry.markup.MarkupWriterSource;
019 import org.apache.tapestry.services.RequestLocaleManager;
020 import org.apache.tapestry.services.ResponseBuilder;
021 import org.apache.tapestry.services.ResponseContributor;
022 import org.apache.tapestry.web.WebResponse;
023
024 import java.io.IOException;
025
026 /**
027 * Factory that is used if no other has been chosen, handles normal html
028 * responses.
029 *
030 * TODO: Should probably implement this as a hivemind pipeline.
031 *
032 * @author jkuhnert
033 */
034 public class DefaultResponseContributorImpl implements ResponseContributor
035 {
036 protected RequestLocaleManager _localeManager;
037
038 protected MarkupWriterSource _markupWriterSource;
039
040 protected WebResponse _webResponse;
041
042 protected AssetFactory _assetFactory;
043
044 /**
045 * {@inheritDoc}
046 */
047 public ResponseBuilder createBuilder(IRequestCycle cycle)
048 throws IOException
049 {
050 return new DefaultResponseBuilder(cycle, _localeManager, _markupWriterSource,
051 _webResponse, _assetFactory, _webResponse.getNamespace());
052 }
053
054 /**
055 * {@inheritDoc}
056 */
057 public boolean handlesResponse(IRequestCycle cycle)
058 {
059 return true;
060 }
061
062 public void setLocaleManager(RequestLocaleManager localeManager)
063 {
064 _localeManager = localeManager;
065 }
066
067 public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
068 {
069 _markupWriterSource = markupWriterSource;
070 }
071
072 public void setWebResponse(WebResponse webResponse)
073 {
074 _webResponse = webResponse;
075 }
076
077 public void setAssetFactory(AssetFactory factory)
078 {
079 _assetFactory = factory;
080 }
081 }