Zastaveni serveru pri vyuziti CXF frameworku v aplikaci bezici na tomcatu 7

Vladislav Krejcirik vkrejcirik na gmail.com
Pondělí Listopad 15 12:20:38 CET 2010


Dobry den,
Mam webovou aplikaci bezici v ramci Tomcatu. Aplikace registruje beanu, 
ktera spravuje beh CXF serveru. Mam vsak problem pri undeployi teto 
aplikace. V metode destroy teto beany server zastavuji. I po odstraneni 
aplikace a zastaveni serveru je port na kterem bezel obsazen. Nemuzu 
tedy provest redeploy aplikace bez restartu Tomcatu a uvolneni tohoto portu.

Kod:

<bean class="my.package.ServicesFactoryBean" init-method="create" 
destroy-method="destroy">
<property name="serviceName" value="ContextService" />
<property name="protoPackage" value="ContextProtos" />
<property name="production" value="true" />
</bean>


public class ServicesFactoryBean {

     ProtobufServerFactoryBean factoryBean = new 
ProtobufServerFactoryBean();
     String serviceName;
     String protoPackage;
     Server server;

     boolean production = true;

     @SuppressWarnings({ "rawtypes", "unchecked" })
     public Server create() throws InstantiationException, 
IllegalAccessException, ClassNotFoundException {
         if (getServiceName() == null)
             throw new IllegalStateException("Service name not set in 
services.xml");

         String pkg;
         if (isProduction())
             pkg = "my.package.srv.";
         else
             pkg = "my.package.srv.stub.";
         Class srvBeanClass = Class.forName(pkg + getServiceName() + 
"Impl");
         Class msgBeanClass = Class.forName("my.package.proto." + 
getProtoPackage() + "$"
                 + getServiceName() + "Message");
         factoryBean.setAddress("http://"
                 + 
ClanCoreProperties.getInstance().getProperty(ClanCoreProperties.CORE_JETTY_HOST_NAME) 
+ ":"
                 + 
ClanCoreProperties.getInstance().getProperty(ClanCoreProperties.CORE_JETTY_PORT) 
+ "/"
                 + getServiceName());
         factoryBean.setServiceBean(srvBeanClass.newInstance());
         factoryBean.setMessageClass(msgBeanClass);

         server = factoryBean.create();
         return server;
     }

     public void destroy() {
         server.stop();
         server = null;

         // factoryBean.getServer().stop();
     }

     public String getServiceName() {
         return serviceName;
     }

     public void setServiceName(String serviceName) {
         this.serviceName = serviceName;
     }

     public boolean isProduction() {
         return production;
     }

     public void setProduction(boolean production) {
         this.production = production;
     }

     public String getProtoPackage() {
         return protoPackage;
     }

     public void setProtoPackage(String protoPackage) {
         this.protoPackage = protoPackage;
     }

}

Dekuji.

-- 
/**************************************/
Best regards / S pozdravem
Vladislav Krejčiřík

http://www.vkrejcirik.info



Další informace o konferenci Konference