예제 #1
0
 public static String name(Configuration configuration) {
   if (configuration instanceof Extension) {
     return ((Extension) configuration).getName();
   }
   return StringUtil.toFriendlyName(configuration.getClass().getName(), "Configuration")
       + " ("
       + configuration.getClass().getPackage().getName()
       + ")";
 }
 private void createConfiguration(OMElement configEle, Configuration config) {
   if (configEle == null) {
     throw new RuntimeException(
         "The configuration element for " + config.getClass().getName() + " is null");
   }
   try {
     for (Iterator<OMElement> iter = configEle.getChildrenWithLocalName("property");
         iter.hasNext(); ) {
       OMElement propEle = iter.next();
       setProperty(config, propEle);
     }
   } catch (Exception e) {
     throw new RuntimeException("Error setting values to " + config.getClass().getName(), e);
   }
 }
예제 #3
0
 private void loadConfigurations() {
   PlugInContext pc = context.createPlugInContext();
   for (Iterator i = configurations.iterator(); i.hasNext(); ) {
     Configuration configuration = (Configuration) i.next();
     monitor.report(LOADING + " " + name(configuration) + " " + version(configuration));
     long start = secondsSince(0);
     try {
       configuration.configure(pc);
       System.out.println(
           "Loading "
               + name(configuration)
               + " "
               + version(configuration)
               + " took "
               + secondsSinceString(start)
               + "s");
     } catch (Throwable e) {
       context.getErrorHandler().handleThrowable(e);
       context
           .getWorkbench()
           .getFrame()
           .log(configuration.getClass().getName() + " " + NOT_INITIALIZED, this.getClass());
     }
   }
 }
예제 #4
0
 // return the RpcEngine configured to handle a protocol
 static synchronized RpcEngine getProtocolEngine(Class<?> protocol, Configuration conf) {
   RpcEngine engine = PROTOCOL_ENGINES.get(protocol);
   if (engine == null) {
     Class<?> impl =
         conf.getClass(ENGINE_PROP + "." + protocol.getName(), WritableRpcEngine.class);
     engine = (RpcEngine) ReflectionUtils.newInstance(impl, conf);
     PROTOCOL_ENGINES.put(protocol, engine);
   }
   return engine;
 }
예제 #5
0
 public void testGetClass() throws IOException {
   out = new BufferedWriter(new FileWriter(CONFIG));
   startConfig();
   appendProperty("test.class1", "java.lang.Integer");
   appendProperty("test.class2", " java.lang.Integer ");
   endConfig();
   Path fileResource = new Path(CONFIG);
   conf.addResource(fileResource);
   assertEquals("java.lang.Integer", conf.getClass("test.class1", null).getCanonicalName());
   assertEquals("java.lang.Integer", conf.getClass("test.class2", null).getCanonicalName());
 }
예제 #6
0
 @Override
 public String toString() {
   Configuration root = getRoot();
   return new StringBuilder()
       .append(getClass().getSimpleName())
       .append("[path='")
       .append(getCurrentPath())
       .append("', root='")
       .append(root == null ? null : root.getClass().getSimpleName())
       .append("']")
       .toString();
 }
예제 #7
0
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();

    builder.append(getClass().getSimpleName());
    builder.append("[path='");
    builder.append(getCurrentPath());
    builder.append("', root='");
    builder.append(root.getClass().getSimpleName());
    builder.append("']");

    return builder.toString();
  }