我要评分
获取效率
正确性
完整性
易理解

Determining and Modifying WebLogic Private Functions

Determining WebLogic Private Functions

In addition to standard Java EE interfaces, WebLogic provides some private functions. For developers, WebLogic provides some private APIs, configuration files, and configuration options. Related content needs to be modified on TomEE.

  • Modify the private API.

    The package names of private APIs start with com.bea, com.oracle, commonj, oracle, or weblogic. During the porting process, you can use a regular expression (import [com\.bea|com\.oracle|common|oracle|weblogic]) to check whether the source code calls the related interface.

    If private APIs are used, analyze the code functions of the private APIs. It is recommended that standard APIs be used to implement the same functions.

  • Modify the private configuration file.

    In addition to standard configuration files, WebLogic has some private configuration files. The names of the private configuration files start with "weblogic", for example, weblogic.xml and weblogic-application.xml. You can search for the configuration files globally.

    The WebLogic private configuration file is used to support the WebLogic private API. Therefore, if the WebLogic private API is used, you need to analyze the private configuration file and replace the private API. If the WebLogic private API is not used, there is no private WebLogic configuration file.

Modifying Private Configuration Options

The configuration options in the same configuration file may vary with WebLogic and TomEE. The main difference lies in the configuration of the Java EE components or the configuration of the cluster, for example, the meta-inf/persistence.xml file related to JPA persistence.

The configuration options are WebLogic private configuration options because the implementation classes need to be specified for some configurations. For example, the class used to implement the JPA function and driver used by JDBC. You need to check whether the WebLogic private configuration is used (check whether the configuration options contain the strings related to the WebLogic, BEA, and Oracle.)

The official TomEE website provides some examples of modifying specific WebLogic configuration options. If there are specific WebLogic configuration options, see http://tomee.apache.org/latest/examples/.

The following describes how to modify private configuration options by creating a database, specifying the correct JDBC data source, and performing related configurations.

  1. Modify META-INF/persistence.xml.
    • Before:
      <persistence-unit name="annotationServlet" transaction-type="RESOURCE_LOCAL">
          <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
          <class>examples.webapp.servlets.annotations.Visitor</class>
          <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/examples;create=true"/>
            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
            <property name="javax.persistence.jdbc.user" value="examples"/>
            <property name="javax.persistence.jdbc.password" value="examples"/>
            <property name="eclipselink.ddl-generation" value="create-tables"/>
          </properties>
        </persistence-unit>
    • After:
      <persistence-unit name="annotationServlet" transaction-type="RESOURCE_LOCAL">
          <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
              <non-jta-data-source>MySQL_Database</non-jta-data-source>
              <class>examples.webapp.servlets.annotations.Visitor</class>
              <properties>
                <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
              </properties>
        </persistence-unit>
  2. Create the example_mysql database and copy the corresponding MySQL connection driver (for example, mysql-connector-Java-8.0.19.jar) to the lib directory of TomEE.
  3. Specify the JDBC data source. Add the tomee.xml file to the conf directory. The file content is as follows:
    <Resource id="MySQL_Database" type="DataSource">
        JdbcDriver=com.mysql.jdbc.Driver
        JdbcUrl=jdbc:mysql://localhost:3306/example
        UserName=root
        password=admin
        JtaManaged=false
    </Resource>