Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member182372
Active Contributor
0 Kudos

Introduction


In this blog I will describe how 2 Eclipse plug-ins (and actually one tool which is used by one of plug-in) helped me to solve couple of questions on SDN forums.


The plug-ins we are talking about are JadEclipse and JAR Class Finder .




The JAR Class Finder usage is pretty good described on SDN:





So, if you would like to use plug-ins, just download, unpack to plugin folder in NWDS, restart IDE and do following:




For JAR Class Finder follow instructions described in Using JAR Class Finder blog;


For JadEclipse: set JadClipse as <b>Windows->Preferences->Workbench->File Associations</b> as default editor for *.class extension. Check <b>Output original lines number as comments</b> and <b>Align code for debugging</b> checkboxes at <b>Windows->Preferences->Java->JadClipse->Debug</b>. Check <b>Turn off the support of inner class</b> checkbox at <b>Windows->Preferences->Java->JadClipse->Directives</b>.</li>
</ul>


Story #1: how to list the datasource which is configured in visual administration?


The question was originally posted how to list the datasource  which is configed in visual administration ?.



So, what is the sequence? We all know that visual administrator contains <b>JDBC Connector</b> service view which contains exactly the same data as requested. If we check <b>Additional Info</b> tab we will see that name of service is <b>dbpool</b>.



Well, we go to C:usrsapJ2EJC00j2eeclusterserver0 inservicesdbpool and see 3 jar files. dbpool.jar looks appropriate for us. We open it and checking content. From my experience the entry point for WAS service is so-called "frame" (<b>ApplicationServiceFrame</b> class extension). We see <b>PoolFrame</b> class in <b>com.sap.engine.services.dbpool</b> package. We extract it from jar file and "jad" it (jad *.class). We need to find a place where service implementation is instantiated in <b>start()</b> method and what is the class name for service implementation. We can see that it is <b>DataSourceManagerImpl</b>. We extract <b>DataSourceManagerImpl</b>, "jad" it and going through content to find a method appropriate for us. And we find it, it is <b>getDataSources()</b> and it returns <b>Hashtable</b>. But <b>Hashtable</b> of what? Let's investigate. It returns <b>containerImpl.appsDescr</b>. We can see that <b>containerImpl</b> is of type <b>ContainerImpl</b> class. Let`s rip it too. We need to find a place where the values are putted to <b>Hashtable</b>. And we find this place: <b>appsDescr.put(appName, dsVtr);</b> <b>appName</b> is String and <b>dsVtr</b> is Vector. But Vector of what :smile: ? Let`s check again. And after check we see that vector contains <b>JDBCDescriptor</b> class.





So, to use this functionality we need to specify service reference to <b>dbpool</b> service, add jar file (founded by JAR Class Finder plug-in) with all files we need (<b>DataSourceManager</b>, <b>JDBCDescriptor</b>) and put the code as I suggested in forum.
</p>


Story #2: How to get server status and programmatically restart cluster?


The question was originally posted Programmatically restart cluster and How to get server status.




As we know NWDS contains a <b>J2EE Engine</b> view. This view allows us to see server tree with properties and manage parts of it - restart, enable debugging etc. So, the view is doing exactly what we need.





All NWDS plug-ins are located in <root>SAPJDTeclipseplugins folder. After some "scanning" we can find com.sap.ide.eclipse.j2ee.engine plugin. Open plugin.jar, and finding <b>ClusterShutdown</b> class (for example). "Jad" it and see that shutdown is done by following code:





JStartupClusterController controller = …;
controller.shutdownClusterAsync(false);

 



Now we need a way how to get <b>JStartupClusterController</b> instance. After some investigation we find a class <b>AbstractEngineInstallation</b> and method <b>getClusterController()</b> containing exactly what we need:




JStartupClusterControllerFactory clusCtrlFac =
JStartupInitialFactory.
getInitialFactory().
getClusterControllerFactory();
clusterController = clusCtrlFac.getClusterController(msHost, msPort);

 



So, now we know how to get cluster controller and can get information about it or perform an action on it as described in my post on forum.


Story #3: How to get WAS Installation Number and System Id?


Question was published How to get WAS Installation Number and  System Id?.



The way how to get SID is well known and is not a issue at all:




String systemID = System.getProperty("SAPSYSTEMNAME");

 



But installation number is something we need to research to obtain. We have a entry point - <b>System Information</b> application (available through http://<SERVER>:<PORT>/sap/monitoring/SystemInfo). There is a section <b>Licenses</b> and <b>Installation Number</b> field. So, the only thing we need - find where is the source for this servlet or JSP and what code returns the installation number.



Trying to find a file containing <b>systeminfo</b> under C:usrsapJ2EJC00j2eeclusterserver0apps folder and finding C:usrsapJ2EJC00j2eeclusterserver0appssap.com     cmonitoringsysteminfo. Open it and navigate to C:usrsapJ2EJC00j2eeclusterserver0appssap.com     cmonitoringsysteminfoservlet_jspsapmonitoring
oot
and see SystemInfo.jsp. Open it, looking for <b>Installation Number</b> and see the code:Find the <b>SystemInfoFactory</b> class under C:usrsapJ2EJC00j2eeclusterserver0appssap.com     cmonitoringsysteminfoservlet_jspsapmonitoring
ootWEB-INFclassescomsapenginemonitorinfoapp
, "jad" it and check <b>getInfo()</b> method:




public static SystemInfo getInfo() throws SystemInfoException
{
return getFactory().getSystemInfo();
}

 



And <b>getFactory()</b> method:




static SystemInfoFactory getFactory() throws SystemInfoException
{
SystemInfoFactory theFactory = factory;
if(theFactory == null)
{
theFactory = new SystemInfoFactory();
factory = theFactory;
}
return theFactory;
}

 



So, it is singleton and we need to check constructor. In constructor we can see the way how to get the information we need:




mbsc = (MBeanServerConnection)ctx.lookup("jmx");
ObjectName kernelQuery =
ObjectNameFactory.
getPatternForServerChildPerNode("SAP_J2EEKernelPerNode", null, null);

 



And in <b>getInstallationNumber()</b> method:




String number = null;
number = (String)mbsc.getAttribute(LICENSING_SERVICE_ON, "InstNo");

 



The only thing we need to do is to find jar with classes (using JAR Class Finder) and ad it to classpath, add reference to <b>tc~jmx</b> library and provide a authorized user to execute the code.</p>


Conclusion


After this blog I hope you will be able to reuse functionality from J2EE services on SAP J2EE WAS, J2EE applications running on SAP J2EE WAS and Eclipse plugins from NWDS.

2 Comments