Abhishek
Abhishek

Reputation: 698

How to extract Deployed OSB Source code from Environment or SB Console or Weblogic

Could anyone please help me in getting a way to get the source code from Environment or SB Console or Weblogic.

I created the python script whick exports the JAR, but I need the source code. Because if I unjar the jar, I do not get the exact source code, as file names are shorten and some code is added by itself in wsdls, xqueries etc. I don't want that.

Here's my wlst Python/Jython Script:

    from java.io import FileInputStream
    from java.io import FileOutputStream
    from java.util import ArrayList
    from java.util import Collections
    from com.bea.wli.sb.util import EnvValueTypes
    from com.bea.wli.config.env import EnvValueQuery;
    from com.bea.wli.config import Ref
    from com.bea.wli.config.customization import Customization
    from com.bea.wli.config.customization import FindAndReplaceCustomization
  import sys

#=======================================================================================
# Utility function to load properties from a config file
#=======================================================================================
def exportAll(exportConfigFile):


def exportAll(exportConfigFile):
        try:
            print "Loading export config from :", exportConfigFile
            exportConfigProp = loadProps(exportConfigFile)
            adminUrl = exportConfigProp.get("adminUrl")
            exportUser = exportConfigProp.get("exportUser")
            exportPasswd = exportConfigProp.get("exportPassword")

            exportJar = exportConfigProp.get("exportJar")
            customFile = exportConfigProp.get("customizationFile")

            passphrase = exportConfigProp.get("passphrase")
            project = sys.argv[2]
            if project == None :
               project = exportConfigProp.get("project")

            connectToServer(exportUser, exportPasswd, adminUrl)

            ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
            print "ALSBConfiguration MBean found"

            print "Input project: ", project
            if project == None :
                ref = Ref.DOMAIN
                collection = Collections.singleton(ref)
                if passphrase == None :
                    print "Export the config"
                    theBytes = ALSBConfigurationMBean.exportProjects(collection, None)
                else :
                    print "Export and encrypt the config"
                    theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
            else :
                ref = Ref.makeProjectRef(project);
                print "Export the project", project
                collection = Collections.singleton(ref)
                theBytes = ALSBConfigurationMBean.export(collection, false, None)

            aFile = File(exportJar)
            out = FileOutputStream(aFile)
            out.write(theBytes)
            out.close()
            print "ALSB Configuration file: "+ exportJar + " has been exported"
            if customFile != None:
                print collection
                query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
                customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
                print 'EnvValueCustomization created'
                customList = ArrayList()
                customList.add(customEnv)
                print customList
                aFile = File(customFile)
                out = FileOutputStream(aFile)
                Customization.toXML(customList, out)
                out.close()

            print "ALSB Dummy Customization file: "+ customFile + " has been created"
        except:
            raise

    #=======================================================================================
    # Utility function to load properties from a config file
    #=======================================================================================

    def loadProps(configPropFile):
        propInputStream = FileInputStream(configPropFile)
        configProps = Properties()
        configProps.load(propInputStream)
        return configProps

    #=======================================================================================
    # Connect to the Admin Server
    #=======================================================================================

    def connectToServer(username, password, url):
        connect(username, password, url)
        domainRuntime()


    # EXPORT script init
    try:
        exportAll(sys.argv[1])

    except:
        print "Unexpected error: ", sys.exc_info()[0]
        dumpStack()
        raise

Any help would be appreciated.

Upvotes: 0

Views: 995

Answers (1)

Jang-Vijay Singh
Jang-Vijay Singh

Reputation: 732

What you get as a result of the export is the deployed unit. Yes, there is some metadata added/modified as a result of the deployment on the OSB runtime (deployment could also mean creating/editing components directly on the servicebus console).

To get it back as "source code" from the exported jar, you can simply import it back into JDeveloper (12c) or Eclipse with OEPE (11g)

Upvotes: 3

Related Questions