public void addAll(Object target) { this.targetClass = target.getClass(); Method[] methods = targetClass.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (isGetter(method)) { addGetter(target, method); } else if (isSetter(method)) { addSetter(target, method); } else { addOperation(target, method); } } }
/** * Delegating DynamicGBean getAttribute method. * @param name of attribute. * @return attribute value. * @throws Exception */ public Object getAttribute(final String name) throws Exception { return delegate.getAttribute(name); }
/** * Gets the config properties in the form of a map where the key is the * property name and the value is property type (as a Class). */ public Map<String, Class> getConfigProperties() { String[] props = delegate.getProperties(); Map<String, Class> map = new HashMap<String, Class>(); for (String prop : props) { if (prop.equals("logWriter")) { continue; } map.put(prop, delegate.getPropertyType(prop)); } return map; }
public ActivationSpecWrapperGBean(@ParamAttribute(name="activationSpecClass")final String activationSpecClass, @ParamAttribute(name="containerId")final String containerId, @ParamReference(name="ResourceAdapaterWrapper", namingType = NameFactory.RESOURCE_ADAPTER)final ResourceAdapterWrapper resourceAdapterWrapper, @ParamSpecial(type = SpecialAttributeType.classLoader)final ClassLoader cl, @ParamReference(name = "ValidatorFactory", namingType = NameFactory.VALIDATOR_FACTORY) ValidatorFactoryGBean validatorFactory) throws IllegalAccessException, InstantiationException, ClassNotFoundException { super(activationSpecClass, containerId, resourceAdapterWrapper, cl, validatorFactory != null ? validatorFactory.getFactory() : null); delegate = new DynamicGBeanDelegate(); delegate.addAll(activationSpec); }
public void setConfigProperty(String property, Object value) throws Exception { Class cls = delegate.getPropertyType(property); if(value != null && value instanceof String && !cls.getName().equals("java.lang.String")) { if(cls.isPrimitive()) { if(cls.equals(int.class)) { cls = Integer.class; } else if(cls.equals(boolean.class)) { cls = Boolean.class; } else if(cls.equals(float.class)) { cls = Float.class; } else if(cls.equals(double.class)) { cls = Double.class; } else if(cls.equals(long.class)) { cls = Long.class; } else if(cls.equals(short.class)) { cls = Short.class; } else if(cls.equals(byte.class)) { cls = Byte.class; } else if(cls.equals(char.class)) { cls = Character.class; } } Constructor con = cls.getConstructor(new Class[]{String.class}); value = con.newInstance(new Object[]{value}); } kernel.setAttribute(abstractName, property, value); }
public void addGetter(Object target, Method method) { String name = method.getName(); if (name.startsWith("get")) { addGetter(name.substring(3), target, method); } else if (name.startsWith("is")) { addGetter(name.substring(2), target, method); } else { throw new IllegalArgumentException("Method name must start with 'get' or 'is' " + method); } }
public void addSetter(Object target, Method method) { if (!method.getName().startsWith("set")) { throw new IllegalArgumentException("Method name must start with 'set' " + method); } addSetter(method.getName().substring(3), target, method); }
Class clazz = cl.loadClass(managedConnectionFactoryClass); managedConnectionFactory = (ManagedConnectionFactory) clazz.newInstance(); delegate = new DynamicGBeanDelegate(); delegate.addAll(managedConnectionFactory); this.kernel = kernel; this.abstractName = abstractName;
public void setConfigProperty(String property, Object value) throws Exception { Class cls = delegate.getPropertyType(property); if(value != null && value instanceof String && !cls.getName().equals("java.lang.String")) { if(cls.isPrimitive()) { if(cls.equals(int.class)) { cls = Integer.class; } else if(cls.equals(boolean.class)) { cls = Boolean.class; } else if(cls.equals(float.class)) { cls = Float.class; } else if(cls.equals(double.class)) { cls = Double.class; } else if(cls.equals(long.class)) { cls = Long.class; } else if(cls.equals(short.class)) { cls = Short.class; } else if(cls.equals(byte.class)) { cls = Byte.class; } else if(cls.equals(char.class)) { cls = Character.class; } } Constructor con = cls.getConstructor(new Class[]{String.class}); value = con.newInstance(new Object[]{value}); } kernel.setAttribute(abstractName, property, value); }
public ResourceAdapterWrapperGBean( @ParamAttribute(name="resourceAdapterClass") String resourceAdapterClass, @ParamAttribute(name="messageListenerToActivationSpecMap") Map<String, String> messageListenerToActivationSpecMap, @ParamReference(name="WorkManager", namingType = NameFactory.JCA_WORK_MANAGER) GeronimoWorkManager workManager, @ParamReference(name="XATerminator", namingType = NameFactory.JCA_WORK_MANAGER)XATerminator xaTerminator, @ParamReference(name="TransactionManager", namingType = NameFactory.JTA_RESOURCE)RecoverableTransactionManager transactionManager, @ParamReference(name="TransactionSynchronizationRegistry", namingType = NameFactory.JTA_RESOURCE) TransactionSynchronizationRegistry transactionSynchronizationRegistry, @ParamSpecial(type= SpecialAttributeType.classLoader )ClassLoader cl, @ParamSpecial(type= SpecialAttributeType.objectName )String objectName, @ParamReference(name = "ValidatorFactory", namingType = NameFactory.VALIDATOR_FACTORY) ValidatorFactoryGBean validatorFactory) throws InstantiationException, IllegalAccessException, ClassNotFoundException { super(objectName, resourceAdapterClass, messageListenerToActivationSpecMap, new GeronimoBootstrapContext(workManager, xaTerminator, transactionSynchronizationRegistry), transactionManager, cl, validatorFactory != null ? validatorFactory.getFactory() : null); delegate = new DynamicGBeanDelegate(); delegate.addAll(resourceAdapter); this.objectName = objectName; }
/** * Gets the config properties in the form of a map where the key is the * property name and the value is property type (as a String not a Class). */ public Map getConfigProperties() { String[] props = delegate.getProperties(); Map map = new HashMap(); for (int i = 0; i < props.length; i++) { String prop = props[i]; if(prop.equals("logWriter")) { continue; } map.put(prop, delegate.getPropertyType(prop)); } return map; }
/** * Delegating DynamicGBean getAttribute method. * * @param name of attribute. * @return attribute value. * @throws Exception */ public Object getAttribute(final String name) throws Exception { return delegate.getAttribute(name); }
/** * Normal managed constructor. * * @param adminObjectInterface Interface the proxy will implement. * @param adminObjectClass Class of admin object to be wrapped. * @throws IllegalAccessException * @throws InstantiationException */ public AdminObjectWrapperGBean( @ParamAttribute(name="adminObjectInterface") String adminObjectInterface, @ParamAttribute(name="adminObjectClass") String adminObjectClass, @ParamReference(name="ResourceAdapterWrapper", namingType = NameFactory.JCA_RESOURCE_ADAPTER) ResourceAdapterWrapper resourceAdapterWrapper, @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel, @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abstractName, @ParamSpecial(type = SpecialAttributeType.objectName) String objectName, @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader cl, @ParamReference(name = "ValidatorFactory", namingType = NameFactory.VALIDATOR_FACTORY) ValidatorFactoryGBean validatorFactory) throws IllegalAccessException, InstantiationException, ClassNotFoundException { super(adminObjectInterface, adminObjectClass, resourceAdapterWrapper, cl, validatorFactory == null ? null : validatorFactory.getFactory()); this.kernel = kernel; this.abstractName = abstractName; this.objectName = objectName; delegate = new DynamicGBeanDelegate(); delegate.addAll(adminObject); }
public Object getConfigProperty(String property) throws Exception { return delegate.getAttribute(property); }
public Object getConfigProperty(String property) throws Exception { return delegate.getAttribute(property); }
public Object getAttribute(String name) throws Exception { return delegate.getAttribute(name); }
public Object getAttribute(String name) throws Exception { Thread thread = Thread.currentThread(); ClassLoader oldTCL = thread.getContextClassLoader(); thread.setContextClassLoader(classLoader); try { return delegate.getAttribute(name); } finally { thread.setContextClassLoader(oldTCL); } }