本文整理汇总了Java中java.rmi.server.RMIClassLoader.getClassAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java RMIClassLoader.getClassAnnotation方法的具体用法?Java RMIClassLoader.getClassAnnotation怎么用?Java RMIClassLoader.getClassAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.server.RMIClassLoader
的用法示例。
在下文中一共展示了RMIClassLoader.getClassAnnotation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ServiceConfiguration.installServiceConfigurationFile();
System.setProperty(
"java.rmi.server.RMIClassLoaderSpi", "default");
String classname = "Foo";
URL codebaseURL = null;
try {
codebaseURL = TestLibrary.installClassInCodebase(
classname, "remote_codebase");
} catch (MalformedURLException e) {
TestLibrary.bomb(e);
}
TestLibrary.suggestSecurityManager(null);
Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
if (!fooClass.getName().equals(classname)) {
throw new RuntimeException(
"wrong class name, expected: " + classname +
", received: " + fooClass.getName());
}
String annotation = RMIClassLoader.getClassAnnotation(fooClass);
if (!annotation.equals(codebaseURL.toString())) {
throw new RuntimeException(
"wrong class annotation, expected: " + codebaseURL.toString() +
", received: " + annotation);
}
System.err.println("TEST PASSED");
}
示例2: checkLoad
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
ClassLoader proxyLoader = proxy.getClass().getClassLoader();
String proxyAnnotation =
RMIClassLoader.getClassAnnotation(proxy.getClass());
if ((proxyAnnotation == null) ||
!proxyAnnotation.equals(publicUrl.toString()))
{
TestLibrary.bomb("proxy class had incorrect annotation: " +
proxyAnnotation);
} else {
System.err.println("proxy class had correct annotation: " +
proxyAnnotation);
}
boolean proxyOk = false;
if (boomerangSemantics) {
ClassLoader ctxLoader =
Thread.currentThread().getContextClassLoader();
if (proxyLoader == ctxLoader) {
proxyOk = true;
}
} else if (proxyLoader.getClass().
getName().indexOf("sun.rmi") >= 0)
{
proxyOk = true;
}
if (proxyOk) {
System.err.println("\ncase5: proxy loaded from" +
" correct loader: " + proxyLoader);
} else {
TestLibrary.bomb("case5: proxy interface loaded from " +
"incorrect loader: " + proxyLoader);
}
}
示例3: getCodebase
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Returns the codebase of the given class.
*/
public String getCodebase(Class clz)
{
return RMIClassLoader.getClassAnnotation(clz);
}
示例4: annotateClass
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Annotates specified class with it's codebase URL if available.
*
* @param cl class to be annotated
*/
protected void annotateClass(Class cl) throws IOException {
String annot = RMIClassLoader.getClassAnnotation(cl);
hasAnnotations |= (annot != null);
locStream.writeObject(annot);
}
示例5: addServiceItems
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
public static boolean addServiceItems(ServiceItem si,
DefaultMutableTreeNode service, String[] nameFilter, String[] inf) {
// add ServiceID
if (!checkName(si.attributeSets, nameFilter)
|| !matchesFilterImpl(si.service.getClass(), inf)) {
return false;
}
DefaultMutableTreeNode sidNode = new DefaultMutableTreeNode(
new PropertiesNode(PropertiesNode.SERVICE_ID, "ServiceID: "
+ si.serviceID));
String annotation = RMIClassLoader.getClassAnnotation(si.service.getClass());
if(annotation!=null && annotation.length()>0) {
StringTokenizer tok = new StringTokenizer(annotation, " ");
URL[] urls = new URL[tok.countTokens()];
int i=0;
while(tok.hasMoreTokens()) {
String url = tok.nextToken();
try {
urls[i] = new URL(url);
} catch (MalformedURLException e) {
_logger.warn(" Unable to create URL for ["+url+"]", e);
}
i++;
}
addCodebase(urls, service);
}
ClassLoader cl = si.service.getClass().getClassLoader();
/*if (cl instanceof URLClassLoader) {
addCodebase(((URLClassLoader) cl).getURLs(), service);
}*/
// add the methods at the top level
DefaultMutableTreeNode methodsNode = new DefaultMutableTreeNode("Methods");
service.add(sidNode);
// addInterfaces
DefaultMutableTreeNode inode = new DefaultMutableTreeNode("Interfaces");
service.add(inode);
addInterfaces(si.service.getClass(), inode, si.service, methodsNode);
Object proxy = si.service;
if (proxy instanceof Administrable) {
Administrable admin = (Administrable) proxy;
try {
Object adminProxy = admin.getAdmin();
if (adminProxy != null) {
DefaultMutableTreeNode anode = new DefaultMutableTreeNode(
"Admin interfaces");
service.add(anode);
addInterfaces(adminProxy.getClass(), anode, adminProxy,
methodsNode);
}
} catch (Exception ex) {
System.err.println(ex);
}
}
addAttributes(service, si, cl);
service.add(methodsNode);
return true;
}
示例6: getCodebase
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Returns the codebase, if any, for the given class.
* @param clz the class to get a codebase for.
* @return a space-separated list of URLs, or null.
*/
public String getCodebase(java.lang.Class clz) {
return RMIClassLoader.getClassAnnotation(clz);
}
示例7: annotateClass
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Writes the annotation for the class passed as argument on the
* {@link RMIObjectOutputStream}
*
* @param cl
* the class to be annotated
* @throws IOException
* if the I/O operation fails
*/
protected final void annotateClass(Class cl) throws IOException {
Object obj = RMIClassLoader.getClassAnnotation(cl);
this.writeObject(obj);
}
示例8: annotateProxyClass
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Writes the annotation for the Proxy class passed as argument on the
* RMIOutputStream.
*
* @param cl
* the class to be annotated
* @throws IOException
* if the I/O operation fails
*/
@Override
protected final void annotateProxyClass(Class<?> cl) throws IOException {
Object obj = RMIClassLoader.getClassAnnotation(cl);
this.writeObject(obj);
}
示例9: annotateClass
import java.rmi.server.RMIClassLoader; //导入方法依赖的package包/类
/**
* Writes the annotation for the class passed as argument on the
* {@link RMIObjectOutputStream}
*
* @param cl
* the class to be annotated
* @throws IOException
* if the I/O operation fails
*/
@Override
protected final void annotateClass(Class<?> cl) throws IOException {
Object obj = RMIClassLoader.getClassAnnotation(cl);
this.writeObject(obj);
}