[Design the new POJO MicroContainer] - Re: enums, generics and other animals
by adrian@jboss.org
"alesj" wrote : "adrian(a)jboss.org" wrote : Why have you created a package called "enums"?
| |
| Now you complain. :-)
| I proposed the name in the first few posts.
| Just following the silence rule. ;-)
|
This thread is pages long (you expect me to spot a package name
called enums in discussion about enums ;-)
anonymous wrote :
| @Factory does what our constructor xml factory does as well.
| It just happens to be on the class rather than on the constructor.
| If the factoryClass is not specified, the class on which it is defined is used.
|
| @FactoryMethod is probably an extension, but functionally similar to @Factory with class and method specified.
| You scan the static methods which are annotated to be factory methods.
Ok, makes sense now, it just looked stupid at first glance. I should RTFM
and remember to engage my brain before opening my mouth :-)
| /**
| * Mark static method as factory method.
| *
| * @author <a href="mailto:ales.justin@jboss.com">Ales Justin</a>
| */
| public @interface FactoryMethod
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134950#4134950
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134950
18 years, 1 month
[Design of Clustering on JBoss (Clusters/JBoss)] - Re: Another way to write clustered singletons
by sebastianlacuesta
Excellent. I want to call a method of a singleton service. I tried using an RMIAdaptor this way:
| public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
| PrintWriter out = response.getWriter();
| String numero = request.getParameter("numero");
| String mensaje = request.getParameter("mensaje");
| try {
| Context context = new InitialContext();
| RMIAdaptor rmiAdaptor = (RMIAdaptor)context.lookup("jmx/rmi/RMIAdaptor");
| if ((rmiAdaptor != null) && (rmiAdaptor.isRegistered(new ObjectName("poksmedia.mbean:service=MBloxService")))) {
| rmiAdaptor.invoke(new ObjectName("poksmedia.mbean:service=MBloxService"), "sendMessage", new Object[]{numero, mensaje}, new String[]{"java.lang.String", "java.lang.String"});
| out.print("El mensaje se envió correctamente (creo).");
| }
| } catch (NamingException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (MalformedObjectNameException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (NullPointerException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (InstanceNotFoundException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (MBeanException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| } catch (ReflectionException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
This works awesome in the same node where the service is running. But not in the others. It throws a javax.management.RuntimeMBeanException
.
Any ideas?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134945#4134945
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134945
18 years, 1 month
[Design the new POJO MicroContainer] - Re: enums, generics and other animals
by alesj
"adrian(a)jboss.org" wrote : Why have you created a package called "enums"?
|
Now you complain. :-)
I proposed the name in the first few posts.
Just following the silence rule. ;-)
"adrian(a)jboss.org" wrote :
| Would you create a package called "classes"? :-)
|
Why are then plenty of interfaces packages (not in MC, but 'around')?
And the annotations, like you figured out your self.
And I didn't start with those. ;-)
"adrian(a)jboss.org" wrote :
| Either put the enums in the annotations package or create a package called model or something. This package would also contain callback interfaces referenced (like the ScopeFactory in the metadata repository) so calling it "enums" is plain wrong.
|
OK, model it is.
"adrian(a)jboss.org" wrote :
| 1) Why do you have class names as strings in the annotations?
| To be able to read the annotations at all the classloader must exist
| so there's no problem with letting the users specify classes.
|
Bug. :-)
That's why I called the commit initial.
"adrian(a)jboss.org" wrote :
| 2) How can the Factory(Method) annotations work?
|
| These are used at object construction. You don't know the type until
| the object is constructed so how can read the annotations? :-)
|
Why should the object be constructed?
Isn't class enough, to read off the annotations?
@Factory does what our constructor xml factory does as well.
It just happens to be on the class rather than on the constructor.
If the factoryClass is not specified, the class on which it is defined is used.
@FactoryMethod is probably an extension, but functionally similar to @Factory with class and method specified.
You scan the static methods which are annotated to be factory methods.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134944#4134944
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134944
18 years, 1 month
[Design the new POJO MicroContainer] - Re: enums, generics and other animals
by adrian@jboss.org
Why have you created a package called "enums"?
That's just stupid. Packages should be based on what they provide
not what there contents are.
Would you create a package called "classes"? :-)
e.g. The metatype project has
org.jboss.metatype.api
- annotations
- types
- values
I think a package called "annotations" is stupid as well, but it seems to be a convention. :-)
Either put the enums in the annotations package or create a package called
model or something. This package would also contain callback interfaces referenced
(like the ScopeFactory in the metadata repository) so calling it "enums" is plain wrong.
A couple of related issues now that I look at the annotations:
1) Why do you have class names as strings in the annotations?
To be able to read the annotations at all the classloader must exist
so there's no problem with letting the users specify classes.
2) How can the Factory(Method) annotations work?
These are used at object construction. You don't know the type until
the object is constructed so how can read the annotations? :-)
I could understand it if this was somehow used to annotation a package
with what beans need constructing and how to do it.
e.g.
| @Beans
| ({
| @Bean(name="blah", class=MyBean.class),
| @Bean(name="blah2", factory=MyFactory.class, method="create")
| })
| package com.acme;
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134935#4134935
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134935
18 years, 1 month