本文整理了Java中org.eclipse.persistence.internal.helper.Helper.getDeclaredMethod()
方法的一些代码示例,展示了Helper.getDeclaredMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.getDeclaredMethod()
方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:getDeclaredMethod
[英]INTERNAL: Returns a Method for the specified Class, method name, and that has no parameters. Uses Class.getDeclaredMethod(String Class[]) to find the method. If the method is not found on the specified class the superclass is checked, and so on, recursively. Set accessible to true, so we can access private/package/protected methods.
[中]内部:返回指定类、方法名和无参数的方法。使用类。getDeclaredMethod(String类[])来查找该方法。如果在指定的类上找不到该方法,则递归地检查超类,依此类推。将accessible设置为true,这样我们就可以访问private/package/protected方法。
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Returns a Method for the specified Class, method name, and that has no
* parameters. Uses Class.getDeclaredMethod(String Class[]) to find the
* method. If the method is not found on the specified class the superclass
* is checked, and so on, recursively. Set accessible to true, so we can
* access private/package/protected methods.
*/
public static Method getDeclaredMethod(Class javaClass, String methodName) throws NoSuchMethodException {
return getDeclaredMethod(javaClass, methodName, (Class[]) null);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.oracle
public XDKPlatform() {
super();
try {
Class[] argTypes = { URL.class };
buildSchemaMethod = Helper.getDeclaredMethod(XSDBuilder.class, "build", argTypes);
} catch (NoSuchMethodException e) {
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public XDKPlatform() {
super();
try {
Class[] argTypes = { URL.class };
buildSchemaMethod = Helper.getDeclaredMethod(XSDBuilder.class, "build", argTypes);
} catch (NoSuchMethodException e) {
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Returns a Method for the specified Class, method name, and that has no
* parameters. Uses Class.getDeclaredMethod(String Class[]) to find the
* method. If the method is not found on the specified class the superclass
* is checked, and so on, recursively. Set accessible to true, so we can
* access private/package/protected methods.
*/
public static Method getDeclaredMethod(Class javaClass, String methodName) throws NoSuchMethodException {
return getDeclaredMethod(javaClass, methodName, (Class[]) null);
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Returns a Method for the specified Class, method name, and that has no
* parameters. Uses Class.getDeclaredMethod(String Class[]) to find the
* method. If the method is not found on the specified class the superclass
* is checked, and so on, recursively. Set accessible to true, so we can
* access private/package/protected methods.
*/
public static Method getDeclaredMethod(Class javaClass, String methodName) throws NoSuchMethodException {
return getDeclaredMethod(javaClass, methodName, (Class[]) null);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Build the specified method.
*/
protected Method buildMethod(Class methodClass, String methodName, Class[] methodParameterTypes) throws DescriptorException {
try {
return Helper.getDeclaredMethod(methodClass, methodName, methodParameterTypes);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Set the keyMethod or keyField based on the keyName.
*/
protected void initializeKey() {
// Should only run through this once ...
if (keyName != null && keyMethod == null && keyField == null) {
try {
keyMethod = Helper.getDeclaredMethod(elementClass, keyName, (Class[]) null);
} catch (NoSuchMethodException ex) {
try {
keyField = Helper.getField(elementClass, keyName);
} catch (NoSuchFieldException e) {
throw ValidationException.mapKeyNotDeclaredInItemClass(keyName, elementClass);
}
}
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Set the keyMethod or keyField based on the keyName
*/
protected void initializeKey(){
// Should only run through this once ...
if (keyName != null && keyMethod == null && keyField == null) {
try {
keyMethod = Helper.getDeclaredMethod(elementClass, keyName, (Class[]) null);
} catch (NoSuchMethodException ex) {
try {
keyField = Helper.getField(elementClass, keyName);
} catch (NoSuchFieldException e) {
throw ValidationException.mapKeyNotDeclaredInItemClass(keyName, elementClass);
}
}
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Build the specified method.
*/
protected Method buildMethod(Class methodClass, String methodName, Class[] methodParameterTypes) throws DescriptorException {
try {
return Helper.getDeclaredMethod(methodClass, methodName, methodParameterTypes);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Build the specified method.
*/
protected Method buildMethod(Class methodClass, String methodName, Class[] methodParameterTypes) throws DescriptorException {
try {
return Helper.getDeclaredMethod(methodClass, methodName, methodParameterTypes);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingInstantiationPolicy(methodClass.getName() + "." + methodName, this.getDescriptor(), exception);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Set the keyMethod or keyField based on the keyName.
*/
protected void initializeKey() {
// Should only run through this once ...
if (keyName != null && keyMethod == null && keyField == null) {
try {
keyMethod = Helper.getDeclaredMethod(elementClass, keyName, (Class[]) null);
} catch (NoSuchMethodException ex) {
try {
keyField = Helper.getField(elementClass, keyName);
} catch (NoSuchFieldException e) {
throw ValidationException.mapKeyNotDeclaredInItemClass(keyName, elementClass);
}
}
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Find the method corresponding to the event selector. The method MUST take
* DescriptorEvent as argument, Session is also supported as argument for
* backward compatibility.
*/
protected Method findMethod(int selector) throws DescriptorException {
Class[] declarationParameters = new Class[1];
declarationParameters[0] = ClassConstants.DescriptorEvent_Class;
String methodName = getEventSelectors().get(selector);
try {
return Helper.getDeclaredMethod(getDescriptor().getJavaClass(), methodName, declarationParameters);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodOnFindObsoleteMethod(methodName, getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityOnFindMethod(methodName, getDescriptor(), exception);
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Find the method corresponding to the event selector. The method MUST take
* DescriptorEvent as argument, Session is also supported as argument for
* backward compatibility.
*/
protected Method findMethod(int selector) throws DescriptorException {
Class[] declarationParameters = new Class[1];
declarationParameters[0] = ClassConstants.DescriptorEvent_Class;
String methodName = (String)getEventSelectors().elementAt(selector);
try {
return Helper.getDeclaredMethod(getDescriptor().getJavaClass(), methodName, declarationParameters);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodOnFindObsoleteMethod(methodName, getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityOnFindMethod(methodName, getDescriptor(), exception);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Find the method corresponding to the event selector. The method MUST take
* DescriptorEvent as argument, Session is also supported as argument for
* backward compatibility.
*/
protected Method findMethod(int selector) throws DescriptorException {
Class[] declarationParameters = new Class[1];
declarationParameters[0] = ClassConstants.DescriptorEvent_Class;
String methodName = (String)getEventSelectors().elementAt(selector);
try {
return Helper.getDeclaredMethod(getDescriptor().getJavaClass(), methodName, declarationParameters);
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodOnFindObsoleteMethod(methodName, getDescriptor(), exception);
} catch (SecurityException exception) {
throw DescriptorException.securityOnFindMethod(methodName, getDescriptor(), exception);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid.
*/
public void initialize(ClassDescriptor descriptor, Session session) throws DescriptorException {
setDescriptor(descriptor);
Class[] declarationParameters = new Class[1];
declarationParameters[0] = ClassConstants.DatabaseRow_Class;
try {
setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters));
} catch (NoSuchMethodException ignore) {
declarationParameters[0] = ClassConstants.Record_Class;
try {
setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters));
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception);
}
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception);
}
// CR#2818667 Ensure the method is static.
if (!Modifier.isStatic(getClassExtractionMethod().getModifiers())) {
throw DescriptorException.classExtractionMethodMustBeStatic(getClassExtractionMethodName(), descriptor);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.moxy
/**
* Override to avoid exceptions due to lack of get method.
*/
public void initializeAttributes(Class theJavaClass) throws DescriptorException {
if (getAttributeName() == null) {
throw DescriptorException.attributeNameNotSpecified();
}
try {
if (!isWriteOnly()) {
Class[] parameterTypes = new Class[1];
parameterTypes[0] = Helper.getClassFromClasseName(parameterTypeAsString, loader);
attributeClassification = parameterTypes[0];
setSetMethod(Helper.getDeclaredMethod(theJavaClass, setMethodName, parameterTypes));
}
} catch (NoSuchMethodException ex) {
DescriptorException descriptorException = DescriptorException.noSuchMethodWhileInitializingAttributesInMethodAccessor(getSetMethodName(), getGetMethodName(), theJavaClass.getName());
descriptorException.setInternalException(ex);
throw descriptorException;
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Set get and set method after creating these methods by using
* get and set method names
*/
public void initializeAttributes(Class theJavaClass) throws DescriptorException {
if (getAttributeName() == null) {
throw DescriptorException.attributeNameNotSpecified();
}
try {
setGetMethod(Helper.getDeclaredMethod(theJavaClass, getGetMethodName(), (Class[])null));
// The parameter type for the set method must always be the return type of the get method.
if(!isWriteOnly()) {
Class[] parameterTypes = new Class[1];
parameterTypes[0] = getGetMethodReturnType();
setSetMethod(Helper.getDeclaredMethod(theJavaClass, getSetMethodName(), parameterTypes));
}
} catch (NoSuchMethodException ex) {
DescriptorException descriptorException = DescriptorException.noSuchMethodWhileInitializingAttributesInMethodAccessor(getSetMethodName(), getGetMethodName(), theJavaClass.getName());
descriptorException.setInternalException(ex);
throw descriptorException;
} catch (SecurityException exception) {
DescriptorException descriptorException = DescriptorException.securityWhileInitializingAttributesInMethodAccessor(getSetMethodName(), getGetMethodName(), theJavaClass.getName());
descriptorException.setInternalException(exception);
throw descriptorException;
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Override to avoid exceptions due to lack of get method.
*/
public void initializeAttributes(Class theJavaClass) throws DescriptorException {
if (getAttributeName() == null) {
throw DescriptorException.attributeNameNotSpecified();
}
try {
if (!isWriteOnly()) {
Class[] parameterTypes = new Class[1];
parameterTypes[0] = Helper.getClassFromClasseName(parameterTypeAsString, loader);
attributeClassification = parameterTypes[0];
setSetMethod(Helper.getDeclaredMethod(theJavaClass, setMethodName, parameterTypes));
}
} catch (NoSuchMethodException ex) {
DescriptorException descriptorException = DescriptorException.noSuchMethodWhileInitializingAttributesInMethodAccessor(getSetMethodName(), getGetMethodName(), theJavaClass.getName());
descriptorException.setInternalException(ex);
throw descriptorException;
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid.
*/
public void initialize(ClassDescriptor descriptor, Session session) throws DescriptorException {
setDescriptor(descriptor);
Class[] declarationParameters = new Class[1];
declarationParameters[0] = ClassConstants.DatabaseRow_Class;
try {
setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters));
} catch (NoSuchMethodException ignore) {
declarationParameters[0] = ClassConstants.Record_Class;
try {
setClassExtractionMethod(Helper.getDeclaredMethod(descriptor.getJavaClass(), getClassExtractionMethodName(), declarationParameters));
} catch (NoSuchMethodException exception) {
throw DescriptorException.noSuchMethodWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception);
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception);
}
} catch (SecurityException exception) {
throw DescriptorException.securityWhileInitializingClassExtractionMethod(getClassExtractionMethodName(), descriptor, exception);
}
// CR#2818667 Ensure the method is static.
if (!Modifier.isStatic(getClassExtractionMethod().getModifiers())) {
throw DescriptorException.classExtractionMethodMustBeStatic(getClassExtractionMethodName(), descriptor);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* This method will lazily initialize the set method
* Lazy initialization occurs to that we are not required to have a handle on
* the actual class that we are using until runtime. This helps to satisfy the
* weaving requirement that demands that we avoid loading domain classes into
* the main class loader until after weaving occurs.
*/
protected Method getSetMethod() {
if (setMethod == null) {
ForeignReferenceMapping sourceMapping = (ForeignReferenceMapping)mapping;
// The parameter type for the set method must always be the return type of the get method.
Class[] parameterTypes = new Class[1];
parameterTypes[0] = sourceMapping.getReferenceClass();
try {
setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes);
} catch (NoSuchMethodException e){
throw DescriptorException.errorAccessingSetMethodOfEntity(sourceMapping.getDescriptor().getJavaClass(), setMethodName ,sourceMapping.getDescriptor(), e);
}
}
return setMethod;
}
内容来源于网络,如有侵权,请联系作者删除!