'2016/08/23'에 해당되는 글 4건

  1. 2016.08.23 @PropertySource 값이 null 로 들어오는 경우
  2. 2016.08.23 mybatis query parameter binding
  3. 2016.08.23 Spring RestTemplate
  4. 2016.08.23 eclipse Hotswap Agent 1
카테고리 없음2016. 8. 23. 18:15
반응형


클래스에 EnvironmentAware 상속 받은다음에 Override setEnvironment 해주면 됩니다.

시점때문에 생기는 문제네요..



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@Configuration
@PropertySource("classpath:myProperties.properties")
public class MyConfiguration implements EnvironmentAware {
 
    private Environment environment;
 
    @Override
    public void setEnvironment(final Environment environment) {
        this.environment = environment;
    }
 
    public void myMethod() {
        final String myPropertyValue = environment.getProperty("myProperty");
        // ...
    }
 
}
cs



1
2
3
4
5
6
7
8
9
10
public class SystemLogApplication  implements EnvironmentAware{
 
@Autowired
private static Environment env;
 
@Override
    public void setEnvironment(Environment environment) {
        // TODO Auto-generated method stub
        this.env = environment;
    } 
cs


Posted by 1010
카테고리 없음2016. 8. 23. 18:11
반응형


1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <setting name="callSettersOnNulls" value="true" />
        <setting name="jdbcTypeForNull" value="NULL" />
    </settings>
    <plugins>
        <plugin interceptor="kr.go.safepeople.config.interceptor.MybatisSqlLogInterceptor" />
    </plugins>
</configuration>
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
import java.lang.reflect.Field;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Properties;
 
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
@Intercepts({
     @Signature(type=StatementHandler.class, method="update", args={Statement.class})
    ,@Signature(type=StatementHandler.class, method="query", args={Statement.class, ResultHandler.class})
})
public class MybatisSqlLogInterceptor implements Interceptor {
 
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        // TODO Auto-generated method stub
        StatementHandler handler = (StatementHandler)invocation.getTarget();
        BoundSql boundSql = handler.getBoundSql();
        String sql = boundSql.getSql();
        Object param = handler.getParameterHandler().getParameterObject();
        
        if(param == null){                
            sql = sql.replaceFirst("\\?""''");
        }else{
            if(param instanceof Integer || param instanceof Long || param instanceof Float || param instanceof Double){
                sql = sql.replaceFirst("\\?", param.toString());
            }else if(param instanceof String){    
                sql = sql.replaceFirst("\\?""'" + param + "'");
            }else if(param instanceof Map){        
                List<ParameterMapping> paramMapping = boundSql.getParameterMappings();    
                
                for(ParameterMapping mapping : paramMapping){
                    String propValue = mapping.getProperty();        
                    Object value = ((Map) param).get(propValue);    
                    if(value != null){
                        if(value instanceof String){            
                            sql = sql.replaceFirst("\\?""'" + value + "'");
                        }else{
                            sql = sql.replaceFirst("\\?", value.toString());
                        }
                    }else{
                        sql = sql.replaceFirst("\\?""'null'");
                    }
                    
                }
            }else{
                List<ParameterMapping> paramMapping = boundSql.getParameterMappings();
                Class<extends Object> paramClass = param.getClass();
                for(ParameterMapping mapping : paramMapping){
                    String propValue = mapping.getProperty();            
                    Field field = paramClass.getDeclaredField(propValue);    
                    field.setAccessible(true);                    
                    Class<?> javaType = mapping.getJavaType();            
                    if(String.class == javaType){                
                        sql = sql.replaceFirst("\\?""'" + field.get(param) + "'");
                    }else{
                        sql = sql.replaceFirst("\\?", field.get(param).toString());
                    }
                }
            }
        }
         
        logger.debug("=====================================================================");
        logger.debug("SQL : "+sql);
        logger.debug("=====================================================================");
 
        return invocation.proceed(); 
    }
 
    @Override
    public Object plugin(Object target) {
        // TODO Auto-generated method stub
            return Plugin.wrap(target, this);
    }
 
    @Override
    public void setProperties(Properties properties) {
        // TODO Auto-generated method stub
    }
 
}
 
cs


Posted by 1010
카테고리 없음2016. 8. 23. 13:03
반응형

In an earlier post, I blogged about the REST capabilities we added to Spring @MVC version 3.0. Later, Alef wrote about using the introduced functionality to add an Atom view to the Pet Clinic application. In this post, I would like to introduce the client-side capabilities we added in Milestone 2.

RestTemplate

The RestTemplate is the central Spring class for client-side HTTP access. Conceptually, it is very similar to the JdbcTemplateJmsTemplate, and the various other templates found in the Spring Framework and other portfolio projects. This means, for instance, that the RestTemplate is thread-safe once constructed, and that you can use callbacks to customize its operations.

RestTemplate Methods

The main entry points of the template are named after the six main HTTP methods:

HTTPRESTTEMPLATE
DELETEdelete(String, String...)
GETgetForObject(String, Class, String...)
HEADheadForHeaders(String, String...)
OPTIONSoptionsForAllow(String, String...)
POSTpostForLocation(String, Object, String...)
PUTput(String, Object, String...)

The names of these methods clearly indicate which HTTP method they invoke, while the second part of the name indicates what is returned. For instance, getForObject() will perform a GET, convert the HTTP response into an object type of your choice, and returns that object.postForLocation will do a POST, converting the given object into a HTTP request, and returns the response HTTP Location header where the newly created object can be found. As you can see, these methods try to enforce REST best practices.

URI Templates

Each of these methods takes a URI as first argument. That URI can be a URI template, and variables can be used to expand the template to a normal URI. The template variables can be passed in two forms: as a String variable arguments array, or as a Map<String, String>. The string varargs variant expands the given template variables in order, so that


String result = restTemplate.getForObject("http://example.com/hotels/{hotel}/bookings/{booking}", String.class, "42", "21");

will perform a GET on http://example.com/hotels/42/bookings/21. The map variant expands the template based on variable name, and is therefore more useful when using many variables, or when a single variable is used multiple times. For example:


Map<String, String> vars = new HashMap<String, String>(); vars.put("hotel", "42"); vars.put("booking", "21"); String result = restTemplate.getForObject("http://example.com/hotels/{hotel}/bookings/{booking}", String.class, vars);

will also perform a GET on http://example.com/hotels/42/rooms/42.

HttpMessageConverters

Objects passed to and returned from the methods getForObject()postForLocation(), andput() and are converted to HTTP requests and from HTTP responses by HttpMessageConverters. Converters for the main mime types and Java types are registered by default, but you can also write your own converter and plug it in the RestTemplate. In the example below, I will show you how that’s done.

Using the RestTemplate to retrieve photos from Flickr

Rather than going through the various methods of the RestTemplate, I will show you how to use it for retrieving pictures from Flickr, Yahoo!s online photo-sharing application. This sample application searches Flickr for photos that match a given search term. It then shows these pictures using a simple Swing UI. To run the application yourself, you will need to create a Flickr account and apply for an API key.

Searching for photos

Flickr exposes various APIs to manipulate its vast library of photos. The flickr.photos.searchmethod allows you to search for photos, by issuing a GET request onhttp://www.flickr.com/services/rest?method=flickr.photos.search&api+key=xxx&tags=penguins, where you enter your API key and the thing to search for (penguins in this case). As a result, you get back a XML document, describing the photos that conform to your query. Something like:


<photos page="2" pages="89" perpage="10" total="881"> <photo id="2636" owner="47058503995@N01" secret="a123456" server="2" title="test_04" ispublic="1" isfriend="0" isfamily="0" /> <photo id="2635" owner="47058503995@N01" secret="b123456" server="2" title="test_03" ispublic="0" isfriend="1" isfamily="1" /> <photo id="2633" owner="47058503995@N01" secret="c123456" server="2" title="test_01" ispublic="1" isfriend="0" isfamily="0" /> <photo id="2610" owner="12037949754@N01" secret="d123456" server="2" title="00_tall" ispublic="1" isfriend="0" isfamily="0" /> </photos>

Using the RestTemplate, retrieving such a document is quite trivial:


final String photoSearchUrl = "http://www.flickr.com/services/rest?method=flickr.photos.search&api+key={api-key}&tags={tag}&per_page=10"; Source photos = restTemplate.getForObject(photoSearchUrl, Source.class, apiKey, searchTerm);

where apiKey and searchTerm are two Strings given on the command line. This method uses theSourceHttpMessageConverter to convert the HTTP XML response into ajavax.xml.transform.Source (Note that the SourceHttpMessageConverter was introduced shortly after we released Spring 3.0 M2, so you will have to get a recent snapshot (or the upcoming M3) to use it. The sample project available below is set up to retrieve these via Maven).

Retrieving the photos

Next, we’re going to use an XPath expression to retrieve all the photo elements of the document. For this, we are going to use the XPathTemplate from Spring Web Services. We are going to execute the //photo expressions, returning all photo elements occurring anywhere in the document. The NodeMapper is a callback interface, whose mapNode() method will be invoked for each photo element in the document. In this case, we are retrieving the serverid, andsecret attributes of this element, and use those to fill up a Map. Finally, we use the RestTemplate again, to retrieve the photo as a java.awt.image.BufferedImage. Thus when the XPath evaluation is done, the resulting imageList will contain an image for each photo in the XML document.


List<BufferedImage> imageList = xpathTemplate.evaluate("//photo", photos, new NodeMapper() { public Object mapNode(Node node, int i) throws DOMException { Element photo = (Element) node; Map<String, String> variables = new HashMap<String, String>(3); variables.put("server", photo.getAttribute("server")); variables.put("id", photo.getAttribute("id")); variables.put("secret", photo.getAttribute("secret")); String photoUrl = "http://static.flickr.com/{server}/{id}_{secret}_m.jpg"; return restTemplate.getForObject(photoUrl, BufferedImage.class, variables); } });

For instance, given the XML document given above, the imageList will contain 4 images. The URL for the first image retrieved will be http://static.flickr.com/2/2636_ a123456_m.jpg, the second is http://static.flickr.com/2/2635_ b123456_m.jpg, etc.

Converting the images

There is one more thing that needs to be done in order for the code to work: we will need to write a HttpMessageConverter that is able to read from the HTTP response, and create aBufferedImagefrom that. Doing so with the Java Image I/O API is fairly simple, we just need to implement the read() method defined in the HttpMessageConverter interface. Overall, our simple converter looks like this:


public class BufferedImageHttpMessageConverter implements HttpMessageConverter<BufferedImage> { public List<MediaType> getSupportedMediaTypes() { return Collections.singletonList(new MediaType("image", "jpeg")); } public boolean supports(Class<? extends BufferedImage> clazz) { return BufferedImage.class.equals(clazz); } public BufferedImage read(Class<BufferedImage> clazz, HttpInputMessage inputMessage) throws IOException { return ImageIO.read(inputMessage.getBody()); } public void write(BufferedImage image, HttpOutputMessage message) throws IOException { throw new UnsupportedOperationException("Not implemented"); } }

Note that we didn’t implement write() because we are not uploading images, just downloading them. Now we just have to plug this converter into the RestTemplate. We do that in the Spring application context:


<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="flickrClient" class="com.springsource.samples.resttemplate.FlickrClient"> <constructor-arg ref="restTemplate"/> <constructor-arg ref="xpathTemplate"/> </bean> <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/> <bean class="com.springsource.samples.resttemplate.BufferedImageHttpMessageConverter"/> </list> </property> </bean> <bean id="xpathTemplate" class="org.springframework.xml.xpath.Jaxp13XPathTemplate"/> </beans>

Showing the photos

The final stage is to show the photos in a simple GUI. For this, we use Swing:


JFrame frame = new JFrame(searchTerm + " photos"); frame.setLayout(new GridLayout(2, imageList.size() / 2)); for (BufferedImage image : imageList) { frame.add(new JLabel(new ImageIcon(image))); } frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);

which gives us the following:

Penguins

Overall, I hope this post showed you how simple it can be to use the RestTemplate to interact with HTTP servers. In just under 30 lines of Java code, we created a GUI that shows pictures of everybody’s favorite bird: the penguin! Check out the RestTemplate and let us know what you think!

Downloads

A Maven project containing the code above can be downloaded here. Note that the project is based on a nightly snapshot build of Spring. The upcoming Milestone 3 of Spring will contain the necessary classes as well.

Posted by 1010
카테고리 없음2016. 8. 23. 11:23
반응형

ava unlimited runtime class and resource redefinition.

The main purpose of this project is to avoid infamous change->restart + wait->check development lifecycle. Save&Reload during development should be standard and many other languages (including C#) contain this feature.

This project is still in a beta version.

Easy to start

Download and install latest DCEVM Java patch + agent jar and launch your application server with options -XXaltjvm=dcevm -javaagent:hotswap-agent.jar to get basic setup. Optionally add hotswap-agent.properties to your application to configure plugins and agent behaviour.

Plugins

Each application framework (Spring, Hibernate, Logback, ...) needs special reloading mechanism to keep up-to-date after class redefinition (e.g. Hibernate configuration reload after new entity class is introduced). Hotswap agent works as a plugin system and ships preconfigured with all major framework plugins. It is easy to write your custom plugin even as part of your application.

Contribute

This project is very complex due to lot of supported frameworks and various versions. Community contribution is mandatory to keep it alive. You can start by creating a plugin inside your application or by writing an example/integration test. There is always need for documentation improvement :-). Thank you for any help!

Quick start:

Install

  1. download latest release of DCEVM Java patch and launch the installer (e.g. java -jar installer-light.jar). Currently you need to select correct installer for Java major version (7/8).
  2. select java installation directory on your disc and press "Install DCEVM as altjvm" button. Java 1.7+ versions are supported.
  3. download latest release of Hotswap agent jar, unpack hotswap-agent.jar and put it anywhere on your disc. For example:C:\java\hotswap-agent.jar

Run your application

  1. add following command line java attributes: -XXaltjvm=dcevm -javaagent:PATH_TO_AGENT\hotswap-agent.jar (you need to replace PATH_TO_AGENT with an actual) directory. For example java -XXaltjvm=dcevm -javaagent:c:\java\hotswap-agent.jar YourApp. See IntelliJ IDEA and Netbeans forum threads for IDE specific setup guides.
  2. (optional) create a file named "hotswap-agent.properties" inside your resources directory, see available properties and default values: https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/resources/hotswap-agent.properties
  3. start the application in debug mode, check that the agent and plugins are initialized correctly:

    HOTSWAP AGENT: 9:49:29.548 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent - unlimited runtime class redefinition.
    HOTSWAP AGENT: 9:49:29.725 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [org.hotswap.agent.plugin.hotswapper.HotswapperPlugin, org.hotswap.agent.plugin.jvm.AnonymousClassPatchPlugin, org.hotswap.agent.plugin.hibernate.HibernatePlugin, org.hotswap.agent.plugin.spring.SpringPlugin, org.hotswap.agent.plugin.jetty.JettyPlugin, org.hotswap.agent.plugin.tomcat.TomcatPlugin, org.hotswap.agent.plugin.zk.ZkPlugin, org.hotswap.agent.plugin.logback.LogbackPlugin]
    ...
    HOTSWAP AGENT: 9:49:38.700 INFO (org.hotswap.agent.plugin.spring.SpringPlugin) - Spring plugin initialized - Spring core version '3.2.3.RELEASE'
    
  4. save a changed resource and/or use the HotSwap feature of your IDE to reload changes

What is available?

  • Enhanced Java Hotswap - change method body, add/rename a method, field, ... The only unsupported operation is hierarchy change (change the superclass or remove an interface).
    • You can use standard Java Hotswap from IDE in debug mode to reload changed class
    • or set autoHotswap property -XXaltjvm=dcevm -javaagent:PATH_TO_AGENT\hotswap-agent.jar=autoHotswap=true to reload changed classes after compilation. This setup allows even reload on production system without restart.
  • Automatic configuration - all local classes and resources known to the running Java application are automatically discovered and watched for reload (all files on local filesystem, not inside JAR file).
  • Extra classpath - Need change a runtime class inside dependent JAR? Use extraClasspath property to add any directory as a classpath to watch for class files.
  • Reload resource after a change - resources from webapp directory are usually reloaded by application server. But what about other resources like src/main/resources? Use watchResources property to add any directory to watch for a resource change.
  • Framework support - through plugin system, many frameworks are supported. New plugins can be easily added.
  • Fast - until the plugin is initialized, it does not consume any resources or slow down the application (see Runtime overhead for more information)

Should you have any problems or questions, ask at HotswapAgent forum.

This project is similar to JRebel. Main differences are:

  • HotswapAgent (DCEVM) supports Java8!
  • HotswapAgent does not need any additional configuration for basic project setup.
  • JRebel is currently more mature and contains more plugins.
  • JRebel is neither open source nor free.
  • JRebel modifies bytecode of all classes on reload. You need special IDE plugin to fix debugging.
  • HotswapAgent extraClasspath is similar to JRebel configuration
  • HotswapAgent adds watchResources configuration

Examples

See HotswapAgentExamples GitHub project. The purpose of an example application is:

  • complex automate integration tests (check various configurations before a release, see run-tests.sh script)
  • to check "real world" plugin usage during plugin development (i.e. inside container)
  • to provide working solution for typical application setups
  • sandbox to simulate issues for existing or new setups

Feel free to fork/branch and create an application for your setup (functional, but as simple as possible). General setups will be merged into the master.

IDE support

None needed :) Really, all changes are transparent and all you need to do is to download patch+agent and setup your application / application server. Because we use standard java hotswap behaviour, your IDE will work as expected. However, we work on IDE plugins to help with download & configuration.

Configuration

The basic configuration set to reload classes and resources from classpath known to the running application (classloader). If you need a different configuration, add hotswap-agent.properties file to the classpath root (e.g. src/main/resources/hotswap-agent.properties).

Detail documentation of available properties and default values can be found in the agent properties file

Hotswap agent command line options

Full syntax of command line options is:

-javaagent:[yourpath/]hotswap-agent.jar=[option1]=[value1],[option2]=[value2]

Hotswap agent accepts following options:

  • autoHotswap=true - watch all .class files for change and automatically Hotswap the class in the running application (instead of running Hotswap from your IDE debugging session)
  • disablePlugin=[pluginName] - disable a plugin. Note that this will completely forbid the plugin to load (opposite to disablePlugin option in hotswap-agent.properties, which will only disable the plugin for a classloader. You can repeat this option for every plugin to disable.

How does it work?

DCEVM

Hotswap agent does the work of reloading resources and framework configuration (Spring, Hibernate, ...), but it depends on standard Java hotswap mechanism to actually reload classes. Standard Java hotswap allows only method body change , which makes it practically unusable. DCEVM is a JRE patch witch allows almost any structural class change on hotswap (with an exception of a hierarchy change). Although hotswap agent works even with standard java, we recommend to use DCEVM (and all tutorials use DCEVM as target JVM).

Hotswap agent

Hotswap agent is a plugin container with plugin manager, plugin registry, and several agent services (e.g. to watch for class/resource change). It helps with common tasks and classloading issues. It scans classpath for class annotated with @Plugin annotation, injects agent services and registers reloading hooks. Runtime bytecode modification is provided by javaasist library.

Plugins

Plugins administered by Hotswap agent are usually targeted towards a specific framework. For example Spring plugin uses agent services to:

  • Modify root Spring classes to get Spring contexts and registered scan path
  • Watch for any resource change on a scan path
  • Watch for a hotswap of a class file within a scan path package
  • Reload bean definition after a change
  • ... and many other

Packaged plugins:

  • Hibernate (4x) - Reload Hibernate configuration after entity create/change.
  • Spring (3x) - Reload Spring configuration after class definition/change.
  • Jetty - add extra classpath to the app classloader. All versions supporting WebAppContext.getExtraClasspath should be supported.
  • ZK (5x-7x) - ZK Framework (http://www.zkoss.org/). Change library properties default values to disable caches, maintains Label cache and bean resolver cache.
  • Logback - Logback configuration reload
  • Hotswapper - Watch for any class file change and reload (hotswap) it on the fly via Java Platform Debugger Architecture (JPDA)
  • AnonymousClassPatch - Swap anonymous inner class names to avoid not compatible changes.
  • ELResolver 2.2 (JuelEL, Appache Commons EL, Oracle EL 3.0)- clear ELResolver cache on class change. Support hotswap for #{...} expressions.
  • Seam (2.2, 2.3) - flush JBoss reference cache. Support for properties file change (messages[])
  • JBossModules - add extra class path to JBoss's module class loader.
  • JSF (mojarra 2.1, 2.2) - support for application resource bundle files change (properties files).
  • OsgiEquinox - Hotswap support for Eclipse plugin or Eclipse platform development.
  • RESTEasy (2.x, 3.x) - reload @Path annotated classes on class create/change
  • CDI/Weld - reload bean class definition after class create(managed beans)/change. Proxy bean redefinition after proxied class change. EAR support.
  • WebObjects - Clear key value coding, component, action and validation caches after class change.

Find a detail documentation of each plugin in the plugin project main README.md file.

Runtime overhead

It really depends on how many frameworks you use and which caches are disabled. Example measurements for a large, real world enterprise application based on Spring + Hibernate, run on Jetty.

SetupStartup time
Run (plain Java)23s
Debug (plain Java)24s
Debug (plain DCEVM)28s
Agent - disabled all plugins31s
Agent - all plugins35s

How to write a plugin

You can write plugin directly as a part of your application. Set pluginPackages=your.plugin.package inside your hotswap-agent.properties configuration to discover @Plugin annotated classes. You will also need agent JAR dependency to compile, but be careful NOT to add the JAR to your application, it must be loaded only as a javaagent. Maven dependency:

    <dependency>
        <groupId>org.hotswap.agent</groupId>
        <artifactId>HotswapAgent</artifactId>
        <version>${project.version}</version>
        <scope>provided</scope>
    </dependency>

(Note that the JAR is not yet in central maven repository - you need to build it from source first).

See ExamplePlugin (part of TestApplication) to go through a commented simple plugin. Read agent readme to understand agent concepts. Check existing plugins source code for more examples.

Creating Release

Launch run-tests.sh script in the main directory. Currently you have to setup JAVA_HOME location directory manually. At least Java 7 and Java 8 with DCEVM should be checked before a release. All automatic tests are set to fail the whole script in case of any single test failure.

Go to directory representing repository root. In case DCEVM is named dcevm

mvn release:prepare
mvn release:perform

In case your DCEVM is named differently i.e. server

mvn release:prepare -Darguments="-Ddcevm=server"
mvn release:perform -Darguments="-Ddcevm=server"

Plugin specific settings

OsgiEquinox / Eclipse RCP

OsgiEquinox / Eclipse plugin provides hotswap support for Eclipse plugin or Eclipse platform development (Do not confuse it with common development in Eclipse!).

Following options should be setup in eclipse.ini for debugee Eclipse instance:

 # use application classloader for the framework
-Dosgi.frameworkParentClassloader=app
 # development classpath that is added to each plugin classpath
-Dosgi.dev=[extra_classpath]
 # use dcevm as JVM
-XXaltjvm=dcevm
 # enable hotswapagent
-javaagent:PATH_TO_AGENT/hotswap-agent.jar
 # enable remote debugging on port 8000
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

extra_classpath points to directory with compiled classes. When a new class is compiled it is sent by remote debugger to HotswapAgent. HotswapAgent stores this file into extra_classpath directory.

It is also necessary to setup following hotswap-agent.properties:

extraClasspath=[extra_classpath]
osgiEquinox.debugMode=true

then connect the IDE debugger (eclipse, netbeans or idea) to port 8000 and happy hotswapping!

Posted by 1010