Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
tomecode committed Feb 16, 2017
1 parent 715267e commit 392e4da
Show file tree
Hide file tree
Showing 8 changed files with 610 additions and 0 deletions.
131 changes: 131 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tomecode.oracle.osb12c</groupId>
<artifactId>osb12c-xquery-warmup</artifactId>
<version>0.0.1-SNAPSHOT</version>


<properties>
<wls12cHome>c:/Oracle/FMW12c1221/wlserver</wls12cHome>
<osb12cHome>c:/Oracle/FMW12c1221/osb</osb12cHome>
<common12cHome>c:/Oracle/FMW12c1221/oracle_common</common12cHome>
</properties>

<dependencies>
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${wls12cHome}/server/lib/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.servicebus.configfwk</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${osb12cHome}/lib/modules/oracle.servicebus.configfwk.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.servicebus.resources.xquery</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${osb12cHome}/lib/modules/oracle.servicebus.resources.xquery.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.servicebus.services.core</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${osb12cHome}/lib/modules/oracle.servicebus.services.core.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.servicebus.resources.core</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${osb12cHome}/lib/modules/oracle.servicebus.resources.core.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.servicebus.kernel-api</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${osb12cHome}/lib/modules/oracle.servicebus.kernel-api.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.common</groupId>
<artifactId>xqjapi</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${common12cHome}/modules/oracle.xdk/xqjapi.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.common</groupId>
<artifactId>xqjapi</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${common12cHome}/modules/oracle.xdk/xqjapi.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.common</groupId>
<artifactId>com.bea.core.xquery</artifactId>
<version>12c</version>
<scope>system</scope>
<systemPath>${common12cHome}/modules/com.bea.core.xquery_1.8.0.0.jar</systemPath>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>ear</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<archiverConfig>
<appxml>${basedir}/src/main/ear/META-INF/application.xml</appxml>
</archiverConfig>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Specification-Version>1.0</Specification-Version>
<Implementation-Version>${project.version}-${maven.build.timestamp}</Implementation-Version>
<Class-Path>APP-INF/lib/${project.artifactId}.jar</Class-Path>
</manifestEntries>
</archive>
<descriptors>
<descriptor>${basedir}/src/main/assembly/ear.xml</descriptor>
</descriptors>
<finalName>${project.artifactId}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
23 changes: 23 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# osb12c-xquery-warmup
Recompile/warm-up any XQueries at runtime in the OSB 12c

# What is it
- a simple application (packaged as EAR) deployed in OSB/WLS
- activated when the OSB starting or XQuery is/was deployed (or if something is/was changed in XQuery and session is/was activated)
- pre-compile/execute Xquery with dummy arguments - warm-up

# Install
- Download latest version of application...
- Deploy it as enterprise application: _'Install this deployment as an application'_
- Deployment Order: 20
- Restart the OSB.

# Development
- Build is based on the Maven
- JVM 1.8
- in pom.xml change path for following properties:
| Plugin | README |
| wls12cHome | path to FMW WLS 12c home |
| osb12cHome | path to FMW OSB 12c home |
| common12cHome | path to FMW 12c Oracle Common home |
- mvn clean install
23 changes: 23 additions & 0 deletions src/main/assembly/ear.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>ear</id>
<formats>
<format>ear</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<includeSiteDirectory>false</includeSiteDirectory>
<files>
<file>
<source>${basedir}/src/main/ear/META-INF/weblogic-application.xml</source>
<outputDirectory>/META-INF/</outputDirectory>
</file>
<file>
<source>${basedir}/target/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>/APP-INF/lib/</outputDirectory>
<destName>${project.artifactId}.jar</destName>
</file>
</files>
</assembly>
10 changes: 10 additions & 0 deletions src/main/ear/META-INF/application.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
'-//Sun Microsystems, Inc.//DTD J2EE Application 1.4//EN'
'http://java.sun.com/dtd/application_1_4.dtd'>
<application>
<display-name>osb12c-xquery-warmup</display-name>
<module>
<java>/APP-INF/lib/osb12c-xquery-warmup.jar</java>
</module>
</application>
12 changes: 12 additions & 0 deletions src/main/ear/META-INF/weblogic-application.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.3/weblogic-application.xsd">


<wls:listener>
<wls:listener-class>com.tomecode.oracle.osb12c.warmup.OsbXqueryWamUpLifecycleListener</wls:listener-class>
</wls:listener>

</wls:weblogic-application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.tomecode.oracle.osb12c.warmup;

import java.security.PrivilegedExceptionAction;

import com.bea.wli.config.ConfigService;
import com.bea.wli.config.spi.ResourceLifecycleListener;
import com.bea.wli.sb.ALSBConfigService;

import weblogic.application.ApplicationLifecycleEvent;
import weblogic.application.ApplicationLifecycleListener;
import weblogic.logging.NonCatalogLogger;

/**
* Application listener
*
* @author Tome
*
*/
public final class OsbXqueryWamUpLifecycleListener extends ApplicationLifecycleListener {

private static final NonCatalogLogger logger = new NonCatalogLogger("OsbXqueryWarmUpListener");

public final void postStart(ApplicationLifecycleEvent evt) {

try {

weblogic.security.Security.runAs(weblogic.security.SubjectUtils.getAnonymousUser(), new PrivilegedExceptionAction<Object>() {

@Override
public final Object run() throws Exception {

ConfigService configService = ALSBConfigService.get().getConfigService();

boolean exists = false;
for (ResourceLifecycleListener listener : configService.getResourceLifecycleListeners()) {
if (listener instanceof XqueryWarmUp) {
exists = true;
}
}

if (!exists) {
// register new listener
configService.registerResourceLifecycleListener(new XqueryWarmUp());
logger.info("OSB XQuery Warm-Up was registered in OSB!");
}
return null;
}
});
} catch (Exception e) {
logger.error("Faile registed OSB XQuery Warm-Up listener in OSB, reason: " + e.getMessage(), e);
}

}
}
74 changes: 74 additions & 0 deletions src/main/java/com/tomecode/oracle/osb12c/warmup/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.tomecode.oracle.osb12c.warmup;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.xmlbeans.XmlObject;

import com.bea.wli.config.Ref;

/**
* Utilities
*
* @author Tome
*
*/
public final class Utils {
/**
* dummy empty message
*/
public static final XmlObject DUMMY_MESSAGE = dummyMessage();

private static final XmlObject dummyMessage() {
try {
return XmlObject.Factory.parse("<soap:Body xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope/\"><AnyElement/></soap:Body>");
} catch (Exception e) {
throw new RuntimeException("Failed to unitialize dummmy body!, reason: " + e.getMessage(), e);
}
}

/**
* format delta time
*
* @param td
* @return
*/
public static final String formatDeltaTime(long td) {
td = td / 1000;
int h = (int) (td / (3600));
int m = (int) ((td - (h * 3600)) / 60);
int s = (int) (td - (h * 3600) - m * 60);
return String.format("%02d:%02d:%02d", h, m, s);
}

/**
* split array of refs to sub-arrays
*
* @param originalArray
* @param chunkSize
* @return
*/
public static final List<Ref[]> splitRefs(Ref[] originalArray, int chunkSize) {
List<Ref[]> listOfArrays = new ArrayList<Ref[]>();
int totalSize = originalArray.length;
if (totalSize < chunkSize) {
chunkSize = totalSize;
}
int from = 0;
int to = chunkSize;

while (from < totalSize) {
Ref[] partArray = Arrays.copyOfRange(originalArray, from, to);
listOfArrays.add(partArray);

from += chunkSize;
to = from + chunkSize;
if (to > totalSize) {
to = totalSize;
}
}
return listOfArrays;
}

}
Loading

0 comments on commit 392e4da

Please sign in to comment.