Exemple #1
1
  DecodeThread(
      CaptureActivity activity,
      Vector<BarcodeFormat> decodeFormats,
      String characterSet,
      ResultPointCallback resultPointCallback) {

    this.activity = activity;
    handlerInitLatch = new CountDownLatch(1);

    hints = new Hashtable<DecodeHintType, Object>(3);

    if (decodeFormats == null || decodeFormats.isEmpty()) {
      decodeFormats = new Vector<BarcodeFormat>();
      decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

    if (characterSet != null) {
      hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
  }
 private Context getInitialContext() {
   Hashtable<String, String> env = new Hashtable<String, String>();
   try {
     env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
     env.put(Context.SECURITY_PRINCIPAL, securityPrincipal);
     env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
     env.put(Context.PROVIDER_URL, providerUrl);
     env.put(Context.SECURITY_AUTHENTICATION, "none");
     return new InitialContext(env);
   } catch (Exception x) {
     fail(
         "An exception occurred while attempting to get the InitialContext with settings ["
             + Context.INITIAL_CONTEXT_FACTORY
             + ":"
             + initialContextFactory
             + ", "
             + Context.SECURITY_PRINCIPAL
             + ":"
             + securityPrincipal
             + ", "
             + Context.SECURITY_CREDENTIALS
             + ":"
             + securityCredentials
             + ", "
             + Context.PROVIDER_URL
             + ":"
             + providerUrl
             + "]: "
             + x);
   }
   return null;
 }
  /**
   * Adds the given permission to this <tt>UserAdminPermissionCollection</tt>. The key for the hash
   * is the name.
   *
   * @param permission the <tt>Permission</tt> object to add.
   * @throws IllegalArgumentException If the given permission is not a <tt>UserAdminPermission</tt>
   * @throws SecurityException If this <tt>UserAdminPermissionCollection</tt> object has been marked
   *     readonly
   */
  public void add(Permission permission) {
    if (!(permission instanceof UserAdminPermission))
      throw new IllegalArgumentException("Invalid permission: " + permission);
    if (isReadOnly()) {
      throw new SecurityException(
          "Attempt to add a Permission to a " + "readonly PermissionCollection");
    }

    UserAdminPermission uap = (UserAdminPermission) permission;
    String name = uap.getName();

    UserAdminPermission existing = (UserAdminPermission) permissions.get(name);

    if (existing != null) {
      int oldMask = existing.getMask();
      int newMask = uap.getMask();
      if (oldMask != newMask) {
        permissions.put(name, new UserAdminPermission(name, oldMask | newMask));
      }
    } else {
      permissions.put(name, permission);
    }

    if (!all_allowed) {
      if (name.equals("*")) all_allowed = true;
    }
  }
  /**
   * To retrieve the current image index that is currently animating and then updating the current
   * to the next image
   *
   * @param id
   */
  public void changeCurrIndex(Integer id) {
    // gives the animation name give the entity id
    String animation = mCurrentAnimation.get(id);
    // gets  the actual array assoc with the name
    CircularArray<Texture2> arr = mReelsNameAssoc.get(animation);

    // checks if the key is in the hash table
    if (mUpdateCurrAni.containsKey(id)) {
      int imgIndex = mUpdateCurrAni.get(id); // Retrieve the last draw's image index

      mUpdateCurrAni.remove(id); // remove it

      if (imgIndex < arr.size() - 1) { // check if the current index is still within bound

        imgIndex++; // increment the index

        mUpdateCurrAni.put(id, imgIndex); //  put next index in
      } else {

        imgIndex = 0; // when we are at the last index wrap back to the beginning
      }

    } else {
      // else is it not in the table we add with the index being 0
      mUpdateCurrAni.put(id, 0);
    }
  }
Exemple #5
0
  public static Bitmap bitmap(@Nonnull final String content, final int size) {
    try {
      final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
      hints.put(EncodeHintType.MARGIN, 0);
      hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
      final BitMatrix result =
          QR_CODE_WRITER.encode(content, BarcodeFormat.QR_CODE, size, size, hints);

      final int width = result.getWidth();
      final int height = result.getHeight();
      final int[] pixels = new int[width * height];

      for (int y = 0; y < height; y++) {
        final int offset = y * width;
        for (int x = 0; x < width; x++) {
          pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
        }
      }

      final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
      return bitmap;
    } catch (final WriterException x) {
      log.info("problem creating qr code", x);
      return null;
    }
  }
 static {
   _methods.put("getOperandoEsquerdo", new java.lang.Integer(0));
   _methods.put("getOperandoDireito", new java.lang.Integer(1));
   _methods.put("getTrechoCodigoFonteOperador", new java.lang.Integer(2));
   _methods.put("getTrechoCodigoFonte", new java.lang.Integer(3));
   _methods.put("aceitar", new java.lang.Integer(4));
 }
Exemple #7
0
  public void insert(int element) {
    int parentindex, tempIndex;
    int temp;
    lastindex += 1;
    heap[lastindex] = element;

    hash.put(element, lastindex);

    tempIndex = lastindex;

    while (tempIndex != 0) {
      parentindex = (tempIndex - 1) / 2;
      if (heap[tempIndex] > heap[parentindex]) {
        temp = heap[parentindex];
        hash.remove(heap[tempIndex]);
        hash.put(heap[tempIndex], parentindex);
        hash.remove(temp);
        hash.put(temp, tempIndex);
        heap[parentindex] = heap[tempIndex];
        heap[tempIndex] = temp;
        tempIndex = parentindex;
      } else {
        tempIndex = 0;
      }
    }
  }
Exemple #8
0
  public void putHsLayout(int id) {
    Hashtable hs = sshare.userInfo();
    if (hs == null) return;
    String key, name;
    JComponent obj;
    PushpinIF pobj;

    for (int i = 0; i < keys.size(); i++) {
      key = (String) keys.get(i);
      obj = (JComponent) panes.get(key);
      if (obj != null && (obj instanceof PushpinIF)) {
        pobj = (PushpinIF) obj;
        name = "tabTool." + id + "." + pobj.getName() + ".";
        hs.put(name + "refY", new Float(pobj.getRefY()));
        hs.put(name + "refX", new Float(pobj.getRefX()));
        hs.put(name + "refH", new Float(pobj.getRefH()));
        key = "open";
        if (pobj.isHide()) key = "hide";
        else if (pobj.isClose()) key = "close";
        hs.put(name + "status", key);
      }
    }
    /*
    name = "tabTool."+id+".TabPanel.";
    key = pinPanel.getLastName();
    if (key != null)
       hs.put(name+"lastName", key);
    key = "open";
    if (pinPanel.isHide())
       key = "hide";
    else if (pinPanel.isClose())
       key = "close";
    hs.put(name+"status", key);
     */
  }
 /**
  * Method to create a new TE LSP initiated in this node
  *
  * @param destinationId IP AddreStart LSP Errorss of the destination of the LSP
  * @param bw Bandwidth requested
  * @param bidirectional bidirectional
  * @param OFcode
  * @throws LSPCreationException
  */
 public long addnewLSP(
     Inet4Address destinationId, float bw, boolean bidirectional, int OFcode, int lspID)
     throws LSPCreationException {
   log.info("Adding New LSP to " + destinationId);
   // FIXME: mirar esto
   // meter structura --> RequestedLSPinformation --> Dependiente de cada tecnologia
   // meter campo con el estado del LSP e ir cambiandolo
   LSPTE lsp =
       new LSPTE(
           lspID,
           localIP,
           destinationId,
           bidirectional,
           OFcode,
           bw,
           PathStateParameters.creatingLPS);
   LSPList.put(new LSPKey(localIP, lsp.getIdLSP()), lsp);
   ReentrantLock lock = new ReentrantLock();
   Condition lspEstablished = lock.newCondition();
   // log.info("Metemos en Lock list con ID: "+lsp.getIdLSP());
   lockList.put(lsp.getIdLSP(), lock);
   conditionList.put(lsp.getIdLSP(), lspEstablished);
   /*log.info("Size lockList : "+lockList.size());
   log.info("Size conditionList : "+conditionList.size());*/
   timeIni = System.nanoTime();
   log.info("Start to establish path: " + System.nanoTime());
   try {
     startLSP(lsp);
   } catch (LSPCreationException e) {
     log.info("Start LSP Error!");
     throw e;
   }
   return lsp.getIdLSP();
 }
 /** INTERNAL: Add TIMESTAMP, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE */
 protected Hashtable buildClassTypes() {
   Hashtable classTypeMapping = super.buildClassTypes();
   classTypeMapping.put("TIMESTAMP", oracle.sql.TIMESTAMP.class);
   classTypeMapping.put("TIMESTAMP WITH TIME ZONE", oracle.sql.TIMESTAMPTZ.class);
   classTypeMapping.put("TIMESTAMP WITH LOCAL TIME ZONE", oracle.sql.TIMESTAMPLTZ.class);
   return classTypeMapping;
 }
Exemple #11
0
  public static void main(String[] args) throws Exception {
    Hashtable<String, String> ht = new Hashtable<String, String>();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");

    Context c = new InitialContext(ht);
    System.out.println("starting lookup and invocation");
    Object obj = c.lookup("silly#beans/Silly");
    System.out.println("found: " + obj);
    Silly silly = (Silly) obj;
    silly.someMethod();
    System.out.println("done!");

    silly.queryDatabase();
    System.out.println("done querying database!");

    System.out.println(silly.queryForAuction(1));
    System.out.println(silly.queryForAuction(222));

    // sample to trigger ERROR
    // System.out.println(silly.queryForAuctionUsingSingleResult(222));

    // Running it via ACC within the container
    /*silly.someMethod();
    System.out.println("done!");*/
  }
  public boolean authenticate(String user, String pass) {
    String returnedAtts[] = {"sn", "givenName", "mail"};
    String searchFilter = "(&(objectClass=user)(sAMAccountName=" + user + "))";

    // Create the search controls
    SearchControls searchCtls = new SearchControls();
    searchCtls.setReturningAttributes(returnedAtts);

    // Specify the search scope
    searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, ldapHost);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, user + "@" + domain);
    env.put(Context.SECURITY_CREDENTIALS, pass);

    LdapContext ctxGC = null;

    try {
      ctxGC = new InitialLdapContext(env, null);
      // Search objects in GC using filters
      NamingEnumeration answer = ctxGC.search(searchBase, searchFilter, searchCtls);
    } catch (NamingException ex) {
      // ex.printStackTrace();
      return false;
    }
    return true;
  }
Exemple #13
0
 protected void addKeyword(String name, int value) {
   // System.out.println("addKeyword " + name + " value = " + value);
   // new Exception().printStackTrace();
   Integer val = new Integer(value);
   currentLexer.put(name, val);
   if (!globalSymbolTable.containsKey(val)) globalSymbolTable.put(val, name);
 }
 public Hashtable getValues() {
   Hashtable values = new Hashtable();
   values.put(DIGITAL_IO_DEVICE_ID_KEY, deviceId);
   values.put(DIGITAL_IO_VALUE_KEY, _value);
   values.put(DIGITAL_IO_OPERATOR_KEY, _operator.name());
   return values;
 }
 /**
  * Busca todos os dispositivos Bluetooth pareados com o device
  *
  * @param callbackContext
  */
 protected void getBluetoothPairedDevices(CallbackContext callbackContext) {
   BluetoothAdapter mBluetoothAdapter = null;
   try {
     mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
     if (mBluetoothAdapter == null) {
       callbackContext.error(this.getErrorByCode(1));
       return;
     }
     if (!mBluetoothAdapter.isEnabled()) {
       Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
       this.mCordova.getActivity().startActivityForResult(enableBluetooth, 0);
     }
     Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
     if (pairedDevices.size() > 0) {
       JSONArray json = new JSONArray();
       for (BluetoothDevice device : pairedDevices) {
         Hashtable map = new Hashtable();
         map.put("type", device.getType());
         map.put("address", device.getAddress());
         map.put("name", device.getName());
         JSONObject jObj = new JSONObject(map);
         json.put(jObj);
       }
       callbackContext.success(json);
     } else {
       callbackContext.error(this.getErrorByCode(2));
     }
   } catch (Exception e) {
     Log.e(LOG_TAG, e.getMessage());
     e.printStackTrace();
     callbackContext.error(e.getMessage());
   }
 }
  static {
    operationPattern = Pattern.compile(OPERATION_PATTERN);
    subscribedPattern = Pattern.compile(CHANNEL_PATTERN);
    receivedPattern = Pattern.compile(RECEIVED_PATTERN);
    receivedPatternFiltered = Pattern.compile(RECEIVED_PATTERN_FILTERED);
    multipartMessagePattern = Pattern.compile(MULTI_PART_MESSAGE_PATTERN);
    unsubscribedPattern = Pattern.compile(CHANNEL_PATTERN);
    exceptionPattern = Pattern.compile(EXCEPTION_PATTERN);
    permissionsPattern = Pattern.compile(PERMISSIONS_PATTERN);

    operationIndex.put("ortc-validated", OrtcOperation.Validated);
    operationIndex.put("ortc-subscribed", OrtcOperation.Subscribed);
    operationIndex.put("ortc-unsubscribed", OrtcOperation.Unsubscribed);
    operationIndex.put("ortc-error", OrtcOperation.Error);

    errorOperationIndex.put("ex", OrtcServerErrorException.OrtcServerErrorOperation.Unexpected);
    errorOperationIndex.put("validate", OrtcServerErrorException.OrtcServerErrorOperation.Validate);
    errorOperationIndex.put(
        "subscribe", OrtcServerErrorException.OrtcServerErrorOperation.Subscribe);
    errorOperationIndex.put(
        "subscribe_maxsize", OrtcServerErrorException.OrtcServerErrorOperation.Subscribe_MaxSize);
    errorOperationIndex.put(
        "unsubscribe_maxsize",
        OrtcServerErrorException.OrtcServerErrorOperation.Unsubscribe_MaxSize);
    errorOperationIndex.put(
        "send_maxsize", OrtcServerErrorException.OrtcServerErrorOperation.Send_MaxSize);
  }
Exemple #17
0
 /**
  * Parse the query string into an unordered map of name/value pairs.
  *
  * <p>If keepDuplicates parameter is true, then the resulting map will contain values of String
  * object when only one occurrence of a key is found in the query, and an ordered List object if
  * more than one occurrence is found, where the list is in the order of which they key occurred in
  * the query.
  *
  * <p>If keepDuplicates parameter is false, all values will be strings, and only the first
  * occurrence of the key will be kept.
  *
  * @param query the decoded query portion of a URI
  * @param keepDuplicates true to preserve duplicate keys.
  * @return the parsed parameters.
  */
 public static Hashtable<String, Object> parseQuery(String query, boolean keepDuplicates)
     throws URISyntaxException {
   if (query == null) {
     return null;
   }
   Hashtable<String, Object> parameters = new Hashtable<String, Object>();
   List<NameValuePair> nvps = parseQueryOrdered(query);
   Iterator<NameValuePair> i = nvps.iterator();
   while (i.hasNext()) {
     NameValuePair nvp = i.next();
     if (parameters.containsKey(nvp.getName())) {
       if (keepDuplicates == true) {
         Object v = parameters.get(nvp.getName());
         if (v instanceof String) {
           parameters.put(nvp.getName(), new String[] {(String) v, nvp.getValue()});
         } else {
           int size = ((String[]) v).length;
           String array[] = new String[size + 1];
           System.arraycopy(v, 0, array, 0, size);
           array[size] = nvp.getValue();
           parameters.put(nvp.getName(), nvp.getValue());
         }
       }
     } else {
       parameters.put(
           nvp.getName(), (nvp.getValue() == null) ? String.valueOf(true) : nvp.getValue());
     }
   }
   return parameters;
 }
 /** @desc 初始化 */
 public void initMethods() {
   getMethods = new Hashtable<String, Method>();
   setMethods = new Hashtable<String, Method>();
   cls = obj.getClass();
   Method[] methods = cls.getMethods();
   // 定义正则表达式,从方法中过滤出getter / setter 函数.
   String gs = "get(\\w+)";
   Pattern getM = Pattern.compile(gs);
   String ss = "set(\\w+)";
   Pattern setM = Pattern.compile(ss);
   // 把方法中的"set" 或者 "get" 去掉
   String rapl = "$1";
   String param;
   for (int i = 0; i < methods.length; ++i) {
     Method m = methods[i];
     String methodName = m.getName();
     if (Pattern.matches(gs, methodName)) {
       param = getM.matcher(methodName).replaceAll(rapl).toLowerCase();
       getMethods.put(param, m);
     } else if (Pattern.matches(ss, methodName)) {
       param = setM.matcher(methodName).replaceAll(rapl).toLowerCase();
       setMethods.put(param, m);
     } else {
       // System.out.println(methodName + " 不是getter,setter方法!");
     }
   }
 }
Exemple #19
0
  public void heapArrange(int index) {
    int l, r;
    int largest;
    l = 2 * index + 1;
    r = 2 * index + 2;
    if (l <= lastindex && heap[l] > heap[index]) {
      largest = l;
    } else {
      largest = index;
    }
    if (r <= lastindex && heap[r] > heap[largest]) {
      largest = r;
    }
    if (largest != index) {
      int temp = heap[largest];
      hash.remove(heap[index]);
      hash.put(heap[index], largest);
      hash.remove(temp);
      hash.put(temp, index);
      heap[largest] = heap[index];
      heap[index] = temp;

      heapArrange(largest);
    }
  }
Exemple #20
0
        public void handle(SubscribeRequest msg) {
          // messages++;
          //			System.out.println("  Server received subscription " + msg.getTopic());

          if (subcriptionRepository.containsKey(msg.getTopic())) {
            Vector<Address> subscriberlist =
                (Vector<Address>) subcriptionRepository.get(msg.getTopic());

            // to avoid duplicate subscriber
            if (!subscriberlist.contains(msg.getSource())) {
              subscriberlist.add(msg.getSource()); // Will this mutate the
              // instant in the object
              // inside?

              subcriptionRepository.remove(msg.getTopic());
              subcriptionRepository.put(msg.getTopic(), subscriberlist);
            }

            //				System.out.println("  Subscriber list for topic id "
            //						+ msg.getTopic() + " : " + subscriberlist.toString());

          } else {
            Vector<Address> subscriberlist = new Vector<Address>();
            subscriberlist.add(msg.getSource());
            //				System.out.println("  Address source: " + msg.getSource());
            subcriptionRepository.put(msg.getTopic(), subscriberlist);

            System.out.println(
                "  Subscriber list for topic id (new topic)"
                    + msg.getTopic()
                    + " : "
                    + subscriberlist.toString());
          }
        }
Exemple #21
0
  public ItemMap(ItemMappedById pMi) {
    mi = pMi;
    baseMap = mi.getMap();

    additionalAttributes.put(ITEM_PROPERTY_NAME, mi.getItem());
    additionalAttributes.put(ITEM_PROPERTY_ID, mi.getItem().getId());
  }
 /**
  * Creates the initial JNDI context to work with.
  *
  * @return context {@link InitialContext}
  * @throws ProcessingException
  */
 public InitialContext createInitialContext() throws ProcessingException {
   Hashtable<String, String> props = new Hashtable<String, String>();
   if (m_initialContextFactory != null) {
     props.put(Context.INITIAL_CONTEXT_FACTORY, m_initialContextFactory);
   }
   if (m_providerUrl != null) {
     props.put(Context.PROVIDER_URL, m_providerUrl);
   }
   if (m_userName != null && m_userName.length() > 0) {
     props.put(Context.SECURITY_PRINCIPAL, m_userName);
   }
   if (m_password != null) {
     props.put(Context.SECURITY_CREDENTIALS, m_password);
   }
   InitialContext ctx;
   try {
     if (props.size() > 0) {
       ctx = new InitialContext(props);
     } else {
       ctx = new InitialContext();
     }
   } catch (NamingException e) {
     throw new ProcessingException(e.getMessage(), e.getCause());
   }
   return ctx;
 }
 @Override
 public Hashtable<TextAttribute, Object> getFontAttrs() {
   Hashtable<TextAttribute, Object> fontAttrs = new Hashtable<TextAttribute, Object>();
   fontAttrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
   fontAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
   return fontAttrs;
 }
  synchronized Hashtable getProperties() {
    if ((props == null) && (text != null)) {
      Hashtable props = new Hashtable();
      int off = 0;
      while (off < text.length) {
        // length of the next key value pair
        int len = text[off++] & 0xFF;
        if ((len == 0) || (off + len > text.length)) {
          props.clear();
          break;
        }
        // look for the '='
        int i = 0;
        for (; (i < len) && (text[off + i] != '='); i++) {;
        }

        // get the property name
        String name = readUTF(text, off, i);
        if (name == null) {
          props.clear();
          break;
        }
        if (i == len) {
          props.put(name, NO_VALUE);
        } else {
          byte value[] = new byte[len - ++i];
          System.arraycopy(text, off + i, value, 0, len - i);
          props.put(name, value);
          off += len;
        }
      }
      this.props = props;
    }
    return props;
  }
  private Bitmap createBitmap(String content, final int size) {
    final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
    hints.put(EncodeHintType.MARGIN, 0);
    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
    BitMatrix result;
    try {
      result = sQRCodeWriter.encode(content, BarcodeFormat.QR_CODE, size, size, hints);
    } catch (WriterException ex) {
      mLogger.warn("qr encoder failed: " + ex.toString());
      return null;
    }

    final int width = result.getWidth();
    final int height = result.getHeight();
    final int[] pixels = new int[width * height];

    for (int y = 0; y < height; y++) {
      final int offset = y * width;
      for (int x = 0; x < width; x++) {
        pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
      }
    }

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);

    return bitmap;
  }
  private void initQuery() throws IOException {
    Hashtable<String, String> map = new Hashtable<String, String>();
    map.put("uid", "TEMP_USER");
    map.put("pwd", "TEMP_PASSWORD");
    map.put(QUERY_PARAM, Base64.encodeToString(TEST_QUERY.getBytes(), 0));

    HttpParams params = new BasicHttpParams();

    HttpConnectionParams.setStaleCheckingEnabled(params, false);
    HttpConnectionParams.setConnectionTimeout(params, ConnectionManager.DEFAULT_TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, ConnectionManager.DEFAULT_TIMEOUT);
    DefaultHttpClient httpClient = new DefaultHttpClient(params);

    // create post method
    HttpPost postMethod = new HttpPost(QUERY_URI);

    ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
    ObjectOutputStream objOS = new ObjectOutputStream(byteArrayOS);
    objOS.writeObject(map);
    ByteArrayEntity req_entity = new ByteArrayEntity(byteArrayOS.toByteArray());
    req_entity.setContentType(MIMETypeConstantsIF.BINARY_TYPE);

    // associating entity with method
    postMethod.setEntity(req_entity);

    // Executing post method
    executeHttpClient(httpClient, postMethod);
  }
Exemple #27
0
  public static void main(String[] args) throws Exception {

    Context jndiContext = null;
    try {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, providerContextFactory);
      env.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
      //			env.put(Context.SECURITY_PRINCIPAL, "admin");
      //			env.put(Context.SECURITY_CREDENTIALS, "");
      jndiContext = new InitialContext(env);
    } catch (Exception e) {
      System.out.println("Failed to create InitialContext");
      e.printStackTrace();
    }
    System.out.println("contex is " + jndiContext.getEnvironment().toString());
    //		ConnectionFactory factory = (javax.jms.ConnectionFactory)
    // jndiContext.lookup("ConnectionFactory");
    //		System.out.println(jndiContext.lookup("topic.sample"));
    //		jndiContext.bind("jbofy","Jbofy Yang");
    //		TopicConnectionFactory topicFactory = (javax.jms.TopicConnectionFactory) jndiContext
    //				.lookup("jms");
    //
    QueueConnectionFactory queueFactory =
        (javax.jms.QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory");
    System.out.println(queueFactory);

    Topic topic = (javax.jms.Topic) jndiContext.lookup("topic/subscribe");
    Queue queue = (javax.jms.Queue) jndiContext.lookup("queue/request");

    System.out.println(topic);
    System.out.println(queue);
  }
Exemple #28
0
 public ActionButton(String caption, Icon img) {
   properties = new Hashtable();
   properties.put(DEFAULT, caption);
   properties.put(NAME, caption);
   properties.put(SHORT_DESCRIPTION, caption);
   if (img != null) properties.put(SMALL_ICON, img);
 }
  public void initEJB() {
    try {
      InputStream inputStream =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("hu/neuron/java/sales/services/Settings.properties");

      Properties properties = new Properties();

      try {
        properties.load(inputStream);
      } catch (IOException e) {
        e.printStackTrace();
      }

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, properties.getProperty("SECURITY_PRINCIPAL"));
      env.put(Context.SECURITY_CREDENTIALS, properties.getProperty("SECURITY_CREDENTIALS"));
      env.put(Context.PROVIDER_URL, properties.getProperty("PROVIDER_URL"));
      Context ctx;

      ctx = new InitialContext(env);
      System.out.println("ctx  = " + ctx);
      offerService =
          (OfferServiceRemote)
              ctx.lookup("OfferService#hu.neuron.java.sales.service.OfferServiceRemote");
    } catch (NamingException e) {
      e.printStackTrace();
    }
  }
Exemple #30
0
  /**
   * A Method to add a single tag event.
   *
   * @param eventType The event type
   * @param trigger The trigger that lead to this event
   * @param timeTick The time tick
   * @param timeUTC The time UTC
   */
  protected final void updateTagEvent(
      final String eventType, final Trigger trigger, final long timeTick, final Date timeUTC) {

    TagEventType tempEventType;

    tagEvents = new Hashtable();
    tempEventType = new TagEventType();
    tempEventType.setEventType(eventType);
    tempEventType.setTimeTick(timeTick);
    tempEventType.setTimeUTC(timeUTC);
    tagEvents.put(EventType.EV_NEW, tempEventType);

    // in case of ev_new, ev_glimpsed ist alsow thrown
    if (eventType.equals(EventType.EV_NEW)) {
      tempEventType = new TagEventType();
      tempEventType.setEventType(EventType.EV_GLIMPSED);
      tempEventType.setTimeTick(timeTick);
      tempEventType.setTimeUTC(timeUTC);
      tagEvents.put(EventType.EV_GLIMPSED, tempEventType);
    }

    if (trigger != null) {
      tempEventType.getEventTriggers().put(trigger.getName(), trigger);
    }
  }