Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kie.remote.services.jaxb;
  
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
 
 
 import  org.kie.services.client.serialization.JaxbSerializationProvider;
 import  org.kie.services.client.serialization.SerializationException;
 
 public class ServerJaxbSerializationProvider extends JaxbSerializationProvider {
 
     private static Set<Class<?>> SERVER_SIDE_JAXB_CLASS_SET;
     static { 
         Class [] serviceSideClasses = { 
                 JaxbCommandsRequest.class,
                 JaxbCommandsResponse.class,
                 JaxbContentResponse.class,
                 JaxbTaskResponse.class,
                 JaxbTaskSummaryListResponse.class
         };
         List<Class<?>> serverSideJaxbClassList = new ArrayList<Class<?>>();
         forClass clazz : serviceSideClasses ) { 
             serverSideJaxbClassList.add(clazz);
         } 
          = Collections.unmodifiableSet(new HashSet<Class<?>>(serverSideJaxbClassList));
     }
     
     public static Set<Class<?>> getModuleClasses() {
         return ;
     }
     
   // General methods -------------------------------------------------------------------------------------------------------------------
 
     private static Class<?> [] ALL_BASE_JAXB_CLASSES = null;
     static { 
         int kieJaxbClassSetLength = KIE_JAXB_CLASS_SET.size();
         Class<?> [] types = new Class<?> [kieJaxbClassSetLength + PRIMITIVE_ARRAY_CLASS_SET.size()];
         System.arraycopy(KIE_JAXB_CLASS_SET.toArray(new Class<?>[kieJaxbClassSetLength]), 0, types, 0, kieJaxbClassSetLength);
         int primArrClassSetLength = PRIMITIVE_ARRAY_CLASS_SET.size();
         System.arraycopy(PRIMITIVE_ARRAY_CLASS_SET.toArray(new Class<?>[primArrClassSetLength]), 0, typeskieJaxbClassSetLengthprimArrClassSetLength);
          = types;
     }
 
     private Class<?> [] getAllJaxbClasses() { 
         Class<?> [] allBaseJaxbClassArr = getAllBaseJaxbClasses();
         if.isEmpty() ) { 
             return allBaseJaxbClassArr;
         }
         Class<?> [] extraJaxbClassArr = .toArray(new Class<?>[.size()]);
         return addClassArrToClassArr(allBaseJaxbClassArrextraJaxbClassArr);
     }
     
     public static Class<?> [] getAllBaseJaxbClasses() { 
         Set<Class<?>> sideJaxbClassSet = getModuleClasses();
         Class<?> [] sideJaxbClasses = new Class<?>[sideJaxbClassSet.size()];
         sideJaxbClasses = sideJaxbClassSet.toArray(sideJaxbClasses);
         return addClassArrToClassArr(sideJaxbClasses);
     }
 
     private static Class<?> [] addClassArrToClassArr(Class<?> [] baseArrClass<?> [] addArr) { 
         Class<?> [] copy = new Class<?>[baseArr.length + addArr.length];
         System.arraycopy(baseArr, 0, copy, 0, baseArr.length);
         System.arraycopy(addArr, 0, copybaseArr.lengthaddArr.length);
         return copy;
     }
     
     private JAXBContext jaxbContext = null;
     protected Set<Class<?>> extraJaxbClasses = new HashSet<Class<?>>();
 
     public JAXBContext getJaxbContext() { 
         return ;
     }
     
     public static JaxbSerializationProvider newInstance() { 
         ServerJaxbSerializationProvider jaxbSerProvider = new ServerJaxbSerializationProvider();
         jaxbSerProvider.initialize();
         return jaxbSerProvider;
     }
 
     public static JaxbSerializationProvider newInstance(Class<?>... extraJaxbClasses) { 
         ServerJaxbSerializationProvider jaxbSerProvider = new ServerJaxbSerializationProvider(extraJaxbClasses);
         jaxbSerProvider.initialize();
         return jaxbSerProvider;
     }
 
     public static JaxbSerializationProvider newInstance(JAXBContext jaxbContext) { 
         JaxbSerializationProvider jaxbSerProvider = new ServerJaxbSerializationProvider(jaxbContext);
         return jaxbSerProvider;
     }
    
     private void initialize() {
         initialize(getAllJaxbClasses());
    }
    private void initialize(Class<?> [] jaxbClasses) {
        try {
            this. = JAXBContext.newInstance(jaxbClasses);
        } catch (JAXBException jaxbe) {
            throw new SerializationException("Unsupported JAXB Class encountered during initialization: " + jaxbe.getMessage(), jaxbe);
        }
    }
   
    /* (non-Javadoc)
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#dispose()
     */
    @Override
    public void dispose() { 
       ifthis. != null ) { 
           this..clear();
           this. = null;
       }
       ifthis. != null ) { 
           this. = null;
       }
    }
  
    //  Functional methods -------------------------------------------------------------------------------------------------------
    
    /* (non-Javadoc)
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#addJaxbClasses(java.lang.Class)
     */
    @Override
    public void addJaxbClasses(Class... jaxbClass) {
        for (int i = 0; i < jaxbClass.length; ++i) {
            .add(jaxbClass[i]);
        }
    }
    /* (non-Javadoc)
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#addJaxbClassesAndInitialize(java.lang.Class)
     */
    @Override
    public void addJaxbClassesAndReinitialize(Class... jaxbClass) {
        addJaxbClasses(jaxbClass);
        initialize(getAllJaxbClasses());
    }
    /* (non-Javadoc)
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#getExtraJaxbClasses()
     */
    @Override
    public Collection<Class<?>> getExtraJaxbClasses() { 
        return new HashSet<Class<?>>();
    }
   
    // Constructors ---------------------------------------------------------------------------------------------------------------
    private ServerJaxbSerializationProvider() { 
       // default 
    }
    
    public ServerJaxbSerializationProvider(Class<?> [] extraJaxbClassArr) { 
        this..addAll(Arrays.asList(extraJaxbClassArr));
    }
    
    public ServerJaxbSerializationProvider(JAXBContext jaxbContext) { 
        this. = jaxbContext;
     }
New to GrepCode? Check out our FAQ X