Pages

Saturday, August 23, 2014

When I want to get the list of services in a Package, I will use below code


Java service -

i/p pipeline - package (string)
o/p pipeline - services (string list)


IDataCursor idatacursor = pipeline.getCursor();
        String s = IDataUtil.getString(idatacursor, "package");
        int i = s.lastIndexOf(File.separator) + 1;
        String s1 = s.substring(i);
        IData idata1 = IDataFactory.create();
        IDataCursor idatacursor1 = idata1.getCursor();
        IDataUtil.put(idatacursor1, "showServices", "true");
        IDataUtil.put(idatacursor1, "package", s1);
        IData idata2 = IDataFactory.create();
        String as[] = null;
        try
        {
            IData idata3 = Service.doInvoke("wm.server.packages.adminui", "packageInfo", idata1);
            IDataCursor idatacursor2 = idata3.getCursor();
            as = IDataUtil.getStringArray(idatacursor2, "services");
            idatacursor2.destroy();
        }
        catch(Exception exception) { }
        IDataUtil.put(idatacursor, "services", as);
        IDataUtil.put(idatacursor, "index", (new StringBuilder()).append("").append(s1).toString());
        idatacursor.destroy();


Runtime - Give the package name as the input. Output will be list of all services in that package.

hmmm... may be I can enhance above code, to use characters(%,*,?) in the package name? Yes, it will be handy.


cheers!

4 comments:

  1. no need for Java service.
    The inbuilt service can be directly used.

    ReplyDelete
  2. What is the inbuilt service name? can you please tell

    ReplyDelete
  3. Hi naidu , I am getting error for this line:-

    int i = s.lastIndexOf(File.separator) + 1; as File cannot be resolved as a variable

    ReplyDelete
  4. I need one clarification.I am getting flat file schemas also as part of the services in the output

    ReplyDelete