18 changed files with 822 additions and 632 deletions
@ -1,88 +0,0 @@
@@ -1,88 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.instrument.classloading.oc4j; |
||||
|
||||
import java.lang.instrument.ClassFileTransformer; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
import java.lang.reflect.Method; |
||||
import java.lang.reflect.Proxy; |
||||
|
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* Reflective wrapper around a OC4J class loader. Used to |
||||
* encapsulate the classloader-specific methods (discovered and |
||||
* called through reflection) from the load-time weaver. |
||||
* |
||||
* @author Costin Leau |
||||
*/ |
||||
class OC4JClassLoaderAdapter { |
||||
|
||||
private static final String CL_UTILS = "oracle.classloader.util.ClassLoaderUtilities"; |
||||
private static final String PREPROCESS_UTILS = "oracle.classloader.util.ClassPreprocessor"; |
||||
|
||||
private final ClassLoader classLoader; |
||||
private final Class<?> processorClass; |
||||
private final Method addTransformer; |
||||
private final Method copy; |
||||
|
||||
public OC4JClassLoaderAdapter(ClassLoader classLoader) { |
||||
try { |
||||
// Since OC4J 10.1.3's PolicyClassLoader is going to be removed,
|
||||
// we rely on the ClassLoaderUtilities API instead.
|
||||
Class<?> utilClass = classLoader.loadClass(CL_UTILS); |
||||
this.processorClass = classLoader.loadClass(PREPROCESS_UTILS); |
||||
|
||||
this.addTransformer = utilClass.getMethod("addPreprocessor", new Class[] { ClassLoader.class, |
||||
this.processorClass }); |
||||
this.copy = utilClass.getMethod("copy", new Class[] { ClassLoader.class }); |
||||
|
||||
} catch (Exception ex) { |
||||
throw new IllegalStateException( |
||||
"Could not initialize OC4J LoadTimeWeaver because OC4J API classes are not available", ex); |
||||
} |
||||
|
||||
this.classLoader = classLoader; |
||||
} |
||||
|
||||
public void addTransformer(ClassFileTransformer transformer) { |
||||
Assert.notNull(transformer, "ClassFileTransformer must not be null"); |
||||
try { |
||||
OC4JClassPreprocessorAdapter adapter = new OC4JClassPreprocessorAdapter(transformer); |
||||
Object adapterInstance = Proxy.newProxyInstance(this.processorClass.getClassLoader(), |
||||
new Class[] { this.processorClass }, adapter); |
||||
this.addTransformer.invoke(null, new Object[] { this.classLoader, adapterInstance }); |
||||
} catch (InvocationTargetException ex) { |
||||
throw new IllegalStateException("OC4J addPreprocessor method threw exception", ex.getCause()); |
||||
} catch (Exception ex) { |
||||
throw new IllegalStateException("Could not invoke OC4J addPreprocessor method", ex); |
||||
} |
||||
} |
||||
|
||||
public ClassLoader getClassLoader() { |
||||
return this.classLoader; |
||||
} |
||||
|
||||
public ClassLoader getThrowawayClassLoader() { |
||||
try { |
||||
return (ClassLoader) this.copy.invoke(null, new Object[] { this.classLoader }); |
||||
} catch (InvocationTargetException ex) { |
||||
throw new IllegalStateException("OC4J copy method failed", ex.getCause()); |
||||
} catch (Exception ex) { |
||||
throw new IllegalStateException("Could not copy OC4J classloader", ex); |
||||
} |
||||
} |
||||
} |
||||
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.instrument.classloading.oc4j; |
||||
|
||||
import java.lang.instrument.ClassFileTransformer; |
||||
import java.lang.instrument.IllegalClassFormatException; |
||||
import java.lang.reflect.InvocationHandler; |
||||
import java.lang.reflect.Method; |
||||
import java.security.ProtectionDomain; |
||||
|
||||
/** |
||||
* Adapter that implements OC4J ClassPreProcessor interface, delegating to a |
||||
* standard JDK {@link ClassFileTransformer} underneath. |
||||
* |
||||
* <p>To avoid compile time checks again the vendor API, a dynamic proxy is |
||||
* being used. |
||||
* |
||||
* @author Costin Leau |
||||
*/ |
||||
class OC4JClassPreprocessorAdapter implements InvocationHandler { |
||||
|
||||
private final ClassFileTransformer transformer; |
||||
|
||||
/** |
||||
* Creates a new {@link OC4JClassPreprocessorAdapter}. |
||||
* @param transformer the {@link ClassFileTransformer} to be adapted (must |
||||
* not be {@code null}) |
||||
*/ |
||||
public OC4JClassPreprocessorAdapter(ClassFileTransformer transformer) { |
||||
this.transformer = transformer; |
||||
} |
||||
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
||||
String name = method.getName(); |
||||
|
||||
if ("equals".equals(name)) { |
||||
return (Boolean.valueOf(proxy == args[0])); |
||||
} else if ("hashCode".equals(name)) { |
||||
return hashCode(); |
||||
} else if ("toString".equals(name)) { |
||||
return toString(); |
||||
} else if ("initialize".equals(name)) { |
||||
initialize(proxy, (ClassLoader) args[0]); |
||||
return null; |
||||
} else if ("processClass".equals(name)) { |
||||
return processClass((String) args[0], (byte[]) args[1], (Integer) args[2], (Integer) args[3], |
||||
(ProtectionDomain) args[4], (ClassLoader) args[5]); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown method: " + method); |
||||
} |
||||
} |
||||
|
||||
// maps to oracle.classloader.util.ClassPreprocessor#initialize
|
||||
// the proxy is passed since it implements the Oracle interface which
|
||||
// is asked as a return type
|
||||
public Object initialize(Object proxy, ClassLoader loader) { |
||||
return proxy; |
||||
} |
||||
|
||||
public byte[] processClass(String className, byte origClassBytes[], int offset, int length, ProtectionDomain pd, |
||||
ClassLoader loader) { |
||||
try { |
||||
byte[] tempArray = new byte[length]; |
||||
System.arraycopy(origClassBytes, offset, tempArray, 0, length); |
||||
|
||||
// NB: OC4J passes className as "." without class while the
|
||||
// transformer expects a VM, "/" format
|
||||
byte[] result = this.transformer.transform(loader, className.replace('.', '/'), null, pd, tempArray); |
||||
return (result != null ? result : origClassBytes); |
||||
} catch (IllegalClassFormatException ex) { |
||||
throw new IllegalStateException("Cannot transform because of illegal class format", ex); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder builder = new StringBuilder(getClass().getName()); |
||||
builder.append(" for transformer: "); |
||||
builder.append(this.transformer); |
||||
return builder.toString(); |
||||
} |
||||
} |
||||
@ -1,79 +0,0 @@
@@ -1,79 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.instrument.classloading.oc4j; |
||||
|
||||
import java.lang.instrument.ClassFileTransformer; |
||||
|
||||
import org.springframework.instrument.classloading.LoadTimeWeaver; |
||||
import org.springframework.util.Assert; |
||||
import org.springframework.util.ClassUtils; |
||||
|
||||
/** |
||||
* {@link LoadTimeWeaver} implementation for OC4J's instrumentable ClassLoader. |
||||
* Requires Oracle OC4J version 10.1.3.1 or higher. |
||||
* |
||||
* <p>Many thanks to <a href="mailto:mike.keith@oracle.com">Mike Keith</a> |
||||
* for his assistance. |
||||
* |
||||
* @author Costin Leau |
||||
* @author Juergen Hoeller |
||||
* @since 2.0 |
||||
* @deprecated as of Spring 3.2, in favor of |
||||
* {@link org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver} |
||||
* since Oracle end-of-lifed OC4J in favor of WebLogic |
||||
*/ |
||||
@Deprecated |
||||
public class OC4JLoadTimeWeaver implements LoadTimeWeaver { |
||||
|
||||
private final OC4JClassLoaderAdapter classLoader; |
||||
|
||||
|
||||
/** |
||||
* Creates a new instance of thie {@link OC4JLoadTimeWeaver} class
|
||||
* using the default {@link ClassLoader class loader}. |
||||
* @see org.springframework.util.ClassUtils#getDefaultClassLoader() |
||||
*/ |
||||
public OC4JLoadTimeWeaver() { |
||||
this(ClassUtils.getDefaultClassLoader()); |
||||
} |
||||
|
||||
/** |
||||
* Creates a new instance of the {@link OC4JLoadTimeWeaver} class
|
||||
* using the supplied {@link ClassLoader}. |
||||
* @param classLoader the {@code ClassLoader} to delegate to for weaving |
||||
*/ |
||||
public OC4JLoadTimeWeaver(ClassLoader classLoader) { |
||||
Assert.notNull(classLoader, "ClassLoader must not be null"); |
||||
this.classLoader = new OC4JClassLoaderAdapter(classLoader); |
||||
} |
||||
|
||||
|
||||
public void addTransformer(ClassFileTransformer transformer) { |
||||
Assert.notNull(transformer, "Transformer must not be null"); |
||||
// Since OC4J 10.1.3's PolicyClassLoader is going to be removed,
|
||||
// we rely on the ClassLoaderUtilities API instead.
|
||||
this.classLoader.addTransformer(transformer); |
||||
} |
||||
|
||||
public ClassLoader getInstrumentableClassLoader() { |
||||
return this.classLoader.getClassLoader(); |
||||
} |
||||
|
||||
public ClassLoader getThrowawayClassLoader() { |
||||
return this.classLoader.getThrowawayClassLoader(); |
||||
} |
||||
} |
||||
@ -1,8 +0,0 @@
@@ -1,8 +0,0 @@
|
||||
|
||||
/** |
||||
* |
||||
* Support for class instrumentation on Oracle OC4J. |
||||
* |
||||
*/ |
||||
package org.springframework.instrument.classloading.oc4j; |
||||
|
||||
@ -0,0 +1,531 @@
@@ -0,0 +1,531 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<xsd:schema xmlns="http://www.springframework.org/schema/context" |
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans" |
||||
xmlns:tool="http://www.springframework.org/schema/tool" |
||||
targetNamespace="http://www.springframework.org/schema/context" |
||||
elementFormDefault="qualified" attributeFormDefault="unqualified"> |
||||
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.2.xsd" /> |
||||
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.2.xsd" /> |
||||
|
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Defines the configuration elements for the Spring Framework's application |
||||
context support. Effects the activation of various configuration styles |
||||
for the containing Spring ApplicationContext. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
|
||||
<xsd:complexType name="propertyPlaceholder"> |
||||
<xsd:attribute name="location" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The location of the properties file to resolve placeholders against, as a Spring |
||||
resource location: a URL, a "classpath:" pseudo URL, or a relative file path. |
||||
Multiple locations may be specified, separated by commas. If neither location nor properties-ref is |
||||
specified, placeholders will be resolved against system properties. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="properties-ref" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:java.util.Properties"><![CDATA[ |
||||
The bean name of a Java Properties object that will be used for property substitution. |
||||
If neither location nor properties-ref is specified, placeholders will be resolved against system properties. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="file-encoding" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Specifies the encoding to use for parsing properties files. Default is none, |
||||
using the java.util.Properties default encoding. Only applies to classic |
||||
properties files, not to XML files. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="order" type="xsd:integer"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Specifies the order for this placeholder configurer. If more than one is present in a context |
||||
the order can be important since the first one to be match a placeholder will win. Often used |
||||
in conjunction with |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="ignore-resource-not-found" type="xsd:boolean" |
||||
default="false"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Specifies if failure to find the property resource location should be ignored. Default |
||||
is "false", meaning that if there is no file in the location specified an exception will |
||||
be raised at runtime. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="ignore-unresolvable" type="xsd:boolean" |
||||
default="false"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Specifies if failure to find the property value to replace a key should be ignored. Default |
||||
is "false", meaning that this placeholder configurer will raise an exception if it cannot resolve |
||||
a key. Set to "true" to allow the configurer to pass on the key to any others in |
||||
the context that have not yet visited the key in question. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="local-override" type="xsd:boolean" |
||||
default="false"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Specifies whether local properties override properties from files. Default |
||||
is "false": Properties from files override local defaults. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
|
||||
<xsd:element name="property-placeholder"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Activates replacement of ${...} placeholders by registering a |
||||
PropertySourcesPlaceholderConfigurer within the application context. Properties will |
||||
be resolved against the specified properties file or Properties object -- so called |
||||
"local properties", if any, and against the Spring Environment's current set of |
||||
PropertySources. |
||||
|
||||
Note that as of Spring 3.1 the system-properties-mode attribute has been removed in |
||||
favor of the more flexible PropertySources mechanism. However, Spring 3.1-based |
||||
applications may continue to use the 3.0 (and older) versions of the spring-context |
||||
schema in order to preserve system-properties-mode behavior. In this case, the |
||||
traditional PropertyPlaceholderConfigurer component will be registered instead of the |
||||
new PropertySourcesPlaceholderConfigurer. |
||||
|
||||
See ConfigurableEnvironment Javadoc for more information on using. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports |
||||
type="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:complexContent> |
||||
<xsd:extension base="propertyPlaceholder"> |
||||
<xsd:attribute name="system-properties-mode" default="ENVIRONMENT"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Controls how to resolve placeholders against system properties. As of Spring 3.1, this |
||||
attribute value defaults to "ENVIRONMENT", indicating that resolution of placeholders |
||||
against system properties is handled via PropertySourcesPlaceholderConfigurer and its |
||||
delegation to the current Spring Environment object. |
||||
|
||||
For maximum backward compatibility, this attribute is preserved going forward with the |
||||
3.1 version of the context schema, and any values other than the default "ENVIRONMENT" |
||||
will cause a traditional PropertyPlaceholderConfigurer to be registered instead of the |
||||
newer PropertySourcesPlaceholderConfigurer variant. In this case, the Spring Environment |
||||
and its property sources are not interrogated when resolving placeholders. Users are |
||||
encouraged to consider this attribute deprecated, and to take advantage of |
||||
Environment/PropertySource mechanisms. See ConfigurableEnvironment Javadoc for examples. |
||||
|
||||
"ENVIRONMENT" indicates placeholders should be resolved against the current Environment and against any local properties; |
||||
"NEVER" indicates placeholders should be resolved only against local properties and never against system properties; |
||||
"FALLBACK" indicates placeholders should be resolved against any local properties and then against system properties; |
||||
"OVERRIDE" indicates placeholders should be resolved first against system properties and then against any local properties; |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="ENVIRONMENT"/> |
||||
<xsd:enumeration value="NEVER"/> |
||||
<xsd:enumeration value="FALLBACK"/> |
||||
<xsd:enumeration value="OVERRIDE"/> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
</xsd:extension> |
||||
</xsd:complexContent> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="property-override"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Activates pushing of override values into bean properties, based on configuration |
||||
lines of the following format: beanName.property=value |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports |
||||
type="org.springframework.beans.factory.config.PropertyOverrideConfigurer" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:complexContent> |
||||
<xsd:extension base="propertyPlaceholder" /> |
||||
</xsd:complexContent> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="annotation-config"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Activates various annotations to be detected in bean classes: Spring's @Required and |
||||
@Autowired, as well as JSR 250's @PostConstruct, @PreDestroy and @Resource (if available), |
||||
JAX-WS's @WebServiceRef (if available), EJB3's @EJB (if available), and JPA's |
||||
@PersistenceContext and @PersistenceUnit (if available). Alternatively, you may |
||||
choose to activate the individual BeanPostProcessors for those annotations. |
||||
|
||||
Note: This tag does not activate processing of Spring's @Transactional or EJB3's |
||||
@TransactionAttribute annotation. Consider the use of the <tx:annotation-driven> |
||||
tag for that purpose. |
||||
|
||||
See Javadoc for org.springframework.context.annotation.AnnotationConfigApplicationContext |
||||
for information on code-based alternatives to bootstrapping annotation-driven support. |
||||
from XML. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="component-scan"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Scans the classpath for annotated components that will be auto-registered as |
||||
Spring beans. By default, the Spring-provided @Component, @Repository, |
||||
@Service, and @Controller stereotypes will be detected. |
||||
|
||||
Note: This tag implies the effects of the 'annotation-config' tag, activating @Required, |
||||
@Autowired, @PostConstruct, @PreDestroy, @Resource, @PersistenceContext and @PersistenceUnit |
||||
annotations in the component classes, which is usually desired for autodetected components |
||||
(without external configuration). Turn off the 'annotation-config' attribute to deactivate |
||||
this default behavior, for example in order to use custom BeanPostProcessor definitions |
||||
for handling those annotations. |
||||
|
||||
Note: You may use placeholders in package paths, but only resolved against system |
||||
properties (analogous to resource paths). A component scan results in new bean definition |
||||
being registered; Spring's PropertyPlaceholderConfigurer will apply to those bean |
||||
definitions just like to regular bean definitions, but it won't apply to the component |
||||
scan settings themselves. |
||||
|
||||
See Javadoc for org.springframework.context.annotation.ComponentScan for information |
||||
on code-based alternatives to bootstrapping component-scanning. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="include-filter" type="filterType" |
||||
minOccurs="0" maxOccurs="unbounded"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Controls which eligible types to include for component scanning. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:element> |
||||
<xsd:element name="exclude-filter" type="filterType" |
||||
minOccurs="0" maxOccurs="unbounded"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Controls which eligible types to exclude for component scanning. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:element> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="base-package" type="xsd:string" |
||||
use="required"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The comma-separated list of packages to scan for annotated components. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="resource-pattern" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Controls the class files eligible for component detection. Defaults to "**/*.class", the recommended value. |
||||
Consider use of the include-filter and exclude-filter elements for a more fine-grained approach. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="use-default-filters" type="xsd:boolean" |
||||
default="true"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Indicates whether automatic detection of classes annotated with @Component, @Repository, @Service, |
||||
or @Controller should be enabled. Default is "true". |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="annotation-config" type="xsd:boolean" |
||||
default="true"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Indicates whether the implicit annotation post-processors should be enabled. Default is "true". |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="name-generator" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The fully-qualified class name of the BeanNameGenerator to be used for naming detected components. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:expected-type type="java.lang.Class" /> |
||||
<tool:assignable-to |
||||
type="org.springframework.beans.factory.support.BeanNameGenerator" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="scope-resolver" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The fully-qualified class name of the ScopeMetadataResolver to be used for resolving the scope of |
||||
detected components. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:expected-type type="java.lang.Class" /> |
||||
<tool:assignable-to |
||||
type="org.springframework.context.annotation.ScopeMetadataResolver" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="scoped-proxy"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Indicates whether proxies should be generated for detected components, which may be necessary |
||||
when using scopes in a proxy-style fashion. Default is to generate no such proxies. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="no" /> |
||||
<xsd:enumeration value="interfaces" /> |
||||
<xsd:enumeration value="targetClass" /> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="load-time-weaver"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Activates a Spring LoadTimeWeaver for this application context, available as |
||||
a bean with the name "loadTimeWeaver". Any bean that implements the |
||||
LoadTimeWeaverAware interface will then receive the LoadTimeWeaver reference |
||||
automatically; for example, Spring's JPA bootstrap support. |
||||
|
||||
The default weaver is determined automatically: see DefaultContextLoadTimeWeaver's |
||||
javadoc for details. |
||||
|
||||
The activation of AspectJ load-time weaving is specified via a simple flag |
||||
(the 'aspectj-weaving' attribute), with the AspectJ class transformer |
||||
registered through Spring's LoadTimeWeaver. AspectJ weaving will be activated |
||||
by default if a "META-INF/aop.xml" resource is present in the classpath. |
||||
|
||||
This also activates the current application context for applying dependency |
||||
injection to non-managed classes that are instantiated outside of the Spring |
||||
bean factory (typically classes annotated with the @Configurable annotation). |
||||
This will only happen if the AnnotationBeanConfigurerAspect is on the classpath |
||||
(i.e. spring-aspects.jar), effectively activating "spring-configured" by default. |
||||
|
||||
See Javadoc for org.springframework.context.annotation.EnableLoadTimeWeaving |
||||
for information on code-based alternatives to bootstrapping load-time weaving support. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports |
||||
type="org.springframework.instrument.classloading.LoadTimeWeaver" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="weaver-class" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The fully-qualified classname of the LoadTimeWeaver that is to be activated. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:expected-type type="java.lang.Class" /> |
||||
<tool:assignable-to |
||||
type="org.springframework.instrument.classloading.LoadTimeWeaver" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="aspectj-weaving" default="autodetect"> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="on"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Switches Spring-based AspectJ load-time weaving on. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:enumeration> |
||||
<xsd:enumeration value="off"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Switches Spring-based AspectJ load-time weaving off. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:enumeration> |
||||
<xsd:enumeration value="autodetect"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Switches AspectJ load-time weaving on if a "META-INF/aop.xml" resource |
||||
is present in the classpath. If there is no such resource, then AspectJ |
||||
load-time weaving will be switched off. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:enumeration> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="spring-configured"> |
||||
<xsd:annotation> |
||||
<xsd:documentation |
||||
source="java:org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"> |
||||
<![CDATA[ |
||||
Signals the current application context to apply dependency injection |
||||
to non-managed classes that are instantiated outside of the Spring bean |
||||
factory (typically classes annotated with the @Configurable annotation). |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string" /> |
||||
</xsd:simpleType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="mbean-export"> |
||||
<xsd:annotation> |
||||
<xsd:documentation |
||||
source="java:org.springframework.jmx.export.annotation.AnnotationMBeanExporter"><![CDATA[ |
||||
Activates default exporting of MBeans by detecting standard MBeans in the Spring |
||||
context as well as @ManagedResource annotations on Spring-defined beans. |
||||
|
||||
The resulting MBeanExporter bean is defined under the name "mbeanExporter". |
||||
Alternatively, consider defining a custom AnnotationMBeanExporter bean explicitly. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports |
||||
type="org.springframework.jmx.export.annotation.AnnotationMBeanExporter" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="default-domain" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The default domain to use when generating JMX ObjectNames. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="server" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The bean name of the MBeanServer to which MBeans should be exported. |
||||
Default is to use the platform's default MBeanServer (autodetecting |
||||
WebLogic 9+, WebSphere 5.1+ and the JDK 1.5+ platform MBeanServer). |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="registration"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The registration behavior, indicating how to deal with existing MBeans |
||||
of the same name: fail with an exception, ignore and keep the existing |
||||
MBean, or replace the existing one with the new MBean. |
||||
|
||||
Default is to fail with an exception. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:NMTOKEN"> |
||||
<xsd:enumeration value="failOnExisting" /> |
||||
<xsd:enumeration value="ignoreExisting" /> |
||||
<xsd:enumeration value="replaceExisting" /> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="mbean-server"> |
||||
<xsd:annotation> |
||||
<xsd:documentation |
||||
source="java:org.springframework.jmx.support.MBeanServerFactoryBean"><![CDATA[ |
||||
Exposes a default MBeanServer for the current platform. |
||||
Autodetects WebLogic 9+, WebSphere 6.1+ and the JDK 1.5+ platform MBeanServer. |
||||
|
||||
The default bean name for the exposed MBeanServer is "mbeanServer". |
||||
This may be customized through specifying the "id" attribute. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports type="javax.management.MBeanServer" /> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexType> |
||||
<xsd:complexContent> |
||||
<xsd:extension base="beans:identifiedType"> |
||||
<xsd:attribute name="agent-id" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The agent id of the target MBeanServer, if any. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:extension> |
||||
</xsd:complexContent> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:complexType name="filterType"> |
||||
<xsd:attribute name="type" use="required"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Controls the type of filtering to apply to the expression. |
||||
|
||||
"annotation" indicates an annotation to be present at the type level in target components; |
||||
"assignable" indicates a class (or interface) that the target components are assignable to (extend/implement); |
||||
"aspectj" indicates an AspectJ type expression to be matched by the target components; |
||||
"regex" indicates a regex expression to be matched by the target components' class names; |
||||
"custom" indicates a custom implementation of the org.springframework.core.type.TypeFilter interface. |
||||
|
||||
Note: This attribute will not be inherited by child bean definitions. |
||||
Hence, it needs to be specified per concrete bean definition. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="annotation" /> |
||||
<xsd:enumeration value="assignable" /> |
||||
<xsd:enumeration value="aspectj" /> |
||||
<xsd:enumeration value="regex" /> |
||||
<xsd:enumeration value="custom" /> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="expression" type="xsd:string" use="required"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Indicates the filter expression, the type of which is indicated by "type". |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
|
||||
</xsd:schema> |
||||
@ -1,253 +0,0 @@
@@ -1,253 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2012 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.transaction.jta; |
||||
|
||||
import java.lang.reflect.InvocationTargetException; |
||||
import java.lang.reflect.Method; |
||||
import javax.transaction.NotSupportedException; |
||||
import javax.transaction.SystemException; |
||||
import javax.transaction.Transaction; |
||||
import javax.transaction.UserTransaction; |
||||
|
||||
import org.springframework.transaction.TransactionDefinition; |
||||
import org.springframework.transaction.TransactionSystemException; |
||||
import org.springframework.util.ClassUtils; |
||||
|
||||
/** |
||||
* Special {@link JtaTransactionManager} variant for Oracle OC4J (10.1.3 and higher). |
||||
* Supports the full power of Spring's transaction definitions on OC4J's |
||||
* transaction coordinator, <i>beyond standard JTA</i>: transaction names |
||||
* and per-transaction isolation levels. |
||||
* |
||||
* <p>Uses OC4J's special {@code begin(name)} method to start a JTA transaction, |
||||
* in orderto make <b>Spring-driven transactions visible in OC4J's transaction |
||||
* monitor</b>. In case of Spring's declarative transactions, the exposed name will |
||||
* (by default) be the fully-qualified class name + "." + method name. |
||||
* |
||||
* <p>Supports a <b>per-transaction isolation level</b> through OC4J's corresponding |
||||
* {@code OC4JTransaction.setTransactionIsolation(int)} method. This will |
||||
* apply the specified isolation level (e.g. ISOLATION_SERIALIZABLE) to all |
||||
* JDBC Connections that participate in the given transaction. |
||||
* |
||||
* <p>Automatically detects the available OC4J server version and adapts accordingly. |
||||
* Supports the "com.evermind.server" package in OC4J 10.1.3.2 as well as the |
||||
* "oracle.j2ee.transaction" package in later OC4J versions. |
||||
* |
||||
* <p>By default, the JTA UserTransaction and TransactionManager handles are |
||||
* fetched directly from OC4J's {@code TransactionUtility} in 10.1.3.2+. |
||||
* This can be overridden by specifying "userTransaction"/"userTransactionName" |
||||
* and "transactionManager"/"transactionManagerName", passing in existing handles |
||||
* or specifying corresponding JNDI locations to look up. |
||||
* |
||||
* <p>Thanks to Oracle for donating the original version of this extended OC4J |
||||
* integration code to the Spring project! |
||||
* |
||||
* @author Paul Parkinson |
||||
* @author Juergen Hoeller |
||||
* @since 2.0.3 |
||||
* @see org.springframework.transaction.TransactionDefinition#getName |
||||
* @see org.springframework.transaction.TransactionDefinition#getIsolationLevel |
||||
* @deprecated as of Spring 3.2, in favor of {@link WebLogicJtaTransactionManager} |
||||
* since Oracle end-of-lifed OC4J in favor of WebLogic |
||||
*/ |
||||
@Deprecated |
||||
@SuppressWarnings("serial") |
||||
public class OC4JJtaTransactionManager extends JtaTransactionManager { |
||||
|
||||
private static final String TRANSACTION_UTILITY_CLASS_NAME = |
||||
"oracle.j2ee.transaction.TransactionUtility"; |
||||
|
||||
private static final String TRANSACTION_MANAGER_CLASS_NAME = |
||||
"oracle.j2ee.transaction.OC4JTransactionManager"; |
||||
|
||||
private static final String TRANSACTION_CLASS_NAME = |
||||
"oracle.j2ee.transaction.OC4JTransaction"; |
||||
|
||||
private static final String FALLBACK_TRANSACTION_MANAGER_CLASS_NAME = |
||||
"com.evermind.server.ApplicationServerTransactionManager"; |
||||
|
||||
private static final String FALLBACK_TRANSACTION_CLASS_NAME = |
||||
"com.evermind.server.ApplicationServerTransaction"; |
||||
|
||||
|
||||
private Method beginWithNameMethod; |
||||
|
||||
private Method setTransactionIsolationMethod; |
||||
|
||||
|
||||
@Override |
||||
public void afterPropertiesSet() throws TransactionSystemException { |
||||
super.afterPropertiesSet(); |
||||
loadOC4JTransactionClasses(); |
||||
} |
||||
|
||||
@Override |
||||
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException { |
||||
try { |
||||
Class transactionUtilityClass = getClass().getClassLoader().loadClass(TRANSACTION_UTILITY_CLASS_NAME); |
||||
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance"); |
||||
Object transactionUtility = getInstanceMethod.invoke(null); |
||||
logger.debug("Retrieving JTA UserTransaction from OC4J TransactionUtility"); |
||||
Method getUserTransactionMethod = |
||||
transactionUtility.getClass().getMethod("getOC4JUserTransaction"); |
||||
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility); |
||||
} |
||||
catch (ClassNotFoundException ex) { |
||||
logger.debug("Could not find OC4J 10.1.3.2 TransactionUtility: " + ex); |
||||
// Return null to make the superclass perform its standard J2EE lookup,
|
||||
// which will work on earlier OC4J versions.
|
||||
return null; |
||||
} |
||||
catch (InvocationTargetException ex) { |
||||
throw new TransactionSystemException( |
||||
"OC4J's TransactionUtility.getOC4JUserTransaction() method failed", ex.getTargetException()); |
||||
} |
||||
catch (Exception ex) { |
||||
throw new TransactionSystemException( |
||||
"Could not invoke OC4J's TransactionUtility.getOC4JUserTransaction() method", ex); |
||||
} |
||||
} |
||||
|
||||
private void loadOC4JTransactionClasses() throws TransactionSystemException { |
||||
// Find available OC4J API (in "oracle.j2ee.transaction" or "com.evermind.server")
|
||||
Class transactionManagerClass = null; |
||||
Class transactionClass = null; |
||||
try { |
||||
transactionManagerClass = getClass().getClassLoader().loadClass(TRANSACTION_MANAGER_CLASS_NAME); |
||||
transactionClass = getClass().getClassLoader().loadClass(TRANSACTION_CLASS_NAME); |
||||
} |
||||
catch (ClassNotFoundException ex) { |
||||
try { |
||||
transactionManagerClass = getClass().getClassLoader().loadClass(FALLBACK_TRANSACTION_MANAGER_CLASS_NAME); |
||||
transactionClass = getClass().getClassLoader().loadClass(FALLBACK_TRANSACTION_CLASS_NAME); |
||||
} |
||||
catch (ClassNotFoundException ex2) { |
||||
throw new TransactionSystemException( |
||||
"Could not initialize OC4JJtaTransactionManager because OC4J API classes are not available", ex); |
||||
} |
||||
} |
||||
|
||||
// Cache reflective Method references for later use.
|
||||
if (transactionManagerClass.isInstance(getUserTransaction())) { |
||||
this.beginWithNameMethod = ClassUtils.getMethodIfAvailable( |
||||
transactionManagerClass, "begin", String.class); |
||||
this.setTransactionIsolationMethod = ClassUtils.getMethodIfAvailable( |
||||
transactionClass, "setTransactionIsolation", int.class); |
||||
logger.info("Support for OC4J transaction names and isolation levels available"); |
||||
} |
||||
else { |
||||
logger.info("Support for OC4J transaction names and isolation levels not available"); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected void doJtaBegin(JtaTransactionObject txObject, TransactionDefinition definition) |
||||
throws NotSupportedException, SystemException { |
||||
|
||||
int timeout = determineTimeout(definition); |
||||
applyTimeout(txObject, timeout); |
||||
|
||||
// Apply transaction name, if any, through the extended OC4J transaction begin method.
|
||||
if (this.beginWithNameMethod != null && definition.getName() != null) { |
||||
/* |
||||
oracle.j2ee.transaction.OC4JTransactionManager otm = (oracle.j2ee.transaction.OC4JTransactionManager) ut; |
||||
otm.begin(definition.getName()); |
||||
*/ |
||||
try { |
||||
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName()); |
||||
} |
||||
catch (InvocationTargetException ex) { |
||||
throw new TransactionSystemException( |
||||
"OC4J's UserTransaction.begin(String) method failed", ex.getTargetException()); |
||||
} |
||||
catch (Exception ex) { |
||||
throw new TransactionSystemException( |
||||
"Could not invoke OC4J's UserTransaction.begin(String) method", ex); |
||||
} |
||||
} |
||||
else { |
||||
// No OC4J UserTransaction available or no transaction name specified
|
||||
// -> standard JTA begin call.
|
||||
txObject.getUserTransaction().begin(); |
||||
} |
||||
|
||||
// Specify isolation level, if any, through the corresponding OC4J transaction method.
|
||||
if (this.setTransactionIsolationMethod != null) { |
||||
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { |
||||
try { |
||||
Transaction tx = getTransactionManager().getTransaction(); |
||||
/* |
||||
oracle.j2ee.transaction.OC4JTransaction otx = (oracle.j2ee.transaction.OC4JTransaction) tx; |
||||
otx.setTransactionIsolation(definition.getIsolationLevel()); |
||||
*/ |
||||
this.setTransactionIsolationMethod.invoke(tx, definition.getIsolationLevel()); |
||||
} |
||||
catch (InvocationTargetException ex) { |
||||
throw new TransactionSystemException( |
||||
"OC4J's Transaction.setTransactionIsolation(int) method failed", ex.getTargetException()); |
||||
} |
||||
catch (Exception ex) { |
||||
throw new TransactionSystemException( |
||||
"Could not invoke OC4J's Transaction.setTransactionIsolation(int) method", ex); |
||||
} |
||||
} |
||||
} |
||||
else { |
||||
applyIsolationLevel(txObject, definition.getIsolationLevel()); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public Transaction createTransaction(String name, int timeout) throws NotSupportedException, SystemException { |
||||
if (this.beginWithNameMethod != null && name != null) { |
||||
UserTransaction ut = getUserTransaction(); |
||||
if (timeout >= 0) { |
||||
ut.setTransactionTimeout(timeout); |
||||
} |
||||
try { |
||||
this.beginWithNameMethod.invoke(ut, name); |
||||
} |
||||
catch (InvocationTargetException ex) { |
||||
if (ex.getTargetException() instanceof NotSupportedException) { |
||||
throw (NotSupportedException) ex.getTargetException(); |
||||
} |
||||
else if (ex.getTargetException() instanceof SystemException) { |
||||
throw (SystemException) ex.getTargetException(); |
||||
} |
||||
else if (ex.getTargetException() instanceof RuntimeException) { |
||||
throw (RuntimeException) ex.getTargetException(); |
||||
} |
||||
else { |
||||
throw new SystemException( |
||||
"OC4J's begin(String) method failed with an unexpected error: " + ex.getTargetException()); |
||||
} |
||||
} |
||||
catch (Exception ex) { |
||||
throw new SystemException("Could not invoke OC4J's UserTransaction.begin(String) method: " + ex); |
||||
} |
||||
return new ManagedTransactionAdapter(getTransactionManager()); |
||||
} |
||||
|
||||
else { |
||||
// No name specified - standard JTA is sufficient.
|
||||
return super.createTransaction(name, timeout); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,247 @@
@@ -0,0 +1,247 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
|
||||
<xsd:schema xmlns="http://www.springframework.org/schema/tx" |
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
||||
xmlns:beans="http://www.springframework.org/schema/beans" |
||||
xmlns:tool="http://www.springframework.org/schema/tool" |
||||
targetNamespace="http://www.springframework.org/schema/tx" |
||||
elementFormDefault="qualified" |
||||
attributeFormDefault="unqualified"> |
||||
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"/> |
||||
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.2.xsd"/> |
||||
|
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Defines the elements used in the Spring Framework's declarative |
||||
transaction management infrastructure. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
|
||||
<xsd:element name="advice"> |
||||
<xsd:complexType> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.interceptor.TransactionInterceptor"><![CDATA[ |
||||
Defines the transactional semantics of the AOP advice that is to be |
||||
executed. |
||||
|
||||
That is, this advice element is where the transactional semantics of |
||||
any number of methods are defined (where transactional semantics |
||||
includes the propagation settings, the isolation level, the rollback |
||||
rules, and suchlike). |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports type="org.springframework.transaction.interceptor.TransactionInterceptor"/> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
<xsd:complexContent> |
||||
<xsd:extension base="beans:identifiedType"> |
||||
<xsd:sequence> |
||||
<xsd:element name="attributes" type="attributesType" minOccurs="0" maxOccurs="1"/> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="transaction-manager" type="xsd:string" default="transactionManager"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.PlatformTransactionManager"><![CDATA[ |
||||
The bean name of the PlatformTransactionManager that is to be used |
||||
to drive transactions. |
||||
|
||||
This attribute is not required, and only needs to be specified |
||||
explicitly if the bean name of the desired PlatformTransactionManager |
||||
is not 'transactionManager'. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation kind="ref"> |
||||
<tool:expected-type type="org.springframework.transaction.PlatformTransactionManager"/> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:extension> |
||||
</xsd:complexContent> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="annotation-driven"> |
||||
<xsd:complexType> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"><![CDATA[ |
||||
Indicates that transaction configuration is defined by Java 5 |
||||
annotations on bean classes, and that proxies are automatically |
||||
to be created for the relevant annotated beans. |
||||
|
||||
The default annotations supported are Spring's @Transactional |
||||
and EJB3's @TransactionAttribute (if available). |
||||
|
||||
Transaction semantics such as propagation settings, the isolation level, |
||||
the rollback rules, etc are all defined in the annotation metadata. |
||||
|
||||
See org.springframework.transaction.annotation.EnableTransactionManagement Javadoc |
||||
for information on code-based alternatives to this XML element. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:attribute name="transaction-manager" type="xsd:string" default="transactionManager"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.PlatformTransactionManager"><![CDATA[ |
||||
The bean name of the PlatformTransactionManager that is to be used |
||||
to drive transactions. |
||||
|
||||
This attribute is not required, and only needs to be specified |
||||
explicitly if the bean name of the desired PlatformTransactionManager |
||||
is not 'transactionManager'. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation kind="ref"> |
||||
<tool:expected-type type="org.springframework.transaction.PlatformTransactionManager"/> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="mode" default="proxy"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Should annotated beans be proxied using Spring's AOP framework, |
||||
or should they rather be weaved with an AspectJ transaction aspect? |
||||
|
||||
AspectJ weaving requires spring-aspects.jar on the classpath, |
||||
as well as load-time weaving (or compile-time weaving) enabled. |
||||
|
||||
Note: The weaving-based aspect requires the @Transactional annotation to be |
||||
defined on the concrete class. Annotations in interfaces will not work |
||||
in that case (they will rather only work with interface-based proxies)! |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="proxy"/> |
||||
<xsd:enumeration value="aspectj"/> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Are class-based (CGLIB) proxies to be created? By default, standard |
||||
Java interface-based proxies are created. |
||||
|
||||
Note: Class-based proxies require the @Transactional annotation to be |
||||
defined on the concrete class. Annotations in interfaces will not work |
||||
in that case (they will rather only work with interface-based proxies)! |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="order" type="xsd:int"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[ |
||||
Controls the ordering of the execution of the transaction advisor |
||||
when multiple advice executes at a specific joinpoint. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
|
||||
<xsd:element name="jta-transaction-manager"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Creates a default JtaTransactionManager bean with name "transactionManager", |
||||
matching the default bean name expected by the "annotation-driven" tag. |
||||
Automatically detects WebLogic and WebSphere: creating a WebLogicJtaTransactionManager |
||||
or WebSphereUowTransactionManager, respectively. |
||||
|
||||
For customization needs, consider defining a JtaTransactionManager bean as a regular |
||||
Spring bean definition with name "transactionManager", replacing this element. |
||||
]]></xsd:documentation> |
||||
<xsd:appinfo> |
||||
<tool:annotation> |
||||
<tool:exports type="org.springframework.transaction.jta.JtaTransactionManager"/> |
||||
</tool:annotation> |
||||
</xsd:appinfo> |
||||
</xsd:annotation> |
||||
</xsd:element> |
||||
|
||||
<xsd:complexType name="attributesType"> |
||||
<xsd:sequence> |
||||
<xsd:element name="method" minOccurs="1" maxOccurs="unbounded"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="name" type="xsd:string" use="required"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The method name(s) with which the transaction attributes are to be |
||||
associated. The wildcard (*) character can be used to associate the |
||||
same transaction attribute settings with a number of methods; for |
||||
example, 'get*', 'handle*', '*Order', 'on*Event', etc. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="propagation" default="REQUIRED"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.annotation.Propagation"><![CDATA[ |
||||
The transaction propagation behavior. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="REQUIRED"/> |
||||
<xsd:enumeration value="SUPPORTS"/> |
||||
<xsd:enumeration value="MANDATORY"/> |
||||
<xsd:enumeration value="REQUIRES_NEW"/> |
||||
<xsd:enumeration value="NOT_SUPPORTED"/> |
||||
<xsd:enumeration value="NEVER"/> |
||||
<xsd:enumeration value="NESTED"/> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="isolation" default="DEFAULT"> |
||||
<xsd:annotation> |
||||
<xsd:documentation source="java:org.springframework.transaction.annotation.Isolation"><![CDATA[ |
||||
The transaction isolation level. |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
<xsd:simpleType> |
||||
<xsd:restriction base="xsd:string"> |
||||
<xsd:enumeration value="DEFAULT"/> |
||||
<xsd:enumeration value="READ_UNCOMMITTED"/> |
||||
<xsd:enumeration value="READ_COMMITTED"/> |
||||
<xsd:enumeration value="REPEATABLE_READ"/> |
||||
<xsd:enumeration value="SERIALIZABLE"/> |
||||
</xsd:restriction> |
||||
</xsd:simpleType> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="timeout" type="xsd:integer" default="-1"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The transaction timeout value (in seconds). |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="read-only" type="xsd:boolean" default="false"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
Is this transaction read-only? |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="rollback-for" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The Exception(s) that will trigger rollback; comma-delimited. |
||||
For example, 'com.foo.MyBusinessException,ServletException' |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
<xsd:attribute name="no-rollback-for" type="xsd:string"> |
||||
<xsd:annotation> |
||||
<xsd:documentation><![CDATA[ |
||||
The Exception(s) that will *not* trigger rollback; comma-delimited. |
||||
For example, 'com.foo.MyBusinessException,ServletException' |
||||
]]></xsd:documentation> |
||||
</xsd:annotation> |
||||
</xsd:attribute> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:sequence> |
||||
</xsd:complexType> |
||||
|
||||
</xsd:schema> |
||||
Loading…
Reference in new issue