Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2013-06-20T10:21:42Z by SRIEAI
daniel64
daniel64
5 Posts
ACCEPTED ANSWER

Pinned topic [DEV] How to retrieve service module name in Java implementation...

‏2012-03-12T16:17:35Z |
Hello,
I have a Java component, I would like to retrieve the service module name within a Java implementation as import component... I canonly get the current component (ServiceManager.INSTANCE.getComponent()) but I can't understand how to retrieve the running module...??...

Any idea ?
Thanks.

Daniel.
Updated on 2013-02-12T18:10:04Z at 2013-02-12T18:10:04Z by sbhatta6
  • ak1973
    ak1973
    7 Posts
    ACCEPTED ANSWER

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-12T19:50:14Z  in response to daniel64
    Hi;

    Did you try processInstance().getDisplayName() or processInstance().getName()??

    I guess these are part of com.ibm.bpe.api package to get process instance data in BPEL module.
    iak
  • Ronn78
    Ronn78
    12 Posts
    ACCEPTED ANSWER

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-12T20:15:05Z  in response to daniel64
    Hi,

    Try this -->
    SCAServices scaServices = this.getSCAServices();
    String serviceName = scaServices.getModuleName();
    System.out.println("Service Name: " + serviceName);

    Make sure to include this in Java Imports Tab-->

    import com.ibm.wsspi.sibx.mediation.esb.SCAServices;

    Thanks
    • daniel64
      daniel64
      5 Posts
      ACCEPTED ANSWER

      Re: [DEV] How to retrieve service module name in Java implementation...

      ‏2012-03-15T09:11:50Z  in response to Ronn78
      Hello,

      Thanks for your responses.
      Unfortunaltely, they both don't work as:
      - I don't use BPEL
      - the Java class is not an implementation of a primitive in the mediation flow

      To be more precise, see the location of the JavaComponent in the diagram attached.
      The generated code is the follwing:
      
      
      
      import com.ibm.websphere.sca.ServiceManager;   
      
      public 
      
      class JavaComposantImpl 
      { 
      /** * Default constructor. */ 
      
      public JavaComposantImpl() 
      { 
      
      super(); 
      }   
      /** * Return a reference to the component service instance for this implementation * class.  This method should be used when passing this service to a partner reference * or if you want to invoke this component service asynchronously. * * @generated (com.ibm.wbit.java) */ @SuppressWarnings(
      "unused") 
      
      private Object getMyService() 
      { 
      
      return (Object) ServiceManager.INSTANCE.locateService(
      "self"); 
      }   
      /** * Method generated to support implementation of operation "testoperation" defined for WSDL port type * named "Interface". * * Please refer to the WSDL Definition for more information * on the type of input, output and fault(s). */ 
      
      public String testoperation(Boolean input) 
      { 
      //TODO Needs to be implemented. 
      
      return 
      
      null; 
      }   
      }
      


      I would like to retrieve the running module name in the testoperation method of this class.

      Thanks.
      Daniel.
      • Ronn78
        Ronn78
        12 Posts
        ACCEPTED ANSWER

        Re: [DEV] How to retrieve service module name in Java implementation...

        ‏2012-03-15T19:24:16Z  in response to daniel64
        Ok.. I believe this is outside your scope to get what you want. I would say get the service name in mediation and pass it to Java component.My two cents...
        Thanks.
  • sbhatta6
    sbhatta6
    1 Post
    ACCEPTED ANSWER

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2013-02-12T18:10:04Z  in response to daniel64
    Not sure if it will help you anymore as it's been a long time since you posted this question. I faced a similar problem yesterday. I am using a mediation module and a custom data handler to process outgoing data. I needed to access the module name from the data handler code. I created a class with a static variable and from within the mediation module I set the modulename in the static variable of the class. From within the data handler, I access the same static member of the class and get the module name back.

    Sanjay
    • This reply was deleted by SRIEAI 2013-06-20T10:20:43Z.
    • SRIEAI
      SRIEAI
      2 Posts
      ACCEPTED ANSWER

      Re: [DEV] How to retrieve service module name in Java implementation...

      ‏2013-06-20T10:21:42Z  in response to sbhatta6

      Hi,

       

      use the below code in custom mediation primitive

       


      import com.ibm.ws.sca.internal.container.Container;


      String module = Container.INSTANCE.getModule().getModule().getName();

      Thanks,

      Srikanth