001/** 002 * GRANITE DATA SERVICES 003 * Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S. 004 * 005 * This file is part of the Granite Data Services Platform. 006 * 007 * Granite Data Services is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * Granite Data Services is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 015 * General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 020 * USA, or see <http://www.gnu.org/licenses/>. 021 */ 022package org.granite.config; 023 024import java.util.List; 025 026import org.granite.messaging.amf.io.util.ActionScriptClassDescriptor; 027import org.granite.util.TypeUtil; 028 029/** 030 * @author Franck WOLFF 031 */ 032public class ActionScriptClassDescriptorFactory implements ConfigurableFactory<Class<? extends ActionScriptClassDescriptor>> { 033 034 private static final class NullActionScriptClassDescriptor extends ActionScriptClassDescriptor { 035 public NullActionScriptClassDescriptor(String type, byte encoding) { 036 super(type, encoding); 037 throw new RuntimeException("Not implemented"); 038 } 039 @Override 040 public void defineProperty(String name) { 041 } 042 @Override 043 public Object newJavaInstance() { 044 return null; 045 } 046 } 047 private static final Class<? extends ActionScriptClassDescriptor> NULL_ASC_DESCRIPTOR 048 = NullActionScriptClassDescriptor.class; 049 050 public Class<? extends ActionScriptClassDescriptor> getNullInstance() { 051 return NULL_ASC_DESCRIPTOR; 052 } 053 054 public Class<? extends ActionScriptClassDescriptor> getInstance(String type, GraniteConfig config) throws GraniteConfigException { 055 try { 056 return TypeUtil.forName(type, ActionScriptClassDescriptor.class); 057 } catch (Exception e) { 058 throw new GraniteConfigException("Could not load ActionScriptClassDescriptor type: " + type, e); 059 } 060 } 061 062 public Class<? extends ActionScriptClassDescriptor> getInstanceForBean( 063 List<Class<? extends ActionScriptClassDescriptor>> scannedConfigurables, 064 Class<?> beanClass, 065 GraniteConfig config) throws GraniteConfigException { 066 067 return NULL_ASC_DESCRIPTOR; 068 } 069}