private Enhancer lookupOrCreateEnhancerFor(Class<?> cls) { Enhancer enhancer = enhancerByClass.get(cls); if (enhancer == null) { enhancer = new Enhancer(); enhancer.setSuperclass(cls); enhancer.setInterfaces(ArrayUtils.combine( cls.getInterfaces(), new Class<?>[] { CglibEnhanced.class })); enhancer.setCallback(callback); enhancerByClass.put(cls, enhancer); } return enhancer; }
public static Object[] getObjectAsObjectArray(final Object option) { final Class<?> arrayType = option.getClass().getComponentType(); if (!arrayType.isPrimitive()) { return (Object[]) option; } if (arrayType == char.class) { return convertCharToCharacterArray(option); } else { return convertPrimitiveToObjectArray(arrayType, option); } }
public Object[] getChoices(final NakedObject owningAdapter) { final Object options = NakedObjectInvokeUtils.invoke(method, owningAdapter); if (options == null) { return null; } if (options.getClass().isArray()) { return ArrayUtils.getObjectAsObjectArray(options); } final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesClass); return NakedObjectAdapterUtils.getCollectionAsObjectArray(options, specification, getRuntimeContext()); }
public Object[] getChoices(final NakedObject owningAdapter) { final Object options = NakedObjectInvokeUtils.invoke(method, owningAdapter); if (options == null) { return null; } if (options.getClass().isArray()) { return ArrayUtils.getObjectAsObjectArray(options); } final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesClass); return NakedObjectAdapterUtils.getCollectionAsObjectArray(options, specification, getRuntimeContext()); }
public NakedObjectAction getObjectAction(final NakedObjectActionType type, final String nameParmsIdentityString) { final NakedObjectAction[] availableActions = ArrayUtils.combine(objectActions, getServiceActions(type)); return getAction2(availableActions, type, nameParmsIdentityString); }
public static Object[] getObjectAsObjectArray(final Object option) { final Class<?> arrayType = option.getClass().getComponentType(); if (!arrayType.isPrimitive()) { return (Object[]) option; } if (arrayType == char.class) { return convertCharToCharacterArray(option); } else { return convertPrimitiveToObjectArray(arrayType, option); } }
public Object[] getChoices(final NakedObject owningAdapter) { final Object options = NakedObjectInvokeUtils.invoke(method, owningAdapter); if (options == null) { return new Object[0]; } if (options.getClass().isArray()) { return ArrayUtils.getObjectAsObjectArray(options); } else { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesType); return NakedObjectAdapterUtils.getCollectionAsObjectArray(options, specification, getRuntimeContext()); } }
public NakedObjectAction getObjectAction( final NakedObjectActionType type, final String id, final NakedObjectSpecification[] parameters) { final NakedObjectAction[] availableActions = ArrayUtils.combine(objectActions, getServiceActions(type)); return getAction(availableActions, type, id, parameters); }
public Object[] getChoices(final NakedObject owningAdapter) { final Object options = NakedObjectInvokeUtils.invoke(method, owningAdapter); if (options == null) { return new Object[0]; } if (options.getClass().isArray()) { return ArrayUtils.getObjectAsObjectArray(options); } else { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesType); return NakedObjectAdapterUtils.getCollectionAsObjectArray(options, specification, getRuntimeContext()); } }
public NakedObjectAction getObjectAction( final NakedObjectActionType type, final String id, final NakedObjectSpecification[] parameters) { final NakedObjectAction[] availableActions = ArrayUtils.combine(objectActions, getServiceActions(type)); return getAction(availableActions, type, id, parameters); }
public Object[][] getChoices(final NakedObject owningAdapter) { final Object[] options = (Object[]) NakedObjectInvokeUtils.invoke(method, owningAdapter); final Object[][] results = new Object[options.length][]; for (int i = 0; i < results.length; i++) { if (options[i] == null) { results[i] = null; } else if (options[i].getClass().isArray()) { results[i] = ArrayUtils.getObjectAsObjectArray(options[i]); } else { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesType); results[i] = NakedObjectAdapterUtils.getCollectionAsObjectArray(options[i], specification, getRuntimeContext()); } } return results; }
private <T> Enhancer lookupOrCreateEnhancerFor(FutureResultFactory<T> resultFactory) { Enhancer enhancer = enhancerByResultFactory.get(resultFactory); Class<T> cls = resultFactory.getResultClass(); if (enhancer == null) { enhancer = new Enhancer(); enhancer.setSuperclass(cls); enhancer.setInterfaces(ArrayUtils.combine( cls.getInterfaces(), new Class<?>[] { Future.class })); enhancer.setCallback(new EvaluatingMethodInterceptor<T>(resultFactory)); enhancerByResultFactory.put(resultFactory, enhancer); } return enhancer; }
public Object[][] getChoices(final NakedObject owningAdapter) { final Object[] options = (Object[]) NakedObjectInvokeUtils.invoke(method, owningAdapter); final Object[][] results = new Object[options.length][]; for (int i = 0; i < results.length; i++) { if (options[i] == null) { results[i] = null; } else if (options.getClass().isArray()) { results[i] = ArrayUtils.getObjectAsObjectArray(options[i]); } else { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(choicesType); results[i] = NakedObjectAdapterUtils.getCollectionAsObjectArray(options[i], specification, getRuntimeContext()); } } return results; }
public NakedObjectAction getObjectAction(final NakedObjectActionType type, final String nameParmsIdentityString) { final NakedObjectAction[] availableActions = ArrayUtils.combine(objectActions, getServiceActions(type)); return getAction2(availableActions, type, nameParmsIdentityString); }
public List<Object> getServices( final DeploymentType deploymentType) { LOG.info("installing " + this.getClass().getName()); final Object[] common = createServices(getConfiguration(), null); final Object[] specific = createServices(getConfiguration(), deploymentType.name()); final Object[] combined = ArrayUtils.combine(common, specific); if (combined.length == 0) { throw new InitialisationException("No services specified"); } return ListUtils.asList(combined); }
@SuppressWarnings("unchecked") public <T> T newInstance(Class<T> cls) { ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setSuperclass(cls); proxyFactory.setInterfaces(ArrayUtils.combine( cls.getInterfaces(), new Class<?>[]{JavassistEnhanced.class})); proxyFactory.setFilter(new MethodFilter() { public boolean isHandled(Method m) { // ignore finalize() return !m.getName().equals("finalize"); } }); Class<T> proxySubclass = proxyFactory.createClass(); try { T newInstance = proxySubclass.newInstance(); ProxyObject proxyObject = (ProxyObject)newInstance; proxyObject.setHandler(methodHandler); return newInstance; } catch (InstantiationException e) { throw new NakedObjectException(e); } catch (IllegalAccessException e) { throw new NakedObjectException(e); } }
@SuppressWarnings("unchecked") public <T> T newInstance(Class<T> cls) { ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setSuperclass(cls); proxyFactory.setInterfaces(ArrayUtils.combine( cls.getInterfaces(), new Class<?>[]{JavassistEnhanced.class})); proxyFactory.setFilter(new MethodFilter() { public boolean isHandled(Method m) { // ignore finalize() return !m.getName().equals("finalize"); } }); Class<T> proxySubclass = proxyFactory.createClass(); try { T newInstance = proxySubclass.newInstance(); ProxyObject proxyObject = (ProxyObject)newInstance; proxyObject.setHandler(methodHandler); return newInstance; } catch (InstantiationException e) { throw new NakedObjectException(e); } catch (IllegalAccessException e) { throw new NakedObjectException(e); } }
public static void addObjectMenuOptions(final NakedObject object, final UserActionSet options) { if (object != null) { final NakedObjectAction[] actions1 = object.getSpecification().getObjectActions(NakedObjectActionConstants.USER); final NakedObjectAction[] actions2 = object.getSpecification().getObjectActions( NakedObjectActionConstants.EXPLORATION); final NakedObjectAction[] actions3 = object.getSpecification().getObjectActions(NakedObjectActionConstants.DEBUG); final NakedObjectAction[] actions = ArrayUtils.combine(actions1, actions2, actions3); menuOptions(actions, object, options); final Oid oid = object.getOid(); final boolean isPersistent = oid != null && !oid.isTransient(); if (!(object.getSpecification().isService()) && !(object.getObject() instanceof NakedObjectList) && isPersistent) { options.add(new DisposeObjectOption()); } } }