Пример #1
0
 public static Connection getConnection(Connection c) throws Exception {
   Connection conn = c;
   if (c != null && !c.isClosed()) {
     return c;
   } else {
     Class clazz = Class.forName("org.luciddb.jdbc.LucidDbLocalDriver");
     LucidDbLocalDriver driver = (LucidDbLocalDriver) clazz.newInstance();
     String urlPrefix = driver.getUrlPrefix();
     Properties props = new Properties();
     props.setProperty("user", "sa");
     props.setProperty("password", "");
     props.setProperty("requireExistingEngine", "true");
     c = DriverManager.getConnection(urlPrefix, props);
   }
   return c;
 }
Пример #2
0
 /**
  * This method provides a readable classname if it's an array, i.e. either the classname of the
  * component type for arrays of java reference types or the name of the primitive type for arrays
  * of java primitive types. Otherwise, it returns null.
  */
 public static String getArrayClassName(String name) {
   String className = null;
   if (name.startsWith("[")) {
     int index = name.lastIndexOf("[");
     className = name.substring(index, name.length());
     if (className.startsWith("[L")) {
       className = className.substring(2, className.length() - 1);
     } else {
       try {
         Class<?> c = Class.forName(className);
         className = c.getComponentType().getName();
       } catch (ClassNotFoundException e) {
         // Should not happen
         throw new IllegalArgumentException("Bad class name " + name, e);
       }
     }
   }
   return className;
 }
  private Object unmarshall(Object value) {
    if (value instanceof ObjectName) {
      ObjectName name = (ObjectName) value;

      return new MBean(_server, name);
    } else if (value instanceof ObjectName[]) {
      ObjectName[] names = (ObjectName[]) value;

      MBean[] mbeans = new MBean[names.length];

      for (int i = 0; i < names.length; i++) mbeans[i] = new MBean(_server, names[i]);

      return mbeans;
    } else if (value instanceof CompositeData) {
      CompositeData compositeValue = (CompositeData) value;

      CompositeType type = compositeValue.getCompositeType();

      if (type != null) {
        String typeName = type.getTypeName();

        try {
          ClassLoader loader = Thread.currentThread().getContextClassLoader();

          Class typeClass = Class.forName(typeName, false, loader);

          Method from = typeClass.getMethod("from", new Class[] {CompositeData.class});

          if (from != null) return from.invoke(null, compositeValue);
        } catch (Exception e) {
          log.log(Level.FINER, e.toString(), e);
        }
      }

      return new CompositeDataBean(compositeValue);
    } else return value;
  }
Пример #4
0
 /**
  * This method returns the class matching the name className. It's used to cater for the primitive
  * types.
  */
 public static Class<?> getClass(String className) throws ClassNotFoundException {
   Class<?> c;
   if ((c = primitiveMap.get(className)) != null) return c;
   return Class.forName(className);
 }