コード例 #1
0
ファイル: Widget.java プロジェクト: lcy03406/amber
 public static void initnames() {
   if (!inited) {
     for (Factory f : dolda.jglob.Loader.get(RName.class).instances(Factory.class)) {
       synchronized (types) {
         types.put(f.getClass().getAnnotation(RName.class).value(), f);
       }
     }
     inited = true;
   }
 }
コード例 #2
0
ファイル: Material.java プロジェクト: puruscor/Purus-Pasta
 static {
   for (Class<?> cl : dolda.jglob.Loader.get(ResName.class).classes()) {
     String nm = cl.getAnnotation(ResName.class).value();
     if (ResCons.class.isAssignableFrom(cl)) {
       final ResCons scons;
       try {
         scons = cl.asSubclass(ResCons.class).newInstance();
       } catch (InstantiationException e) {
         throw (new Error(e));
       } catch (IllegalAccessException e) {
         throw (new Error(e));
       }
       rnames.put(
           nm,
           new ResCons2() {
             public Res.Resolver cons(Resource res, Object... args) {
               final GLState ret = scons.cons(res, args);
               return (new Res.Resolver() {
                 public void resolve(Collection<GLState> buf) {
                   if (ret != null) buf.add(ret);
                 }
               });
             }
           });
     } else if (ResCons2.class.isAssignableFrom(cl)) {
       try {
         rnames.put(nm, cl.asSubclass(ResCons2.class).newInstance());
       } catch (InstantiationException e) {
         throw (new Error(e));
       } catch (IllegalAccessException e) {
         throw (new Error(e));
       }
     } else if (GLState.class.isAssignableFrom(cl)) {
       final Constructor<? extends GLState> cons;
       try {
         cons = cl.asSubclass(GLState.class).getConstructor(Resource.class, Object[].class);
       } catch (NoSuchMethodException e) {
         throw (new Error("No proper constructor for res-consable GL state " + cl.getName(), e));
       }
       rnames.put(
           nm,
           new ResCons2() {
             public Res.Resolver cons(final Resource res, final Object... args) {
               return (new Res.Resolver() {
                 public void resolve(Collection<GLState> buf) {
                   buf.add(Utils.construct(cons, res, args));
                 }
               });
             }
           });
     } else {
       throw (new Error("Illegal material constructor class: " + cl));
     }
   }
 }