示例#1
0
  private void loadCustomAMF3Serializer(XMap element, boolean custom) {
    XMap amf3Serializer = element.getOne("amf3-serializer");
    if (amf3Serializer != null) {
      String type = amf3Serializer.get("@type");
      try {
        Class<AMF3Serializer> amf3SerializerClass = TypeUtil.forName(type, AMF3Serializer.class);
        amf3SerializerConstructor =
            TypeUtil.getConstructor(amf3SerializerClass, new Class<?>[] {OutputStream.class});
      } catch (Exception e) {
        throw new GraniteConfigException(
            "Could not get constructor for AMF3 serializer: " + type, e);
      }
    }

    XMap amf3Deserializer = element.getOne("amf3-deserializer");
    if (amf3Deserializer != null) {
      String type = amf3Deserializer.get("@type");
      try {
        Class<AMF3Deserializer> amf3DeserializerClass =
            TypeUtil.forName(type, AMF3Deserializer.class);
        amf3DeserializerConstructor =
            TypeUtil.getConstructor(amf3DeserializerClass, new Class<?>[] {InputStream.class});
      } catch (Exception e) {
        throw new GraniteConfigException(
            "Could not get constructor for AMF3 deserializer: " + type, e);
      }
    }
  }
示例#2
0
 private void loadCustomInstantiators(XMap element, boolean custom) {
   XMap instantiators = element.getOne("instantiators");
   if (instantiators != null) {
     for (XMap instantiator : instantiators.getAll("instantiator"))
       this.instantiators.put(instantiator.get("@type"), instantiator.get("."));
   }
 }
示例#3
0
 private void loadCustomMethodMatcher(XMap element, boolean custom) {
   XMap methodMatcher = element.getOne("method-matcher");
   if (methodMatcher != null) {
     String type = methodMatcher.get("@type");
     try {
       this.methodMatcher = (MethodMatcher) TypeUtil.newInstance(type);
     } catch (Exception e) {
       throw new GraniteConfigException("Could not construct method matcher: " + type, e);
     }
   }
 }
示例#4
0
 private void loadCustomMessageSelector(XMap element, boolean custom) {
   XMap selector = element.getOne("message-selector");
   if (selector != null) {
     String type = selector.get("@type");
     try {
       messageSelectorConstructor = TypeUtil.getConstructor(type, new Class<?>[] {String.class});
     } catch (Exception e) {
       throw new GraniteConfigException("Could not construct message selector: " + type, e);
     }
   }
 }
示例#5
0
 private void loadCustomClassGetter(XMap element, boolean custom) {
   XMap classGetter = element.getOne("class-getter");
   if (classGetter != null) {
     String type = classGetter.get("@type");
     try {
       this.classGetter = (ClassGetter) TypeUtil.newInstance(type);
       classGetterSet = true;
     } catch (Exception e) {
       throw new GraniteConfigException("Could not instantiate ClassGetter: " + type, e);
     }
   }
 }
示例#6
0
 private void loadCustomInvocationListener(XMap element, boolean custom) {
   XMap invocationListener = element.getOne("invocation-listener");
   if (invocationListener != null) {
     String type = invocationListener.get("@type");
     try {
       this.invocationListener = (ServiceInvocationListener) TypeUtil.newInstance(type);
     } catch (Exception e) {
       throw new GraniteConfigException(
           "Could not instantiate ServiceInvocationListener: " + type, e);
     }
   }
 }
示例#7
0
 private void loadCustomDistributedDataFactory(XMap element, boolean custom) {
   XMap distributedDataFactory = element.getOne("distributed-data-factory");
   if (distributedDataFactory != null) {
     String type = distributedDataFactory.get("@type");
     try {
       this.distributedDataFactory = (DistributedDataFactory) TypeUtil.newInstance(type);
     } catch (Exception e) {
       throw new GraniteConfigException(
           "Could not construct build distributed data factory: " + type, e);
     }
   }
 }
示例#8
0
 private void loadCustomAMF3MessageInterceptor(XMap element, boolean custom) {
   XMap interceptor = element.getOne("amf3-message-interceptor");
   if (interceptor != null) {
     String type = interceptor.get("@type");
     try {
       amf3MessageInterceptor = (AMF3MessageInterceptor) TypeUtil.newInstance(type);
     } catch (Exception e) {
       throw new GraniteConfigException(
           "Could not construct amf3 message interceptor: " + type, e);
     }
   }
 }
示例#9
0
  private void loadCustomConverters(XMap element, boolean custom) {
    XMap converters = element.getOne("converters");
    if (converters != null) {
      // Should we override standard config converters?
      String override = converters.get("@override");
      if (Boolean.TRUE.toString().equals(override)) converterClasses.clear();

      int i = 0;
      for (XMap converter : converters.getAll("converter")) {
        String type = converter.get("@type");
        try {
          // For custom config, shifts any standard converters to the end of the list...
          converterClasses.add(i++, TypeUtil.forName(type, Converter.class));
        } catch (Exception e) {
          throw new GraniteConfigException("Could not get converter class for: " + type, e);
        }
      }
    }
  }
示例#10
0
 private void loadCustomAMF3DeserializerSecurizer(XMap element, boolean custom) {
   XMap securizer = element.getOne("amf3-deserializer-securizer");
   if (securizer != null) {
     String type = securizer.get("@type");
     try {
       amf3DeserializerSecurizer = (AMF3DeserializerSecurizer) TypeUtil.newInstance(type);
     } catch (Exception e) {
       throw new GraniteConfigException(
           "Could not construct amf3 deserializer securizer: " + type, e);
     }
     String param = securizer.get("@param");
     try {
       amf3DeserializerSecurizer.setParam(param);
     } catch (Exception e) {
       throw new GraniteConfigException(
           "Could not set param of amf3 deserializer securizer: " + type + ", param: " + param, e);
     }
   }
 }
示例#11
0
  private void loadCustomExternalizers(XMap element, boolean custom) {
    externalizersConfiguration = element.getOne("externalizers/configuration");

    for (XMap externalizer : element.getAll("externalizers/externalizer")) {
      String externalizerType = externalizer.get("@type");

      for (XMap include : externalizer.getAll("include")) {
        String type = include.get("@type");
        if (type != null)
          externalizersByType.put(type, EXTERNALIZER_FACTORY.getInstance(externalizerType, this));
        else {
          String instanceOf = include.get("@instance-of");
          if (instanceOf != null) externalizersByInstanceOf.put(instanceOf, externalizerType);
          else {
            String annotatedWith = include.get("@annotated-with");
            if (annotatedWith == null)
              throw new GraniteConfigException(
                  "Element 'include' has no attribute 'type', 'instance-of' or 'annotated-with'");
            externalizersByAnnotatedWith.put(annotatedWith, externalizerType);
          }
        }
      }
    }
  }
示例#12
0
  private void loadCustomSecurity(XMap element, boolean custom) {
    XMap security = element.getOne("security");
    if (security != null) {
      String type = security.get("@type");
      try {
        securityService = (SecurityService) TypeUtil.newInstance(type);
      } catch (Exception e) {
        throw new GraniteConfigException("Could not instantiate SecurityService: " + type, e);
      }

      Map<String, String> params = new HashMap<String, String>();
      for (XMap param : security.getAll("param")) {
        String name = param.get("@name");
        String value = param.get("@value");
        params.put(name, value);
      }
      try {
        securityService.configure(params);
      } catch (Exception e) {
        throw new GraniteConfigException(
            "Could not configure SecurityService " + type + " with: " + params, e);
      }
    }
  }
示例#13
0
 private void loadCustomGravity(XMap element, boolean custom) {
   gravityConfig = element.getOne("gravity");
 }