001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License version 2
011: * as published by the Free Software Foundation.
012: *
013: * Resin Open Source is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
016: * of NON-INFRINGEMENT. See the GNU General Public License for more
017: * details.
018: *
019: * You should have received a copy of the GNU General Public License
020: * along with Resin Open Source; if not, write to the
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.jsf.cfg;
030:
031: import com.caucho.config.types.DescriptionGroupConfig;
032: import com.caucho.config.program.ConfigProgram;
033: import java.util.*;
034:
035: import javax.annotation.*;
036:
037: import javax.el.*;
038:
039: import javax.faces.*;
040: import javax.faces.application.*;
041: import javax.faces.component.*;
042: import javax.faces.component.html.*;
043: import javax.faces.context.*;
044: import javax.faces.convert.*;
045: import javax.faces.el.*;
046: import javax.faces.event.*;
047: import javax.faces.render.*;
048: import javax.faces.validator.*;
049:
050: import javax.xml.bind.annotation.*;
051:
052: import com.caucho.config.*;
053: import com.caucho.config.j2ee.*;
054: import com.caucho.jsf.el.*;
055: import com.caucho.util.*;
056:
057: public class ConverterConfig extends DescriptionGroupConfig {
058: private static final L10N L = new L10N(ConverterConfig.class);
059:
060: private String _name;
061: private Class _forClass;
062: private Class _class;
063:
064: public void setName(String name) {
065: _name = name;
066: }
067:
068: public void setConverterId(String name) {
069: setName(name);
070: }
071:
072: public void setForClass(Class forClass) {
073: _forClass = forClass;
074: }
075:
076: public void setConverterForClass(Class forClass) {
077: setForClass(forClass);
078: }
079:
080: public void setClass(Class cl) {
081: Config.validate(cl, Converter.class);
082:
083: _class = cl;
084: }
085:
086: public void setConverterClass(Class cl) {
087: setClass(cl);
088: }
089:
090: public void addAttribute(AttributeConfig attribute)
091: throws ConfigException {
092: }
093:
094: public void addProperty(PropertyConfig property)
095: throws ConfigException {
096: }
097:
098: public void setConverterExtension(ConfigProgram program)
099: throws ConfigException {
100: }
101:
102: public void configure(Application app) {
103: if (_forClass != null)
104: app.addConverter(_forClass, _class.getName());
105: else if (_name != null)
106: app.addConverter(_name, _class.getName());
107: }
108: }
|