本文整理了Java中javax.naming.Reference.getFactoryClassLocation
方法的一些代码示例,展示了Reference.getFactoryClassLocation
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getFactoryClassLocation
方法的具体详情如下:
包路径:javax.naming.Reference
类名称:Reference
方法名:getFactoryClassLocation
暂无
代码示例来源:origin: com.atlassian.manager/application-manager-common
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
Context contextProxy = (Context) proxy;
final String methodName = method.getName();
if (log.isDebugEnabled())
{
log.debug("invoking [ " + methodName + "(" + argsString(args) + ") ] on [ " + delegate + " ]");
}
if ("createSubContext".equals(methodName))
{
Context context = (Context) method.invoke(delegate, args);
return new JNDIContextHandler(context);
}
else
{
final Object result = method.invoke(delegate, args);
if (result instanceof Reference)
{
Reference ref = (Reference) result;
ObjectFactory f = (ObjectFactory) contextProxy.lookup(ref.getFactoryClassLocation());
final Object res = f.getObjectInstance(ref, null, null, null);
System.out.println(res);
return res;
}
else
{
return result;
}
}
}
代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common
if (reference.getFactoryClassLocation() != null)
writer.writeAttribute(FACTORY_LOCATION_ATTR, reference.getFactoryClassLocation());
代码示例来源:origin: org.jboss.openjdk-orb/openjdk-orb-jdk9-supplement
/**
* Check whether object factory code base is trusted.
* Classes may only be loaded from an arbitrary URL code base when
* the system property com.sun.jndi.rmi.object.trustURLCodebase
* has been set to "true".
*/
public static boolean isObjectFactoryTrusted(Object obj)
throws NamingException {
// Extract Reference, if possible
Reference ref = null;
if (obj instanceof Reference) {
ref = (Reference) obj;
} else if (obj instanceof Referenceable) {
ref = ((Referenceable)(obj)).getReference();
}
if (ref != null && ref.getFactoryClassLocation() != null &&
!CNCtx.trustURLCodebase) {
throw new ConfigurationException(
"The object factory is untrusted. Set the system property" +
" 'com.sun.jndi.cosnaming.object.trustURLCodebase' to 'true'.");
}
return true;
}
代码示例来源:origin: c3p0/c3p0
/**
* @deprecated nesting references seemed useful until I realized that
* references are Serializable and can be stored in a BinaryRefAddr.
* Oops.
*/
public static void appendToReference(Reference appendTo, Reference orig)
throws NamingException
{
int len = orig.size();
appendTo.add( new StringRefAddr( REFADDR_VERSION, String.valueOf( CURRENT_REF_VERSION ) ) );
appendTo.add( new StringRefAddr( REFADDR_CLASSNAME, orig.getClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY, orig.getFactoryClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY_CLASS_LOCATION,
orig.getFactoryClassLocation() ) );
appendTo.add( new StringRefAddr( REFADDR_SIZE, String.valueOf(len) ) );
for (int i = 0; i < len; ++i)
appendTo.add( orig.get(i) );
}
代码示例来源:origin: c3p0/c3p0
String fClassLocation = ref.getFactoryClassLocation();
代码示例来源:origin: com.mchange/mchange-commons-java
String fClassLocation = ref.getFactoryClassLocation();
代码示例来源:origin: com.mchange.c3p0/com.springsource.com.mchange.v2.c3p0
String fClassLocation = ref.getFactoryClassLocation();
代码示例来源:origin: com.mchange.c3p0/com.springsource.com.mchange.v2.c3p0
/**
* @deprecated nesting references seemed useful until I realized that
* references are Serializable and can be stored in a BinaryRefAddr.
* Oops.
*/
public static void appendToReference(Reference appendTo, Reference orig)
throws NamingException
{
int len = orig.size();
appendTo.add( new StringRefAddr( REFADDR_VERSION, String.valueOf( CURRENT_REF_VERSION ) ) );
appendTo.add( new StringRefAddr( REFADDR_CLASSNAME, orig.getClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY, orig.getFactoryClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY_CLASS_LOCATION,
orig.getFactoryClassLocation() ) );
appendTo.add( new StringRefAddr( REFADDR_SIZE, String.valueOf(len) ) );
for (int i = 0; i < len; ++i)
appendTo.add( orig.get(i) );
}
代码示例来源:origin: com.mchange/mchange-commons-java
/**
* @deprecated nesting references seemed useful until I realized that
* references are Serializable and can be stored in a BinaryRefAddr.
* Oops.
*/
public static void appendToReference(Reference appendTo, Reference orig)
throws NamingException
{
int len = orig.size();
appendTo.add( new StringRefAddr( REFADDR_VERSION, String.valueOf( CURRENT_REF_VERSION ) ) );
appendTo.add( new StringRefAddr( REFADDR_CLASSNAME, orig.getClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY, orig.getFactoryClassName() ) );
appendTo.add( new StringRefAddr( REFADDR_FACTORY_CLASS_LOCATION,
orig.getFactoryClassLocation() ) );
appendTo.add( new StringRefAddr( REFADDR_SIZE, String.valueOf(len) ) );
for (int i = 0; i < len; ++i)
appendTo.add( orig.get(i) );
}
代码示例来源:origin: hibernate/hibernate-ogm
@Test
public void testJNDIReference() throws Exception {
final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "ogm", TestHelper.getDefaultTestSettings() );
SessionFactory factory = (SessionFactory) emf;
Reference reference = factory.getReference();
assertThat( reference.getClassName() ).isEqualTo( OgmSessionFactoryImpl.class.getName() );
assertThat( reference.getFactoryClassName() ).isEqualTo( ObjectFactoryImpl.class.getName() );
assertThat( reference.get( 0 ) ).isNotNull();
assertThat( reference.getFactoryClassLocation() ).isNull();
ObjectFactory objFactory = new ObjectFactoryImpl();
SessionFactory factoryFromRegistry = (SessionFactory) objFactory.getObjectInstance( reference, null, null, null );
assertThat( factoryFromRegistry.getClass() ).isEqualTo( OgmSessionFactoryImpl.class );
assertThat( factoryFromRegistry.getReference() ).isEqualTo( factory.getReference() );
emf.close();
}
代码示例来源:origin: hibernate/hibernate-ogm
@Test
public void testGetReferenceImplementation() throws Exception {
final Session session = openSession();
SessionFactory factory = session.getSessionFactory();
assertThat( factory.getClass() ).isEqualTo( OgmSessionFactoryImpl.class );
Reference reference = factory.getReference();
assertThat( reference.getClassName() ).isEqualTo( OgmSessionFactoryImpl.class.getName() );
assertThat( reference.getFactoryClassName() ).isEqualTo( ObjectFactoryImpl.class.getName() );
assertThat( reference.get( 0 ) ).isNotNull();
assertThat( reference.getFactoryClassLocation() ).isNull();
ObjectFactory objFactory = new ObjectFactoryImpl();
SessionFactory factoryFromRegistry = (SessionFactory) objFactory.getObjectInstance( reference, null, null, null );
assertThat( factoryFromRegistry.getClass() ).isEqualTo( OgmSessionFactoryImpl.class );
assertThat( factoryFromRegistry.getReference() ).isEqualTo( factory.getReference() );
session.close();
}
内容来源于网络,如有侵权,请联系作者删除!