Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 International Business Machines Corp.
   * 
   * See the NOTICE file distributed with this work for additional information
   * regarding copyright ownership. Licensed under the Apache License, 
   * Version 2.0 (the "License"); you may not use this file except in compliance
   * with the License. You may obtain a copy of the License at
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 */
 package com.ibm.jbatch.container.artifact.proxy;
 
 
 
 /*
  * Introduce a level of indirection so proxies are not instantiated directly by newing them up.
  */
 public class ProxyFactory {
 
     protected static ServicesManager servicesManager = ServicesManagerImpl.getInstance();
 
     
 
     protected static Object loadArtifact(String idInjectionReferences injectionReferences) {
         .set(injectionReferences);
         
         Object loadedArtifact = null;
         try {
             loadedArtifact = .load(id);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
         return loadedArtifact;
     }
     
     public static InjectionReferences getInjectionReferences() {
         return .get();
     }
     
     /*
      * Decider
      */
     public static DeciderProxy createDeciderProxy(String idInjectionReferences injectionRefsthrows ArtifactValidationException {
         Decider loadedArtifact = (Decider)loadArtifact(idinjectionRefs);
         DeciderProxy proxy = new DeciderProxy(loadedArtifact);
 
         return proxy;
     }
 
     /*
      * Batchlet artifact
      */
     public static BatchletProxy createBatchletProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
         Batchlet loadedArtifact = (Batchlet)loadArtifact(idinjectionRefs);
         BatchletProxy proxy = new BatchletProxy(loadedArtifact);
         proxy.setStepContext(stepContext);
         
         return proxy;
     }
     
     /*
      * The four main chunk-related artifacts
      */    
     
         CheckpointAlgorithm loadedArtifact = (CheckpointAlgorithm)loadArtifact(idinjectionRefs);
         CheckpointAlgorithmProxy proxy = new CheckpointAlgorithmProxy(loadedArtifact);
         proxy.setStepContext(stepContext);
         
         return proxy;
     }
     
     public static ItemReaderProxy createItemReaderProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
         ItemReader loadedArtifact = (ItemReader)loadArtifact(idinjectionRefs);
         ItemReaderProxy proxy = new ItemReaderProxy(loadedArtifact);
         proxy.setStepContext(stepContext);
        
        return proxy;
    }
    
    public static ItemProcessorProxy createItemProcessorProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
        ItemProcessor loadedArtifact = (ItemProcessor)loadArtifact(idinjectionRefs);
        ItemProcessorProxy proxy = new ItemProcessorProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        
        return proxy;
    }
    
    public static ItemWriterProxy createItemWriterProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
        ItemWriter loadedArtifact = (ItemWriter)loadArtifact(idinjectionRefs);
        ItemWriterProxy proxy = new ItemWriterProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        
        return proxy;
    }
        
    /*
     * The four partition-related artifacts
     */
    
    public static PartitionReducerProxy createPartitionReducerProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
        PartitionReducer loadedArtifact = (PartitionReducer)loadArtifact(idinjectionRefs);
        PartitionReducerProxy proxy = new PartitionReducerProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        return proxy;
    }
    
    public static PartitionMapperProxy createPartitionMapperProxy(String idInjectionReferences injectionRefsStepContextImpl stepContextthrows ArtifactValidationException {
        PartitionMapper loadedArtifact = (PartitionMapper)loadArtifact(idinjectionRefs);
        PartitionMapperProxy proxy = new PartitionMapperProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        return proxy;
    }
    
        PartitionAnalyzer loadedArtifact = (PartitionAnalyzer)loadArtifact(idinjectionRefs);
        PartitionAnalyzerProxy proxy = new PartitionAnalyzerProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        return proxy;
    }
    
        PartitionCollector loadedArtifact = (PartitionCollector)loadArtifact(idinjectionRefs);
        PartitionCollectorProxy proxy = new PartitionCollectorProxy(loadedArtifact);
        proxy.setStepContext(stepContext);
        return proxy;
    }
New to GrepCode? Check out our FAQ X