Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.spi.ee.openejb » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with this
    4    * work for additional information regarding copyright ownership. The ASF
    5    * licenses this file to You under the Apache License, Version 2.0 (the
    6    * "License"); you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
    9    * or agreed to in writing, software distributed under the License is
   10    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   11    * KIND, either express or implied. See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    */
   14   package org.apache.webbeans.spi.ee.openejb;
   15   
   16   import java.lang.reflect.Field;
   17   
   18   import javax.naming.Context;
   19   
   20   import org.apache.openejb.loader.SystemInstance;
   21   import org.apache.openejb.spi.ContainerSystem;
   22   
   23   public class ResourceFactory
   24   {
   25       private static ResourceFactory factory = null;
   26       
   27       private ResourceInjectionProcessor processor = null;
   28       
   29       private static Context context = null;
   30       
   31       static
   32       {
   33           try
   34           {
   35               context = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
   36               
   37           } catch(Exception e) {
   38              
   39               context = null;
   40           }
   41   
   42       }
   43       
   44       public static ResourceFactory getInstance()
   45       {
   46           if(factory ==  null)
   47           {
   48               factory = new ResourceFactory();
   49               factory.processor = new ResourceInjectionProcessor(context);
   50           }
   51           
   52           return factory;
   53       }
   54       
   55       public Object getResourceObject(Field field) throws RuntimeException
   56       {
   57           try
   58           {
   59               return this.processor.getResourceObject(field);   
   60               
   61           }catch(Exception e)
   62           {
   63               throw new RuntimeException(e);
   64           }
   65       }
   66   
   67   }

Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.spi.ee.openejb » [javadoc | source]