public SignalHandlerDefaultWInvoke(Object target, Method method) {
    this.target = target;

    FastClass fastClass =
        FastClass.create(Thread.currentThread().getContextClassLoader(), target.getClass());
    fastMethod = fastClass.getMethod(method);
  }
Ejemplo n.º 2
0
  private Object createServiceInterfaceProxy(
      String serviceInterfaceClassName,
      Map seiPortNameToFactoryMap,
      Map seiClassNameToFactoryMap,
      ClassLoader classLoader)
      throws NamingException {
    boolean initialize = (this.serviceConstructor == null);

    if (initialize) {
      Class serviceInterface;
      try {
        serviceInterface = classLoader.loadClass(serviceInterfaceClassName);
      } catch (ClassNotFoundException e) {
        throw (NamingException)
            new NamingException(
                    "Could not load service interface class " + serviceInterfaceClassName)
                .initCause(e);
      }

      // create method interceptors
      Callback callback = new ServiceMethodInterceptor(seiPortNameToFactoryMap);
      this.methodInterceptors = new Callback[] {NoOp.INSTANCE, callback};

      // create service class
      Enhancer enhancer = new Enhancer();
      enhancer.setClassLoader(classLoader);
      enhancer.setSuperclass(ServiceImpl.class);
      enhancer.setInterfaces(new Class[] {serviceInterface});
      enhancer.setCallbackFilter(new NoOverrideCallbackFilter(Service.class));
      enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class});
      enhancer.setUseFactory(false);
      enhancer.setUseCache(false);
      this.enhancedServiceClass = enhancer.createClass();

      // get constructor
      this.serviceConstructor =
          FastClass.create(this.enhancedServiceClass).getConstructor(SERVICE_CONSTRUCTOR_TYPES);
    }

    // associate the method interceptors with the generated service class on the current thread
    Enhancer.registerCallbacks(this.enhancedServiceClass, this.methodInterceptors);

    Object[] arguments = new Object[] {seiPortNameToFactoryMap, seiClassNameToFactoryMap};

    Object serviceInstance = null;

    try {
      serviceInstance = this.serviceConstructor.newInstance(arguments);
    } catch (InvocationTargetException e) {
      throw (NamingException)
          new NamingException("Could not construct service instance")
              .initCause(e.getTargetException());
    }

    if (initialize) {
      for (Iterator iterator = seiPortNameToFactoryMap.values().iterator(); iterator.hasNext(); ) {
        SeiFactoryImpl seiFactory = (SeiFactoryImpl) iterator.next();
        try {
          seiFactory.initialize(serviceInstance, classLoader);
        } catch (ClassNotFoundException e) {
          throw (NamingException)
              new NamingException("Could not load service interface class; " + e.getMessage())
                  .initCause(e);
        }
      }
    }

    return serviceInstance;
  }
Ejemplo n.º 3
0
 public SimpleFieldAccessor(Field field) {
   this(field, FastClass.create(field.getDeclaringClass()));
 }
Ejemplo n.º 4
0
  RecordDescriptor(Class<? extends Record> clazz) {
    super();
    if (clazz == null) throw new RecordDescriptorCreationExcetption();

    this.recordClass = FastClass.create(clazz);
  }