How to determine the Current Domain name from inside an Mbean / Java Prog

We have registered an Application Defined MBean. The mbean has several APIs. Now we want to determine the currrent domain using some java api inside this Mbean. Similarly we have deployed a Webapp/Service in the Weblogic domain. And inside this app we need to know the current Domain. Is there any java api that will give this runtime information.
Note: We are the MBean providers not clients who can connect to the WLS (using user/passwd) and get the domain MBean and determine the domain.
Fusion Applcore

Not sure if this will address exactly what you are looking to do, but I use this technique all the time to access runtime JMX information from within a Weblogic deployed application without having to pass authentication credentials. You are limited, however, to what you can access via the RuntimeServiceMBean. The example class below shows how to retrieve the domain name and managed server name from within a Weblogic deployed application (System.out calls only included for simplicity in this example):
package com.yourcompany.jmx;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.InitialContext;
public class JMXWrapper {
    private static JMXWrapper instance = new JMXWrapper();
    private String domainName;
    private String managedServerName;
    private JMXWrapper() {
    public static JMXWrapper getInstance() {
        return instance;
    public String getDomainName() {
        if (domainName == null) {
            try {
                MBeanServer server = getMBeanServer();
                ObjectName domainMBean = (ObjectName) server.getAttribute(getRuntimeService(), "DomainConfiguration");
                domainName = (String) server.getAttribute(domainMBean, "Name");
            } catch (Exception ex) {
                System.out.println("Caught Exception: " + ex);
                ex.printStackTrace();
        return domainName;
    public String getManagedServerName() {
        if (managedServerName == null) {
            try {
                managedServerName = (String) getMBeanServer().getAttribute(getRuntimeService(), "ServerName");
            } catch (Exception ex) {
                System.out.println("Caught Exception: " + ex);
                ex.printStackTrace();
        return managedServerName;
    private MBeanServer getMBeanServer() {
        MBeanServer retval = null;
        InitialContext ctx = null;
        try {
            //fetch the RuntimeServerMBean using the
            //MBeanServer interface
            ctx = new InitialContext();
            retval = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");
        } catch (Exception ex) {
            System.out.println("Caught Exception: " + ex);
            ex.printStackTrace();
        } finally {
            if (ctx != null) {
                try {
                    ctx.close();
                } catch (Exception dontCare) {
        return retval;
    private ObjectName getRuntimeService() {
        ObjectName retval = null;
        try {
            retval = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
        } catch (Exception ex) {
            System.out.println("Caught Exception: " + ex);
            ex.printStackTrace();
        return retval;
}I then created a simply test JSP to call the JMXWrapper singleton and display retrieved values:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.yourcompany.jmx.JMXWrapper"%>
<%
   JMXWrapper jmx = JMXWrapper.getInstance();
   String domainName = jmx.getDomainName();
   String managedServerName = jmx.getManagedServerName();
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JMX Wrapper Test</title>
    </head>
    <body>
        <h2>Domain Name: <%= domainName %></h2>
        <h2>Managed Server Name: <%= managedServerName %></h2>
    </body>
</html>

Similar Messages

  • How to get the current schema name

    Hi,
    Can anybody please tell me how to get the current schema name, there is some inbuilt function for this,but i am not getting that. Please help me.
    Thanks
    Jogesh

    ok folks, I found the answer at Tom's as usual.
    http://asktom.oracle.com/tkyte/who_called_me/index.html
    I rewrote it into a function for kicks. just pass the results of DBMS_UTILITY.FORMAT_CALL_STACK to this function and you will get back the owner of the code making the call as well some extra goodies like the name of the code and the type of code depending on the parameter. This ignores the AUTHID CURRENT_USER issues which muddles the schemaid. Quick question, does the average user always have access to DBMS_UTILITY.FORMAT_CALL_STACK or does this get locked down on some systems?
    cheers,
    paul
    create or replace
    FUNCTION SELF_EXAM (
       p_call_stack VARCHAR2,
       p_type VARCHAR2 DEFAULT 'SCHEMA'
    ) RETURN VARCHAR2
    AS
       str_stack   VARCHAR2(4000);
       int_n       PLS_INTEGER;
       str_line    VARCHAR2(255);
       found_stack BOOLEAN DEFAULT FALSE;
       int_cnt     PLS_INTEGER := 0;
       str_caller  VARCHAR2(30);
       str_name    VARCHAR2(30);
       str_owner   VARCHAR2(30);
       str_type    VARCHAR2(30);
    BEGIN
       str_stack := p_call_stack;
       -- Loop through each line of the call stack
       LOOP
         int_n := INSTR( str_stack, chr(10) );
         EXIT WHEN int_cnt = 3 OR int_n IS NULL OR int_n = 0;
         -- get the line
         str_line := SUBSTR( str_stack, 1, int_n - 1 );
         -- remove the line from the stack str
         str_stack := substr( str_stack, int_n + 1 );
         IF NOT found_stack
         THEN
            IF str_line like '%handle%number%name%'
            THEN
               found_stack := TRUE;
            END IF;
         ELSE
            int_cnt := int_cnt + 1;
             -- cnt = 1 is ME
             -- cnt = 2 is MY Caller
             -- cnt = 3 is Their Caller
             IF int_cnt = 1
             THEN
                str_line := SUBSTR( str_line, 22 );
                dbms_output.put_line('->' || str_line);
                IF str_line LIKE 'pr%'
                THEN
                   int_n := LENGTH('procedure ');
                ELSIF str_line LIKE 'fun%'
                THEN
                   int_n := LENGTH('function ');
                ELSIF str_line LIKE 'package body%'
                THEN
                   int_n := LENGTH('package body ');
                ELSIF str_line LIKE 'pack%'
                THEN
                   int_n := LENGTH('package ');
                ELSIF str_line LIKE 'anonymous%'
                THEN
                   int_n := LENGTH('anonymous block ');
                ELSE
                   int_n := null;
                END IF;
                IF int_n IS NOT NULL
                THEN
                   str_type := LTRIM(RTRIM(UPPER(SUBSTR( str_line, 1, int_n - 1 ))));
                 ELSE
                   str_type := 'TRIGGER';
                 END IF;
                 str_line  := SUBSTR( str_line, NVL(int_n,1) );
                 int_n     := INSTR( str_line, '.' );
                 str_owner := LTRIM(RTRIM(SUBSTR( str_line, 1, int_n - 1 )));
                 str_name  := LTRIM(RTRIM(SUBSTR( str_line, int_n + 1 )));
              END IF;
           END IF;
       END LOOP;
       IF UPPER(p_type) = 'NAME'
       THEN
          RETURN str_name;
       ELSIF UPPER(p_type) = 'SCHEMA.NAME'
       OR    UPPER(p_type) = 'OWNER.NAME'
       THEN
          RETURN str_owner || '.' || str_name;
       ELSIF UPPER(p_type) = 'TYPE'
       THEN
          RETURN str_type;
       ELSE
          RETURN str_owner;
       END IF;
    END SELF_EXAM;

  • How to get the Portal Page name from PLSQL?

    Can anyone tell me how to get the portal page name from my dynamic page using plsql?
    Apparently you can get the page id and work it out from there, but my calls to get the page id are not returning any values anyway.
    My code for attempting to get the page id is below.
    <oracle>
    declare
    v_pageid varchar2(30);
    begin
    v_pageid := wwpro_api_parameters.get_value('_pageid', '/pls/portal30');
    htp.print('Page is '|| v_pageid);
    end;
    </oracle>
    Ideally I'd actually just like to get the page name. Is there a straightforward way to do this?
    Thanks in advance!
    Sarah

    Few clarifications -
    1. wwpro_api_parameters cannot be used to get default portal
    page parameters such as '_pageid', '_dad', '_schema' etc.,
    2. Page information can be obtained through any components which
    are available in that particular page. For example, in case of
    dynamic page, we need to publish it as a portlet and add it to the
    page. This process creates necessary packages in the DB, but we
    will not have access to the portlet methods.
    So, I would prefer creating a simple DB provider & portlet and access
    page title from its show method as follows -
    //Declare local variable l_page_id, l_page_title as varchar2
    select page_id into l_page_id from wwpob_portlet_instance$ where
    portlet_id = p_portlet_record.portlet_id and
    provider_id = p_portlet_record.provider_id;
    select name into l_page_title from wwpob_page$ where id=l_page_id;
    More information on DB provider can be found at
    http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/articles/understanding.database.providers.html
    Secondly, usage of wwpro_api_parameters.get_value method is
    incorrect. This method expects two arguments -
    <ul>
    <li><b>p_name : </b> The name of the parameter to be returned.</li>
    <li><b>p_reference_path : </b> An unique identifier for a portlet instance on the current page.</li>
    </ul>
    p_reference_path would be something like 99_SNOOP_PORTLET_76535103 and not some type of path as its name suggests.
    The following code fragment fetches all parameters available
    for a portlet.
    Note : Copy this code into 'show' method of your portlet.
    //Declare l_names, l_values as owa.vc_arr
    * Retreive all of the names of parameters for this portlet
    l_names := wwpro_api_parameters.get_names(
    p_reference_path=>p_portlet_record.reference_path);
    * Retreive all of the values of parameters for this portlet
    l_values := wwpro_api_parameters.get_values(p_names=>l_names,
    p_reference_path=>p_portlet_record.reference_path);
    //Loop through these arrays to get parameter information
    htp.p('<center><table BORDER COLS=2 WIDTH="90%" >');
    htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
    htp.tableData(wwui_api_portlet.portlet_heading('Name',1));
    htp.tableData(wwui_api_portlet.portlet_heading('Value',1));
    htp.tableRowClose;
    if l_names.count = 0 then
    htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
    htp.p('<td COLSPAN="2">'
    ||wwui_api_portlet.portlet_text(
    'No portlet parameters were passed on the URL.',1)
    ||'</td>');
    htp.tableRowClose;
    else
    for i in 1..l_names.count loop
    htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
    htp.tableData(l_names(i));
    htp.tableData(l_values(i));
    htp.tableRowClose;
    end loop;
    end if;
    htp.p('</table></center>');
    Hope it helps...
    -aMJAD.

  • How to get the current function name in java

    How to get the current function name in java.
    In c it is done as
    printf("%s",__func__);
    Thanx in advance.

    j0o wrote:
    System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
    "/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
    "/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
    I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes!

  • How to retrieve the all user name from system domain(including login user)?

    Hi, I am trying to get the system domain all users name. But I unable to get the all user name except domain login user name. I used the below code. What I want to do to get the all user name from system domain. Kindly any one help me.
    Properties envVars = new Properties();
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
         if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1 ) || (OS.indexOf("windows xp") > -1) )
              p = r.exec( "cmd.exe /c set" );
         BufferedReader br = new BufferedReader ( new InputStreamReader( p.getInputStream() ) );
         String line;
         while( (line = br.readLine()) != null )
              int idx = line.indexOf( '=' );
              String key = line.substring( 0, idx );
              String value = line.substring( idx+1 );
              envVars.setProperty( key, value );
         String domainDNSName = envVars.getProperty("USERDNSDOMAIN");
         String userName = envVars.getProperty("USERNAME");
         System.out.println("\n\n\n DOMAIN NAME == "+domainDNSName +" USERNAME == "+userName);
    Thanks & Regards
    Palani

    Thanks kajbj,
    I don't know, How many users in domain. I neet to get all the user names from my domain. User like A, B,C,D, E,F. I need to get this users name.
    public class Env {
         public static void main(String[] args) {
              System.out.println("USERDOMAIN: " + System.getenv("USERDOMAIN"));
              System.out.println("USERNAME: " + System.getenv("USERNAME"));
    Here , I am getting the login user name only. So i needs all user name. How to retrive or get this.
    Regards
    Palani

  • How to determine the current update level of the system

    How can we determine the current update level of the system. uname -a shows the release but how to obtain the update level through a program?
    I have this sample program to display the version
    #include <iostream>
    #include <sys/utsname.h>
    #include <dirent.h>
    using namespace std;
    int main()
      struct utsname osinfo;
      // Call uname to get system info, then extract strings.
      uname(&osinfo);
      if (osinfo.machine)  {
        cout<<" Machine : "<<  osinfo.machine;
      if (osinfo.sysname)  {
        cout << "\nOS Name : " << osinfo.sysname;
    if (osinfo.release[0] != '\0')  {
        cout<<"\nRelease : " << osinfo.release;
    }My aim is to check if the Solaris box is 5.10 update 4 or not.
    Edited by: nidhish9 on Nov 27, 2007 5:11 AM

    nidhish9 wrote:
    How can we determine the current update level of the system. uname -a shows the release but how to obtain the update level through a program?
    I have this sample program to display the version
    #include <iostream>
    #include <sys/utsname.h>
    #include <dirent.h>
    using namespace std;
    int main()
    struct utsname osinfo;
    // Call uname to get system info, then extract strings.
    uname(&osinfo);
    if (osinfo.machine)  {
    cout<<" Machine : "<<  osinfo.machine;
    if (osinfo.sysname)  {
    cout << "\nOS Name : " << osinfo.sysname;
    if (osinfo.release[0] != '\0')  {
    cout<<"\nRelease : " << osinfo.release;
    }My aim is to check if the Solaris box is 5.10 update 4 or not.
    Edited by: nidhish9 on Nov 27, 2007 5:11 AMIt's in /etc/release...
    essapd020-u004$ cat /etc/release
                           Solaris 10 8/07 s10s_u4wos_12b SPARC
               Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
                            Use is subject to license terms.
                                Assembled 16 August 2007
    essapd020-u004$ It can be processed with some simple commands:
    essapd020-u004$ cat /etc/release | head -1
                           Solaris 10 8/07 s10s_u4wos_12b SPARC
    essapd020-u004$ cat /etc/release | head -1 | cut -f2 -d_ | cut -c1,2
    u4
    essapd020-u004$ Best,

  • IWork Numbers -- how to determine the current selected column/row?

    I am trying to write a script that grabs some text from a Numbers spreadsheet based on the selected field. I just can't figure how to actually get the column and row in a way I can use. Here's my start:
    tell application "Numbers"
    tell document 1
    -- DETERMINE THE CURRENT SHEET
    set currentsheetindex to 0
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of (tables whose selection range is not missing value)
    end tell
    if x is not 0 then
    set the currentsheetindex to i
    exit repeat
    end if
    end repeat
    if the currentsheetindex is 0 then error "No sheet has a selected table."
    -- GET THE VALUES OF THE SELECTED CELLS
    tell sheet currentsheetindex
    set the current_table to the first table whose selection range is not missing value
    tell the current_table
    set the range_values to the value of every cell of the selection range
    set therange to every cell of the selection range
    set thecol to column of first item of therange
    set therow to row of first item of therange
    end tell
    end tell
    end tell
    end tell
    It gives me a result like
    row "30" of table "table" of sheet "sheet 1" of document "Scheduler.numbers" of application "Numbers"
    but what I need is just "30" so I can use it for my scripts. I can't figure how to convert this to a string or some other useful format.
    Can anyone help? I like Numbers but I always run into little problems like this, something I can't figure how to do, compared with other scriptable programs.

    Search forGetSelParams or better for get_SelParams in the existing threads.
    I posted this handler more than 30 times !
    Yvan KOENIG (VALLAURIS, France) vendredi 18 mars 2011 17:03:05

  • Uix frameset - how to get the current frame name?

    I have a frameset with 3 different frames in it. a top, center and bottom.
    There is a menu in the top frame that changes the contents of the center or bottom frame.
    How can I get the value of the frame name for the current frame into a bound value like a httpsession or page?
    for example if I change the center frame to "listadmin.uix" how can I load a bound value with the frames new source?
    Is there a way to pass javascript to a boundvalue? I could get the frames new properties from javascript

    In Jdev 9.0.3 you could do something like this:<frameBorderLayout>
    <start>
       <frame name="sideFrame">
        <boundAttribute name="source">
         <ctrl:pageURL name="sideFramePage">
          <ctrl:properties>
           <ctrl:property key="currentFrame"
                          value="sideFrame"/>
          </
         </
        </
       </
    </
    </then in startFramePage.uix you can access the current frame name by doing:<styledText data:text="currentFrame@ctrl:page"/>

  • How to know the current jvm name executable ?

    Hi,
    I should want know what is the current jvm executable, from a java program. For exemple c:\foo\bar\bin\java.exe, or /home/foo/bar/java_1.6/jre/bin/java and other.
    With system properties, I can know java home, version, vendor etc of JVM, but how I can know "bin\java.exe" or other ?
    Thanks.

    Yes.
    I see java.runtime.name=Java(TM) SE Runtime Environment, I see the classpath, I see java.runtime.version=1.6.0_14-b08, I see java.home=/home/herve/java/jdk1.6.0_14/jre, but I don't see the name of java programme.
    For me it is something like {java.home}/bin/java. I don't see that in system properties.

  • InfoPath 2013: How to find the current file name?

    Hello,
    Is there any way to find the file name in the rule formulas when an existing xml file in a sharepoint form library is being edited in InfoPath? I am looking for a function that returns the current file name that is being edited.
    Thank you,

    Hi,
    According to your post, my understanding is that you want to get the current file name in the InfoPath form.
    Here is a similar thread for you to take a look at:
    http://social.technet.microsoft.com/Forums/en-US/a24f01d5-744c-4b75-b30d-3295311ab054/how-do-i-find-the-file-name-of-the-currently-open-infopath-form?forum=sharepointcustomizationlegacy
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to get the actual font name from a font file?

    Hi
    I have only the font Path I have to get the font name from that path. Any idea how to get the actual font name?
    Thanks,

    I would ask you these questions:
    Why do you need to do this?  What are you ultimately trying to accomplish?
    Are you really asking about the InDesign SDK?
    Do you really need to get the "name" of a font from an arbitrary file?  Or do you want information about a font installed on the system?  If so, what OS?
    Do you need to be able to handle any font format?
    Which font "name" do you mean?
    What language do you want the name in?
    (1) It's not clear what you're trying to accomplish.  A bit more information about your ultimate goal would be helpful.
    (2) This question is not at all specific to the InDesign SDK.  Are you really trying to do something in the context of an InDesign plug-in?  If so, you probably want to look at IID_IFONTFAMILY and the IFontFamily::GetFamilyName function.
    (3) If you are asking more generally, Windows and Mac both have system API calls to get this information, although those tend to deal with installed system fonts, not with arbitrary font files per se.
    Also, you can parse the name table from a True Type or Open Type font without using any system APIs; as True Type and Open Type are well-documented standards.  I would start by reading these:
    The Naming Table
    Font Names Table
    (4) Although there are other standards, such as Type 1 (PostScript) fonts, and True Type Collection files and other formats, especially on Mac.
    (5) Also, when you start down this road, you will quickly realize that your seemingly simple question is actually ambiguous, and that the answer is kind of complicated, because a font can have many names (a family name, a full font name, a style name, a PostScript name, etc.).
    (6) And not only does a font have multiple names, it can have each of those names in multiple languages and encodings.
    Any clarification would make this a better question.

  • How to get the failover partner name from C++ client

    Hi All,
    I have configured the mirroring session for my application.
    I want to modify the connection string with failover partner name.
    Could any one please let me to know how to get the failover partner instance from C++ client dynamically.
    Thanks,
    Prasad.

    Are you looking for this?
    http://www.connectionstrings.com/sql-server-2012/
    http://stackoverflow.com/questions/25534972/auto-failover-multiple-connections-to-mirror-database-when-principal-goes-down

  • How to determine the download media required from my License key?

    Hi
    After recently rebuilding a dead PC,  The user has advised me she used to use Illustrator.
    Unfortunately the user does not have the install media available.
    Support advised my license key is a volume license for Design Standard.
    I have downloaded Design Standard (Universal) but the Licence key is not accepted.
    Can anyone advise how to determine the correct download based on my License key?
    Many thanks

    Some times you may need to sign in to volume licensing account and download
    refer
    Adobe Licensing Website | Serial numbers | Orders | Accounts

  • How to determine the Country and Organization from IP

    Hi,
    I would like to determine the Country and Organization from a given IP. I have to write a JSP, which when given the IP address gives the country and the organization to which the IP belongs. The organization may be the ISP, or a MNC or any other corporate/government body, or it may be of an individual. I have to do it progamitically from inside a JSP?
    Any suggestions anybody
    Thanks in Advance for your reply

    even when tracking IP's, if it is static you can narrow it down pretty far - if it's dynamic, you can only narrow it down to a specific part of the country.

  • How to get the current class name in static method?

    Hi,
    I'd like to get the current class name in a static method. This class is intended to be extended. So I would expect that the subclass need not to override this method and at the runtime, the method can get the subclass name.
    getClass() doesn't work, because it is not a static method.
    I would suggest Java to make getClass() static. It makes sense.
    But in the mean time, does anybody give an idea to work around it?
    Thank you,
    Bill

    Why not create an instance in a static method and use getClass() of the instance?
    public class Test {
       public static Class getClassName() {
          return new Test().getClass();

Maybe you are looking for