private void updateStartTypeEmailType() {
   EmailTypeHome home;
   try {
     home = (EmailTypeHome) IDOLookup.getHome(EmailType.class);
     home.updateStartData();
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   } catch (IDOException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   } catch (CreateException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   }
 }
Beispiel #2
0
  /** Open socket. */
  private void openSocket() {
    LOG.entering(this.getClass().getName(), "openSocket");
    this.serverSocket = null;
    this.clientSocket = null;
    OutputStream out = null;
    InputStream in = null;
    try {
      this.serverSocket = new ServerSocket(this.listenerPort);
      LOG.fine("Socket successfully created on port: " + this.listenerPort);
      this.clientSocket = this.serverSocket.accept();
      LOG.fine("Got connection on accepted server socket. Start reading now");
      out = this.clientSocket.getOutputStream();
      in = this.clientSocket.getInputStream();
      while (true) {
        final byte[] buf = new byte[4096];
        int bytes_read = 0;
        bytes_read = in.read(buf, 0, buf.length);
        if (bytes_read < 0) {
          LOG.info("Exit command from client received or line is null. Will close sockets now");
          break;
        }
        final String stringCommand = new String(buf, 0, bytes_read);
        LOG.info("Received " + bytes_read + " bytes, data=" + (stringCommand));
        final Command command = this.commandDispatcher.getCommand(stringCommand.getBytes());
        if (LOG.isLoggable(Level.INFO)) {
          LOG.info("Received command over socket: " + command);
        }
        final CommandResult result = this.configService.getController().execute(command);
        if (LOG.isLoggable(Level.INFO)) {
          LOG.info("Send back result over socket: " + result);
        }
        final byte[] resultByte = this.commandDispatcher.getCommandResult(result);
        out.write(resultByte);
        out.flush();
      }

    } catch (final Exception e) {
      LOG.throwing(
          SocketInboundAdapter.class.getName(),
          "Essssxit command from client received or line is null. Will close sockets now",
          e);
    } finally {
      try {
        this.clientSocket.close();
        this.serverSocket.close();
      } catch (final Exception e) {
        LOG.throwing(this.getClass().getName(), "openSocket", e);
      }
      this.openSocket();
    }
  }
  /**
   * Unlocks the room at the given index with the given lock without throwing any checked
   * exceptions. The checked exceptions could not reasonably be handled at this layer. This method
   * is inspired by commons-io closeQuietly().
   *
   * @param index the index of the room to unlock.
   * @param lock the lock the room was locked with.
   */
  private void unlockQuietly(final int index, final long lock) {

    if (lock == NOT_LOCKED) {
      return;
    }

    try {
      roomOfferDao.unlock(index, lock);
    } catch (final suncertify.db.SecurityException e) {
      logger.throwing(getClass().getName(), "unlockQuietly", e);
    } catch (final RecordNotFoundException e) {
      logger.throwing(getClass().getName(), "unlockQuietly", e);
    }
  }
  @POST
  @Path("/getFilterInGEOJSON/{filter}")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_PLAIN)
  public String getFilterInGEOJSON(WrapperFilter filter) {
    log.info("init getFilterInGEOJSON");
    ChronometerUtil c = new ChronometerUtil();
    c.start();
    try {
      String result =
          executeFilterWFS(
              filter,
              MapRequestBuilder.MidwareTypes.geoserver.name(),
              MapRequestBuilder.MidwareProduces.geojson.name());

      return result;

    } catch (Exception e) {

      log.throwing(WrapperResource.class.getSimpleName(), "getFilterInGEOJSON", e);
    } finally {
      log.info(c.stop("finish getFilterInGEOJSON"));
    }
    return null;
  }
Beispiel #5
0
 @Override
 /** {@inheritDoc} */
 public int execute(final String... parameters) {
   if (parameters.length > MINIMUM_PARAMETERS_COUNT) {
     return new Command_help().execute(parameters);
   }
   Command command = null;
   String inName = parameters[0];
   File inFile = new File(inName);
   String name = inFile.getName();
   String commandArg = "";
   try {
     if (!inFile.isFile()) {
       throw new IllegalArgumentException("The given parameter isn't a HKX or XML file.");
     }
     String ext = name.substring(name.lastIndexOf('.') + 1);
     if (ext.equals("hkx")) {
       command = new Command_unpack();
       commandArg = "unpack";
     } else if (ext.equals("xml")) {
       command = new Command_pack();
       commandArg = "pack";
     } else {
       throw new IllegalArgumentException("Unsupported file type.");
     }
   } catch (IllegalArgumentException e) {
     LOGGER.throwing(this.getClass().getName(), "execute", e);
     return 1;
   }
   return command.execute(commandArg, inName);
 }
Beispiel #6
0
  private void findAliases(Term primeTerm, String target, String prefix) {
    Morpher morpher = null;
    try {
      morpher = new Morpher(target);
      if (morpher.getData()) {
        Set<String> aliases = new HashSet<String>();
        for (Morpher.Morph morph : morpher.getAllMorph()) {
          if (morph == null) {
            return;
          }
          String alias = prefix + morph.text;
          if (morph != null && !alias.isEmpty() && !alias.equals(primeTerm.getName())) {
            if (!aliases.contains(alias)) {
              TermMorph termMorph = commonDao.get(TermMorph.class, alias);
              if (termMorph == null) {
                commonDao.save(new TermMorph(alias, primeTerm.getUri()));

                log.info("Alias added: " + alias);
              }
              aliases.add(alias);
            }
          }
        }
        /* for (Map.Entry<String, Term> entry : aliases.entrySet()) {
            if (primeTerm.getUri().equals(entry.getValue().generateUri())) continue;
            commonDao.save(new Link(primeTerm, entry.getValue(), Link.ALIAS, Link.MORPHEME_WEIGHT));
        }*/
      }
    } catch (Exception e) {
      log.throwing(getClass().getName(), "findAliases", e);
      throw new RuntimeException(e);
    }
  }
Beispiel #7
0
 /**
  * Used to return all of the Preferences used across the application. Preferences can then be
  * edited locally within the calling class.
  *
  * @return A new instance of Preferences to be used locally
  */
 public static Preferences getOdinPrefs() {
   // Obtain a logger to write progress to
   Logger log = LoggerFactory.getLogger("odin.odin.object.OdinPreferences");
   log.log(Level.FINEST, "Examining preferences to see if it's null or not.", prefsOdin);
   if (prefsOdin == null) {
     log.finest(
         "Preferences object was null, creating a new one from the default file (odin.prefs.xml).");
     try {
       // Obtain the FileInputStream for the central Preferences file
       BufferedInputStream bisXMLPrefs = new BufferedInputStream(new FileInputStream(sPrefsPath));
       // Providing the file isn't null then import the preferences
       if (bisXMLPrefs != null) {
         prefsOdin.importPreferences(bisXMLPrefs);
       }
     } catch (Exception x) {
       // If any errors are thrown then record them in the logger
       log.throwing("OdinPreferences", "getOdinPrefs()", x);
     }
   }
   // Obtain the Preferences for this class, this allows for everything to be centralised within
   // the file
   prefsOdin = Preferences.userNodeForPackage(OdinPreferences.class);
   // Return the Preferences to the receiver.
   return prefsOdin;
 }
  @Override
  public UrlyBirdRoomOffer bookRoomOffer(final BookRoomCommand command) throws Exception {

    checkNotNull(command, "command");

    final RoomOffer clientRoomToBook = command.getRoomToBook();
    final int roomOfferIndex = clientRoomToBook.getIndex();

    long lock = NOT_LOCKED;
    try {
      lock = roomOfferDao.lock(roomOfferIndex);
      final RoomOffer dbRoomToBook = roomOfferDao.read(roomOfferIndex);

      checkStaleRoomData(clientRoomToBook, dbRoomToBook);

      if (!isRoomBookable.isSatisfiedBy(dbRoomToBook)) {
        throw new Exception("the room to book: " + clientRoomToBook + " is already booked");
      }

      final UrlyBirdRoomOffer bookedRoomOffer =
          factory.copyRoomOfferWithNewCustomer(clientRoomToBook, command.getCustomerId());
      roomOfferDao.update(bookedRoomOffer, lock);
      return bookedRoomOffer;
    } catch (final Exception e) {
      logger.throwing(getClass().getName(), "bookRoomOffer", e);
      throw new Exception(e);
    } finally {
      unlockQuietly(roomOfferIndex, lock);
    }
  }
  @Override
  public List<RoomOffer> findRoomOffer(final FindRoomCommand command) throws Exception {

    checkNotNull(command, "command");

    // TODO this could give stale data
    try {
      if (command.isAnd()) {
        return new ArrayList<RoomOffer>(
            roomOfferDao.find(
                Arrays.asList(
                    command.getHotel(), command.getLocation(), null, null, null, null, null)));

      } else {
        final ArrayList<UrlyBirdRoomOffer> matchingHotels =
            new ArrayList<UrlyBirdRoomOffer>(
                roomOfferDao.find(
                    Arrays.asList(command.getHotel(), null, null, null, null, null, null)));
        final ArrayList<UrlyBirdRoomOffer> matchingLocations =
            new ArrayList<UrlyBirdRoomOffer>(
                roomOfferDao.find(
                    Arrays.asList(null, command.getLocation(), null, null, null, null, null)));

        final Set<UrlyBirdRoomOffer> union = new HashSet<UrlyBirdRoomOffer>();
        union.addAll(matchingHotels);
        union.addAll(matchingLocations);
        return new ArrayList<RoomOffer>(union);
      }
    } catch (final Exception e) {
      logger.throwing(getClass().getName(), "findRoomOffer", e);
      throw new Exception(e);
    }
  }
  @Override
  public UrlyBirdRoomOffer updateRoomOffer(final UpdateRoomCommand command) throws Exception {

    checkNotNull(command, "command");

    long lock = NOT_LOCKED;
    final List<String> values = command.getNewValues();
    final RoomOffer clientRoomToUpdate = command.getRoomToUpdate();
    final int index = clientRoomToUpdate.getIndex();
    try {
      lock = roomOfferDao.lock(index);

      final RoomOffer dbRoomToUpdate = roomOfferDao.read(index);
      checkStaleRoomData(clientRoomToUpdate, dbRoomToUpdate);

      final UrlyBirdRoomOffer updatedRoomOffer = factory.createRoomOffer(values, index);

      roomOfferDao.update(updatedRoomOffer, lock);
      return updatedRoomOffer;
    } catch (final Exception e) {
      logger.throwing(getClass().getName(), "updateRoomOffer", e);
      throw new Exception(e);
    } finally {
      unlockQuietly(index, lock);
    }
  }
 @GET
 @Path("/getSchema")
 @Produces(MediaType.APPLICATION_JSON)
 public WrapperFilter getSchema() {
   log.info("init getSchema");
   ChronometerUtil c = new ChronometerUtil();
   c.start();
   try {
     WrapperFilter f = new WrapperFilter();
     Operators[] operators =
         new Operators[] {new Operators(new String[] {"valor1", "valor2"}, "IN")};
     Filters[] filters = new Filters[] {new Filters("column", operators, "table")};
     f.setFilters(filters);
     Join[] joins = new Join[] {new Join("name", "column")};
     f.setJoin(joins);
     f.setLayer("layer");
     f.setTable(new Table("table"));
     return f;
   } catch (Exception e) {
     log.throwing(WrapperResource.class.getSimpleName(), "getFilterWfsURL", e);
   } finally {
     log.info(c.stop("finish getSchema"));
   }
   return null;
 }
Beispiel #12
0
 /*
  * Checks that all the provided <code>URL</code> s have permission to use
  * the given policy.
  */
 private static void checkPolicyPermission(String policy, URL[] urls) {
   logger.entering(
       ActivateWrapper.class.getName(),
       "checkPolicyPermission",
       new Object[] {policy, urlsToPath(urls)});
   // Create desired permission object
   Permission perm = new SharedActivationPolicyPermission(policy);
   Certificate[] certs = null;
   CodeSource cs;
   ProtectionDomain pd;
   // Loop over all codebases
   for (URL url : urls) {
     // Create ProtectionDomain for given codesource
     cs = new CodeSource(url, certs);
     pd = new ProtectionDomain(cs, null, null, null);
     logger.log(Level.FINEST, "Checking protection domain: {0}", pd);
     // Check if current domain allows desired permission
     if (!pd.implies(perm)) {
       SecurityException se =
           new SecurityException(
               "ProtectionDomain " + pd + " does not have required permission: " + perm);
       logger.throwing(ActivateWrapper.class.getName(), "checkPolicyPermission", se);
       throw se;
     }
   }
   logger.exiting(ActivateWrapper.class.getName(), "checkPolicyPermission");
 }
  /**
   * Creates a new EigenbaseException object.
   *
   * @param message error message
   * @param cause underlying cause
   */
  public EigenbaseException(String message, Throwable cause) {
    super(message, cause);

    // TODO: Force the caller to pass in a Logger as a trace argument for
    // better context.  Need to extend ResGen for this.
    tracer.throwing("EigenbaseException", "constructor", this);
    tracer.severe(toString());
  }
Beispiel #14
0
 @SuppressWarnings("unchecked")
 public NSDActionInvocation(org.teleal.cling.model.meta.Action action, JSONObject args) {
   super(action);
   log.finest("setInput action:" + action.getName());
   try {
     // Throws InvalidValueException if the value is of wrong type
     Iterator keys = args.keys();
     while (keys.hasNext()) {
       String name = (String) keys.next(), value = args.get(name).toString();
       log.finest("setInput " + name + " " + value);
       setInput(name, value);
     }
   } catch (JSONException e) {
     log.throwing(this.getClass().getName(), "NSDActionInvocation", e);
   } catch (InvalidValueException ex) {
     log.throwing(this.getClass().getName(), "NSDActionInvocation", ex);
   }
 }
Beispiel #15
0
 /** Used to update any changes within the preferences to the main XML file. */
 public static void updateOdinPrefs() {
   // Obtain a logger to write progress to
   Logger log = LoggerFactory.getLogger("odin.odin.object.OdinPreferences");
   try {
     log.finest("Exporting preferences to file: " + sPrefsPath);
     // Record all of the preferences in the odin.prefs.xml file
     prefsOdin.exportNode(new FileOutputStream(sPrefsPath));
   } catch (Exception x) {
     // If an error was encountered during the update then write the details to the log
     log.throwing("OdinPreferences", "updateOdinPrefs()", x);
   }
 }
 /**
  * Creates an instance of {@code JmxModel} for a {@link JmxApplication}.
  *
  * @param application the {@link JmxApplication}.
  */
 public JmxModelImpl(JmxApplication application) {
   try {
     final ProxyClient proxyClient = new ProxyClient(this, application);
     client = proxyClient;
     removedListener = new ApplicationRemovedListener();
     availabilityListener = new ApplicationAvailabilityListener();
     connect(application, proxyClient, removedListener, availabilityListener);
   } catch (Exception e) {
     LOGGER.throwing(JmxModelImpl.class.getName(), "<init>", e); // NOI18N
     client = null;
   }
 }
 private void updateStartDataGroupRelationType() {
   /*
    * @todo Move to user plugin system
    **/
   // Temporary Fix to make sure GroupRelation table exists:
   new GroupRelationBMPBean();
   try {
     ICObjectTypeHome home = (ICObjectTypeHome) IDOLookup.getHome(ICObjectType.class);
     home.updateStartData();
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "updateStartDataGroupRelationType", e);
   } catch (IDOException e) {
     log.throwing(this.getClass().getName(), "updateStartDataGroupRelationType", e);
   }
   insertGroupRelationType("GROUP_PARENT");
   insertGroupRelationType("FAM_CHILD");
   insertGroupRelationType("FAM_PARENT");
   insertGroupRelationType("FAM_SPOUSE");
   insertGroupRelationType("FAM_CUSTODIAN");
   insertGroupRelationType("FAM_SIBLING");
 }
 private void insertGroupRelationType(String groupRelationType) {
   /** @todo Move this to a more appropriate place */
   try {
     GroupRelationTypeHome grtHome =
         (GroupRelationTypeHome) com.idega.data.IDOLookup.getHome(GroupRelationType.class);
     GroupRelationType grType;
     try {
       grType = grtHome.findByPrimaryKey(groupRelationType);
     } catch (FinderException fe) {
       try {
         grType = grtHome.create();
         grType.setType(groupRelationType);
         grType.store();
         log.fine("Registered Group relation type: '" + groupRelationType + "'");
       } catch (CreateException e) {
         log.throwing(this.getClass().getName(), "insertGroupRelationType", e);
       }
     }
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "insertGroupRelationType", e);
   }
 }
Beispiel #19
0
 /**
  * Returns a service UI descriptorfor this service. Usally this method is used as an entry in
  * provider configuration files when smart proxies are deployed with a standard off the shelf
  * {@link sorcer.core.provider.ServiceProvider}.
  *
  * @return service UI descriptor
  */
 public static UIDescriptor getUIDescriptor() {
   UIDescriptor uiDesc = null;
   try {
     uiDesc =
         UIDescriptorFactory.getUIDescriptor(
             MainUI.ROLE,
             new UIComponentFactory(
                 new URL[] {new URL(Sorcer.getWebsterUrl() + "/ssu1-mvc-ui.jar")},
                 SortView.class.getName()));
   } catch (Exception ex) {
     logger.throwing(SortView.class.getName(), "getUIDescriptor", ex);
   }
   return uiDesc;
 }
 /**
  * If this thread was constructed using a separate <code>Runnable</code> run object, then that
  * <code>Runnable</code> object's <code>run</code> method is called; otherwise, this method does
  * nothing and returns.
  *
  * <p>Subclasses of <code>Thread</code> should override this method.
  *
  * @see Thread#start()
  * @see Thread#stop()
  * @see Thread#Thread(ThreadGroup,Runnable,String)
  * @see Runnable#run()
  */
 public void run() {
   fireThreadRunStarted();
   try {
     read(fontMap);
     fireThreadRunFinished();
   } catch (IOException e) {
     setMessage("Invalid FontMap " + fontMap.getFontMapFile().getAbsolutePath());
     logger.throwing("intellibitz.sted.actions.LoadFontMapAction", "readFontMap", e);
     fireThreadRunFailed();
   } catch (SAXException e) {
     setMessage("Invalid FontMap " + fontMap.getFontMapFile().getAbsolutePath());
     logger.throwing("intellibitz.sted.actions.LoadFontMapAction", "readFontMap", e);
     fireThreadRunFailed();
   } catch (ParserConfigurationException e) {
     setMessage("Invalid FontMap " + fontMap.getFontMapFile().getAbsolutePath());
     logger.throwing("intellibitz.sted.actions.LoadFontMapAction", "readFontMap", e);
     fireThreadRunFailed();
   } catch (HeadlessException e) {
     setMessage("Invalid FontMap " + fontMap.getFontMapFile().getAbsolutePath());
     logger.throwing("intellibitz.sted.actions.LoadFontMapAction", "readFontMap", e);
     fireThreadRunFailed();
   }
 }
 private Cruddable getCruddable(String cruddableName) {
   Context jndiContext = null;
   Cruddable crud = null;
   String commonPrefix = "java:global/BusinessLogicProxy/";
   String commonSuffix = "Bean";
   try {
     jndiContext = new InitialContext();
     crud = (Cruddable) jndiContext.lookup(commonPrefix + cruddableName + commonSuffix);
     log.fine("Cruddable instance created for entity [" + cruddableName + "]");
   } catch (java.lang.Exception e) {
     log.severe("Unable to load jndi context component");
     log.throwing(this.getClass().getName(), "getCruddable", e);
   }
   return crud;
 }
Beispiel #22
0
 @Override
 public void shutDown() {
   LOG.entering(this.getClass().getName(), "shutDown");
   try {
     if (this.clientSocket != null) {
       this.clientSocket.shutdownInput();
       this.clientSocket.close();
     }
     if (this.serverSocket != null) {
       this.serverSocket.close();
     }
   } catch (final IOException e) {
     LOG.throwing(this.getClass().getName(), "shutDown", e);
   }
 }
Beispiel #23
0
 /**
  * Analog to {@link java.rmi.activation.Activatable#register(java.rmi.activation.ActivationDesc)
  * Activatable.register()} for activatable objects that want to use this wrapper mechanism.
  *
  * @return activation ID of the registered service
  * @throws ActivationException if there was a problem registering the activatable class with the
  *     activation system
  * @throws RemoteException if there was a problem communicating with the activation system
  */
 public static ActivationID register(
     ActivationGroupID gid, ActivateDesc desc, boolean restart, ActivationSystem sys)
     throws ActivationException, RemoteException {
   logger.entering(
       ActivateWrapper.class.getName(), "register", new Object[] {gid, desc, restart, sys});
   MarshalledObject data;
   try {
     data = new MarshalledObject(desc);
   } catch (Exception e) {
     MarshalException me = new MarshalException("marshalling ActivateDesc", e);
     logger.throwing(ActivateWrapper.class.getName(), "register", me);
     throw me;
   }
   ActivationDesc adesc =
       new ActivationDesc(gid, ActivateWrapper.class.getName(), null, data, restart);
   logger.log(Level.FINEST, "Registering descriptor with activation: {0}", adesc);
   ActivationID aid = sys.registerObject(adesc);
   logger.exiting(ActivateWrapper.class.getName(), "register", aid);
   return aid;
 }
Beispiel #24
0
  public static JSONObject bundleJsonResponseObject(String name, Object o) {
    try {
      Gson gson = new Gson();
      String jsonString = gson.toJson(o);
      log.finer(jsonString);

      JSONObject obj = new JSONObject();

      if (o instanceof Collection) {
        JSONArray arr = new JSONArray(jsonString);
        obj.put(name, arr);
      } else {
        JSONObject obj2 = new JSONObject(jsonString);
        obj.put(name, obj2);
      }
      return obj;
    } catch (JSONException e) {
      log.throwing(KEY, "bundleJsonResponse", e);
      return null;
    }
  }
  @Override
  public UrlyBirdRoomOffer createRoomOffer(final CreateRoomCommand command) throws Exception {

    checkNotNull(command, "command");

    final List<String> values = command.getValues();
    final Date date = factory.getBookableDateFromValues(values);
    if (!isOccupancyIn48Hours.isSatisfiedBy(date)) {
      throw new Exception(
          "the occupany of the new room is not in the next 48 hours, the room can not be added");
    }

    UrlyBirdRoomOffer roomOffer = null;
    try {
      roomOffer = roomOfferDao.create(values);
    } catch (final Exception e) {
      logger.throwing(getClass().getName(), "createRoomOffer", e);
      throw new Exception(e);
    }

    return roomOffer;
  }
  @Override
  public int deleteRoomOffer(final DeleteRoomCommand command) throws Exception {

    checkNotNull(command, "command");

    final RoomOffer clientRoomToDelete = command.getRoomOfferToDelete();
    final int index = clientRoomToDelete.getIndex();
    long lock = NOT_LOCKED;
    try {
      lock = roomOfferDao.lock(index);
      final RoomOffer dbRoomToDelete = roomOfferDao.read(index);

      checkStaleRoomData(clientRoomToDelete, dbRoomToDelete);

      roomOfferDao.delete(index, lock);
      return index;
    } catch (final Exception e) {
      logger.throwing(getClass().getName(), "deleteRoomOffer", e);
      throw new Exception(e);
    } finally {
      unlockQuietly(index, lock);
    }
  }
Beispiel #27
0
  public static JsonRepresentation bundleJsonResponse(
      String name, Object o, String repository, String patid) {
    try {
      Gson gson = new Gson();
      String jsonString = gson.toJson(o);
      log.finer(jsonString);

      JSONObject obj = new JSONObject();
      obj.put("patient_id", patid);
      obj.put("repository", repository);
      if (o instanceof Collection) {
        JSONArray arr = new JSONArray(jsonString);
        obj.put(name, arr);
      } else {
        JSONObject obj2 = new JSONObject(jsonString);
        obj.put(name, obj2);
      }
      return new JsonRepresentation(obj);
    } catch (JSONException e) {
      log.throwing(KEY, "bundleJsonResponse", e);
      return null;
    }
  }
 /**
  * Creates an instance of {@code JmxModel} for a {@link JvmstatApplication}.
  *
  * @param application the {@link JvmstatApplication}.
  */
 public JmxModelImpl(Application application, JvmstatModel jvmstat) {
   try {
     JvmJvmstatModel jvmstatModel = JvmJvmstatModelFactory.getJvmstatModelFor(application);
     // Create ProxyClient (i.e. create the JMX connection to the JMX agent)
     ProxyClient proxyClient = null;
     if (Application.CURRENT_APPLICATION.equals(application)) {
       // Monitor self
       proxyClient = new ProxyClient(this);
     } else if (application.isLocalApplication()) {
       // Create a ProxyClient from local pid
       String connectorAddress =
           jvmstat.findByName("sun.management.JMXConnectorServer.address"); // NOI18N
       String javaHome = jvmstat.findByName("java.property.java.home"); // NOI18N
       LocalVirtualMachine lvm =
           new LocalVirtualMachine(
               application.getPid(),
               AttachModelFactory.getAttachFor(application) != null,
               connectorAddress,
               javaHome);
       if (!lvm.isManageable()) {
         if (lvm.isAttachable()) {
           proxyClient = new ProxyClient(this, lvm);
         } else {
           if (LOGGER.isLoggable(Level.WARNING)) {
             LOGGER.warning(
                 "The JMX management agent "
                     + // NOI18N
                     "cannot be enabled in this application (pid "
                     + // NOI18N
                     application.getPid()
                     + ")"); // NOI18N
           }
         }
       } else {
         proxyClient = new ProxyClient(this, lvm);
       }
     }
     if (proxyClient == null) {
       // Create a ProxyClient for the remote out-of-the-box
       // JMX management agent using the port and security
       // related information retrieved through jvmstat.
       List<String> urls =
           jvmstat.findByPattern(
               "sun.management.JMXConnectorServer.[0-9]+.remoteAddress"); // NOI18N
       if (urls.size() != 0) {
         List<String> auths =
             jvmstat.findByPattern(
                 "sun.management.JMXConnectorServer.[0-9]+.authenticate"); // NOI18N
         proxyClient = new ProxyClient(this, urls.get(0));
         if ("true".equals(auths.get(0))) { // NOI18N
           supplyCredentials(application, proxyClient);
         }
       } else {
         // Create a ProxyClient for the remote out-of-the-box
         // JMX management agent using the port specified in
         // the -Dcom.sun.management.jmxremote.port=<port>
         // system property
         String jvmArgs = jvmstatModel.getJvmArgs();
         StringTokenizer st = new StringTokenizer(jvmArgs);
         int port = -1;
         boolean authenticate = false;
         while (st.hasMoreTokens()) {
           String token = st.nextToken();
           if (token.startsWith("-Dcom.sun.management.jmxremote.port=")) { // NOI18N
             port = Integer.parseInt(token.substring(token.indexOf("=") + 1)); // NOI18N
           } else if (token.equals("-Dcom.sun.management.jmxremote.authenticate=true")) { // NOI18N
             authenticate = true;
           }
         }
         if (port != -1) {
           proxyClient = new ProxyClient(this, application.getHost(), port);
           if (authenticate) {
             supplyCredentials(application, proxyClient);
           }
         }
       }
     }
     if (proxyClient != null) {
       client = proxyClient;
       removedListener = new ApplicationRemovedListener();
       availabilityListener = new ApplicationAvailabilityListener();
       connect(application, proxyClient, removedListener, availabilityListener);
     }
   } catch (Exception e) {
     LOGGER.throwing(JmxModelImpl.class.getName(), "<init>", e); // NOI18N
     client = null;
   }
 }
Beispiel #29
0
 protected void throwing(String cls, String method, Throwable ex) {
   if (_logger != null) _logger.throwing(cls, method, ex);
   else ex.printStackTrace();
 }
Beispiel #30
0
 @Override
 public void error(String s, Throwable e) {
   logger.throwing(s, e.getMessage(), e);
 }