javabeans

spring destroy bean manually instead of ctx.close()

二次信任 提交于 2019-12-25 05:46:12
问题 is it possible to tell the container of spring to destroy a specific bean (prototype) in order to save up memory? I dont want to user ctx.close() in order to see this bean destroyed, but rather on runtime. 回答1: If I understand you correctly you want to remove bean that was defined in the ctx at runtime, will I use BeanDefinitionRegistry to get this done, BeanDefinitionRegistry has a method of removeBean() which takes the bean name as the parameter. BeanDefinitionRegistry factory =

Register additional beans from xml definition into application context that is already initialized

青春壹個敷衍的年華 提交于 2019-12-25 04:04:58
问题 I've got an application context already initialized and I need to load another beans from xml definition into it in addition. I can do applicationContext.getAutowireCapableBeanFactory() but it is just for autowiring properties of some Object. I can't find how to do that via XmlBeanDefinitionReader and ContextLoader, because as you can see, only public method is loadContext(String... locations) and it always creates a new context. public final ConfigurableApplicationContext loadContext(String.

How can I put 2 java swing elements on top of each other?

落爺英雄遲暮 提交于 2019-12-25 01:34:08
问题 so I have this project that I'm doing, which draws a circle and a square, and resizes them through buttons. Everything works great, however what I must do is put the circle inside the square, so that the circle is inscribed, and I can't seem to figure out how to put both swing elements on top of each other. Here's a picture of how it currently is: And here's a photoshop version of how it should look like: Here's my Circle class: import java.awt.Canvas; import java.awt.Color; import java.awt

Wildfly Artemis ActiveMQ lookup fail

▼魔方 西西 提交于 2019-12-25 00:15:58
问题 My lookup for a que fail. The que is registered in the wildfly and configured with ironjacamar.xml wildfly output on start: Bound JCA AdminObject [java:jboss/activemq/queue/HELLOWORLDMDBQueue] ironjacamar config: <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/HELLOWORLDMDBQueue"> <config-property name="PhysicalName"> activemq/queue/HELLOWORLDMDBQueue </config-property> </admin-object> ra.xml: <adminobject> <adminobject-interface>javax

Java EE 7 containers: initialize bean at startup without adding it to beans.xml?

一世执手 提交于 2019-12-24 20:01:16
问题 Is there any bean type or Java EE annotation to get a bean initialized at container startup without adding the bean to beans.xml? 回答1: Yes, there is. This is what I use when I need a singleton, application scoped bean started on deploy: import javax.ejb.Singleton; import javax.ejb.Startup; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.annotation.PostConstruct; @Named( "myBean" ) @ApplicationScoped @Startup @Singleton public class MyBean {

Using JSP Bean in a Servlet

假装没事ソ 提交于 2019-12-24 19:11:26
问题 So I'm using a bean on a JSP page to store some data, like so: <jsp:useBean id="data" class="myclass" scope="session" /> Is there anyway to access this bean from a servlet at a later time in the same session? EDIT: Apparently I'm not accessing the same session when I load the jsp page and the servlet. I'm printing out the session ID and it's giving me a different value for both pages, so I can't access the bean. Any ideas? 回答1: Yes, you can obtain it as attribute from the session by the id as

spring validation in a desktop application

微笑、不失礼 提交于 2019-12-24 16:17:14
问题 Here I have a sample of the most basic spring validator I can imagine :-). Since it is a desktop application, i am not running the container, that is supposed to call validate in certain moments. Is there any utility to invoke the validate method the same way the spring container does? Or calling validate is sufficient? In this case, what is the concrete implementation of Errors object that i have to pass to validate? Here is the example (mostly decorative): First i have a Person class, with

Compare two pojo and output difference to another pojo

一世执手 提交于 2019-12-24 15:04:02
问题 I have a pojo class as follows. public class Person { private String name; private Address address; public String getName() { ... } public Address getAddress() { ... } //Address bean public void setName() { ... } public void setAddress() { ... } } Get data from DB (json converted to above POJO) Show it to user User changes his Address Saving back to DB This is what currently happening. Now I am trying to make a delta of user made changes Vs database changes. (which is address alone) I need to

JavaFX FXML table; why won't my data display

我的未来我决定 提交于 2019-12-24 14:42:49
问题 I'm trying to create a simple table using FXML. The table displays fine, but it's not displaying my data. Here's my main program. public final class TableTest extends Application { @Override public void start(final Stage primaryStage) { URL fxml = ClassLoader.getSystemClassLoader().getResource("Table.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(fxml); TableController tableController = new TableController(); fxmlLoader.setController(tableController); try { Pane rootPane = (Pane) fxmlLoader

Can't get Spring to inject my dependencies

可紊 提交于 2019-12-24 12:10:09
问题 I've been trying to get Spring to inject an @Autowired dependency into my application without avail. What am I doing wrong? I created a bean called TimeService. Its job is to return the current time to anyone that asks. package com.foxbomb.springtest.domain.time; import java.util.Date; import org.springframework.stereotype.Service; @Service public class TimeService { public TimeService() { super(); System.out.println("Instantiating TimeService..."); } public Date getTime() { return new Date()