001/* 002 * Copyright 2010 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.html; 017 018import org.apache.avalon.framework.service.ServiceException; 019import org.apache.avalon.framework.service.ServiceManager; 020import org.apache.cocoon.xml.XMLConsumer; 021 022import org.ametys.cms.transformation.AbstractEnhancementHandler; 023import org.ametys.cms.transformation.AbstractEnhancementTransformer; 024import org.ametys.cms.transformation.EnhancementHandlersExtensionPoint; 025 026/** 027 * This cocoon transformer use the DocbookEnhancementExtensionPoint to be based upon a serie of EnhancementHandler 028 */ 029public class HTMLEnhancementTransformer extends AbstractEnhancementTransformer 030{ 031 private HTMLEnhancementExtensionPoint _htmlEnhancementExtensionPoint; 032 private EnhancementHandlersExtensionPoint _enhancementHandlersExtensionPoint; 033 034 @Override 035 public void service(ServiceManager smanager) throws ServiceException 036 { 037 super.service(smanager); 038 _htmlEnhancementExtensionPoint = (HTMLEnhancementExtensionPoint) smanager.lookup(HTMLEnhancementExtensionPoint.ROLE); 039 _enhancementHandlersExtensionPoint = (EnhancementHandlersExtensionPoint) smanager.lookup(EnhancementHandlersExtensionPoint.ROLE); 040 } 041 042 @Override 043 public void setConsumer(XMLConsumer consumer) 044 { 045 _contentHandler = consumer; 046 _lexicalHandler = consumer; 047 048 for (String handlerRole : _htmlEnhancementExtensionPoint.getHtml2HTMLHandlers()) 049 { 050 AbstractEnhancementHandler handler = _enhancementHandlersExtensionPoint.getExtension(handlerRole); 051 052 handler.setContentHandler(_contentHandler); 053 _contentHandler = handler; 054 055 handler.setLexicalHandler(_lexicalHandler); 056 _lexicalHandler = handler; 057 } 058 } 059 060}