本文整理汇总了Java中org.springframework.core.InfrastructureProxy类的典型用法代码示例。如果您正苦于以下问题:Java InfrastructureProxy类的具体用法?Java InfrastructureProxy怎么用?Java InfrastructureProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InfrastructureProxy类属于org.springframework.core包,在下文中一共展示了InfrastructureProxy类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSpringInfrastructureProxyOnImportersWithTheSameRef
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testSpringInfrastructureProxyOnImportersWithTheSameRef() throws Exception {
Object service = new Object();
ServiceInvoker invokerA = new ServiceStaticInterceptor(createObjectTrackingBundleContext(service), ref);
ServiceInvoker invokerB = new ServiceStaticInterceptor(createObjectTrackingBundleContext(service), ref);
InfrastructureProxy proxyA = new InfrastructureOsgiProxyAdvice(invokerA);
InfrastructureProxy proxyB = new InfrastructureOsgiProxyAdvice(invokerB);
// though this is not normal, we want the interceptors to be different to make sure the wrapped object
// gets properly delegated
assertFalse("invokers should not be equal (they have different bundle contexts)", invokerA.equals(invokerB));
assertFalse("proxies should not be equal", proxyA.equals(proxyB));
assertSame(proxyA.getWrappedObject(), proxyB.getWrappedObject());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:14,代码来源:OsgiServiceProxyEqualityTest.java
示例2: testProxyForUnaryCardinality
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testProxyForUnaryCardinality() throws Exception {
long time = 1234;
Date date = new Date(time);
ServiceRegistration reg = publishService(date);
fb.setAvailability(Availability.MANDATORY);
fb.setInterfaces(new Class<?>[] { Date.class });
fb.afterPropertiesSet();
ImportedOsgiServiceProxy refAware = null;
try {
Object result = fb.getObject();
assertTrue(result instanceof Date);
// check it's our object
assertEquals(time, ((Date) result).getTime());
assertTrue(result instanceof SpringProxy);
assertTrue(result instanceof ImportedOsgiServiceProxy);
assertTrue(result instanceof InfrastructureProxy);
refAware = (ImportedOsgiServiceProxy) result;
assertNotNull(refAware.getServiceReference());
assertEquals("wrong target returned", date, ((InfrastructureProxy) result).getWrappedObject());
}
finally {
if (reg != null)
reg.unregister();
}
// test reference after the service went down
assertNotNull(refAware.getServiceReference());
assertNull(refAware.getServiceReference().getBundle());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:35,代码来源:ServiceRefAwareWithSingleServiceTest.java
示例3: testServiceReferenceProperties
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testServiceReferenceProperties() throws Exception {
long time = 1234;
Date date = new Date(time);
Dictionary dict = new Properties();
dict.put("foo", "bar");
dict.put("george", "michael");
ServiceRegistration reg = publishService(date, dict);
fb.setAvailability(Availability.MANDATORY);
fb.setFilter("(&(foo=bar)(george=michael))");
fb.setInterfaces(new Class<?>[] { Date.class });
fb.afterPropertiesSet();
try {
Object result = fb.getObject();
assertTrue(result instanceof Date);
// check it's our object
assertEquals(time, ((Date) result).getTime());
ImportedOsgiServiceProxy refAware = (ImportedOsgiServiceProxy) result;
assertTrue(doesMapContainsDictionary(dict,
OsgiServiceReferenceUtils.getServicePropertiesAsMap(refAware.getServiceReference())));
InfrastructureProxy targetAware = (InfrastructureProxy) result;
assertEquals(date, targetAware.getWrappedObject());
}
finally {
if (reg != null)
reg.unregister();
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:34,代码来源:ServiceRefAwareWithSingleServiceTest.java
示例4: testSpringInfrastructureProxyOnImportersWithDifferentRefs
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testSpringInfrastructureProxyOnImportersWithDifferentRefs() throws Exception {
Object service = new Object();
BundleContext ctx = createObjectTrackingBundleContext(service);
ServiceInvoker invokerA = new ServiceStaticInterceptor(ctx, new MockServiceReference());
ServiceInvoker invokerB = new ServiceStaticInterceptor(ctx, new MockServiceReference());
InfrastructureProxy proxyA = new InfrastructureOsgiProxyAdvice(invokerA);
InfrastructureProxy proxyB = new InfrastructureOsgiProxyAdvice(invokerB);
assertFalse("invokers should not be equal (they have different service references)", invokerA.equals(invokerB));
assertFalse("proxies should not be equal", proxyA.equals(proxyB));
assertFalse("target objects should not be equal", proxyA.getWrappedObject().equals(proxyB.getWrappedObject()));
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:13,代码来源:OsgiServiceProxyEqualityTest.java
示例5: testNakedTargetPropertyReturnedByTheInfrastructureProxy
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testNakedTargetPropertyReturnedByTheInfrastructureProxy() throws Exception {
Object service = new Object();
ServiceInvoker invoker = new ServiceStaticInterceptor(createObjectTrackingBundleContext(service), ref);
InfrastructureProxy proxy = new InfrastructureOsgiProxyAdvice(invoker);
assertSame(TestUtils.invokeMethod(invoker, "getTarget", null), proxy.getWrappedObject());
assertSame(service, proxy.getWrappedObject());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:8,代码来源:OsgiServiceProxyEqualityTest.java
示例6: testCreatedProxy
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testCreatedProxy() throws Exception {
MockServiceReference ref = new MockServiceReference();
Object proxy = proxyCreator.createServiceProxy(ref).proxy;
assertTrue(proxy instanceof ImportedOsgiServiceProxy);
assertTrue(proxy instanceof InfrastructureProxy);
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:8,代码来源:InfrastructureProxyTest.java
示例7: unwrapResourceIfNecessary
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
/**
* Unwrap the given resource handle if necessary; otherwise return
* the given handle as-is.
* @see org.springframework.core.InfrastructureProxy#getWrappedObject()
*/
static Object unwrapResourceIfNecessary(Object resource) {
Assert.notNull(resource, "Resource must not be null");
Object resourceRef = resource;
// unwrap infrastructure proxy
if (resourceRef instanceof InfrastructureProxy) {
resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
}
if (aopAvailable) {
// now unwrap scoped proxy
resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
}
return resourceRef;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:TransactionSynchronizationUtils.java
示例8: testProxyForUnaryCardinality
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testProxyForUnaryCardinality() throws Exception {
long time = 1234;
Date date = new Date(time);
ServiceRegistration reg = publishService(date);
fb.setCardinality(Cardinality.C_1__1);
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
ImportedOsgiServiceProxy refAware = null;
try {
Object result = fb.getObject();
assertTrue(result instanceof Date);
// check it's our object
assertEquals(time, ((Date) result).getTime());
assertTrue(result instanceof SpringProxy);
assertTrue(result instanceof ImportedOsgiServiceProxy);
assertTrue(result instanceof InfrastructureProxy);
refAware = (ImportedOsgiServiceProxy) result;
assertNotNull(refAware.getServiceReference());
assertEquals("wrong target returned", date, ((InfrastructureProxy) result).getWrappedObject());
}
finally {
if (reg != null)
reg.unregister();
}
// test reference after the service went down
assertNotNull(refAware.getServiceReference());
assertNull(refAware.getServiceReference().getBundle());
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:35,代码来源:ServiceRefAwareWithSingleServiceTest.java
示例9: testServiceReferenceProperties
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testServiceReferenceProperties() throws Exception {
long time = 1234;
Date date = new Date(time);
Dictionary dict = new Properties();
dict.put("foo", "bar");
dict.put("george", "michael");
ServiceRegistration reg = publishService(date, dict);
fb.setCardinality(Cardinality.C_1__1);
fb.setFilter("(&(foo=bar)(george=michael))");
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
try {
Object result = fb.getObject();
assertTrue(result instanceof Date);
// check it's our object
assertEquals(time, ((Date) result).getTime());
ImportedOsgiServiceProxy refAware = (ImportedOsgiServiceProxy) result;
assertTrue(doesMapContainsDictionary(dict,
OsgiServiceReferenceUtils.getServicePropertiesAsMap(refAware.getServiceReference())));
InfrastructureProxy targetAware = (InfrastructureProxy) result;
assertEquals(date, targetAware.getWrappedObject());
}
finally {
if (reg != null)
reg.unregister();
}
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:34,代码来源:ServiceRefAwareWithSingleServiceTest.java
示例10: testFactoryBeanForMultipleServicesAsClasses
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testFactoryBeanForMultipleServicesAsClasses() throws Exception {
fb.setAvailability(Availability.OPTIONAL);
fb.setInterfaces(new Class<?>[] { Date.class });
fb.afterPropertiesSet();
List registrations = new ArrayList(3);
long time = 321;
Date dateA = new Date(time);
try {
Object result = fb.getObject();
assertTrue(result instanceof Collection);
Collection col = (Collection) result;
assertTrue(col.isEmpty());
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(dateA));
try {
iter.next();
fail("should have thrown exception");
}
catch (NoSuchElementException ex) {
// expected
}
assertTrue(iter.hasNext());
Object service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertEquals(dateA, ((InfrastructureProxy) service).getWrappedObject());
assertFalse(iter.hasNext());
time = 111;
Date dateB = new Date(time);
registrations.add(publishService(dateB));
assertTrue(iter.hasNext());
service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertFalse(dateA.equals(((InfrastructureProxy) service).getWrappedObject()));
assertEquals(dateB, ((InfrastructureProxy) service).getWrappedObject());
}
finally {
cleanRegistrations(registrations);
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:50,代码来源:MultiServiceProxyFactoryBeanTest.java
示例11: testIteratorWhenServiceGoesDown
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testIteratorWhenServiceGoesDown() throws Exception {
fb.setAvailability(Availability.OPTIONAL);
fb.setInterfaces(new Class<?>[] { Date.class });
fb.afterPropertiesSet();
long time = 123;
Date date = new Date(time);
Properties props = new Properties();
props.put("Moroccan", "Sunset");
List registrations = new ArrayList(3);
try {
Collection col = (Collection) fb.getObject();
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(date, props));
assertTrue(iter.hasNext());
// deregister service
((ServiceRegistration) registrations.remove(0)).unregister();
// has to successed
Object obj = iter.next();
assertTrue(obj instanceof ImportedOsgiServiceProxy);
assertTrue(obj instanceof Date);
assertTrue(obj instanceof InfrastructureProxy);
// the properties will contain the ObjectClass also
assertEquals(((ImportedOsgiServiceProxy) obj).getServiceReference().getProperty("Moroccan"), "Sunset");
try {
// make sure the service is dead
((Date) obj).getTime();
fail("should have thrown exception");
}
catch (ServiceUnavailableException ex) {
// proxy is dead
}
}
finally {
cleanRegistrations(registrations);
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:44,代码来源:MultiServiceProxyFactoryBeanTest.java
示例12: testProxyForMultipleCardinality
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testProxyForMultipleCardinality() throws Exception {
fb.setAvailability(Availability.OPTIONAL);
fb.setInterfaces(new Class<?>[] { Date.class });
fb.afterPropertiesSet();
List registrations = new ArrayList(3);
long time = 321;
Date dateA = new Date(time);
try {
Object result = fb.getObject();
assertTrue(result instanceof Collection);
Collection col = (Collection) result;
assertTrue(col.isEmpty());
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(dateA));
assertTrue(iter.hasNext());
Object service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertTrue(service instanceof ImportedOsgiServiceProxy);
assertNotNull(((ImportedOsgiServiceProxy) service).getServiceReference());
assertSame(dateA, ((InfrastructureProxy) service).getWrappedObject());
assertFalse(iter.hasNext());
time = 111;
Date dateB = new Date(time);
registrations.add(publishService(dateB));
assertTrue(iter.hasNext());
service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertTrue(service instanceof ImportedOsgiServiceProxy);
assertNotNull(((ImportedOsgiServiceProxy) service).getServiceReference());
assertTrue(service instanceof InfrastructureProxy);
assertSame(dateB, ((InfrastructureProxy) service).getWrappedObject());
}
finally {
for (int i = 0; i < registrations.size(); i++) {
((ServiceRegistration) registrations.get(i)).unregister();
}
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:50,代码来源:ServiceRefAwareWithMultiServiceTest.java
示例13: testFactoryBeanForMultipleServicesAsClasses
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testFactoryBeanForMultipleServicesAsClasses() throws Exception {
fb.setCardinality(Cardinality.C_0__N);
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
List registrations = new ArrayList(3);
long time = 321;
Date dateA = new Date(time);
try {
Object result = fb.getObject();
assertTrue(result instanceof Collection);
Collection col = (Collection) result;
assertTrue(col.isEmpty());
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(dateA));
try {
iter.next();
fail("should have thrown exception");
}
catch (NoSuchElementException ex) {
// expected
}
assertTrue(iter.hasNext());
Object service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertEquals(dateA, ((InfrastructureProxy) service).getWrappedObject());
assertFalse(iter.hasNext());
time = 111;
Date dateB = new Date(time);
registrations.add(publishService(dateB));
assertTrue(iter.hasNext());
service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertFalse(dateA.equals(((InfrastructureProxy) service).getWrappedObject()));
assertEquals(dateB, ((InfrastructureProxy) service).getWrappedObject());
}
finally {
cleanRegistrations(registrations);
}
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:50,代码来源:MultiServiceProxyFactoryBeanTest.java
示例14: testIteratorWhenServiceGoesDown
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testIteratorWhenServiceGoesDown() throws Exception {
fb.setCardinality(Cardinality.C_0__N);
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
long time = 123;
Date date = new Date(time);
Properties props = new Properties();
props.put("Moroccan", "Sunset");
List registrations = new ArrayList(3);
try {
Collection col = (Collection) fb.getObject();
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(date, props));
assertTrue(iter.hasNext());
// deregister service
((ServiceRegistration) registrations.remove(0)).unregister();
// has to successed
Object obj = iter.next();
assertTrue(obj instanceof ImportedOsgiServiceProxy);
assertTrue(obj instanceof Date);
assertTrue(obj instanceof InfrastructureProxy);
// the properties will contain the ObjectClass also
assertEquals(((ImportedOsgiServiceProxy) obj).getServiceReference().getProperty("Moroccan"), "Sunset");
try {
// make sure the service is dead
((Date) obj).getTime();
fail("should have thrown exception");
}
catch (ServiceUnavailableException ex) {
// proxy is dead
}
}
finally {
cleanRegistrations(registrations);
}
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:44,代码来源:MultiServiceProxyFactoryBeanTest.java
示例15: testProxyForMultipleCardinality
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
public void testProxyForMultipleCardinality() throws Exception {
fb.setCardinality(Cardinality.C_0__N);
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
List registrations = new ArrayList(3);
long time = 321;
Date dateA = new Date(time);
try {
Object result = fb.getObject();
assertTrue(result instanceof Collection);
Collection col = (Collection) result;
assertTrue(col.isEmpty());
Iterator iter = col.iterator();
assertFalse(iter.hasNext());
registrations.add(publishService(dateA));
assertTrue(iter.hasNext());
Object service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertTrue(service instanceof ImportedOsgiServiceProxy);
assertNotNull(((ImportedOsgiServiceProxy) service).getServiceReference());
assertSame(dateA, ((InfrastructureProxy) service).getWrappedObject());
assertFalse(iter.hasNext());
time = 111;
Date dateB = new Date(time);
registrations.add(publishService(dateB));
assertTrue(iter.hasNext());
service = iter.next();
assertTrue(service instanceof Date);
assertEquals(time, ((Date) service).getTime());
assertTrue(service instanceof ImportedOsgiServiceProxy);
assertNotNull(((ImportedOsgiServiceProxy) service).getServiceReference());
assertTrue(service instanceof InfrastructureProxy);
assertSame(dateB, ((InfrastructureProxy) service).getWrappedObject());
}
finally {
for (int i = 0; i < registrations.size(); i++) {
((ServiceRegistration) registrations.get(i)).unregister();
}
}
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:50,代码来源:ServiceRefAwareWithMultiServiceTest.java
示例16: buildSessionFactory
import org.springframework.core.InfrastructureProxy; //导入依赖的package包/类
/**
* Build the Hibernate {@code SessionFactory} through background bootstrapping,
* using the given executor for a parallel initialization phase
* (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}).
* <p>{@code SessionFactory} initialization will then switch into background
* bootstrap mode, with a {@code SessionFactory} proxy immediately returned for
* injection purposes instead of waiting for Hibernate's bootstrapping to complete.
* However, note that the first actual call to a {@code SessionFactory} method will
* then block until Hibernate's bootstrapping completed, if not ready by then.
* For maximum benefit, make sure to avoid early {@code SessionFactory} calls
* in init methods of related beans, even for metadata introspection purposes.
*
* @see #buildSessionFactory()
* @since 4.3
*/
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
new Class<?>[]{SessionFactoryImplementor.class, InfrastructureProxy.class},
new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
}
开发者ID:baomidou,项目名称:hibernate-plus,代码行数:22,代码来源:HibernateSpringSessionFactoryBuilder.java
注:本文中的org.springframework.core.InfrastructureProxy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论