1 package org.exoplatform.services.xml.querying.impl.xtas.object; 2 import org.exoplatform.services.xml.querying.object.MarshallerCreateException; 3 4 11 public class ObjectMarshallerFactory { 12 13 static { 14 System.setProperty("xtas.marshaller.internal", "org.exoplatform.services.xml.querying.impl.xtas.object.plugins.CastorClassMarshaller"); 15 System.setProperty("xtas.marshaller.custom", "org.exoplatform.services.xml.querying.impl.xtas.object.plugins.CastorMappedMarshaller"); 16 } 17 18 20 21 22 24 25 26 public static ObjectMarshallerFactory getInstance() 27 { 28 return new ObjectMarshallerFactory(); 29 } 30 31 38 public ObjectMarshaller getMarshaller( int mappingType ) throws MarshallerCreateException 39 { 40 String implProperty; 41 42 if( mappingType == MappingType.CUSTOM ) 43 implProperty = "xtas.marshaller.custom"; 44 else if ( mappingType == MappingType.INTERNAL ) 45 implProperty = "xtas.marshaller.internal"; 46 else 47 throw new MarshallerCreateException("Mapping Type is invalid! "); 48 49 try { 50 51 ObjectMarshaller impl = (ObjectMarshaller)Class.forName( System.getProperty( implProperty ) ).newInstance(); 52 return impl; 53 54 } catch (Exception e) { 55 throw new MarshallerCreateException(e.getMessage()); 57 } 58 } 59 60 } 61 | Popular Tags |