示例#1
0
 protected void addToScope(Scriptable scope) {
   Object value = exportingBundle.lookup(name);
   StringTokenizer tokenizer = new StringTokenizer(name, "."); // $NON-NLS-1$
   while (true) {
     String token = tokenizer.nextToken();
     Object current = scope.get(token, scope);
     if (!tokenizer.hasMoreTokens()) {
       if (current == Scriptable.NOT_FOUND) {
         if (value instanceof NativeObject) {
           Scriptable wrapped = Context.getCurrentContext().newObject(scope);
           wrapped.setPrototype((Scriptable) value);
           value = wrapped;
         }
         scope.put(token, scope, value);
         return;
       }
       throw new IllegalStateException(
           "Resolve error: "
               + name
               + " already exists for "
               + this.toString()); // $NON-NLS-1$//$NON-NLS-2$	
     }
     if (current == Scriptable.NOT_FOUND) {
       current = ScriptableObject.getProperty(scope, token);
       if (current == Scriptable.NOT_FOUND) current = Context.getCurrentContext().newObject(scope);
       else if (current instanceof NativeObject) {
         // we need to wrap this object from the prototype
         Scriptable wrapped = Context.getCurrentContext().newObject(scope);
         wrapped.setPrototype((Scriptable) current);
         current = wrapped;
       } else
         throw new IllegalStateException(
             "Resolve error: "
                 + name
                 + "-"
                 + token
                 + " already exists for "
                 + this.toString()); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
       scope.put(token, scope, current);
     }
     scope = (Scriptable) current;
   }
 }
示例#2
0
 public int getBundleId() {
   return exportingBundle.getBundleId();
 }
示例#3
0
 public Version getBundleVersion() {
   return exportingBundle.getVersion();
 }
示例#4
0
 public String getBundleSymbolicName() {
   return exportingBundle.getSymbolicName();
 }