use of org.jowidgets.util.IDecorator in project jo-client-platform by jo-source.
the class ServicesDecoratorProviderImpl method getDecorator.
@Override
public <SERVICE_TYPE> IDecorator<SERVICE_TYPE> getDecorator(final IServiceId<SERVICE_TYPE> id) {
Assert.paramNotNull(id, "id");
final IDecorator typeDecorator = decorators.get(id);
if (defaultDecorator != null || typeDecorator != null) {
return new IDecorator<SERVICE_TYPE>() {
@Override
public SERVICE_TYPE decorate(final SERVICE_TYPE original) {
SERVICE_TYPE result = original;
if (defaultDecorator != null) {
result = (SERVICE_TYPE) defaultDecorator.decorate(result);
}
if (typeDecorator != null) {
result = (SERVICE_TYPE) typeDecorator.decorate(result);
}
return result;
}
};
} else {
return null;
}
}
use of org.jowidgets.util.IDecorator in project jo-client-platform by jo-source.
the class CancelServicesDecoratorProviderImpl method getDecorator.
@Override
public <SERVICE_TYPE> IDecorator<SERVICE_TYPE> getDecorator(final IServiceId<SERVICE_TYPE> id) {
Assert.paramNotNull(id, "id");
final Class<? extends SERVICE_TYPE> serviceType = id.getServiceType();
return new IDecorator<SERVICE_TYPE>() {
@SuppressWarnings("unchecked")
@Override
public SERVICE_TYPE decorate(final SERVICE_TYPE original) {
if (services.contains(serviceType)) {
final InvocationHandler invocationHandler = new CancelInvocationHandler(original);
return (SERVICE_TYPE) Proxy.newProxyInstance(serviceType.getClassLoader(), new Class[] { serviceType }, invocationHandler);
} else {
return original;
}
}
};
}
use of org.jowidgets.util.IDecorator in project jo-client-platform by jo-source.
the class SecureServiceDecoratorProviderImpl method getDecorator.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <SERVICE_TYPE> IDecorator<SERVICE_TYPE> getDecorator(final IServiceId<SERVICE_TYPE> id) {
Assert.paramNotNull(id, "id");
if (id instanceof ISecureServiceId) {
final Object authorization = ((ISecureServiceId) id).getAuthorization();
final Class<? extends SERVICE_TYPE> serviceType = id.getServiceType();
return new IDecorator<SERVICE_TYPE>() {
@Override
public SERVICE_TYPE decorate(final SERVICE_TYPE original) {
final InvocationHandler invocationHandler = new SecurityInvocationHandler(original, authorization);
return (SERVICE_TYPE) Proxy.newProxyInstance(serviceType.getClassLoader(), new Class[] { serviceType }, invocationHandler);
}
};
} else if (DecorationMode.ALLOW_UNSECURE == decorationMode) {
return new IdentityTransformationDecorator<SERVICE_TYPE>();
} else {
throw new RuntimeException("The service with the id '" + id + "' has not the type '" + ISecureServiceId.class.getName() + "'");
}
}
use of org.jowidgets.util.IDecorator in project jo-client-platform by jo-source.
the class JpaServicesDecoratorProviderImpl method getDecorator.
@Override
public <SERVICE_TYPE> IDecorator<SERVICE_TYPE> getDecorator(final IServiceId<SERVICE_TYPE> id) {
Assert.paramNotNull(id, "id");
final Class<? extends SERVICE_TYPE> serviceType = id.getServiceType();
return new IDecorator<SERVICE_TYPE>() {
@SuppressWarnings("unchecked")
@Override
public SERVICE_TYPE decorate(final SERVICE_TYPE original) {
if (entityManagerServices.contains(serviceType) || transactionalServices.contains(serviceType)) {
final InvocationHandler invocationHandler = new JpaInvocationHandler(serviceType, original);
return (SERVICE_TYPE) Proxy.newProxyInstance(serviceType.getClassLoader(), new Class[] { serviceType }, invocationHandler);
} else {
return original;
}
}
};
}
use of org.jowidgets.util.IDecorator in project jo-client-platform by jo-source.
the class Neo4JServicesDecoratorProviderImpl method getDecorator.
@Override
public <SERVICE_TYPE> IDecorator<SERVICE_TYPE> getDecorator(final IServiceId<SERVICE_TYPE> id) {
Assert.paramNotNull(id, "id");
final Class<? extends SERVICE_TYPE> serviceType = id.getServiceType();
return new IDecorator<SERVICE_TYPE>() {
@SuppressWarnings("unchecked")
@Override
public SERVICE_TYPE decorate(final SERVICE_TYPE original) {
final InvocationHandler invocationHandler = new Neo4JInvocationHandler(serviceType, original);
return (SERVICE_TYPE) Proxy.newProxyInstance(serviceType.getClassLoader(), new Class[] { serviceType }, invocationHandler);
}
};
}
Aggregations