1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.ajax;
1819import java.io.Reader;
20import java.io.Writer;
2122import org.apache.velocity.app.VelocityEngine;
23import org.apache.velocity.context.Context;
2425/***26 * Response object used for AJAX services.27 * 28 * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>29 *30 */31publicclassAJAXResponseImpl implements AJAXResponse
32 {
3334private Context context;
35private VelocityEngine engine;
36private Reader template;
37private Writer output;
3839publicAJAXResponseImpl(Context context, VelocityEngine engine, Reader template, Writer output)
40 {
41this.context = context;
42this.engine = engine;
43this.template = template;
44this.output = output;
45 }
4647/* (non-Javadoc)48 * @see org.apache.jetspeed.ajax.AJAXResponse#complete()49 */50publicvoid complete() throws AJAXException
51 {
52try53 {
54 engine.evaluate(context, output, "AJAX processor", template);
55 }
56catch (Exception e)
57 {
58thrownew AJAXException("Failed to render velocity xml template: "+e.getMessage(), e);
59 }
6061 }
62636465 }