private static SyndicateFileSystem createHSyndicateFS(Configuration conf, String address)
     throws IOException {
   SyndicateFSConfiguration sconf = HSyndicateConfigUtils.createSyndicateConf(conf, address);
   try {
     return new SyndicateFileSystem(sconf);
   } catch (InstantiationException ex) {
     throw new IOException(ex.getCause());
   }
 }
 public SystemUser load(String id, boolean isCreate) {
   if (id == null) {
     try {
       if (isCreate) return (SystemUser) SystemUser.class.newInstance();
       else return null;
     } catch (InstantiationException e) {
       throw new RuntimeException(e.getCause());
     } catch (IllegalAccessException e) {
       throw new RuntimeException(e.getCause());
     }
   }
   return systemUserDao.load(id);
 }
Ejemplo n.º 3
0
 /**
  * Constructs a new MaterialData relevant for this Material, with the given initial data
  *
  * @param raw Initial data to construct the MaterialData with
  * @return New MaterialData with the given data
  */
 public MaterialData getNewData(final byte raw) {
   try {
     return ctor.newInstance(id, raw);
   } catch (InstantiationException ex) {
     final Throwable t = ex.getCause();
     if (t instanceof RuntimeException) {
       throw (RuntimeException) t;
     }
     if (t instanceof Error) {
       throw (Error) t;
     }
     throw new AssertionError(t);
   } catch (Throwable t) {
     throw new AssertionError(t);
   }
 }
Ejemplo n.º 4
0
      public Object createProxy() {
        final SimpleInterceptorFactoryContext factoryContext =
            new SimpleInterceptorFactoryContext();
        factoryContext.getContextData().put(Component.class, component);
        factoryContext.getContextData().put(ComponentView.class, View.this);
        factoryContext.getContextData().put(ComponentViewInstance.class, this);

        final Map<Method, InterceptorFactory> clientInterceptorFactories =
            ViewService.this.clientInterceptorFactories;
        final Map<Method, Interceptor> clientEntryPoints =
            new IdentityHashMap<Method, Interceptor>(clientInterceptorFactories.size());
        for (Method method : clientInterceptorFactories.keySet()) {
          clientEntryPoints.put(
              method, clientInterceptorFactories.get(method).create(factoryContext));
        }
        final Interceptor postConstructInterceptor = clientPostConstruct.create(factoryContext);
        try {
          Object object =
              proxyFactory.newInstance(
                  new ProxyInvocationHandler(clientEntryPoints, component, View.this, this));
          InterceptorContext interceptorContext = new InterceptorContext();
          interceptorContext.putPrivateData(ComponentView.class, View.this);
          interceptorContext.putPrivateData(ComponentViewInstance.class, this);
          interceptorContext.putPrivateData(Component.class, component);
          try {
            postConstructInterceptor.processInvocation(interceptorContext);
          } catch (Exception e) {
            InstantiationException exception =
                new InstantiationException("Post-construct lifecycle failed");
            exception.initCause(e);
            throw exception;
          }
          return object;
        } catch (InstantiationException e) {
          InstantiationError error = new InstantiationError(e.getMessage());
          Throwable cause = e.getCause();
          if (cause != null) error.initCause(cause);
          throw error;
        } catch (IllegalAccessException e) {
          IllegalAccessError error = new IllegalAccessError(e.getMessage());
          Throwable cause = e.getCause();
          if (cause != null) error.initCause(cause);
          throw error;
        }
      }
Ejemplo n.º 5
0
 public Object newInstance(Class<?> clazz) {
   try {
     Constructor<?> ctr = clazz.getConstructor(argClasses);
     return ctr.newInstance(args);
   } catch (NoSuchMethodException e) {
     throw new InjectorException(
         "Could not create a new instance of class '" + clazz.getCanonicalName() + "'",
         e.getCause());
   } catch (InvocationTargetException e) {
     throw new InjectorException(
         "Could not create a new instance of class '" + clazz.getCanonicalName() + "'",
         e.getCause());
   } catch (InstantiationException e) {
     throw new InjectorException(
         "Could not create a new instance of class '" + clazz.getCanonicalName() + "'",
         e.getCause());
   } catch (IllegalAccessException e) {
     throw new InjectorException(
         "Could not create a new instance of class '" + clazz.getCanonicalName() + "'",
         e.getCause());
   }
 }
Ejemplo n.º 6
0
  // -----------------------------------------------------------------------------
  @Override
  public SerializableDO deserializeXML(String p_serialized_object) throws CoreException {

    SerializableDO l_dto = null;
    Element l_elem = null;
    XMLParser l_parser = null;
    DOFactory._DOMetaData l_do_md = null;
    String l_c_name = null;

    try {
      l_parser = XMLParserFactory.getParser(true);
      l_parser.parse(p_serialized_object);

      l_elem = l_parser.getDocumentElement();
      l_c_name = l_elem.getAttribute("name");
      if ((l_c_name == null) || l_c_name.isEmpty()) {
        l_c_name = getNodeNameNS(l_elem); // CHANGEV
        l_do_md = DOFactory.getDOMetaDataByName(l_c_name);
        if (l_do_md == null) {
          throw new CoreException(); // No registered object found for node name.
        }
        l_dto = l_do_md.classRef.newInstance();
      } else {
        l_dto = (SerializableDO) Class.forName(l_c_name).newInstance();
        l_do_md = DOFactory.getDOMetaDataByClassName(l_c_name);
        if (l_do_md == null) {
          l_do_md = DOFactory.registerDO(l_dto);
        }
      }
      unmarshall(l_do_md.classRef, l_dto, l_parser.getDocumentElement(), l_parser);
    } catch (InstantiationException e) {
      throw new CoreException(e.getCause());
    } catch (CoreException e) {
      throw e;
    } catch (Exception e) {
      throw new CoreException(e);
    }
    return l_dto;
  }